mirror of
https://github.com/XTXMarkets/ternfs.git
synced 2026-01-07 11:30:49 -06:00
...most notably we now produce fully static binaries in an alpine
image.
A few assorted thoughts:
* I really like static binaries, ideally I'd like to run EggsFS
deployments with just systemd scripts and a few binaries.
* Go already does this, which is great.
* C++ does not, which is less great.
* Linking statically against `glibc` works, but is unsupported.
Not only stuff like NSS (which `gethostbyname` requires)
straight up does not work, unless you build `glibc` with
unsupported and currently apparently broken flags
(`--enable-static-nss`), but also other stuff is subtly
broken (I couldn't remember exactly what was broken,
but see comments such as
<https://github.com/haskell/haskell-language-server/issues/2431#issuecomment-985880838>).
* So we're left with alternative libcs -- the most popular being
musl.
* The simplest way to build a C++ application using musl is to just
build on a system where musl is already the default libc -- such
as alpine linux.
The backtrace support is in a bit of a bad state. Exception stacktraces
work on musl, but DWARF seems to be broken on the normal release build.
Moreover, libunwind doesn't play well with musl's signal handler:
<https://maskray.me/blog/2022-04-10-unwinding-through-signal-handler>.
Keeping it working seems to be a bit of a chore, and I'm going to revisit
it later.
In the meantime, gdb stack traces do work fine.
9 lines
388 B
Docker
9 lines
388 B
Docker
# The image we use to build the static "alpine" binaries
|
|
# that we deploy.
|
|
FROM alpine:3.17
|
|
RUN apk add --no-cache \
|
|
bash perl coreutils python3 musl gcc g++ clang lld make cmake ninja mandoc \
|
|
linux-headers zlib-dev zlib-static elfutils-dev libelf-static libdwarf-dev libdwarf-static \
|
|
xz-dev xz-static xxhash-dev libunwind-dev libunwind-static
|
|
ENV IN_EGGS_BUILD_CONTAINER Y
|