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 “
Is it expected to consume that much memory during build?
What usually helps a lot is to add the following to your initial CMake invocation:
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.
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.
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
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 <email@example.com> ezt írta (időpont: 2020. aug. 15., Szo, 22:23):