From ffe5913f5677ae84c08f95d886592375af323172 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Fri, 22 May 2026 05:41:43 +0300 Subject: [PATCH] minimal-bootstrap: trim binutils-static output Drop unused installed libraries and headers, avoid building unused gprof/libctf components, and replace duplicate target-prefixed tools with symlinks while keeping the conventional paths available. Size impact against upstream/staging: - binutils-static closure: 42.482 MiB -> 21.093 MiB (-21.389 MiB) Assisted-by: codex with gpt-5.5-high --- .../minimal-bootstrap/binutils/static.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix index 90e2eb8126ea..6461f6523c0b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/binutils/static.nix @@ -46,6 +46,8 @@ let "--enable-deterministic-archives" # depends on bison "--disable-gprofng" + # unused downstream + "--disable-gprof" # Turn on --enable-new-dtags by default to make the linker set # RUNPATH instead of RPATH on binaries. This is important because @@ -57,6 +59,8 @@ let # path to force users to declare their use of these libraries. "--with-lib-path=:" "--disable-gold" + # unused in the bootstrap path and removed from the output + "--disable-libctf" "--disable-plugins" ]; in @@ -83,6 +87,7 @@ bash.runCommand "${pname}-${version}" result: bash.runCommand "${pname}-get-version-${version}" { } '' ${result}/bin/ld --version + ${result}/${hostPlatform.config}/bin/ld --version mkdir $out ''; } @@ -106,5 +111,17 @@ bash.runCommand "${pname}-${version}" # gprof/addr2line/elfedit + man pages are unused downstream. rm -f $out/bin/gprof $out/bin/addr2line $out/bin/elfedit - rm -rf $out/share/info $out/share/man + rm -rf $out/include $out/lib $out/share + + # The target-prefixed tools duplicate the unprefixed tools byte-for-byte. + # Keep the conventional target-prefixed paths, but make them symlinks. + targetBin=$out/${hostPlatform.config}/bin + if [ -d "$targetBin" ]; then + for tool in ar as ld ld.bfd nm objcopy objdump ranlib readelf strip; do + if [ -e "$targetBin/$tool" ] && cmp -s "$out/bin/$tool" "$targetBin/$tool"; then + rm "$targetBin/$tool" + ln -s ../../bin/$tool "$targetBin/$tool" + fi + done + fi ''