Too much time to compile clang. Suggestions for a starter?

I would like to start “touching” a bit the code, trying to create some functionalities, but I have no idea where to start, and I will need many trials/tests…

So, one thing I was expecting is fast times to try (Modify-Compile-Run).

I did:

make clang
and it needed like 3-4 hours. I am ok with that.

Then, I add some “stupid” statement like ‘int a = 3;’ somewhere in llvm/tools/clang/lib/Frontend/Rewrite/FixItRewriter.cpp (FixitRewriter::Diag), and it needed:

  • 6.57s. to compile the target (‘make clangRewriteFrontend’).
  • 4min 36.36s to link and build clang (make clang).
    In both cases it spends almost all the time linking (first to a static lib, then to the clang binary itself).

This is really a lot of time to try bit a bit without knowledge of the whole clang, compiling process, etc. Waiting up to is just really time consuming.

What would you do to try the modifications faster?

Any recomendation/blog/guide to follow as a starter trying to modify a bit the codebase of clang?

You can use gold <; to link.
To do so, pass -DLLVM_USE_LINKER=gold at CMake configure time.

This is also a good opportunity to point at a minor issue with CMake
configuration, where even after passing the above switch CMake will
still print

-- Linker detection: GNU ld

instead of

-- Linker detection: GNU Gold

I don't know whether it "just works" for others, but
<; (unreviewed) fixes it for me.

Did you try to run make in parallel using the -j option? That and linking with Gold (as Oleksii mentioned) should greatly improve build times.

Especially for incremental builds, ninja tends to be a much better


A few links that Google found in a simple search:
  - this thread:
  - and these two blog posts: and

I personally took most of the advices from the last blog posts:
  - Ninja, use Clang to build


Thank you very much, Jonas, Nicolas and Oleksii.

I read those blogs and applied just this:

cp ../../llvm-support/ ../cmake/modules/AddLLVM.cmake
(I modified those lines in the
CXX=clang++ CC=clang cmake -G Ninja .. -DLLVM_USE_LINKER=gold

And with just the same modification (int a = 22; in that class) I get
compiled/linked in JUST 10-3 SECONDS.


Thanks again. This thread can be closed.

You might also consider building only those backends you are actually using.
E. g.:

More info: