-
Notifications
You must be signed in to change notification settings - Fork 436
Setup Guide (CMake)
Yulei Sui edited this page May 7, 2017
·
30 revisions
Build LLVM and Clang (if you have already done both, just skip it and jump to step 5)
-
Download LLVM-4.0.0, clang-4.0.0
-
Unzip the LLVM and Clang source files
tar xf llvm-4.0.0.tar.xz
tar xf cfe-4.0.0.tar.xz
mv cfe-4.0.0.src llvm-4.0.0.src/tools/clang
- Create your target build folder and make
mkdir llvm-4.0.0.obj
cd llvm-4.0.0.obj
cmake ../llvm-4.0.0.src (or "cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../llvm-4.0.0.src" for debug version)
make -j8
- Add paths for LLVM and Clang
export LLVM_SRC=your_path_to_llvm-4.0.0.src
export LLVM_OBJ=your_path_to_llvm-4.0.0.obj
export LLVM_DIR=your_path_to_llvm-4.0.0.obj
export PATH=$LLVM_DIR/bin:$PATH
Build SVF
- Download the SVF source code
git clone https://github.com/unsw-corg/SVF.git SVF
- Build SVF using cmake (Alternatively build.sh is used to build release or debug version of SVF)
cd SVF
mkdir Release-build
cmake ../
make -j4
Debug build
cd SVF
mkdir Debug-build
cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../
make -j4
- Add paths for SVF
export PATH=$SVFHOME/Release-build/bin:$PATH
- Compile a single-file C program to a LLVM bitcode file or compile and link multiple C files using llvm-link. To compile a complicated real-world project you may wish to use LLVM gold plugin. See this guide to install it.
clang -c -emit-llvm -g example.c -o example.bc
clang -c -emit-llvm -g example1.c -o example1.bc
clang -c -emit-llvm -g example2.c -o example2.bc
llvm-link example1.bc example2.bc