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-220.127.116.11.6 **" >> /etc/portage/package.keywords
# EXTRA_ECONF="--enable-gold" emerge -av '=sys-devel/binutils-18.104.22.168.6'
- Use binutils-config to switch between your stable binutils, and gold-enabled 22.214.171.124.6 (ld –version will say “GNU gold …”)
And now back to work with greatly reduced linking times, yay!