This repository demonstrates how to use SVF as a library in your project to analyze LLVM bitcode files. We provide examples for three different scenarios of using SVF.
SVF relies on the following libraries & tools:
- CMake (>=3.23)
- LLVM (<=16.0.6)
- Z3 (>=4.8.8)
In this scenario, we build SVF from source and use it directly from the build directory.
# Clone SVF
git clone https://github.com/SVF-tools/SVF.git
cd SVF
# Build SVF in Release mode
cmake -S ./ -B Release-build
cmake --build Release-build
# Or build SVF in Debug mode
cmake -S ./ -B Debug-build -DCMAKE_BUILD_TYPE=Debug
cmake --build Debug-build
# For Release build
cd SVF-example
cmake -B build -S ./ -DSVF_DIR=/path/to/SVF
cmake --build build
# For Debug build
cd SVF-example
cmake -B build -S ./ -DSVF_DIR=/path/to/SVF -DCMAKE_BUILD_TYPE=Debug
cmake --build build
In this scenario, we install SVF to a specific directory and use it from there.
# Clone SVF
git clone https://github.com/SVF-tools/SVF.git
cd SVF
If you build in Release mode, run
bash build.sh
cmake --install ./Release-build --prefix /path/to/install/dir
If you build in Debug mode, run
bash build.sh debug
cmake --install ./Debug-build --prefix /path/to/install/dir
cd SVF-example
cmake -B build -S ./ -DSVF_DIR=/path/to/install/dir
cmake --build build
In this scenario, we use SVF installed through npm.
npm install svf-lib
cd SVF-example
# Get npm root directory
NPM_ROOT=$(npm root)
# Set SVF_DIR to the SVF installation in npm
export SVF_DIR="$NPM_ROOT/SVF"
cmake -B build -S ./
cmake --build build
After building in any of the above scenarios, you can run the example:
./build/svf-example ./data/example.ll
If CMake cannot find SVF, ensure the installation directory is in your CMAKE_PREFIX_PATH
:
# For Bash/Zsh
export CMAKE_PREFIX_PATH="$SVF_DIR${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}"
# For Fish
set -px --path CMAKE_LIBRARY_PATH $SVF_DIR
If you encounter library loading issues, ensure the library path is set correctly:
# For Bash/Zsh
export LD_LIBRARY_PATH="$SVF_DIR/lib:$LD_LIBRARY_PATH"
# For Fish
set -Upx LD_LIBRARY_PATH $SVF_DIR/lib
For more detailed information about SVF setup and configuration, please refer to the SVF wiki.