Giter VIP home page Giter VIP logo

llvm-clang-samples's Introduction

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 r314221 (26-Sep-2017). 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).

llvm-clang-samples's People

Contributors

eliben avatar rpavlik avatar

Watchers

James Cloos avatar Jia-Rung (Tiba) avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.