Building clang

Hi,
I wanted to play with clang, and was trying to build it according to instructions (https://clang.llvm.org/get_started.html), with GCC 5.5 and GNU ld 2.26.1, running my linux 5.6.7.

However, the build regularly fails, running out of memory (my laptop has 12Gb RAM). I tried with both “Unix Makefiles” and “Ninja 1.7.1”. I did specify explicitly “DLLVM_ENABLE_PROJECTS=clang”.

Is it expected to consume that much memory during build?

Regards,

Denis

What usually helps a lot is to add the following to your initial CMake invocation:

-D LLVM_PARALLEL_LINK_JOBS=1

Since linking tends to use lots of memory, and is rather slow, these jobs usually end up clustered together near the end of build stages, and will then fill up all available memory. Limiting the number of parallel link jobs usually helps with this problem.

-Dimitry

GNU ld probably is a bit of a bottleneck here - try gold or lld if you can.

But also what Dimitry said - about reducing the number of link steps.
Also depends if you build with debug info - that adds a lot. Using
Split DWARF can help ease that a bit.

Hi
Thanks to everyone, indeed, using “-DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_USE_LINKER=gold -DLLVM_TARGETS_TO_BUILD=X86”, actually worked!
P.S I had to turn off swap completely, because I prefer process being killed than my laptop being unusable

Thanks again

Regards
Denis

In addition, if you can stomach slower load times but faster builds, you can also use -DBUILD_SHARED_LIBS=ON

denis gantsev via cfe-dev <cfe-dev@lists.llvm.org> ezt írta (időpont: 2020. aug. 15., Szo, 22:23):