CLion Setup¶
How-To Setup VaRA/LLVM in CLion¶
Start CLion
“Import Project from Sources”
Select main llvm source directory
Select “Open existing project” (Important!)
File -> Settings -> Build,Execution,Deployment -> CMake
- Create Debug Build
Name:
DebugBuild Type:
Debug- CMake options:
-DCMAKE_C_FLAGS_DEBUG= -DCMAKE_CXX_FLAGS_DEBUG= -DLLVM_ENABLE_ASSERTIONS=ON -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DVARA_BUILD_LIBGIT=ON -DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;clang-tools-extra;vara;phasar" -DCMAKE_INSTALL_PREFIX=~/work/VaRA
- Environment:
CFLAGS=-O2 -g -fno-omit-frame-pointerCXXFLAGS=-O2 -g -fno-omit-frame-pointer
Generation path:
build/dev-clionBuild options:
-j 4(or whatever you want)
- Create Release Build
Name:
ReleaseBuild Type:
Release- CMake options:
-DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DLLVM_ENABLE_ASSERTIONS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DVARA_BUILD_LIBGIT=ON -DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;clang-tools-extra;vara;phasar" -DCMAKE_INSTALL_PREFIX=~/work/VaRA
- Environment:
CFLAGS=-O3 -DNDEBUG -march=native -gmlt -fno-omit-frame-pointerCXXFLAGS=-O3 -DNDEBUG -march=native -gmlt -fno-omit-frame-pointer
Generation path:
build/opt-clionBuild options:
-j 4(or whatever you want)
Delete the old build directory cmake-build-debug that was created by clion after the first launch (in the main llvm source directory)
- Add Configuration
Add new “Application” configuration
Name:
Build All TargetsTargets:
All targets
If necessary restart CLion or reload CMake (CMake tab -> Reload button)
Wait until “Building symbols”, “Indexing”, etc. is done
- Add another application configuration
Name:
Run clangTargets:
clangExecutable:
clangProgram arguments:
what you wantWorking directory:
what you want
Also add configurations with
clang++/optas target/executableYou can also create configurations for the targets
check-varaandtidy-varafor VaRA regression tests and clang-tidyChoose configuration
Build All Targets->BuildbuttonYou can switch between
DebugandReleasebuilds in CLion’s build configuration drop-down menuDone
Tips & Tricks¶
The debugger does stop at breakpoints and doesn’t show the source code.¶
This is most likely because the build does not include debugging symbols. Check if you have selected the Debug configuration for the build. If it doesn’t work even if you used the debug configuration, the problem might disappear if you delete the build directory (e.g. build/dev-clion), restart CLion and rebuild.