ibrahimcesar/xcargo
π― Cross-compilation, zero friction
Cross-compilation, zero friction
xcargo is a Rust cross-compilation tool that just works. Automatic toolchain management, beautiful output, and zero-configuration cross-compilation.
# Install from crates.io (recommended)
cargo install xcargo
# Install with container support
cargo install xcargo --features container
# Or build from source
git clone https://github.com/ibrahimcesar/xcargo
cd xcargo
cargo build --release --features container
All xcargo release binaries are signed with minisign for authenticity and integrity verification.
Install minisign:
# macOS
brew install minisign
# Linux (Debian/Ubuntu)
sudo apt install minisign
# Linux (other) or from source
cargo install minisign-verify
# Or download from: https://github.com/jedisct1/minisign/releases
# Windows
scoop install minisign
Verify a downloaded binary:
# Download binary, signature, and checksum from GitHub releases
wget https://github.com/ibrahimcesar/xcargo/releases/download/v0.2.0/xcargo-linux-x86_64
wget https://github.com/ibrahimcesar/xcargo/releases/download/v0.2.0/xcargo-linux-x86_64.minisig
wget https://github.com/ibrahimcesar/xcargo/releases/download/v0.2.0/xcargo-linux-x86_64.sha256
# Verify signature
minisign -Vm xcargo-linux-x86_64 -P RWRzZS/Coz8XEj1XGXl9P93QnWHHSkqBfByJoX7tTXRJBUMLxR10WbW6
# Verify checksum
sha256sum -c xcargo-linux-x86_64.sha256
xcargo minisign public key:
RWRzZS/Coz8XEj1XGXl9P93QnWHHSkqBfByJoX7tTXRJBUMLxR10WbW6
The easiest way to get started is with the interactive setup wizard:
xcargo init --interactive
This will guide you through:
# Build for your current platform
xcargo build
# Build for a specific target
xcargo build --target x86_64-pc-windows-gnu
# Build for all configured targets
xcargo build --all
# Release build
xcargo build --target x86_64-unknown-linux-gnu --release
# Build for Windows from any platform
xcargo build --target x86_64-pc-windows-gnu
# Build for Linux ARM
xcargo build --target aarch64-unknown-linux-gnu
# Build for macOS (M1/M2)
xcargo build --target aarch64-apple-darwin
# Build for WebAssembly
xcargo build --target wasm32-unknown-unknown
# Use container for build (requires --features container)
xcargo build --target x86_64-unknown-linux-gnu --container
# List common cross-compilation targets
xcargo target list
# Show installed targets
xcargo target list --installed
# Get detailed info about a target
xcargo target info x86_64-pc-windows-gnu
# Add a new target
xcargo target add x86_64-unknown-linux-musl
# Show current configuration
xcargo config
# Show default configuration template
xcargo config --default
# Initialize with defaults
xcargo init
# Interactive setup wizard
xcargo init --interactive
Create an xcargo.toml in your project root:
[targets]
# Default targets to build when no target is specified
default = [
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-gnu",
]
# Per-target custom configuration
[targets."x86_64-pc-windows-gnu"]
linker = "x86_64-w64-mingw32-gcc"
[targets."x86_64-pc-windows-gnu".env]
CC = "x86_64-w64-mingw32-gcc"
[build]
# Enable parallel builds for multiple targets (2-3x faster!)
parallel = true
# Enable build caching
cache = true
# Force container usage (not yet implemented)
force_container = false
# Additional cargo flags to pass to all builds
cargo_flags = []
[container]
# Container runtime: auto, docker, podman
# Note: youki (pure Rust OCI runtime) will be supported in a future release
runtime = "auto"
# When to use containers
use_when = "target.os != host.os"
# Image pull policy
pull_policy = "if-not-present"
# Build profiles for different scenarios
[profiles.release-all]
targets = [
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-gnu",
"x86_64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-apple-darwin",
]
xcargo supports all Rust targets. Common ones include:
Linux
x86_64-unknown-linux-gnu - Linux x86_64x86_64-unknown-linux-musl - Linux x86_64 (static)aarch64-unknown-linux-gnu - Linux ARM64Windows
x86_64-pc-windows-gnu - Windows x86_64 (MinGW)x86_64-pc-windows-msvc - Windows x86_64 (MSVC)macOS
x86_64-apple-darwin - macOS x86_64aarch64-apple-darwin - macOS ARM64 (M1/M2)WebAssembly
wasm32-unknown-unknown - WebAssemblyRun xcargo target list to see all common targets with descriptions.
For successful cross-compilation, you often need to configure linkers. xcargo makes this easy:
[targets."x86_64-pc-windows-gnu"]
linker = "x86_64-w64-mingw32-gcc"
[targets."x86_64-pc-windows-gnu".env]
CC = "x86_64-w64-mingw32-gcc"
AR = "x86_64-w64-mingw32-ar"
Install on macOS: brew install mingw-w64
Install on Linux: sudo apt install mingw-w64
[targets."x86_64-unknown-linux-gnu"]
linker = "x86_64-linux-gnu-gcc"
[targets."x86_64-unknown-linux-gnu".env]
CC = "x86_64-linux-gnu-gcc"
Note: Linux cross-compilation from macOS often requires containers
CARGO_TARGET_*_LINKER environment variableCC, AR, etc.)For complex cross-compilation scenarios where native toolchains are difficult to set up, xcargo supports container-based builds using Docker or Podman.
# Install xcargo with container feature
cargo install xcargo --features container
# Ensure you have Docker or Podman installed
docker --version # or: podman --version
Container builds are ideal when:
# Build using a container
xcargo build --target x86_64-unknown-linux-gnu --container
# Container builds work with all flags
xcargo build --target aarch64-unknown-linux-gnu --container --release
Configure xcargo to automatically use containers when needed:
# xcargo.toml
[container]
# Container runtime: auto, docker, podman
runtime = "auto"
# Automatically use containers when cross-compiling to different OS
use_when = "target.os != host.os"
# Or always use containers
# use_when = "always"
# Or never use containers
# use_when = "never"
# Image pull policy: always, if-not-present, never
pull_policy = "if-not-present"
With this configuration, xcargo will automatically use containers when building for a different OS:
# On macOS, this will automatically use a container
xcargo build --target x86_64-unknown-linux-gnu
# On Linux, this will use native toolchain
xcargo build --target x86_64-unknown-linux-gnu
xcargo uses pre-built images from cross-rs for these targets:
Linux:
x86_64-unknown-linux-gnux86_64-unknown-linux-muslaarch64-unknown-linux-gnuaarch64-unknown-linux-muslarmv7-unknown-linux-gnueabihfarm-unknown-linux-gnueabihfWindows:
x86_64-pc-windows-gnuAndroid:
aarch64-linux-androidarmv7-linux-androideabix86_64-linux-androidi686-linux-androidNote: macOS and WebAssembly targets don't use containers:
Docker:
# macOS
brew install --cask docker
# Or download from https://www.docker.com/products/docker-desktop
# Linux
sudo apt install docker.io # Ubuntu/Debian
sudo dnf install docker # Fedora
sudo systemctl start docker
sudo usermod -aG docker $USER # Add yourself to docker group
Podman (Docker-compatible alternative):
# macOS
brew install podman
podman machine init
podman machine start
# Linux
sudo apt install podman # Ubuntu/Debian
sudo dnf install podman # Fedora
[container]
# Prefer specific runtime
runtime = "podman"
# Custom registry for images
registry = "my-registry.com/cross-images"
# Always use containers for reproducible builds
use_when = "always"
# Per-target container configuration
[targets."x86_64-unknown-linux-gnu"]
linker = "x86_64-linux-gnu-gcc"
[targets."x86_64-unknown-linux-gnu".env]
CC = "x86_64-linux-gnu-gcc"
CUSTOM_VAR = "value"
cargo build inside the containertarget/ directoryβββββββββββββββββββββββββββββββββββ
β xcargo build --container β
ββββββββββββ¬βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Detect container β
β runtime (Docker/ β
β Podman) β
βββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Pull cross-rs β
β image for target β
βββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Mount project & β
β cargo cache β
βββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Run cargo build β
β in container β
βββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Extract artifacts β
β to local target/ β
βββββββββββββββββββββ
Container runtime not found:
# Check if Docker/Podman is installed and running
docker info
# or
podman info
Permission denied errors (Linux):
# Add your user to the docker group
sudo usermod -aG docker $USER
# Then log out and back in
Image pull failures:
# Manually pull the image
docker pull ghcr.io/cross-rs/x86_64-unknown-linux-gnu:latest
# Check your network/proxy settings
docker info | grep -i proxy
ββββββββββββββββββββββββββββββββ
β xcargo build --target linux β
ββββββββββββ¬ββββββββββββββββββββ
β
βΌ
βββββββββββββββββ
β Detect target β
β requirements β
βββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββ
β Check toolchainβ
β & install if β
β missing β
βββββββββ¬βββββββββ
β
βΌ
ββββββββββββββββββ
β Execute cargo β
β build with β
β proper flags β
ββββββββββββββββββ
name: Cross-Platform Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install xcargo
run: cargo install xcargo
- name: Build for all targets
run: xcargo build --all
build:
image: rust:latest
script:
- cargo install xcargo
- xcargo build --all
artifacts:
paths:
- target/*/release/*
xcargo provides helpful, colored output with tips and hints:
β¨ xcargo Interactive Setup
Let's configure cross-compilation for your project!
β Detected host platform: aarch64-apple-darwin
? Which targets do you want to build for?
ββ to navigate, Space to select, Enter to confirm
[ ] Linux x86_64
[β] Windows x86_64 (GNU)
[β] macOS ARM64 (M1/M2)
β Configuration created successfully!
π Configuration Summary
ββββββββββββββββββββββββ
Targets: x86_64-pc-windows-gnu, aarch64-apple-darwin
Parallel builds: enabled
Build cache: enabled
Container strategy: target.os != host.os
π‘ Tip: Run 'xcargo build' to build for your host platform
π‘ Tip: Run 'xcargo build --all' to build for all configured targets
Current Version: 0.2.0
β Working Features:
parallel = true)--features container)π§ Planned Features:
Goal: Make cross-compilation work out of the box with zero external dependencies.
Bundled toolchain system
~/.xcargo/toolchains/Trade-offs:
Platform-Specific Code Signing π―
Currently, xcargo binaries are signed with minisign (free, cross-platform). For enhanced platform integration, we're considering:
macOS Code Signing:
Windows Authenticode:
Want platform-specific signing?
Note: Platform signing requires paid certificates. We'll implement these features when there's sufficient community interest to justify the ongoing costs. Minisign signatures will always be provided as a free, cross-platform verification method.
Other v0.4 features:
xcargo sign - Help users sign their own binaries
Native dependency detection and management
Advanced build caching
Build profiles and presets
youki integration (pure Rust OCI runtime)
Custom toolchain registry
Build reproducibility guarantees
SBOM (Software Bill of Materials) generation
Integration with cargo-dist
Plugin system for custom targets
We prioritize features based on community feedback. Share your needs:
| Feature | xcargo | cross | cargo-zigbuild |
|---|---|---|---|
| Native-first | β | β | β οΈ Via Zig |
| Auto-install targets | β | β | β |
| Interactive setup | β | β | β |
| Parallel builds | β | β | β |
| Beautiful output | β | β οΈ | β οΈ |
| Configuration file | β | β | β |
| Container support | β | β | β |
| Zero config | β | β | β οΈ |
Contributions are welcome! This is an early-stage project with lots of opportunity to help.
Ways to contribute:
See CONTRIBUTING.md for development setup and guidelines.
MIT Β© Ibrahim Cesar
Inspired by excellent tools in the Rust ecosystem:
xcargo - Cross-compilation, zero friction π―
Made with β€οΈ by Ibrahim Cesar
β Star on GitHub | π¦ View on crates.io | π Read the Docs