Building LLVM in Debug mode takes more than 50 GB of disk space on my machine and then fails due to insufficient RAM (I have 32 GB). Am I missing a tip that could allow me to build on my 2021 laptop?
I just did:
cmake -S llvm -B build -G 'Unix Makefiles' -DLLVM_ENABLE_PROJECTS=clang\;clang-tools-extra -DCMAKE_BUILD_TYPE=Debug
cd build
make -j8
Depending on what system that is, you might be using ld.bfd to link. That always fails for me with a debug build of LLVM, even on systems with exorbitant amounts of ram. Try using LLD instead.
Thanks, I used -DLLVM_PARALLEL_LINK_JOBS=1 and I build with clang, which is much faster. I no longer run out of RAM. But it looks like building with clang does not work in the end?
@OlivierNicole If you don’t need an LLVM with all targets, this might also reduce the resources needed for a compilation.
LLVM_TARGETS_TO_BUILD:STRING
Control which targets are enabled. For example you may only need to enable your native target with, for example, -DLLVM_TARGETS_TO_BUILD=X86.
Thanks for your advice. I can almost build without OOM now. Looks like the rest of my build issues are 32-bit-related (and so unrelated to this thread).
I usually don’t build debug builds, because they are so big. And because I generally don’t need to debug LLVM builds. What I do instead, is that I make a release build with assertions enabled. This will catch most simple mistakes and still produces reasonably usable stack trace when hitting an assertion.
(The other suggestions are also a good idea, especially using lld because it’s so much faster).