Every way to build and ship a Rust program
Debug and release profiles, cross-compilation, static and dynamic linking, containers, per-platform packages, and CI. Getting from cargo build to something other people run.
Start from where the program has to run.
- On your own machine →
cargo build --release, and tune the release profile only after measuring. - On a different OS or CPU (a Raspberry Pi, Linux from a Mac) → cross-compile for that target triple.
- On machines where you can't count on shared libraries (a minimal container, an old Linux server) → link statically, often with the musl target.
- As a service in the cloud → a multi-stage container image with only the executable in the final stage.
- On users' desktops → the platform's own package or installer, signed where the platform expects it.
- Every time someone pushes → CI that formats, lints, tests on each target OS, and audits dependencies, so a release is never the first build of a change.
Building
Section
Source to native binary
What cargo build produces, and why it runs without Rust installed.
Section
Profiles
dev and release, and the settings you can change in each.
Section
Release builds and binary size
opt-level, LTO, codegen-units, strip and panic = "abort", each measured.
Somewhere else
Section
Targets and toolchains
What a target triple names.
Section
Cross-compilation
rustup target add, a linker, and when to reach for cross.
Section
Static and dynamic linking
glibc versus musl, and what ldd tells you.
Section
Rust to WebAssembly
A different kind of target, run inside a browser or a runtime.
Packaging
Section
Containers
A multi-stage Dockerfile with a small final image.
Section
Shipping on each platform
Installers, packages and signing on Windows, macOS and Linux.
Section
Publishing a crate
Shipping a library to crates.io instead of a program to users.
Keeping it shippable
Section
CI pipelines
fmt, clippy, tests on each OS, and cargo audit on every change.
The same dependency versions in CI as on your machine.
Section
Shipping the capstone
All of the above, done once for a real service.