static-tools
Building static binaries of some tools using an Alpine Linux chroot with musl libc:
bsdtar
(from libarchive)mksquashfs
,unsquashfs
(from squashfs-tools)desktop-file-install
,desktop-file-validate
,update-desktop-database
(from desktop-file-utils)
This one I did not find out yet how to build static, but bundling musl libc is so much easier (and smaller) than bundling glibc:
appstreamcli
(from AppStream)
How to build static binaries
- Build inside an Alpine Linux chroot (which gives us many dependencies from the system)
- Build verbose (e.g.,
make -j$(nproc) VERBOSE=1
) - Look for the gcc command that produces the executable (
-o name_of_the_executable
) - Replace
gcc
withgcc -static
- Remove all
-W...
- Remove
-lpthread