Replacing ld with gold - any experience?
As it took me a little while to find out how to selectively use gold (i.e. not system-wide using a symlink), I'll post the solution here. It's based on http://code.google.com/p/chromium/wiki/LinuxFasterBuilds#Linking_using_gold .
- Make a directory where you can put a gold glue script. I am using
~/bin/gold/
. Put the following glue script there and name it
~/bin/gold/ld
:#!/bin/bash gold "$@"
Obviously, make it executable,
chmod a+x ~/bin/gold/ld
.Change your calls to
gcc
togcc -B$HOME/bin/gold
which makes gcc look in the given directory for helper programs likeld
and thus uses the glue script instead of the system-defaultld
.
At the moment it is compiling bigger projects on Ubuntu 10.04. Here you can install and integrate it easily with the binutils-gold
package (if you remove that package, you get your old ld
). Gcc will automatically use gold then.
Some experiences:
- gold doesn't search in
/usr/local/lib
- gold doesn't assume libs like pthread or rt, had to add them by hand
- it is faster and needs less memory (the later is important on big C++ projects with a lot of boost etc.)
What does not work: It cannot compile kernel stuff and therefore no kernel modules. Ubuntu does this automatically via DKMS if it updates proprietary drivers like fglrx. This fails with ld-gold
(you have to remove gold, restart DKMS, reinstall ld-gold
.