Skip to content

Building static binaries of some tools using an Alpine chroot with musl

License

Notifications You must be signed in to change notification settings

lalten/static-tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

static-tools GitHub Actions

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)

Building locally

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.

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 with gcc -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)

About

Building static binaries of some tools using an Alpine chroot with musl

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Shell 100.0%