• This repository has been archived on 01/Jun/2020
  • Stars
    star
    1,187
  • Rank 39,407 (Top 0.8 %)
  • Language
    C++
  • License
    The Unlicense
  • Created about 11 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

UNMAINTAINED: Examples of using the LLVM and Clang compilation libraries and tools

Note (Sep-18-2018): this repository is now unmaintained. Keeping out-of-source samples working with LLVM & Clang is tricky because of the continuously changing build requirements. I have been working on other stuff recently and haven't had the time and stamina to keep up-to-date.

I may take maintainership up again in the future.

https://raw.github.com/eliben/llvm-clang-samples/master/stop.jpg

LLVM & Clang library usage samples

A collection of samples for using LLVM and Clang as libraries.

Branches

LLVM & Clang evolve rapidly and the C++ API is not stable. This means that code that links against LLVM & Clang as libraries in version X may very well not compile or work in version X+1.

Therefore, this repository has branches that track LLVM versions. For example, in branch llvm4.0 the code should compile and work when linked against the released LLVM 4.0; The code in the master branch attempts to track the upstream trunk, but may sometimes lag behind. Also, note that as more samples are added I'll usually add them to master and will not backport them to older branches.

In any case, if anything doesn't compile as you'd expect it to, please open an issue.

Last known LLVM build revision for the master branch

The last upstream LLVM revision I've successfully built the master branch against is r332892 (21-May-2018). It may build with newer revisions, or it may not. If you know it builds successfully with a newer one, please let me know and I'll update this note.

What is where

src_llvm/
Source code for LLVM-based samples. These typically only require LLVM to compile and link.
src_clang/
Source code for Clang-based samples. These require both LLVM and Clang.
using_clang_toolchain/
Some samples of using Clang as a compilation toolchain for C and C++.
inputs/
Some input files for the samples and tests.
test/
Tests for the samples.

Building the samples

A complete Makefile for Linux is included in the repository. Read the documentation at its top; it explains how to configure the build to find your local LLVM & Clang installation/build. A helper shell script named build_vs_released_binary.sh can make the build easier if you just point it to a directory when you've untarred a binary rlease.

Note that LLVM & Clang use modern C++11 constructs and require a fairly up-to-date compiler and standard C++ library to build. This blog post may be useful if you don't have a modern C++ compiler on your machine.

Running tests and tools

Note: This is not really necessary to study the examples. The tests allow me to make sure the examples keep working as LLVM advances.

For running the tests and auxiliary tools (and any other Python scripts in this repo), Python 3 is required (I tested with 3.3+). Once the samples are built with 'make', just run:

make test

Note that it expects to find binaries from the LLVM directory with which the samples were built and linked. Look at the emit_build_config rule in the Makefile for more information.

License

Unless stated otherwise, all the code in this repository is in the public domain. See the LICENSE file for more details. Some source files were taken almost verbatim from LLVM/Clang; for these, the LLVM license header comment is retained and LLVM's license applies (please see LICENSE.txt in the LLVM source tree).

More Repositories

1

pycparser

🐍 Complete C99 parser in pure Python
Python
3,226
star
2

pyelftools

Parsing ELF and DWARF in Python
Python
2,013
star
3

code-for-blog

Code samples from my blog
Go
1,574
star
4

raft

🚣 Raft implementation in Go
Go
1,045
star
5

pss

pss is a power-tool for searching inside source code files.
Python
327
star
6

pykaleidoscope

Implementation of the LLVM tutorial in Python
Python
292
star
7

static-server

A simple, zero-configuration HTTP server CLI for serving static files
Go
183
star
8

modlib

Go project layout with exported packages and command-line tools, using modules
Go
180
star
9

deep-learning-samples

Sample code for deep learning & neural networks
Python
170
star
10

bobscheme

An implementation of Scheme in Python and C++
C++
167
star
11

luz-cpu

Educational open-source CPU suite (with assembler, linker and simulator)
Python
161
star
12

js-8080-sim

Intel 8080 assembler and simulator in JS, optimized for simplicity.
JavaScript
155
star
13

wasm-wat-samples

Samples of WebAssembly Text programs
WebAssembly
128
star
14

gemini-cli

Access Gemini LLMs from the command-line
Go
100
star
15

libjit-samples

Code samples for using libjit
C
91
star
16

go-sudoku

Toolkit for solving and generating Sudoku puzzles in Go
Go
88
star
17

wcx64

Clone of wc in x64 assembly
Assembly
87
star
18

c-unleashed-book-souce-code

Source code for the "C Unleashed" book by Richard Heathfield, Lawrence Kirby, et al.
C
70
star
19

gosax

gosax is a basic wrapper for stream parsing of XML (SAX) Go
Go
62
star
20

asdl_parser

Standalone ASDL parser for upstream CPython 3.x
Python
61
star
21

go-ungrammar

Ungrammar implementation and API in Go
Go
43
star
22

paip-in-clojure

πŸŒ… Code from "Paradigms of Artificial Intelligence Programming" in Clojure
Clojure
39
star
23

cs344

Introduction to Parallel Programming class code
C++
31
star
24

go-sentencepiece

Go implementation of the SentencePiece tokenizer
Go
20
star
25

go-websocket-sample

Sample Go websocket server and JS client with tracing and JSON data interchange
Go
20
star
26

esms

Legacy - ESMS (Electronic Soccer Management Simulator)
C++
18
star
27

xmlgen

C
15
star
28

go-quines

Some quines in the Go programming language
Go
15
star
29

python3-samples

Samples of Python 3 code, libraries, etc.
Python
12
star
30

gogl

Go Generic Library
Go
11
star
31

tupperformula

JS demo of Tupper's formula
JavaScript
9
star
32

arm_asm_hacks

ARM assembly hacks
Assembly
8
star
33

lsystem

JavaScript
8
star
34

hackutils

Various hacky utils for Go
Go
8
star
35

gocloud-samples

Samples/hacks with gocloud
Go
7
star
36

jscool2asm

JavaScript
5
star
37

sample-go-cli

Sample Go CLI project structure
Go
4
star
38

colorful-lines

My JS clone of the Colorful Lines game
JavaScript
4
star
39

cl-in-clj

Common Lisp --> Clojure snippets/idioms translation
Clojure
3
star
40

gocdkx

Fork of google/go-cloud for experiments.
Go
3
star
41

so-tag-sentiment-analysis

Go
2
star
42

ollama-import-experiment

Go
2
star
43

line-plotting

JavaScript
2
star
44

go-travis-test

sandbox
Shell
2
star
45

cljmin

Minimal project template for Clojure
Clojure
2
star
46

diffuse-sim

JavaScript
1
star
47

sample-go-project-vscode

Go
1
star
48

onlisp-in-clojure

Clojure
1
star
49

4clojure-solutions

My solutions to https://www.4clojure.com/problems
Clojure
1
star