Zig Cross-Compilation
Purpose
Guide agents through Zig's built-in cross-compilation: target triple selection, CPU feature targeting, zig cc for cross-compiling C projects, embedded bare-metal targets, and WASM output — all without requiring a system cross-toolchain.
Triggers
- "How do I cross-compile a Zig program for ARM?"
- "How do I build Zig for a different OS?"
- "How do I use Zig to cross-compile C code for another platform?"
- "How do I build Zig for embedded/bare-metal?"
- "How do I target WebAssembly with Zig?"
- "What Zig target triple do I use for Raspberry Pi?"
Workflow
1. Zig's native cross-compilation
Zig has cross-compilation built in — no cross-toolchain, no Docker, no sysroot needed for pure Zig code:
2. Common target triples
3. CPU feature targeting
4. zig cc for C cross-compilation
zig cc cross-compiles C without a system cross-toolchain:
5. Build system cross-compilation
6. Embedded (bare-metal) targets
7. WebAssembly
For target triple reference and embedded linker script setup, see references/zig-target-triples.md [blocked].
Related skills
- Use
skills/zig/zig-compilerfor single-file compilation flags - Use
skills/zig/zig-build-systemfor multi-target build.zig configuration - Use
skills/compilers/cross-gccfor system cross-toolchain setup when needed - Use
skills/rust/rust-crossfor Rust's cross-compilation approach comparison


