Six published targets, one source file. This page is the exact invocation for each, what breaks on each, and why -static is not optional for two of them.
The six targets
| Target id | Artifact | Compiler | Runs on |
|---|---|---|---|
linux-x86_64 | plugin_x | gcc | glibc Linux x86_64 (Debian, Ubuntu, Arch, Omarchy) |
linux-x86_64-musl | plugin_x | musl-gcc -static | any Linux x86_64, including Alpine and distroless |
linux-arm64-musl | plugin_x | aarch64-linux-musl-gcc -static | Raspberry Pi 5, ARM64 servers, Apple Silicon Linux VMs |
macos-arm64 | plugin_x | Apple clang | Apple Silicon macOS |
macos-x86_64 | plugin_x | Apple clang -arch x86_64 | Intel macOS |
windows-x86_64 | plugin_x.exe | x86_64-w64-mingw32-gcc -static | Windows 10/11 x64 |
The node reports which one it wants from GET /plugin_manage?action=platform as preferred_target with a fallback_target. On Linux x86_64 the preferred target is the musl static build and the fallback is the glibc one — because a static binary cannot fail on a missing symbol, and a glibc binary built on a new host cannot run on an older one.
Linux glibc
gcc -O2 -std=c99 -Wall -Wextra -pedantic -o plugin_x src/plugin_x.c
The baseline. It links against whatever glibc the build host ships, so a binary built on a 2024 distribution may refuse to start on a 2019 one with a GLIBC_2.34 not found error at exec time. That is not a plugin bug; it is the normal behaviour of dynamically linked Linux binaries, and it is why this is the fallback rather than the preferred target.
If you must ship this target to unknown hosts, build it in an old container. debian:bullseye or older gives a wide compatibility floor.
Linux musl static
musl-gcc -O2 -std=c99 -Wall -Wextra -static -o plugin_x src/plugin_x.c
musl-gcc is a wrapper that pairs the system GCC with musl's libc and headers. The result is a fully static ELF that starts on Alpine, Debian, Ubuntu, Arch, Omarchy, distroless and anything else with a Linux kernel ABI. It is slightly larger than the glibc build and it does not resolve NSS the same way — getpwnam and friends read /etc/passwd directly rather than going through the plugin chain.
For a plugin that reports system state, that difference is invisible. For a plugin that looks up a user by LDAP, it is not, and you should say so in the capability disclosure.
On Debian and Ubuntu the wrapper comes from musl-tools. On Arch it is the musl package plus a musl-gcc wrapper script.
Linux arm64 static
aarch64-linux-musl-gcc -O2 -std=c99 -Wall -Wextra -static -o plugin_x src/plugin_x.c
The same idea for ARM64. The toolchain is a cross-compiler; you do not need an ARM machine to produce the artifact, only to test it. If you have no ARM host, the honest move is to build it and say in the release notes that it was not executed. That is better than omitting a target that a Raspberry Pi user needs.
__aarch64__ is the macro your source tests for; the starter already handles it in node_arch().
macOS arm64 and x86_64
clang -O2 -std=c99 -Wall -Wextra -o plugin_x src/plugin_x.c
clang -O2 -std=c99 -Wall -Wextra -arch x86_64 -o plugin_x src/plugin_x.c
Both must be built on a Mac. There is no reliable cross-compiler from Linux to Mach-O that produces a signed-enough binary for a modern macOS to execute, and the SDK headers are licensed to the platform.
On Apple Silicon, -arch x86_64 produces an Intel binary that runs under Rosetta 2 — which is fine for a plugin, since a plugin is invoked per request and Rosetta's translation cost is paid once per process. Building the other direction (ARM on Intel) is also supported by recent toolchains but is not useful, because no Intel Mac will ever run an ARM plugin.
Do not pass -static on macOS. Static linking against Apple's libc is not supported; the flag either fails or produces something that will not start.
Windows x86_64 static
x86_64-w64-mingw32-gcc -O2 -std=c99 -Wall -Wextra -static -o plugin_x.exe src/plugin_x.c
-static here means "statically link the MinGW runtime", not "static libc". It removes the dependency on libgcc_s_seh-1.dll, libwinpthread-1.dll and libssp-0.dll, which are present in an MSYS2 install and absent on a stock Windows machine. A MinGW build without -static runs on the build machine and fails on the user's with a missing-DLL dialog that gives no useful error.
Use MSVC only for local experimentation. cl.exe produces a binary that links the Visual C++ runtime dynamically by default, and neither cl nor link has a supported one-flag static option. The published Windows artifacts in this market are all MinGW static.
What does not port
Three families of call need a #if branch or a hard #error:
getpid()— POSIX; Windows hasGetCurrentProcessId(). The starter handles it.gmtime_r()— POSIX; Windows hasgmtime_s()with the arguments in the opposite order. The starter handles it./proc,popen,opendiron/sys— POSIX only.popenexists on Windows as_popenwith different semantics; reading/prochas no equivalent. A plugin that reports Linux system state should compile to a page saying "not available on this platform" rather than fail to build, because a missing target is worse than a degraded one.
The fourth family is sockets: Winsock requires WSAStartup before any socket call and closesocket instead of close. If your plugin makes outbound network requests (almost none should), that is a real branch.
Verifying an artifact before publishing
file plugin_x # ELF 64-bit LSB executable, x86-64, static-pie
ldd plugin_x # "not a dynamic executable" for musl/static builds
plugin_x --meta # metadata parses
QUERY_STRING='action=info' plugin_x # JSON parses, ok:true
ldd saying "not a dynamic executable" is the single check that proves a static build. If it lists libc.so.6 and a version, the binary is dynamic and will fail on an older host.
file on a MinGW binary should say PE32+ executable (console) x86-64, for MS Windows. If it says MS-DOS executable, you built for 32-bit by mistake.
The build script shape
One script that produces all six and prints the SHA-256 of each is enough. It should fail loudly when a toolchain is missing rather than silently skipping a target, because a release that claims six targets and contains four is worse than one that claims four.
The published releases in this market all use a script of that shape, and each artifact's digest goes into the manifest covered on the next page. The manifest is what the one-click installer verifies, so a target that was built but not digested is a target that cannot be installed.
Read next
- The Vendored Connector SDK — the six targets when the plugin also needs HTTPS: one vendored BearSSL, no runtime
.so/.dllon any of them. - dist Manifests and SHA-256 — publishing the six artifacts so a node can verify and install them.
- The C99 Three-Mode Plugin SDK — the source file all six targets are compiled from.
- One-Click Install and Isolation — what the node does with the artifact once the checksum matches.