Giter Site home page Giter Site logo

foreverowl / understanding-clang-llvm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from machiry/understanding-clang-llvm

0.0 0.0 0.0 178 KB

Repository for understanding and writing LLVM passes.

License: BSD 2-Clause "Simplified" License

C++ 81.66% CMake 18.34%

understanding-clang-llvm's Introduction

understanding-clang-llvm

Repository for understanding and writing LLVM passes.

Building and installing Clang/LLVM

This needs ~40GB disk space and compilation time of ~90min.

  1. Download LLVM-8.0.0, clang-8.0.0

  2. Unzip the LLVM and Clang source files

    tar xf llvm-8.0.0.src.tar.xz
    tar xf cfe-8.0.0.src.tar.xz
    mv cfe-8.0.0.src llvm-8.0.0.src/tools/clang
    
  3. Create your target build folder and make

    mkdir llvm-8.0.0.obj
    cd llvm-8.0.0.obj
    cmake -DCMAKE_BUILD_TYPE=Debug ../llvm-8.0.0.src (or add "-DCMAKE_BUILD_TYPE:STRING=Release" for releae version)
    make -j8  
    
  4. Add paths for LLVM and Clang

    export LLVM_SRC=your_path_to_llvm-8.0.0.src
    export LLVM_OBJ=your_path_to_llvm-8.0.0.obj
    export LLVM_DIR=your_path_to_llvm-8.0.0.obj
    export PATH=$LLVM_DIR/bin:$PATH
    

Converting .c file to bitcode file

The folder examples contains a couple of example .c files which you can play with.

LLVM passes run on bitcode file. Here, we explain how to convert a C file to bitcode file.

clang -c -emit-llvm <path_to_c_file> -o <path_to_output_bitcode_file>

Example:

cd examples
clang -c -emit-llvm simple.c -o simple.bc

LLVM Passes

The folder llvm_passes contains various sample LLVM passes.

understanding-clang-llvm's People

Contributors

machiry 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.