Skip to content

Building Clang from source

Sedat Dilek edited this page Jun 4, 2020 · 11 revisions

If you would like to build Clang (and lld) from source for testing purposes, it is really easy! You should have cmake and ninja installed from your distribution.

$ git clone git://github.com/llvm/llvm-project
$ cd llvm-project
$ mkdir build
$ cd build
$ cmake -G Ninja \
        -DCMAKE_BUILD_TYPE=Release \
        -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
        -DLLVM_ENABLE_WARNINGS=OFF \
        ../llvm
$ ninja

You are interested in more optimized binaries and faster compile times? You are invited to use tc-build!

Example: Build Clang and LLD (projects) for X86 (targets) arch-only in a "stage1" build-only

$ git clone git://github.com/ClangBuiltLinux/tc-build
$ cd tc-build
$ ./build-llvm.py --help
$ ./build-llvm.py --projects "clang;lld" --targets "X86" --build-stage1-only

Please see that repo's README for more informations.

Clone this wiki locally