[llvm-dev] debug build busts memory

David Tellenbach via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 26 10:52:46 PST 2019


Hi Brian,

> The linking state of a Debug build seems to require a humongous amount of
> memory.  My poor little linux machine with 16G of ram swaps its brains out.
> Waiting for it to finish (if it ever does) is like the old days when you
> submitted your deck of cards and waited until the next day to see the results.

This actually something I've experienced myself when trying to build LLVM in
debug mode on a machine with 16G of memory. It really is annoying.

> Any ideas to speed things up?


Beside the obvious remark that a machine with more memory for frequent debug
builds is desirable, let me give some remarks:

1. Usually compiling itself is not the problem but linking is. Using a single
threaded build `ninja -j1` should make the build work but causes really
annoyingly long build times.

2. Depending on your host target using a different linker can really help. The
BFD linker didn't work well for me but replacing it with gold (ELF only) or lld
really helped. You can use e.g. the gold linker by setting
`LLVM_USE_LINKER=gold` in your CMake configuration.

3. You can specify the number of parallel link jobs explicitly by setting the
CMake option `LLVM_PARALLEL_LINK_JOBS`. Use a higher number of jobs for
compiling and a lower number for linking.

4. This is a general remark and not limited to a debug build: Use ccache! This
drastically improved build times for me. Enable the CMake option
`LLVM_CCACHE_BUILD` and make sure that ccache is installed and the max. cache
size is big enough (check by running `ccache -s`), I personally use 50G. 

> Is there a way to just build "llc"?

Something I've never tested myself: Build e.g. llc in debug mode (`ninja llc`
in a cmake configuration where the build type is `Debug`), build another
toolchain in non-debug mode and simply replace the non-debug version of llc with
the debug version.

> To debug a new backend, is there a way to just get the debug info for the
> Target/Foo directory?
You could try to modify the step above by building llc for your desired target
only by setting the CMake option LLVM_TARGETS_TO_BUILD="your desired target"`. 

> Thanks, brian

Cheers,
David

> On 26. Nov 2019, at 19:15, Bagel via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> The linking state of a Debug build seems to require a humongous amount of
> memory.  My poor little linux machine with 16G of ram swaps its brains out.
> Waiting for it to finish (if it ever does) is like the old days when you
> submitted your deck of cards and waited until the next day to see the results.
> 
> To debug a new backend, is there a way to just get the debug info for the
> Target/Foo directory?
> 
> Is there a way to just build "llc"?
> 
> Any ideas to speed things up?
> 
> Thanks, brian
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev




More information about the llvm-dev mailing list