Cross-compilation
CLAP cross-compiles out of the box because the pinned Zig toolchain carries every target in one install — no separate cross-GCC, no sysroot hunting, no per-target toolchain packages.
Documented profiles
clap targets prints the current list:
| Profile | Target triple |
|---|---|
windows-x86_64 | x86_64-windows-gnu |
windows-arm64 | aarch64-windows-gnu |
linux-x86_64 | x86_64-linux-gnu |
linux-arm64 | aarch64-linux-gnu |
linux-x86_64-musl | x86_64-linux-musl (static) |
linux-arm64-musl | aarch64-linux-musl (static) |
macos-x86_64 | x86_64-macos |
macos-arm64 | aarch64-macos |
clap build main.c --profile windows-x86_64
# or the same thing explicitly:
clap build main.c --target x86_64-windows-gnuAny Zig/Clang target triple works with --target, not just the presets.
What the artifacts look like — verified
Every row below was produced on an x86-64 Linux host with CLAP 0.49.x and inspected with file:
| Command | Artifact |
|---|---|
--target x86_64-windows-gnu | PE32+ executable (console) x86-64 plus a .pdb debug database |
--target aarch64-linux-gnu | ELF 64-bit ARM aarch64, dynamically linked, interpreter /lib/ld-linux-aarch64.so.1 |
--target aarch64-macos | Mach-O 64-bit arm64 executable |
--target x86_64-linux-musl | ELF 64-bit x86-64, statically linked |
The musl row is the distribution trick worth knowing: Linux musl targets produce fully static binaries with no runtime dependencies at all. The x86-64 musl build above was executed directly on the build host and printed its output — a genuinely portable Linux binary in one command:
clap build main.c --profile linux-x86_64-musl
# or equivalently: clap build main.c --target x86_64-linux-muslHonest caveats
- gnu triples are dynamic. An
aarch64-linux-gnubinary expects aarch64 glibc on the target machine (/lib/ld-linux-aarch64.so.1must exist). For dependency-free Linux artifacts use the musl triples. - macOS artifacts are unsigned. The Mach-O is real and correctly formed, but running it on a Mac involves the usual Gatekeeper dance for unsigned binaries; distribution to macOS users is a signing/notarization question, not a compilation one.
- Cross-building is not cross-testing — except Linux-on-Linux. Windows and macOS artifacts never execute on a foreign host. But on a Linux host with qemu-user installed (
sudo apt install qemu-user),clap run/clap testexecute foreign-architecture Linux binaries transparently: either directly through binfmt_misc when it is registered, or through theqemu-<arch>binary when only that is present. Verified end-to-end: anaarch64-linux-muslbinary built on x86_64 prints its output throughclap runwith zero extra flags. Static musl builds are the reliable shape — dynamic gnu binaries may miss their loader inside qemu. Without qemu-user the honest refusal stands, now with the install hint. - Windows artifacts (
.exe+.pdb) have been executed on real Windows machines as part of platform validation; PE output is not merely well-formed but runnable.
Beyond the presets: wasm32-wasi and other zig targets
The profiles are conveniences — --target accepts any zig target triple. Verified end-to-end: clap build main.c --target wasm32-wasi -o hello.wasm produces a real WebAssembly module with zero configuration, and it runs in Node.js (WASI API) or any wasmtime runtime — C to the browser edge with the same one-command install. Targets zig cannot fully support (missing libc pieces) fail with zig's own diagnostics; the honest boundary is zig's target support matrix, not CLAP's.
Multi-target matrix builds
--profile repeats, so a release matrix is one command:
clap build main.c --profile windows-x86_64 --profile linux-arm64 --profile macos-arm64Each artifact lands next to the sources as <stem>-<profile>[.exe].