llvm
- Do not set 
BUILD_SHARED_LIBS - Do not depend on 
PyYAML; required forllvm-libc LLVM_ENABLE_ASSERTIONSisOFFby default withReleasebuilds- Do we need 
LLVM_PARALLEL_COMPILE_JOBS? - Do we need 
LLVM_PARALLEL_TABLEGEN_JOBS? - Do we need 
LLVM_INSTALL_UTILSforFileCheckandnot? - Do not set 
LLVM_EXTERNAL_LITto allow the bundledlitto 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 
toolchainstage - For list of supported targets by 
LLVM_TARGETS_TO_BUILD, checkllvm/lib/Target/ - Enable 
LLVM_OPTIMIZED_TABLEGENto reduce build time - Disable 
CLANG_ENABLE_STATIC_ANALYZERfortoolchainandcross - To disable 
LIBCXX_ENABLE_RTTIdisableLIBCXX_ENABLE_EXCEPTIONSfirst - What is the default value for 
LIBCXX_CXX_ABI? clangby design is a full fledged cross compilerclangalways ignores-pipeclanguses LLVM’s integrated assembler (llvm-as) by default on all targets where it is supported- Enable 
LIBCXX_USE_COMPILER_RTandLIBCXXABI_USE_COMPILER_RTto usecompiler-rtoverlibgcc_s - Enable 
LIBCXXABI_USE_LLVM_UNWINDERto uselibunwindoverlibgcc_s - Clang defaults to gnu99 mode while GCC defaults to gnu89 mode; try passing 
-std=gnu89to clang for weird link-time errors - Should we set 
CMAKE_CXX_STANDARDto20instead of17 LLVM_BUILD_BENCHMARKS,LLVM_BUILD_DOCS,LLVM_BUILD_EXAMPLESandLLVM_BUILD_TESTSareOFFby defaultLLVM_BUILD_LLVM_DYLIBis used to buildllvmas a single shared library; it can’t be used withBUILD_SHARED_LIBSLLVM_DEFAULT_TARGET_TRIPLEdefaults tohost(the machine wherellvmis being built according to the docs) if no target is explicitly specified; for cross-compilers use$TGTinsteadLLVM_ENABLE_ASSERTIONSdefaults toOFFifCMAKE_BUILD_TYPEisRelease- Explicitly disable 
LLVM_BUILD_TELEMETRYandLLVM_ENABLE_BINDINGS; they areONby default LLVM_ENABLE_PEDANTICdefaults toON- It is better to pass 
compiler-rttoLLVM_ENABLE_RUNTIMESrather thanLLVM_ENABLE_PROJECTS - Try setting 
LLVM_ENABLE_UNWIND_TABLEStoOFFinstead of passing-fno-unwind-tablesinCFLAGS? - Consider 
LLVM_ENABLE_Z3_SOLVER=ONin the future LLVM_INTEGRATED_CRT_ALLOCis only relevant on Windows- Consider 
LLVM_ENABLE_RPMALLOC?; can’t be used withLLVM_USE_SANITIZER=ON LLVM_LINK_LLVM_DYLIB=ONimpliesLLVM_BUILD_LLVM_DYLIB=ON- If 
LLVM_TABLEGENis explicitly set tollvm-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_ARCHset as a triplet, as it’ll resolve via regex toX86almost always LLVM_USE_LINKERprefixes the value (e.g.mold) withld.(so it becomesld.mold)- Set 
LLVM_USE_PERFtoONforpgoto work; also considerLLVM_ENABLE_LIBPFM(should beONby 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-rtcan be built withoutllvm LLVM_ENABLE_LTO=Thindoes not work if you are usinggccto buildllvmobviouslyCLANG_VENDOR_UTIis a macOS only optionCLANG_LINK_CLANG_DYLIBis set toLLVM_LINK_LLVM_DYLIBvalue- Do we need 
CLANG_BUILD_TOOLS=ON? Are the tools really needed for just building software? CLANG_INCLUDE_DOCSandCLANG_INCLUDE_TESTSare set toLLVM_INCLUDE_DOCSandLLVM_INCLUDE_TESTSvalues respectively- Prefer 
CMAKE_C_COMPILERandCMAKE_CXX_COMPILERoverC_COMPILERandCXX_COMPILER; the latter arellvmonly and they set the former internally - Do we need to set 
CMAKE_ASM_COMPILER=clang? LLVM_LIBDIR_SUFFIXis set to""by default; alsoCLANG_LIBDIR_SUFFIXis 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 usecompiler-rtorlibatomic? LIBCXX_HARDENING_MODE=fastis recommended due to minimal overhead- Do we need 
LIBCXX_ENABLE_TIME_ZONE_DATABASE=OFF? - Do not set 
LIBCXX_ENABLE_PEDANTIC=ONandLIBCXXABI_ENABLE_PEDANTIC=ONas#include_nextis used everywhere - Do not mix 
libstdc++andlibc++as they export the same symbols… - Arch does not provide 
clang-tblgen -Wno-devsuppresses developer warnings- To build 
mesayou only needlibllvmand maybeclang(andlibclc?) - It’s better to use 
lldbecause it can tap into private LLVM APIs instead of going back and forth through the generic linker plugin API; verify this? 
References
Section titled “References”- https://archive.fosdem.org/2024/events/attachments/fosdem-2024-2555-building-a-linux-distro-with-llvm/slides/22812/chimera_fosdem_2024_llvm_DIVbHby.pdf
 - https://bcain-llvm.readthedocs.io/projects/libunwind/en/latest/BuildingLibunwind/
 - https://clang.llvm.org/c_status.html
 - https://clang.llvm.org/cxx_status.html
 - https://clang.llvm.org/docs/ClangCommandLineReference.html
 - https://clang.llvm.org/docs/CommandGuide/clang.html
 - https://clang.llvm.org/docs/CrossCompilation.html
 - https://clang.llvm.org/docs/index.html
 - https://clang.llvm.org/docs/InternalsManual.html
 - https://clang.llvm.org/docs/Toolchain.html
 - https://clang.llvm.org/docs/Tooling.html
 - https://clang.llvm.org/docs/UsersManual.html
 - https://clang.llvm.org/get_started.html
 - https://cliutils.gitlab.io/modern-cmake/
 - https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
 - https://cmake.org/cmake/help/latest/index.html
 - https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
 - https://compiler-rt.llvm.org/
 - https://discourse.llvm.org/
 - https://github.com/llvm/llvm-project/tree/main/llvm/lib/Target
 - https://github.com/llvm/llvm-zorg
 - https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/CrossCompiling
 - https://libcxx.llvm.org/Hardening.html
 - https://libcxx.llvm.org/index.html
 - https://libcxx.llvm.org/Modules.html
 - https://libcxx.llvm.org/TestingLibcxx.html
 - https://libcxx.llvm.org/UserDocumentation.html
 - https://libcxx.llvm.org/VendorDocumentation.html
 - https://llvm.org/devmtg/2023-10/slides/tutorials/Hosek-UnderstandingtheLLVMbuild.pdf
 - https://llvm.org/docs/AdvancedBuilds.html
 - https://llvm.org/docs/BuildingADistribution.html
 - https://llvm.org/docs/CMake.html
 - https://llvm.org/docs/CMakePrimer.html
 - https://llvm.org/docs/genindex.html
 - https://llvm.org/docs/GettingStarted.html
 - https://llvm.org/docs/GoldPlugin.html
 - https://llvm.org/docs/HowToCrossCompileBuiltinsOnArm.html
 - https://llvm.org/docs/HowToCrossCompileLLVM.html
 - https://llvm.org/docs/Lexicon.html
 - https://llvm.org/docs/UserGuides.html
 - https://mcilloni.ovh/2021/02/09/cxx-cross-clang/
 - https://muxup.com/building-testing-and-distributing-llvm-clang-and-friends
 - https://rocm.docs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/CMake.html
 - https://wiki.musl-libc.org/building-llvm.html
 - https://www.youtube.com/watch?v=NMQrnVDf-rY