rustc
The Rust compiler. Rust projects usually usecargoinstead of invokingrustcdirectly. More information: https://doc.rust-lang.org/rustc.
-
Compile a binary crate:
rustc {{path/to/main.rs}} -
Compile with optimizations (
smeans optimize for binary size;zis the same with even more optimizations):
rustc -C lto -C opt-level={{0|1|2|3|s|z}} {{path/to/main.rs}} -
Compile with debugging information:
rustc -g {{path/to/main.rs}} -
Explain an error message:
rustc --explain {{error_code}} -
Compile with architecture-specific optimizations for the current CPU:
rustc -C target-cpu={{native}} {{path/to/main.rs}} -
Display the target list (Note: you have to add a target using
rustupfirst to be able to compile for it):
rustc --print target-list -
Compile for a specific target:
rustc --target {{target_triple}} {{path/to/main.rs}}
License and Disclaimer
The content on this page is copyright © 2014—present the tldr-pages team and contributors.This page is used with permission under Creative Commons Attribution 4.0 International License.
While we do attempt to make sure content is accurate, there isn't a warranty of any kind.