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
gcc
withgcc -static
- Remove all
-W...
- Remove
-lpthread
- Some applications that use
./configure
can be configured like this:./configure CFLAGS=-no-pie LDFLAGS=-static
- NOTE:LDFLAGS=-static
only works for binaries, not for libraries: it will not result in having the build system provide a static library (.a
archive)