Building LLVM and Clang

Often it’s useful to build the latest LLVM and Clang from source code, rather than relying on often out-of-date packages available in repositories. This build process can be done quickly and easily with CMake, but it’s worth taking care to ensure the right options are passed.

The following commands will build LLVM and Clang to be installed in /usr/bin (and /usr/lib, etc.). Note that the ‘-j’ option tells make how many recipes may execute at once; use this to your advantage to dramatically reduce the build time on multi-core machines!

The following directory structure is assumed:

(I.e. both LLVM and Clang have been downloaded and moved to /llvm/llvm-src and /clang/clang-src respectively.)