Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

35.3. binutils-2.47

A collection of binary tools

Version 2.47, release 3
Shelf toolchain — The native compilers, the linker, the C library, and the LLVM family
Phase 20_selfhost (Self-Hosting Bootstrap), 6 of 15 in build order
Licence GPL-3.0-or-later AND LGPL-3.0-or-later
Homepage https://www.gnu.org/software/binutils/
Build time 1.4 SBU
Installed size 17.0 MiB in 167 files
Recipe ports/core/toolchain/binutils/kpkgbuild

About

GNU binutils is the assembler, as, the linker, ld, and the tools that read and edit object files: ar, nm, objcopy, objdump, readelf, strip and the rest, over the shared libraries libbfd, libopcodes, libctf and libsframe. GCC assembles and links every program it compiles through this package, and kpkg itself runs objcopy on the largest objects of a package (see Size and language policy).

20_selfhost builds it after zlib and xxhash, which it builds against, and before gcc; 30_foundation names it again so a changed recipe is rebuilt before the rest of that phase. It replaces the binutils Part III built with the cross compiler, and it is native to the chroot’s own triple, so it installs every tool under its plain name. The reasons are in The toolchain rebuilt as packages.

The source is configured and built in a build directory of its own inside the tree, as binutils/README recommends.

Sources

Dependencies

Depends on: zlib, xxhash.

Required by (5): bpftrace, fwupd-efi, llvm, ocaml, stockfish.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Differs from the bootstrap build. Cross binutils builds this source too, in script/phases/00_cross/00_binutils.sh, before kpkg exists.

Only in the bootstrap build: --disable-multilib, --enable-default-hash-style=gnu, --enable-gprofng=no, --enable-new-dtags, --prefix=$CROSS_SYSROOT, --target=$KDOS_TARGET, --with-sysroot=$SYSROOT.

Only in this build: --enable-64-bit-bfd, --enable-deterministic-archives, --enable-ld=default, --enable-lto, --enable-plugins, --enable-shared, --prefix=/usr, --sysconfdir=/etc, --with-system-zlib, --with-xxhash, --without-debuginfod, --without-msgpack, --without-zstd.

Differs from the bootstrap build. Binutils builds this source too, in script/phases/10_bootstrap/090_binutils.sh, before kpkg exists.

Only in the bootstrap build: --disable-multilib, --enable-default-hash-style=gnu, --enable-gprofng=no, --enable-new-dtags, --host=$KDOS_TARGET.

Only in this build: --enable-64-bit-bfd, --enable-deterministic-archives, --enable-ld=default, --enable-lto, --enable-plugins, --enable-shared, --sysconfdir=/etc, --with-system-zlib, --with-xxhash, --without-debuginfod, --without-msgpack, --without-zstd.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/20_selfhost/phase.env && kpkg install binutils'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/toolchain/binutils.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/toolchain/binutils
echo '154ab23b60070e8f27013c22977f1129425d67d1e8acd6e13010e617811e4cff  binutils-2.47.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/binutils
SRC=$SRC_ROOT/binutils-2.47
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf binutils-2.47.tar.xz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -v build
cd       build

../configure \
	--prefix=/usr \
	--sysconfdir=/etc \
	--disable-nls \
	--disable-werror \
	--enable-64-bit-bfd \
	--enable-deterministic-archives \
	--enable-ld=default \
	--enable-lto \
	--enable-plugins \
	--enable-shared \
	--with-system-zlib \
	--with-xxhash \
	--without-zstd \
	--without-debuginfod \
	--without-msgpack
make tooldir=/usr
make tooldir=/usr DESTDIR=$PKG install

install -m644 ../binutils/doc/{addr2line,ar,c++filt,elfedit,nm,objcopy,objdump,ranlib,readelf,size,strings,strip}.1 \
	../gas/doc/as.1 -t "$PKG/usr/share/man/man1"
rm -f "$PKG"/usr/share/man/man1/{dlltool,windres,windmc}.1

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/binutils, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf binutils-2.47-3.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/binutils, and runs the triggers its paths call for.

Contents

Installed programs: addr2line, ar, as, c++filt, elfedit, gprof, ld, ld.bfd, nm, objcopy, objdump, ranlib, readelf, size, strings, strip.

Installed libraries: libbfd-2.47.20260726.so, libbfd.a, libbfd.so, libctf-nobfd.a, libctf-nobfd.so, libctf.a, libctf.so, libopcodes-2.47.20260726.so, libopcodes.a, libopcodes.so, libsframe.a, libsframe.so.

Installed directories: /usr/lib/bfd-plugins, /usr/lib/ldscripts, /usr/share/licenses/binutils.

Short descriptions

addr2line convert addresses or symbol+offset into file names and line numbers
ar create, modify, and extract from archives
as the portable GNU assembler.
c++filt demangle C++ and Java symbols
elfedit update ELF header and program property of ELF files
gprof display call graph profile data
ld The GNU linker
nm list symbols from object files
objcopy copy and translate object files
objdump display information from object files
ranlib generate an index to an archive
readelf display information about ELF files
size list section sizes and total size of binary files
strings print the sequences of printable characters in files
strip discard symbols and other data from object files

Notes

The install line after the build copies the manual pages of the binutils/ tools and of as from the source’s doc directories, where the release carries them already formatted, into the package’s man1. The rm line then deletes the pages of dlltool, windres and windmc, which document Windows-target tools this build does not install.

libbfd and libopcodes carry the full version in their file name and soname (libbfd-<version>.so, where <version> is 2.47.20260726 for this tarball), so a program linked against either must be rebuilt whenever binutils changes version. libctf and libsframe have ordinary numbered sonames.