/rust-cross
Rust cross-compilation skill. Use when building Rust binaries for a different target architecture or OS, using cross or cargo-zigbuild for hermetic cross-compilation, configuring .cargo/config.toml for cross targets, or targeting embedded and bare-metal systems. Activates on
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill rust-cross --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/rust-cross
Context preview
The summary Claude sees to decide when to auto-load this skill.
Rust cross-compilation skill. Use when building Rust binaries for a different target architecture or OS, using cross or cargo-zigbuild for hermetic cross-compilation, configuring .cargo/config.toml for cross targets, or targeting embedded and bare-metal systems. Activates on
SKILL.md
rust-cross.SKILL.mdname: rust-cross
description: Rust cross-compilation skill. Use when building Rust binaries for a different target architecture or OS, using cross or cargo-zigbuild for hermetic cross-compilation, configuring .cargo/config.toml for cross targets, or targeting embedded and bare-metal systems. Activates on queries about Rust cross-compilation, rustup targets, cross tool, cargo-zigbuild, aarch64-unknown-linux-gnu, thumbv7m-none-eabi, or building for embedded.
Rust Cross-Compilation
Purpose
Guide agents through Rust cross-compilation: adding rustup targets, using `cross` for hermetic Docker-based cross-builds, `cargo-zigbuild` for zero-setup cross-compilation, `.cargo/config.toml` configuration, and embedded bare-metal targets.
Triggers
- "How do I cross-compile Rust for ARM/aarch64?"
- "How do I build a Rust binary for a different OS?"
- "How do I use the cross tool for Rust cross-compilation?"
- "How do I build Rust for embedded (no_std) targets?"
- "How do I use cargo-zigbuild?"
- "My cross-compiled Rust binary won't run on the target"
Workflow
1. Add a rustup target
# List installed targets
rustup target list --installed
# List all available targets
rustup target list
# Add a target
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl # static Linux
rustup target add wasm32-unknown-unknown # WASM
rustup target add thumbv7m-none-eabi # Cortex-M
# Build for target
cargo build --target aarch64-unknown-linux-gnu --release
2. Common target triples
| Target | Use case | |--------|----------| | `x86_64-unknown-linux-gnu` | Linux x86-64 (glibc) | | `x86_64-unknown-linux-musl` | Linux x86-64 (musl, static) | | `aarch64-unknown-linux-gnu` | ARM64 Linux (Raspberry Pi 4, AWS Graviton) | | `aarch64-unknown-linux-musl` | ARM64 Linux static | | `x86_64-pc-windows-gnu` | Windows x86-64 (MinGW) | | `x86_64-pc-windows-msvc` | Windows x86-64 (MSVC) | | `x86_64-apple-darwin` | macOS x86-64 | | `aarch64-apple-darwin` | macOS Apple Silicon | | `wasm32-unknown-unknown` | WASM (browser) | | `wasm32-wasi` | WASM with WASI | | `thumbv7m-none-eabi` | Cortex-M3 bare metal | | `thumbv7em-none-eabihf` | Cortex-M4/M7 with FPU | | `riscv32imac-unknown-none-elf` | RISC-V 32-bit bare metal |
3. cross tool (Docker-based, easiest)
`cross` uses pre-built Docker images with the correct cross-toolchain:
# Install
cargo install cross
# Build (drop-in replacement for cargo)
cross build --target aarch64-unknown-linux-gnu --release
cross test --target aarch64-unknown-linux-gnu
# Cross.toml — project configuration
# Cross.toml
[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"
pre-build = [
"apt-get update && apt-get install -y libssl-dev:arm64"
]
[build.env]
passthrough = ["PKG_CONFIG_PATH", "OPENSSL_DIR"]4. cargo-zigbuild (zero-setup, uses zig cc)
`zig cc` ships a complete C cross-toolchain — no system cross-compiler needed:
# Install
cargo install cargo-zigbuild
# Also needs zig installed: https://ziglang.org/download/
# Build (no Docker, no system cross-compiler)
cargo zigbuild --target aarch64-unknown-linux-gnu --release
cargo zigbuild --target x86_64-unknown-linux-musl --release
# Target with glibc version (important for compatibility)
cargo zigbuild --target aarch64-unknown-linux-gnu.2.17 --release
# This builds against glibc 2.17 (very compatible)
# Windows from Linux/macOS
cargo zigbuild --target x86_64-pc-windows-gnu --release
`cargo-zigbuild` advantages over `cross`:
- No Docker required
- Faster (no container startup)
- Works for most targets out of the box
- Supports precise glibc version targeting
5. .cargo/config.toml for cross targets
# .cargo/config.toml
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc" # System cross-linker
# or with zig:
# linker = "zig"
# rustflags = ["-C", "link-arg=cc", "-C", "link-arg=-target", "-C", "link-arg=aarch64-linux-gnu"]
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
rustflags = ["-C", "target-feature=+crt-static"]
[target.wasm32-unknown-unknown]
runner = "wasmtime" # Run WASM tests with wasmtime
[target.thumbv7m-none-eabi]
runner = "qemu-arm -cpu cortex-m3"
6. Static binaries with musl
# Add musl target
rustup target add x86_64-unknown-linux-musl
# Build statically linked binary
cargo build --target x86_64-unknown-linux-musl --release
# Verify it's static
file target/x86_64-unknown-linux-musl/release/myapp
# → ELF 64-bit, statically linked, not stripped
# Or with cargo-zigbuild (easier musl)
cargo zigbuild --target x86_64-unknown-linux-musl --release
7. Embedded bare-metal (#[no_std])
# .cargo/config.toml
[build]
target = "thumbv7em-none-eabihf" # Set default target
[target.'cfg(target_arch = "arm")']
runner = "probe-run --chip STM32F411CE"
// src/main.rs
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[cortex_m_rt::entry]
fn main() -> ! {
loop {}
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}# Cargo.toml
[dependencies]
cortex-m = "0.7"
cortex-m-rt = "0.7"
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
cargo build --release # Uses default target from .cargo/config.toml
For target triple reference and embedded setup details, see [references/](references/).
Related skills
- Use `skills/rust/rustc-basics` for compiler and profile configuration
- Use `skills/compilers/cross-gcc` for the underlying cross-compiler setup
- Use `skills/zig/zig-cross` for Zig's native cross-compilation approach
- Use `skills/build-systems/cmake` when Rust is part of a CMake cross-build
Read more
name: rust-cross description: Rust cross-compilation skill. Use when building Rust binaries for a different target architecture or OS, using cross or cargo-zigbuild for hermetic cross-compilation, configuring .cargo/config.toml for cross targets, or targeting embedded and bare-metal systems. Activates on queries about Rust cross-compilation, rustup targets, cross tool, cargo-zigbuild, aarch64-unknown-linux-gnu, thumbv7m-none-eabi, or building for embedded.
Rust Cross-Compilation
Purpose
Guide agents through Rust cross-compilation: adding rustup targets, using `cross` for hermetic Docker-based cross-builds, `cargo-zigbuild` for zero-setup cross-compilation, `.cargo/config.toml` configuration, and embedded bare-metal targets.
Triggers
- "How do I cross-compile Rust for ARM/aarch64?"
- "How do I build a Rust binary for a different OS?"
- "How do I use the cross tool for Rust cross-compilation?"
- "How do I build Rust for embedded (no_std) targets?"
- "How do I use cargo-zigbuild?"
- "My cross-compiled Rust binary won't run on the target"
Workflow
1. Add a rustup target
# List installed targets rustup target list --installed # List all available targets rustup target list # Add a target rustup target add aarch64-unknown-linux-gnu rustup target add x86_64-unknown-linux-musl # static Linux rustup target add wasm32-unknown-unknown # WASM rustup target add thumbv7m-none-eabi # Cortex-M # Build for target cargo build --target aarch64-unknown-linux-gnu --release
2. Common target triples
| Target | Use case | |--------|----------| | `x86_64-unknown-linux-gnu` | Linux x86-64 (glibc) | | `x86_64-unknown-linux-musl` | Linux x86-64 (musl, static) | | `aarch64-unknown-linux-gnu` | ARM64 Linux (Raspberry Pi 4, AWS Graviton) | | `aarch64-unknown-linux-musl` | ARM64 Linux static | | `x86_64-pc-windows-gnu` | Windows x86-64 (MinGW) | | `x86_64-pc-windows-msvc` | Windows x86-64 (MSVC) | | `x86_64-apple-darwin` | macOS x86-64 | | `aarch64-apple-darwin` | macOS Apple Silicon | | `wasm32-unknown-unknown` | WASM (browser) | | `wasm32-wasi` | WASM with WASI | | `thumbv7m-none-eabi` | Cortex-M3 bare metal | | `thumbv7em-none-eabihf` | Cortex-M4/M7 with FPU | | `riscv32imac-unknown-none-elf` | RISC-V 32-bit bare metal |
3. cross tool (Docker-based, easiest)
`cross` uses pre-built Docker images with the correct cross-toolchain:
# Install cargo install cross # Build (drop-in replacement for cargo) cross build --target aarch64-unknown-linux-gnu --release cross test --target aarch64-unknown-linux-gnu # Cross.toml — project configuration
# Cross.toml
[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"
pre-build = [
"apt-get update && apt-get install -y libssl-dev:arm64"
]
[build.env]
passthrough = ["PKG_CONFIG_PATH", "OPENSSL_DIR"]4. cargo-zigbuild (zero-setup, uses zig cc)
`zig cc` ships a complete C cross-toolchain — no system cross-compiler needed:
# Install cargo install cargo-zigbuild # Also needs zig installed: https://ziglang.org/download/ # Build (no Docker, no system cross-compiler) cargo zigbuild --target aarch64-unknown-linux-gnu --release cargo zigbuild --target x86_64-unknown-linux-musl --release # Target with glibc version (important for compatibility) cargo zigbuild --target aarch64-unknown-linux-gnu.2.17 --release # This builds against glibc 2.17 (very compatible) # Windows from Linux/macOS cargo zigbuild --target x86_64-pc-windows-gnu --release
`cargo-zigbuild` advantages over `cross`:
- No Docker required
- Faster (no container startup)
- Works for most targets out of the box
- Supports precise glibc version targeting
5. .cargo/config.toml for cross targets
# .cargo/config.toml [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" # System cross-linker # or with zig: # linker = "zig" # rustflags = ["-C", "link-arg=cc", "-C", "link-arg=-target", "-C", "link-arg=aarch64-linux-gnu"] [target.x86_64-unknown-linux-musl] linker = "x86_64-linux-musl-gcc" rustflags = ["-C", "target-feature=+crt-static"] [target.wasm32-unknown-unknown] runner = "wasmtime" # Run WASM tests with wasmtime [target.thumbv7m-none-eabi] runner = "qemu-arm -cpu cortex-m3"
6. Static binaries with musl
# Add musl target rustup target add x86_64-unknown-linux-musl # Build statically linked binary cargo build --target x86_64-unknown-linux-musl --release # Verify it's static file target/x86_64-unknown-linux-musl/release/myapp # → ELF 64-bit, statically linked, not stripped # Or with cargo-zigbuild (easier musl) cargo zigbuild --target x86_64-unknown-linux-musl --release
7. Embedded bare-metal (#[no_std])
# .cargo/config.toml [build] target = "thumbv7em-none-eabihf" # Set default target [target.'cfg(target_arch = "arm")'] runner = "probe-run --chip STM32F411CE"
// src/main.rs
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[cortex_m_rt::entry]
fn main() -> ! {
loop {}
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}# Cargo.toml [dependencies] cortex-m = "0.7" cortex-m-rt = "0.7" [profile.release] opt-level = "z" lto = true codegen-units = 1 panic = "abort"
cargo build --release # Uses default target from .cargo/config.toml
For target triple reference and embedded setup details, see [references/](references/).
Related skills
- Use `skills/rust/rustc-basics` for compiler and profile configuration
- Use `skills/compilers/cross-gcc` for the underlying cross-compiler setup
- Use `skills/zig/zig-cross` for Zig's native cross-compilation approach
- Use `skills/build-systems/cmake` when Rust is part of a CMake cross-build
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

