[llvm-dev] difference with autotools, cmake and ninja building methods

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 1 10:01:11 PST 2015


On Tue, Dec 1, 2015 at 2:17 AM, David Chisnall via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On 1 Dec 2015, at 10:03, 慕冬亮 via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> >
> > collect2: fatal error: ld terminated with signal 9 [Killed]
> > compilation terminated.
> > [2706/2983] Linking CXX executable bin/clang-check
> > ninja: build stopped: subcommand failed.
>
> This looks like the linker is running out of memory.  This is a huge link
> job and BFD linker will consume at least one GB of RAM, possibly far more
> depending on your build config.  If you’re on a 32-bit platform, then you
> won’t be able to do this with a debug build.
>

With Fission (AKA Split Dwarf) you might be able to manage it (check for
the BLAH_BLAH_SPLIT_DWARF option in the CMake config)


> The big speedup if you’re using BFD ld is to enable shared library
> support.  This is a particularly big win if you’re doing incremental builds
> a lot, because the extra startup time overhead is likely to be far less
> than the 4-5 minutes of extra time spent linking, even on a fast machine.
>

If you plan to run the regression tests with that build, you'll probably
lose the time you gain by linking - the startup of all the llvm tools for
all those little tests adds up. A "make check-all" of clang/llvm, at least
on my machine (32 core, 32GB of RAM, running of an SSD) is slower (even if
you just touch one cc file - causing maximal linking, minimal compiling,
etc) with a shared library build, unfortunately.


>
> If you do want to do static linking, then your best bet is to do ninja -k
> 10, which should let it skip over the link jobs that fail, but keep
> compiling the sources, then ninja -j1, which will make it do the remaining
> steps one at a time.  In general, the defaults for ninja work well for
> LLVM/Clang if you have at least one GB of RAM per core.
>

I think there's a ninja flag for the number of link jobs you want to run in
parallel, separate from the usual parallelism.


> On a modern laptop, you should be able to do a clean build in 5-10
> minutes, but BFD ld can be a bottleneck.  It would be nice if CMake had an
> option to stick -fuse-ld=gold (or -fuse-ld=lld) in all of the correct
> places, but when I’ve tried poking the link flags to add this myself I’ve
> found weird linking errors that I haven’t had time to debug.
>
> David
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151201/04ad7e8b/attachment.html>


More information about the llvm-dev mailing list