Skip to content

Instantly share code, notes, and snippets.

@llandsmeer
Created January 26, 2022 16:41
Show Gist options
  • Save llandsmeer/0ae6c4ac3d4685ae2c35a05409b71f38 to your computer and use it in GitHub Desktop.
Save llandsmeer/0ae6c4ac3d4685ae2c35a05409b71f38 to your computer and use it in GitHub Desktop.
Static build util-linux tools for pinenote initrd
# This is definitely not the cleanest way to make this work,
# but also the only way I could make it work
git clone 'https://github.com/util-linux/util-linux'
cd util-linux
# modify this to point to your aarch64-linux-musl-cross compiler
export PATH="/home/llandsmeer/Projects/PINENOTE/aarch64-linux-musl-cross/bin:$PATH"
export CC=aarch64-linux-musl-gcc
export CXX=aarch64-linux-musl-g++
export LDFLAGS="-static"
export ac_cs_linux_vers=4
export CFLAGS=-static
export SUID_CFLAGS=-static
export SUID_LDFLAGS=-static
export CPPFLAGS=-static
export LDFLAGS=-static
./configure --host aarch64-linux-gnu --without-tinfo -disable-shared --without-ncurses --disable-ipv6 --disable-pylibmount
make LDFLAGS="--static" -j 12 fdisk
make LDFLAGS="--static" -j 12 lsblk
aarch64-linux-musl-strip fdisk
aarch64-linux-musl-strip lsblk
# which still shows up in file as a dynamically linked executable,
# but runs fine as it doesnt load any library or depend on strange ld.so files
# fdisk: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, stripped
# you can test the binaries (and verify they are static) with the magic of qemu's userland emulation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment