Gold

From Gentoo Wiki
Jump to: navigation, search

gold is a new linker intended as a replacement for the ld.bfd linker.

The two installed linkers are available directly as ld.bfd and ld.gold respectively. Additionally, the default linker is also installed as ld -- and this binary is used by compilers.

Switching the default linker

The easy way

Emerge >=sys-devel/binutils-config-3 and set default linker to gold:

root #binutils-config --linker ld.gold
* Setting default linker to ld.gold for x86_64-pc-linux-gnu-2.22 ...                            [ ok ]

The hard way (manually)

The default linker can be changed immediately by linking ld to ld.gold in the binutils directory.

user $readlink -f /usr/bin/ld
/usr/x86_64-pc-linux-gnu/binutils-bin/2.22/ld

Hard link:

root #ln -f /usr/x86_64-pc-linux-gnu/binutils-bin/2.22/ld.gold /usr/x86_64-pc-linux-gnu/binutils-bin/2.22/ld

Symbolic link:

root #ln -sf ld.gold /usr/x86_64-pc-linux-gnu/binutils-bin/2.22/ld

To make the change persistent across re-installations of binutils, one should pass a flag to the binutils configure script. This can be done using the EXTRA_ECONF variable in a package.env configuration.

FILE /etc/portage/env/gold.confEnvironment overrides to enable gold by default
EXTRA_ECONF="--enable-gold=default"
FILE /etc/portage/package.envEnabling gold.conf override for binutils
sys-devel/binutils gold.conf