rustup-target
Manage Rust cross-compilation targets
TLDR
Add a target to a toolchain
Remove a target from a toolchain
List available and installed targets for a toolchain
List installed targets for a toolchain
SYNOPSIS
rustup target
Examples:
rustup target add target_triple
rustup target remove target_triple
rustup target list
rustup target list --installed
PARAMETERS
add <target_triple>
Adds a new compilation target to the Rust toolchain, installing necessary standard library components for that target. The target_triple specifies the architecture, vendor, OS, and ABI (e.g., aarch64-unknown-linux-gnu).
remove <target_triple>
Removes an installed compilation target and its associated standard library components, freeing up disk space. This reverses the effect of the add subcommand.
list
Lists all available Rust compilation targets supported by rustup. It indicates which targets are already installed on the system.
list --installed
Specifically lists only the compilation targets that are currently installed on the system, providing a concise view of your cross-compilation setup.
--toolchain <toolchain>
Applies the rustup target command to a specific Rust toolchain (e.g., 'stable', 'nightly', or a custom toolchain name). This allows managing targets for different Rust versions independently.
DESCRIPTION
rustup target is a subcommand of the rustup toolchain manager. It allows users to manage different compilation targets (architectures and operating systems) for their Rust projects. This is crucial for cross-compilation, enabling Rust code to be compiled for platforms other than the host system. It facilitates adding, removing, and listing available and installed targets, ensuring the necessary standard library components are present for a given target. Using this command, developers can easily prepare their Rust environment for building applications for a wide range of platforms, from embedded devices to web browsers (via WebAssembly).
CAVEATS
rustup-target is not a standalone executable; it must be invoked via the rustup command (i.e., rustup target).
While rustup target installs Rust's standard library for a given target, cross-compilation often requires additional system-level tools like appropriate linkers (e.g., `gcc` for ARM on Linux) and C toolchains, which must be installed separately by the user.
Target triples must be specified precisely according to Rust's conventions (e.g., x86_64-pc-windows-msvc, armv7-unknown-linux-gnueabihf).
TARGET TRIPLES
Rust compilation targets are identified by a 'target triple', a string that uniquely describes the target system's architecture, vendor, operating system, and optionally the ABI. Common examples include:
- aarch64-unknown-linux-gnu (64-bit ARM Linux using GNU toolchain)
- x86_64-pc-windows-msvc (64-bit Windows using MSVC toolchain)
- armv7-unknown-linux-gnueabihf (ARMv7 Linux with hard-float ABI)
- wasm32-unknown-unknown (32-bit WebAssembly)
HISTORY
rustup target is an integral part of the rustup project, which was developed to simplify the installation and management of Rust toolchains and components. It has been available since the early versions of rustup, becoming a fundamental component for Rust developers engaging in cross-platform development. Its functionality has evolved alongside rustup to support new architectures and platforms as Rust's ecosystem expanded, making cross-compilation more accessible for embedded systems, mobile development, and WebAssembly targets.