To build everything, do this:
$ git clone --depth 1 --branch llvmorg-19.1.0 https://github.com/llvm/llvm-project.git
$ cmake -S llvm-project/llvm -B llvm-project/build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=all \
-DLLVM_ENABLE_RUNTIMES=all
$ cmake --build llvm-project/build -j8
$ cmake --install llvm-project/build --prefix /usr/local # or somewhere else
You might also be interested in the following build flags for the first CMake command:
-DLLVM_ENABLE_ASSERTIONS=ON-- good for debugging-DLLVM_ENABLE_EH=ON-- enable if your application uses C++ exceptions-DLLVM_ENABLE_RTTI=ON-- enable if your application uses C++ RTTI
Also see the upstream documentation: https://llvm.org/docs/CMake.html
Note that some of the LLVM projects can only be built with clang. I won't get into bootstrapping issues, but if the build fails, you can winnow down the list of projects from all to a subset of the following: clang, clang-tools-extra, cross-project-tests, libc, libclc, lld, lldb, openmp, polly, and pstl.
You can also reduce the list of runtimes to a subset of compiler-rt, libc, libcxx, libcxxabi, libunwind, and openmp.
Note that LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES should not overlap. The latter builds each target with the just-built clang.
installation - How do you build all of LLVM? - Stack Overflow
What is considered best practice to get LLVM working on Windows?
how to build llvm-hs from source
Create a cabal project that depends on llvm-hs and use https://cabal.readthedocs.io/en/3.6/cabal-project.html#specifying-packages-from-remote-version-control-locations to specify the commit -- if llvm-hs has a checked-in *.cabal file (either not using hpack, not checked in the generated file).
More on reddit.comWhy is Nixpkgs suddenly building everything from source?
Videos
To build everything, do this:
$ git clone --depth 1 --branch llvmorg-19.1.0 https://github.com/llvm/llvm-project.git
$ cmake -S llvm-project/llvm -B llvm-project/build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=all \
-DLLVM_ENABLE_RUNTIMES=all
$ cmake --build llvm-project/build -j8
$ cmake --install llvm-project/build --prefix /usr/local # or somewhere else
You might also be interested in the following build flags for the first CMake command:
-DLLVM_ENABLE_ASSERTIONS=ON-- good for debugging-DLLVM_ENABLE_EH=ON-- enable if your application uses C++ exceptions-DLLVM_ENABLE_RTTI=ON-- enable if your application uses C++ RTTI
Also see the upstream documentation: https://llvm.org/docs/CMake.html
Note that some of the LLVM projects can only be built with clang. I won't get into bootstrapping issues, but if the build fails, you can winnow down the list of projects from all to a subset of the following: clang, clang-tools-extra, cross-project-tests, libc, libclc, lld, lldb, openmp, polly, and pstl.
You can also reduce the list of runtimes to a subset of compiler-rt, libc, libcxx, libcxxabi, libunwind, and openmp.
Note that LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES should not overlap. The latter builds each target with the just-built clang.
These are the steps I use taken from here:
mkdir llvm
cd llvm
git clone https://github.com/llvm/llvm-project.git .
git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git
git clone https://github.com/intel/opencl-clang.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git ./llvm/projects/SPIRV-Headers
git clone https://github.com/intel/vc-intrinsics.git ./llvm/projects/vc-intrinsics
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=”X86″ -DLLVM_ENABLE_PROJECTS=”clang” -DLLVM_EXTERNAL_PROJECTS=”llvm-spirv;opencl-clang” -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=”../SPIRV-LLVM-Translator” -DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=”../opencl-clang” ../llvm
make opencl-clang