[Qbs] Question about linking (linux-gcc)

Christian Gagneraud chgans at gmail.com
Thu Nov 23 01:00:56 CET 2017

Hi there,

I have two questions related to the linking process, I'm using qbs-1.10 
(as per QtC) on a Ubuntu 17.04 x86_32 VM.

First the simple one:
What is the best way to choose which binutils linker to use? I would 
like to activate the gold linker instead of the bfd one (default), gcc 
option for this is "-fuse-ld=gold", I think this option *has* to be 
passed to gcc, so i wonder if cpp.linkerFlags is the correct place, I 
know it works, but i'm curious to know if there's a better way to do it.

My 2nd question requires a bit of explanation first:
I need to link an app against lots of static libraries. Each static 
library has a list of Depends (mostly Qt deps).
Qbs generate a link command for my app by simply appending all the libs' 
depends. So I endup with a very-very long command line that contains 
hundreds of duplicated Qt linking fragments.
The actual link command is 49384 character longs!

For some reason, it upset the linker (like the linker doesn't seem to 
simplify the command line), I have currently 4 link processes that have 
been running for more than half an hour, with qmake the link time is a 
couple of minutes with bfd, with qmake and the gold linker, the link 
time is roughly a minute or less (2.5 increase in speed).

My static libraries qbs files are very-very simple, a file list, a 
Depends for Qt. I do not use (anymore) exported depends.

Is it possible to work this around?
I have the feeling that it might be due to the use of lto, as the g++ 
sub-process starts with: /usr/bin/ld -plugin .../liblto_plugin.co

When I use the gold linker (with qbs) I do not have this problem, even 
tho the subprocess starts with /usr/bin/ld.gold -plugin .../liblto_plugin.co

Any idea about that, is it a qbs issue or should I blame it on the bfd 


PS: I am actually interested in evaluating LTO, but that's something 
that will come later (LTO is an expansive operation)

More information about the Qbs mailing list