rust-impl-cross-compile

Installation
SKILL.md

rust-impl-cross-compile

The cross-compilation skill: how to build a Rust crate for a target other than the host. Covers target triple format and common triples, rustup target add to install standard library artifacts, cargo build --target <triple>, the cross crate for container-based toolchains, conditional compilation via cfg(target_os = ...) and related predicates, the cfg_attr attribute for selective attribute emission, and per-target linker / runner configuration via .cargo/config.toml.

Cross-references: [[rust-impl-cargo-project]] (single-crate Cargo.toml + profiles), [[rust-impl-build-scripts]] (build.rs that detects target via env vars), [[rust-impl-ffi-bindgen]] (cross-compile C deps and adjust sysroot), [[rust-core-toolchain]] (rustup channels, components, target lists).


When to use this skill

  • User runs cargo build and gets linker 'cc' not found or error: target may not be installed after switching --target.
  • User wants a portable static Linux binary and asks musl vs gnu.
  • User builds for Windows from Linux and asks pc-windows-msvc vs pc-windows-gnu.
  • User builds for macOS ARM (Apple Silicon) from x86_64 host.
  • User asks how to build a .wasm module and asks wasm32-unknown-unknown vs wasm32-wasip1.
  • User writes platform-conditional code with #[cfg(target_os = "...")] or cfg!(...).
  • User wants a single attribute (e.g. #[repr(C)], #[link(...)]) to appear only on one target.
  • User configures a custom linker for a target via [target.<triple>] linker = "..." in .cargo/config.toml.
  • User asks about the cross tool because installing native toolchains is tedious.
Installs
2
GitHub Stars
1
First Seen
May 24, 2026