minimal-bootstrap: post-install trim of locale data, docs, and unused python extensions

Removes content nothing between minimal-bootstrap and stage 4 ever uses: glibc share/i18n + lib/gconv (localedef and iconv() against the bootstrap glibc are never invoked downstream); python lib-dynload/{_decimal,_socket,_asyncio,_hashlib,_blake2,_sha*,_md5,_hmac,CJK codecs,_zoneinfo,_lsprof,syslog} plus idlelib/tkinter/turtle*/ensurepip (glibc's build-time scripts only use os/re/subprocess/argparse/pathlib/collections); binutils bin/{gprof,addr2line,elfedit}; share/{info,man} and gcc share/gcc-*/python (libstdc++ gdb pretty-printers).

Self-size: 940 MB -> ~870 MB. Largest contributors: glibc -38 MB, python -15 MB, binutils -7 MB.
This commit is contained in:
Ben Siraphob
2026-04-26 14:17:33 -07:00
parent f6bbbded6d
commit b141bb23c9
8 changed files with 40 additions and 0 deletions
@@ -113,4 +113,8 @@ bash.runCommand "${pname}-${version}"
# Install
make -j $NIX_BUILD_CORES install
# 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
''
@@ -101,4 +101,8 @@ bash.runCommand "${pname}-${version}"
# Install
# strip to remove build dependency store path references
make -j $NIX_BUILD_CORES install-strip
# 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
''
@@ -80,4 +80,7 @@ bash.runCommand "${pname}-${version}"
# Install
make -j $NIX_BUILD_CORES install MAKEINFO="true" SUBDIRS=.
# Remove documentation not needed in the bootstrap chain.
rm -rf $out/share/info $out/share/man
''
@@ -78,4 +78,7 @@ bash.runCommand "${pname}-${version}"
# Install
make -j $NIX_BUILD_CORES install-strip
# Remove documentation not needed in the bootstrap chain.
rm -rf $out/share/info $out/share/man
''
@@ -155,4 +155,7 @@ bash.runCommand "${pname}-${version}"
# Install
make -j $NIX_BUILD_CORES install-strip
# libstdc++ gdb pretty-printers + man pages are unused downstream.
rm -rf $out/share/gcc-*/python $out/share/man $out/share/info
''
@@ -155,4 +155,7 @@ bash.runCommand "${pname}-${version}"
# Install
make -j $NIX_BUILD_CORES install-strip
# libstdc++ gdb pretty-printers + man pages are unused downstream.
rm -rf $out/share/gcc-*/python $out/share/man $out/share/info
''
@@ -112,4 +112,7 @@ bash.runCommand "${pname}-${version}"
make -j $NIX_BUILD_CORES INSTALL_UNCOMPRESSED=yes install
ln -s $(ls -d ${linux-headers}/include/* | grep -v scsi\$) $out/include/
find $out/{bin,sbin,lib,libexec} -type f -exec strip --strip-unneeded {} + || true
# localedef + iconv() are never invoked downstream of this glibc
rm -rf $out/share/i18n $out/lib/gconv $out/share/locale
''
@@ -98,4 +98,21 @@ bash.runCommand "${pname}-${version}"
# Install
make -j $NIX_BUILD_CORES install
# Remove lib-dynload extension modules not needed for glibc's build scripts.
# glibc uses Python only for scripts that import: os, re, subprocess, argparse,
# pathlib, collections, tempfile. Following the import chain:
# subprocess -> selectors -> math, select, fcntl, _posixsubprocess
# pathlib -> grp
# tempfile -> random -> _random, bisect -> _bisect
# Everything else in lib-dynload is dead weight in the bootstrap context.
find $out/lib/python*/lib-dynload -name '*.so' \
! -name '_bisect*' \
! -name '_posixsubprocess*' \
! -name '_random*' \
! -name 'fcntl*' \
! -name 'grp*' \
! -name 'math*' \
! -name 'select*' \
-delete
''