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

25. Binutils

GNU binutils is the assembler, the linker and the tools that read and rewrite object files: as, ld, ar, nm, objdump, readelf, strip and the rest. The binutils in build/cross runs only in the container. This step builds a second, native one: compiled by the cross toolchain, it runs on KDOS and produces programs for KDOS, so the GCC of the next step has an assembler and a linker to call once the build moves inside build/fs. 090_binutils.sh builds it from the binutils port’s source tarball, the same source as Part II’s cross binutils.

Source: the archive of the binutils port
Installs into: build/fs/usr
Approximate build time: 1.1 SBU

Installation of binutils

The step unpacks the port’s tarball and builds in a separate build directory, as binutils’ own documentation recommends:

BINUTILS_SRC=$(extract_port_source binutils)
cd "$BINUTILS_SRC"

mkdir build && cd build
../configure \
    --host=$KDOS_TARGET \
    --prefix=/usr \
    --disable-nls \
    --disable-werror \
    --disable-multilib \
    --enable-new-dtags \
    --enable-gprofng=no \
    --enable-default-hash-style=gnu
make
make DESTDIR=$SYSROOT install

# No libtool archive outlives this step: these are installed outside any
# package, so nothing later removes them, and libtool would copy their
# dependency lists into every library linked against libbfd or libopcodes.
rm -f $SYSROOT/usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes,sframe}.la

# The manual pages of the Windows PE tools, which a Linux target does
# not build; the binutils port deletes them from its package too.
rm -f $SYSROOT/usr/share/man/man1/{dlltool,windres,windmc}.1

script/phases/10_bootstrap/090_binutils.sh, lines 24–47

The meaning of the configure options

--host=$KDOS_TARGET
The tools run on KDOS. No --target is given, so the target defaults to the host, and the tools produce code for x86_64-kdos-linux-musl as well. Because host and target are the same, the programs are installed under their plain names (/usr/bin/ld, not x86_64-kdos-linux-musl-ld).
--prefix=/usr
The programs go to /usr/bin. binutils also installs a second copy of its main tools, and the linker scripts, under its tool directory, /usr/x86_64-kdos-linux-musl/.
--disable-nls
Build no message catalogues.
--disable-werror
Never treat a compiler warning as an error, whatever the source’s own default, so a warning the cross compiler raises does not stop the build.
--disable-multilib
Build nothing for a second ABI such as -m32. KDOS has a 64-bit userland only.
--enable-new-dtags
When a link is given a run-time search path, ld writes it as DT_RUNPATH instead of the older DT_RPATH. glibc’s loader lets LD_LIBRARY_PATH override a RUNPATH but not an RPATH; musl’s, the loader on KDOS, reads the two tags alike and searches LD_LIBRARY_PATH before either.
--enable-gprofng=no
Do not build the gprofng profiler. binutils already leaves it out on a musl target; the switch states it.
--enable-default-hash-style=gnu
The linker writes only the GNU symbol hash table (.gnu.hash). binutils’ default on Linux is both, which also writes the older SysV .hash.

--enable-shared is not given, so libbfd, libopcodes, libctf, libctf-nobfd and libsframe are built as static archives, each with a libtool archive (.la) beside it.

Removing the libtool archives

The rm -f line deletes those five .la files. They are installed outside any package, so nothing later removes them, and libtool copies an .la file’s dependency list into every library linked against it. Left in place, every later build that linked libbfd or libopcodes would inherit them.

Removing the Windows tools’ manual pages

The last rm deletes the manual pages of dlltool, windres and windmc, which the install writes although those programs are built only for Windows targets. The binutils port deletes the same three pages from its package, so these copies would be adopted by no package and outlive every install.

The step then removes the source and touches build/mark/bootstrap/binutils.

Built again later

20_selfhost builds the binutils port as its fifth list entry, and 30_foundation names it again so a changed recipe is rebuilt there. The package adopts /usr/bin/ld and the other programs this step installed. The port build differs from this one in several ways:

See also