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)appstreamcli(from AppStream)
Binaries are provided on GitHub Releases. To build the runtime yourself, run:
docker run -it --rm --volume `pwd`:/workdir alpine:latest /workdir/build.sh
This whole process takes only a few seconds on GitHub Codespaces.
- 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
gccwithgcc -static - Remove all
-W... - Remove
-lpthread - Some applications that use
./configurecan be configured like this:./configure CFLAGS=-no-pie LDFLAGS=-static- NOTE:LDFLAGS=-staticonly works for binaries, not for libraries: it will not result in having the build system provide a static library (.aarchive)