1.5 KiB
Linux Static Release Build
Because we're depending on SDL and X11 libraries, we can't easily build a completely statically-linked binary using musl unless we recompile those library dependencies also using musl. I was able to build something that was mostly statically-linked except for libc, but then it didn't run in a base Fedora Docker container.
The workaround for this is to use something where everything is already compiled with musl, like an Alpine Linux Docker container.
To build a fully statically-linked binary, use the Dockerfile
in the
root directory.
docker build -t project-ely-build .
This should spit out an executable called project-ely-static
.
Attempts on Debian
I tried installing musl on Debian.
I installed it to my home directory. I also specified my pkgsrc version of GCC.
CC=$HOME/pkg/gcc10/bin/gcc
./configure --disabled-shared --prefix=$HOME/musl
make -j4
make install
Then I had to symlink the X11 include dir.
cd musl-install/include
ln -s /usr/include/X11 X11
I ran into an issue where it was unable to find many basic libraries like Xrandr and asound. But then I hit that same issue with the Alpine container =(
References
Before giving up and using Alpine, I found these cool links that suggest you could do this more easily if we only depended on the C std library stuff, no external dependencies like X11 and SDL.