optimistiCli/builder
Compile CLI binaries for DSM on DSM
Uses Zig's built-in ability to link binaries with arbitrary versions of glibc
for compiling rust and go (and probably other) command line utilities for Synology DSM on same very DSM. Derived from messense/cargo-zigbuild docker image.
$ DOCKER_BUILDKIT=1 docker build -f builder.dockerfile -t builder:latest .
Or just use diwu (-;
The builder.sh
script that comes with the image mounts current dir to /mnt
and sets up a few environment variables needed for compiling rust and go sources. Particular valuies will depend on Synology box's CPU and DSM's glibc version:
CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu.2.26
CC='zig cc -target x86_64-linux-gnu.2.26'
CXX='zig c++ -target x86_64-linux-gnu.2.26'
CGO_ENABLED=1
GOARCH=amd64
GOOS=linux
Following vars might come handy too:
TGT_ARCH=x86_64
TGT_GLIBC=2.26
Environment variables set by the builder.sh
script should be in most cases enough to build in a normal way as applies to a particular project. But your millage may vary. This project comes with no means of a compiled project installation, just put the binaries manually to /usr/local/bin
or wherever you want them.
Though tested only on a x86_64
host, this image would probably work on aarch64
and maybe on some other platforms, but most probably it would require some extra work on it. I created this image for personal consumption and share it “as-is” for fellow tinkerers' inpiration. Plesae note that Synology generally discoureges users from doing anything that requires root access to the DSM command line. So if sometghing goes wrong – it's on you, not me.
zig cc
: a Powerful Drop-In Replacement for GCC/Clang