Cross-Compilation
Build binaries for multiple platforms from a single machine
Anodizer supports three cross-compilation strategies, configurable via the cross field.
Strategies
| Strategy | Tool | Best for |
|---|---|---|
auto | Auto-detects best option | Default — see decision order below |
zigbuild | cargo-zigbuild | Fast, minimal setup, works for most targets |
cross | cross | Targets requiring system libraries (e.g., OpenSSL) |
cargo | Native cargo build | Same-platform targets only |
Config
defaults:
cross: auto # auto | zigbuild | cross | cargo
Per-crate override:
crates:
- name: myapp
cross: zigbuild # override default for this crateHow auto-detection works
When cross: auto (the default):
- If the target is glibc-linked Linux (
*-linux-gnu*) andcargo-zigbuildis installed (with a workingzig— binary on PATH or the pipziglangwheel) → use zigbuild, even when the target matches the host triple. zig links against its own bundled libc, so the binary's glibc floor stays hermetic instead of tracking the build machine — a CI runner image upgrade can't silently raise the glibc requirement of your releases. (musl targets are exempt: static libc, no glibc floor.) - If the target matches the host triple → use native
cargo build - If host and target are both Apple, or both Windows → use native
cargo build(clang / MSVC cross-compile across their own arches) - If
cargo-zigbuildis installed → use it - If
crossis installed → use it - Fall back to native
cargo build(may fail for cross-platform targets)
To opt out of the linux-gnu zigbuild routing and link against the build
host's glibc, set cross: cargo (per-crate or under defaults:).
Run anodizer healthcheck to see which tools are available.
Installing cross-compilation tools
# cargo-zigbuild (recommended for most cases)
cargo install cargo-zigbuild
# cross (for targets needing system libraries)
cargo install crossParallelism
Control the number of parallel build jobs with --parallelism / -p:
anodizer release -p 4 # max 4 parallel builds
anodizer release -p 1 # sequential builds
Defaults to the number of logical CPUs.
Single-target builds
For local testing, build only for your host platform:
anodizer release --single-target