Skip to content

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:

ProfileTarget triple
windows-x86_64x86_64-windows-gnu
windows-arm64aarch64-windows-gnu
linux-x86_64x86_64-linux-gnu
linux-arm64aarch64-linux-gnu
linux-x86_64-muslx86_64-linux-musl (static)
linux-arm64-muslaarch64-linux-musl (static)
macos-x86_64x86_64-macos
macos-arm64aarch64-macos
bash
clap build main.c --profile windows-x86_64
# or the same thing explicitly:
clap build main.c --target x86_64-windows-gnu

Any 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:

CommandArtifact
--target x86_64-windows-gnuPE32+ executable (console) x86-64 plus a .pdb debug database
--target aarch64-linux-gnuELF 64-bit ARM aarch64, dynamically linked, interpreter /lib/ld-linux-aarch64.so.1
--target aarch64-macosMach-O 64-bit arm64 executable
--target x86_64-linux-muslELF 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:

bash
clap build main.c --profile linux-x86_64-musl
# or equivalently: clap build main.c --target x86_64-linux-musl

Honest caveats ​

  • gnu triples are dynamic. An aarch64-linux-gnu binary expects aarch64 glibc on the target machine (/lib/ld-linux-aarch64.so.1 must 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 test execute foreign-architecture Linux binaries transparently: either directly through binfmt_misc when it is registered, or through the qemu-<arch> binary when only that is present. Verified end-to-end: an aarch64-linux-musl binary built on x86_64 prints its output through clap run with 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:

bash
clap build main.c --profile windows-x86_64 --profile linux-arm64 --profile macos-arm64

Each artifact lands next to the sources as <stem>-<profile>[.exe].