This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Gold

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
Resources

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.

Installation

package.env

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 override 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

Remerge

After setting EXTRA_ECONF, (r)emerge sys-devel/binutils:

root #emerge --ask --changed-use --deep --oneshot --verbose sys-devel/binutils

Configuration

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