[go: nahoru, domu]

Skip to content

Setup Guide (Autoconf)

Johannes edited this page Dec 20, 2023 · 3 revisions

Build LLVM and Clang (if you have already done both, just skip it and jump to step 5)

  1. Download LLVM-3.8.0, clang-3.8.0

  2. Unzip the LLVM and Clang source files

tar xf llvm-3.8.0.tar.xz
tar xf cfe-3.8.0.tar.xz
mv cfe-3.8.0.src llvm-3.8.0.src/tools/clang
  1. Create your target build folder and make
mkdir llvm-3.8.0.obj
cd llvm-3.8.0.obj
../llvm-3.8.0.src/configure --enable-assertions
make -j8  (or make -j8 ENABLE_OPTIMIZED=0 for debug version)
  1. Add paths for LLVM and Clang
export LLVM_SRC=your_path_to_llvm-3.8.0.src
export LLVM_OBJ=your_path_to_llvm-3.8.0.obj
export PATH=$LLVM_OBJ/Release+Asserts/bin:$PATH

Build SVF

  1. Download the SVF source code

  2. Clean the previous build configuration files

rm -rf Makefile.common && rm -rf configure
  1. Change configure to point to your LLVM Path
vi autoconf/configure.ac

change value of LLVM_SRC_ROOT to $LLVM_SRC change value of LLVM_OBJ_ROOT to $LLVM_OBJ

cd autoconf
./AutoRegen.sh

input your LLVM_SRC_ROOT and LLVM_OBJ_ROOT following the command line

  1. Configure and make

Build the release version in the source root of SVF folder:

./configure && make 

Build the debug version of SVF (debug version of LLVM is not required):

./configure && make ENABLE_OPTIMIZED=0
  1. 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
  1. Analyze a llvm bit-code file using SVF