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 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
* Setting default linker to for x86_64-pc-linux-gnu-2.22 ...                            [ ok ]

The hard way (manually)

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

user $readlink -f /usr/bin/ld

Hard link:

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

Symbolic link:

root #ln -sf /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
FILE /etc/portage/package.envEnabling gold.conf override for binutils
sys-devel/binutils gold.conf