commit: 639205a9e7547b622b1ed346f033b7385de1aa5f
parent acfd3a127bfcac8d23408c0787255f8f79cbea5e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 1 May 2024 12:40:35 +0200
Remove libc.a from musl
Diffstat:
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
@@ -4,7 +4,7 @@ Copyright 2017 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
SPDX-License-Identifier: MPL-2.0
```
-A initrd generator for Linux to bootstrap a POSIX-ish system from a reasonably small binary seed.
+A initrd generator for Linux to bootstrap a POSIX-ish system from a reasonably small binary seed (1.2MB of binaries).
Full source bootstrap isn't intended as a goal but no further binaries than TCC and musl are allowed (enforced by [deblob](https://hacktivis.me/projects/deblob)). A possible further goal could be to try stripping out as much unreviewable code like autoconf loves to generate.
Status: Very early experiments, has yet to build enough to bootstrap any distro.
@@ -17,7 +17,8 @@ Need to start somewhere and TCC allows to interpret C, allowing to avoid seeding
The reason to not pick Guile+MesCC instead is because I find Guile Scheme to be less well-known than amd64 itself.
### musl (binary)
-Need a libc to start somewhere, tryhards could maybe compile it from source with TCC to reduce the seed further but this hasn't been tried.
+Need a libc to start somewhere, tryhards could maybe compile it from source with TCC to reduce the seed further but this hasn't been tried.
+It's `libc.a` is removed, to shave off 9.1MB from the binary seed, going from 11MB total to 1.2MB total, you're likely going to rebuild musl anyway since this is a sort of stage0.
### loksh
Linux/portable-port of OpenBSD Korn Shell, buildable with only a C compiler while being nicely complete (maybe even too much).
diff --git a/make-root.sh b/make-root.sh
@@ -71,6 +71,8 @@ for apk in $APKS_main $APKS_testing
do
tar xf "${WORKDIR}/distfiles/$apk" --exclude '.*'
done
+# Allows to shave off ~9.1M from the binary seed
+rm usr/lib/libc.a
# For CLOCK_MONOTONIC and clock_gettime
sed -i -e '1a#include <time.h>' loksh-*/c_sh.c || die "Failed patching loksh/c_sh.c"
@@ -102,6 +104,6 @@ sed -i \
sed -i -e '/$(LIBDIR)\/libl.a/d' heirloom-devtools-*/lex/Makefile.mk || die "Failed disabling static lib lex"
-deblob -n
+deblob -n | tee /dev/stderr | awk '/detected: /{ print $2 }' | xargs du -bach | sort -h
cd "${WORKDIR}"