'Building LLVM eats away all my RAM

I'm trying to build LLVM to use Clang tools according to this guide:

https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html

However, I don't seem to be able to build the LLVM packages. When I perform the make check-all, it starts doing its job, but it gets stuck at this step and semi-slowly gobbles up all my RAM.

[ 87%] Linking CXX executable MITests

I tried using CMake too as cmake --build . --target install, but it also gets stuck here:

[ 90%] Linking CXX shared library ../../lib/libLTO.so

What can I do with this? Or is there another method to get the Clang toolkit?



Solution 1:[1]

LLVM is huge, and its libraries are big because they contain a lot of functionality.

I would suggest downloading acquiring more RAM.

Alternatively, don't link in debug symbols, optimize for code size -Os, and ensure you're not performing two links steps concurrently.

If you're using (GNU) ld, you can do tricks like

--hash-size=31 --reduce-memory-overhead

Also try using the gold linker instead if you're on Linux, using -fuse-ld=gold.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Mortensen