Compile artifacts for a non-default platform.

Section: Targets and cross-compilation

Build for a target triple

bash
bash
cargo build --target x86_64-unknown-linux-musl
Explanation

Target-specific artifacts are stored under `target/<triple>/...`.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Targets and cross-compilation
Run is typically host-only
Build target-specific binaries for packaging instead of running them locally.
OpenIn sheetbashsame section
List available targets
Show supported target triples.
OpenIn sheetbashsame section
Add a Linux musl target
Install standard libraries for a cross target.
OpenIn sheetbashsame section
Add Apple Silicon target
Install support for macOS ARM builds.
OpenIn sheetbashsame section
Use stable once without changing defaults
Run one command on the stable toolchain.
OpenIn sheetbash1 tag match
List installed toolchains
Display toolchains available on the machine.