llvm/llvm-project
Configuration
Reference for the most-used CMake variables when configuring an LLVM build. The full list lives in llvm/CMakeLists.txt and the per-subproject CMakeLists.txt files; this page covers the ones a contributor reaches for daily.
Subproject selection
| Variable | Purpose | Typical values |
|---|---|---|
LLVM_ENABLE_PROJECTS |
Compiler/tool subprojects to build | clang;lld;lldb;mlir;flang;bolt;clang-tools-extra;polly |
LLVM_ENABLE_RUNTIMES |
Runtime libraries to build | compiler-rt;libcxx;libcxxabi;libunwind;openmp;libc;flang-rt;orc-rt;offload;llvm-libgcc |
LLVM_TARGETS_TO_BUILD |
Backend targets to enable | host, X86;AArch64;RISCV, all |
LLVM_EXPERIMENTAL_TARGETS_TO_BUILD |
Experimental targets | (per-target) |
Build-type controls
| Variable | Purpose | Typical values |
|---|---|---|
CMAKE_BUILD_TYPE |
Optimization/debug level | Release, RelWithDebInfo, Debug, MinSizeRel |
LLVM_ENABLE_ASSERTIONS |
Enable internal assert()s |
ON (recommended for development), OFF (default in Release) |
LLVM_USE_LINKER |
Override the linker | lld, gold, ld |
LLVM_ENABLE_LTO |
Build LLVM itself with LTO | OFF, Thin, Full |
LLVM_USE_SANITIZER |
Build LLVM under a sanitizer | Address, Thread, Memory, Undefined |
LLVM_BUILD_TESTS |
Enable lit/unit-test targets | ON (default) |
LLVM_INCLUDE_TESTS |
Include test directories in build | ON |
LLVM_INCLUDE_BENCHMARKS |
Include benchmarks | OFF |
LLVM_INCLUDE_EXAMPLES |
Include the examples/ directory |
ON/OFF |
LLVM_BUILD_EXAMPLES |
Actually build them | OFF (default) |
LLVM_PARALLEL_LINK_JOBS |
Cap simultaneous link jobs | 1 for low-RAM machines |
Compiler / cache
| Variable | Purpose |
|---|---|
CMAKE_C_COMPILER / CMAKE_CXX_COMPILER |
Override host compiler |
LLVM_CCACHE_BUILD |
Wrap compiles with ccache |
LLVM_USE_SPLIT_DWARF |
Emit split-dwarf debug info to speed up debug-build links |
LLVM_BUILD_LLVM_DYLIB |
Build a single shared libLLVM rather than per-component statics |
BUILD_SHARED_LIBS |
Produce shared libraries for the per-component build |
Toolchain integration
| Variable | Purpose |
|---|---|
LLVM_DEFAULT_TARGET_TRIPLE |
Default target triple Clang uses |
LLVM_HOST_TRIPLE |
Override the host triple |
LLVM_INSTALL_TOOLCHAIN_ONLY |
When installing, ship just the toolchain (no internal headers) |
LLVM_DISTRIBUTION_COMPONENTS |
Which install components ship in the install-distribution target |
Runtime-build specifics
| Variable | Purpose |
|---|---|
COMPILER_RT_BUILD_BUILTINS |
Build the builtins library |
COMPILER_RT_BUILD_SANITIZERS |
Build the sanitizer runtimes |
COMPILER_RT_BUILD_PROFILE |
Build the profile runtime |
COMPILER_RT_BUILD_XRAY |
Build XRay |
LIBCXX_USE_COMPILER_RT |
Use compiler-rt instead of libgcc for libc++ |
LIBCXXABI_USE_LLVM_UNWINDER |
Use libunwind rather than the system unwinder |
LIBC_TARGETS |
Targets that LLVM-libc should produce overlays for |
CMake presets
llvm/CMakePresets.json bundles common configurations. Useful entry points:
cmake --list-presets
cmake --preset stage1
cmake --preset bootstrapThe presets are a moving target — read the current contents of CMakePresets.json rather than memorizing this list.
Useful CMake invocations
# Iterate quickly on Clang
cmake -G Ninja -S llvm -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_USE_LINKER=lld \
-DLLVM_CCACHE_BUILD=ON \
-DLLVM_TARGETS_TO_BUILD=Native \
-DLLVM_ENABLE_PROJECTS="clang;lld"# Build a runtime-side change against a built clang
cmake -G Ninja -S runtimes -B build-rt \
-DCMAKE_C_COMPILER=$PWD/build/bin/clang \
-DCMAKE_CXX_COMPILER=$PWD/build/bin/clang++ \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"# Two-stage bootstrap (stage-1 builds Clang, stage-2 uses it)
cmake -G Ninja -S llvm -B stage1 \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DLLVM_TARGETS_TO_BUILD=host
ninja -C stage1
cmake -G Ninja -S llvm -B stage2 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=$PWD/stage1/bin/clang \
-DCMAKE_CXX_COMPILER=$PWD/stage1/bin/clang++ \
-DLLVM_USE_LINKER=lld \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind"
ninja -C stage2Reference
- Building LLVM with CMake
- Getting started — the abbreviated practical guide
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.