Skip to content

llvm

  • Do not set BUILD_SHARED_LIBS
  • Do not depend on PyYAML; required for llvm-libc
  • LLVM_ENABLE_ASSERTIONS is OFF by default with Release builds
  • Do we need LLVM_PARALLEL_COMPILE_JOBS?
  • Do we need LLVM_PARALLEL_TABLEGEN_JOBS?
  • Do we need LLVM_INSTALL_UTILS for FileCheck and not?
  • Do not set LLVM_EXTERNAL_LIT to allow the bundled lit to run; needed for standalone builds of subprojects
  • Do we need LLVM_ROOT?
  • Rely on the host’s compiler instead of crafting our own for the toolchain stage
  • For list of supported targets by LLVM_TARGETS_TO_BUILD, check llvm/lib/Target/
  • Enable LLVM_OPTIMIZED_TABLEGEN to reduce build time
  • Disable CLANG_ENABLE_STATIC_ANALYZER for toolchain and cross
  • To disable LIBCXX_ENABLE_RTTI disable LIBCXX_ENABLE_EXCEPTIONS first
  • What is the default value for LIBCXX_CXX_ABI?
  • clang by design is a full fledged cross compiler
  • clang always ignores -pipe
  • clang uses LLVM’s integrated assembler (llvm-as) by default on all targets where it is supported
  • Enable LIBCXX_USE_COMPILER_RT and LIBCXXABI_USE_COMPILER_RT to use compiler-rt over libgcc_s
  • Enable LIBCXXABI_USE_LLVM_UNWINDER to use libunwind over libgcc_s
  • Clang defaults to gnu99 mode while GCC defaults to gnu89 mode; try passing -std=gnu89 to clang for weird link-time errors
  • Should we set CMAKE_CXX_STANDARD to 20 instead of 17
  • LLVM_BUILD_BENCHMARKS, LLVM_BUILD_DOCS, LLVM_BUILD_EXAMPLES and LLVM_BUILD_TESTS are OFF by default
  • LLVM_BUILD_LLVM_DYLIB is used to build llvm as a single shared library; it can’t be used with BUILD_SHARED_LIBS
  • LLVM_DEFAULT_TARGET_TRIPLE defaults to host (the machine where llvm is being built according to the docs) if no target is explicitly specified; for cross-compilers use $TGT instead
  • LLVM_ENABLE_ASSERTIONS defaults to OFF if CMAKE_BUILD_TYPE is Release
  • Explicitly disable LLVM_BUILD_TELEMETRY and LLVM_ENABLE_BINDINGS; they are ON by default
  • LLVM_ENABLE_PEDANTIC defaults to ON
  • It is better to pass compiler-rt to LLVM_ENABLE_RUNTIMES rather than LLVM_ENABLE_PROJECTS
  • Try setting LLVM_ENABLE_UNWIND_TABLES to OFF instead of passing -fno-unwind-tables in CFLAGS?
  • Consider LLVM_ENABLE_Z3_SOLVER=ON in the future
  • LLVM_INTEGRATED_CRT_ALLOC is only relevant on Windows
  • Consider LLVM_ENABLE_RPMALLOC?; can’t be used with LLVM_USE_SANITIZER=ON
  • LLVM_LINK_LLVM_DYLIB=ON implies LLVM_BUILD_LLVM_DYLIB=ON
  • If LLVM_TABLEGEN is explicitly set to llvm-tblgen, then no native TableGen will be compiled, and the one provided by the host will be used; this is useful when cross-compiling to reduce build time by not having to compile a native tool that could be provided by the host itself
  • It is better to not have LLVM_TARGET_ARCH set as a triplet, as it’ll resolve via regex to X86 almost always
  • LLVM_USE_LINKER prefixes the value (e.g. mold) with ld. (so it becomes ld.mold)
  • Set LLVM_USE_PERF to ON for pgo to work; also consider LLVM_ENABLE_LIBPFM (should be ON by default)
  • Do we need LLVM_USE_SANITIZER=OFF? It defaults to an empty string "" so no?
  • Do we need this early on LLVM_ENABLE_LIBXML2?
  • Not all LLVM projects require LLVM; compiler-rt can be built without llvm
  • LLVM_ENABLE_LTO=Thin does not work if you are using gcc to build llvm obviously
  • CLANG_VENDOR_UTI is a macOS only option
  • CLANG_LINK_CLANG_DYLIB is set to LLVM_LINK_LLVM_DYLIB value
  • Do we need CLANG_BUILD_TOOLS=ON? Are the tools really needed for just building software?
  • CLANG_INCLUDE_DOCS and CLANG_INCLUDE_TESTS are set to LLVM_INCLUDE_DOCS and LLVM_INCLUDE_TESTS values respectively
  • Prefer CMAKE_C_COMPILER and CMAKE_CXX_COMPILER over C_COMPILER and CXX_COMPILER; the latter are llvm only and they set the former internally
  • Do we need to set CMAKE_ASM_COMPILER=clang?
  • LLVM_LIBDIR_SUFFIX is set to "" by default; also CLANG_LIBDIR_SUFFIX is set to its value
  • Do we need COMPILER_RT_DEFAULT_TARGET_ARCH?
  • Do we need LIBUNWIND_ENABLE_CROSS_UNWINDING?
  • Do we need COMPILER_RT_USE_ATOMIC_LIBRARY; does it use compiler-rt or libatomic?
  • LIBCXX_HARDENING_MODE=fast is recommended due to minimal overhead
  • Do we need LIBCXX_ENABLE_TIME_ZONE_DATABASE=OFF?
  • Do not set LIBCXX_ENABLE_PEDANTIC=ON and LIBCXXABI_ENABLE_PEDANTIC=ON as #include_next is used everywhere
  • Do not mix libstdc++ and libc++ as they export the same symbols…
  • Arch does not provide clang-tblgen
  • -Wno-dev suppresses developer warnings
  • To build mesa you only need libllvm and maybe clang (and libclc?)

References