The ebuild for sys-apps/toybox lacks a 'static' USE flag. Additionally, toybox cannot be statically linked against glibc. This bug is a request to add a 'static' USE flag to sys-apps/toybox, which results in a statically linked binary suitable for e.g. initramfs usage. Reproducible: Always Instructions for static build using musl: --- 1. Create temp root for build ($TEMP) 2. Build & install musl to $TEMP: a) ./configure --prefix=$TEMP --disable-shared b) make c) make install 3. Symlink /usr/include/linux to $TEMP/include/linux 4. Symlink /usr/include/asm to $TEMP/include/asm 5. Symlink /usr/include/asm-generic to $TEMP/include/asm-generic 6. Configure toybox (make menuconfig), or provide existing .config file 7. Build toybox: CC="$TEMP/bin/musl-gcc" LDFLAGS="-L$TEMP/lib --static" CFLAGS="-I$TEMP/include" make --- Sample build script: --- #!/bin/sh DISTFILES=/usr/portage/distfiles INCLUDEDIR=/usr/include WDIR=/tmp/tb MUSL_VERSION=1.1.10 TOYBOX_VERSION=0.6.0 # set up directory tree and extract source CDIR="$PWD" mkdir -p "$WDIR"/{root,build,build/toybox-$TOYBOX_VERSION} tar -C "$WDIR/build" -xf "$DISTFILES/musl-$MUSL_VERSION.tar.gz" tar -C "$WDIR/build/toybox-$TOYBOX_VERSION" -xf "$DISTFILES/toybox-$TOYBOX_VERSION.tar.gz" # build musl cd "$WDIR/build/musl-$MUSL_VERSION" ./configure --prefix="$WDIR/root" --disable-shared make make install # symlink toybox-required headers ln -s "$INCLUDEDIR/linux" "$WDIR/root/include/" ln -s "$INCLUDEDIR/asm" "$WDIR/root/include/" ln -s "$INCLUDEDIR/asm-generic" "$WDIR/root/include" # configure & build toybox cd "$WDIR/build/toybox-$TOYBOX_VERSION" make menuconfig CC="$WDIR/root/bin/musl-gcc" CFLAGS="-I$WDIR/root/include" LDFLAGS="-L$WDIR/root/lib --static" make PREFIX="$WDIR/root" make install # cleanup cd "$CDIR" ---
Note that the default config for toybox does not include a shell. As that the expected use for a statically-linked toybox is things like initramfs, enabling the shell (CONFIG_SH) when building with USE=static is probably a good idea.