After reading Diego’s post on linkers, I got curious (and interested) by this new linker (also mentioned in LWN and other sites).
Developed by Ian Lance Taylor (from Google), the gold linker is now in binutils, and promises link times divided at least by 5. The code I develop at work is a big C++ project, and takes a looooot of time linking indeed (especially in debug…). So let’s see how to try this new linker
First, a big warning: this is still heavily experimental, I do not recommend to use it for your system itself. It only works on x86/amd64, does NOT link a kernel correctly for now. Keep a stable binutils, and use it for all your emerge operations. UPDATE: see Diego’s warnings too, Remember that I only test gold on C++ debug binaries, not on system packages or other important compilations.
You have been warned 😉 Now let’s see how to install a gold-enabled binutils in parallel with your stable one:
- First step: enable multislot for binutils (so you’ll have both unstable/gold binutils and stable binutils available with binutils-config)
# echo "sys-devel/binutils multislot" >> /etc/portage/package.use
# emerge -av binutils
- Unmask an unstable binutils ebuild, and compile it with gold enabled (thanks to EXTRA_ECONF feature)
# echo "=sys-devel/binutils-188.8.131.52.6 **" >> /etc/portage/package.keywords
# EXTRA_ECONF="--enable-gold" emerge -av '=sys-devel/binutils-184.108.40.206.6'
- Use binutils-config to switch between your stable binutils, and gold-enabled 220.127.116.11.6 (ld –version will say “GNU gold …”)
And now back to work with greatly reduced linking times, yay!
4 thoughts on “Testing the new “gold” linker from binutils”
So in your project do you really get 5x less time ?
I did not have time yet for thorough benchmarks (release time is not good for these), but for example one of the programs now links in about 15-20 seconds, instead of more than a minute. So it’s 3x-4x faster for sure 🙂
Some numbers about duplicate strings collapsing in ld
I haven’t had time to test gold yet, but at least Bernard saved me from finding out how to do so 🙂 I plan on doing it today, as I just finished a script, based again on my ruby-elf, that calculates how much space is saved by collapsing duplicated s…
About gold and speed
Okay yet another post writing about the gold linker. I finally checked out what I wanted: indeed gold does not do the collapse of duplicated substring: my script reports this: flame@enterprise ruby-elf % ruby -Ilib tools/assess_duplicate_save.rb…
Comments are closed.