DeveloperWiki:Toolchain maintenance/Binutils

From ArchWiki

The binutils package provides set of programs to assemble and manipulate binary and object files.


The binutils PKGBUILD is set up to use either release tarballs or git checkouts. As binutils rarely releases bug fix releases, it can be useful to build off the release branch to get important backports. Alternatively, maintainers can select individual patches to include and work with the release tarball which has a PGP signature.

If building from release tarballs, we symlink the release directory to "binutils-gdb" during the prepare() function to unify the build process. Additionally, release branches in git are labelled as developmental builds, so we adjust "bfd/" to set this as a release build.


TODO: document all dependencies (including make and check)

Preparing the Build

Binutils can only be built outside the source tree, so we create a "binutils-build" directory. Using "mkdir -p" is to allow for incremental builds when testing package changes (and is useless during clean chroot builds).

Libiberty configures using "$CPP $CPPFLAGS" which fails using Arch default flags as FORTIFY_SOURCE requires optimisation provided in CFLAGS. We add -O2 the the relevant line in libiberty/configure.

TODO: A potential better solution is to move -D_FORTIFY_SOURCE=2 to CFLAGS (using -Wp,), either in the PKGBUILD or at Arch level. This may also fix testsuite failures (below)

Configuring the Build

The following configure options are used in the binutils build:

Set the default paths in Arch:


We use our bug tracker as the first point of call for Arch users (and derivatives that distribute out packages...):


Options added to enable our unified git/tarball PKGBUILD:


We build the gold linker, but still use the bfd linker as our default, and enable threading when using gold. There may be benefits in Arch switching to used gold as default at some stage:


Enable link time optimization support:


Enables plugin support for the linker:


Enable -z,relro by default. This is enabled as a security feature.:


TODO: is -z,relro needed in makepkg.conf?

Try to use only PIC objects:


Create reproducible archives - zero for UIDs, GIDs, timestamps, and use consistent file modes for all files:


Support Intel CET instructions:


Build the BFD and opcodes libraries as shared libraries, some of which we then delete during packaging...:


NOTE: currently disabled' See upstream bug

Enable producing EFI binaries - useful for setting up UEFI boot with Xen:


Enable debuginfo lookups with debuginfod:


Use the system zlib library rather than the copy in the binutils source:



It is important that the Arch LDFLAGS are overridden before running the binutils testsuite. The testsuite makes decisions of which LDFLAGS to include while test various features, and does not ignore values from the build environment.

Failures in the ld.bfd linker testsuite need examined in detail and documented before release of any package. As is not the default linker, we allow failures in its testsuite. These failures in the gold testsuite have historically been false positives due to the Arch buildflags.

The following tests are the current (binutils-2.35.1) known to fail in the gold testsuite:


TODO: investigate these failures and document reasons. Note testsuite attempts to remove FORTIFY_SOURCE, but assumes it is specified with -Wp in CFLAGS rather than directly in LDFLAGS.

Packaging Notes

We remove man pages for utilities that we do not distribute (Windows/Novell only).

We also prevent programs from dynamically linking against libbfd and libopcodes, as these are rather unstable. Instead, we provide linker scripts to link the static versions (and their dependencies).