RUSTC(1)
π RUSTC(1) β the manual, but make it cute π
okay bestie, welcome to the User Commands section, this is the rustc page and she is iconic. grab a boba, we're going in π§β¨
πΈ NAME πΈ
rustc β the Rust compiler. that's her. that's the whole name. she compiles Rust and she does it gorgeously π
π¦ SYNOPSIS π¦
rustc [OPTIONS] INPUT
literally just rustc, then some [OPTIONS], then your INPUT. that's the whole vibe. no cap.
β¨ DESCRIPTION β¨
so this program? it's a compiler for the Rust language, which lives at https://www.rust-lang.org. you give it Rust, it gives you... machine stuff. slay. it's giving main character energy, fr fr π
π OPTIONS π
okay here's the whole flag menu, every single one, we're not skipping a thing:
-h,--helpβ shows you the help message. when in doubt, ask for help, bestie π«Ά--cfg SPECβ configures the compilation environment. that's the whole job.-L [KIND=]PATHβ adds a directory to the library search path. theKINDpart is optional and can be one of these little cuties:dependencyβ only look up transitive dependencies herecrateβ only look up localextern cratedirectives herenativeβ only look up native libraries hereframeworkβ only look for OSX frameworks hereallβ look for anything here (this is the default, she's flexible π )
-l [KIND=]NAMEβ links the generated crate(s) to the specified libraryNAME.KINDcan bestatic,dylib, orframework. if you just... don't say, thendylibis assumed. she'll assume. π--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]β a comma separated list of types of crates for the compiler to emit.--crate-name NAMEβ specify the name of the crate being built. name your baby.--emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir][=PATH]β configures the output thatrustcwill produce. each emission may also have an optional explicit outputPATHspecified for that particular emission kind. this path takes precedence over the-ooption. so like, she said what she said. π₯--print [crate-name|file-names|sysroot|target-libdir|cfg|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|native-static-libs|stack-protector-strategies|link-args]β a comma separated list of compiler information to print on stdout.-gβ equivalent to-C debuginfo=2. that's it, that's the whole thing, it's a shortcut bestie π-Oβ equivalent to-C opt-level=2. also just a shortcut. optimized and unbothered.-o FILENAMEβ write output toFILENAME. ignored if multiple--emitoutputs are specified which don't have an explicit path otherwise.--out-dir DIRβ write output to compilerβchosen filename inDIR. ignored if-ois specified. defaults to the current directory.--explain OPTβ provides a detailed explanation of an error message. she will explain herself, and honestly? she's right to.--testβ build a test harness.--target TARGETβ target triple for which the code is compiled. this option defaults to the host's target triple. the target triple has the general format<arch><sub>-<vendor>-<sys>-<abi>, where:<arch>βx86,arm,thumb,mips, etc.<sub>β for example on ARM:v5,v6m,v7a,v7m, etc.<vendor>βpc,apple,nvidia,ibm, etc.<sys>βnone,linux,win32,darwin,cuda, etc.<abi>βeabi,gnu,android,macho,elf, etc.
-W helpβ prints'lint'options and default settings.-W OPT,--warn OPTβ set lint warnings. gentle nudge energy π-A OPT,--allow OPTβ set lint allowed. she's cool with it, live your truth.-D OPT,--deny OPTβ set lint denied. nope. not today.-F OPT,--forbid OPTβ set lint forbidden. absolutely not, don't even try it π-C FLAG[=VAL],--codegen FLAG[=VAL]β set a codegenβrelated flag to the value specified. use-C helpto print available flags. see CODEGEN OPTIONS below, there's a whole section, she's thorough.-V,--versionβ prints version info and exits. just the facts, then she's gone βοΈ-v,--verboseβ use verbose output. she's gonna tell you everything, bestie.--remap-path-prefix from=toβ remaps source path prefixes in all output, including compiler diagnostics, debug information, macro expansions, etc. thefrom=toparameter is scanned from right to left, sofrommay contain'=', buttomay not.
this is useful for normalizing build products, for example by removing the current directory out of pathnames emitted into the object files. the replacement is purely textual, with no consideration of the current system's pathname syntax. for example --remap-path-prefix foo=bar will match foo/lib.rs but not ./foo/lib.rs.
--extern NAME=PATHβ specify where an external rust library is located. these should matchexterndeclarations in the crate's source code.--sysroot PATHβ override the system root.-Z FLAGβ set unstable / perma-unstable options. use-Z helpto print available options. (iykyk π)--color auto|always|neverβ configure coloring of output:autoβ colorize, if output goes to a tty (default)alwaysβ always colorize outputneverβ never colorize output
π CODEGEN OPTIONS π
these are the -C girlies. absolutely gorgeous, every one:
linker=/path/to/ccβ path to the linker utility to use when linking libraries, executables, and objects.link-args='-flag1 -flag2'β a spaceβseparated list of extra arguments to pass to the linker when the linker is invoked.ltoβ perform LLVM linkβtime optimizations.target-cpu=helpβ selects a target processor. if the value is'help', then a list of available CPUs is printed.target-feature='+feature1,-feature2'β a commaβseparated list of features to enable or disable for the target. a preceding'+'enables a feature while a preceding'-'disables it. available features can be discovered throughllc -mcpu=help.passes=valβ a spaceβseparated list of extra LLVM passes to run. a value of'list'will causerustcto print all known passes and exit. the passes specified are appended at the end of the normal pass manager.llvm-args='-arg1 -arg2'β a spaceβseparated list of arguments to pass through to LLVM.save-tempsβ if specified, the compiler will save more files (.bc,.o,.no-opt.bc) generated throughout compilation in the output directory.rpathβ if specified, then the rpath value for dynamic libraries will be set in either dynamic library or executable outputs.no-prepopulate-passesβ suppresses preβpopulation of the LLVM pass manager that is run over the module.no-vectorize-loopsβ suppresses running the loop vectorization LLVM pass, regardless of optimization level.no-vectorize-slpβ suppresses running the LLVM SLP vectorization pass, regardless of optimization level.soft-floatβ generates software floating point library calls instead of hardware instructions.prefer-dynamicβ prefers dynamic linking to static linking.no-integrated-asβ force usage of an external assembler rather than LLVM's integrated one.no-redzoneβ disable the use of the redzone.relocation-model=[pic,static,dynamic-no-pic]β the relocation model to use. (Default:pic)code-model=[small,kernel,medium,large]β choose the code model to use.metadata=valβ metadata to mangle symbol names with.extra-filename=valβ extra data to put in each output filename.codegen-units=nβ divide crate intonunits to optimize in parallel.remark=valβ print remarks for these optimization passes (space separated, or"all").no-stack-checkβ disable checks for stack exhaustion (a memoryβsafety hazard!).
π¨ bestie. it literally says memory-safety hazard. that's the manpage's own words, i'm just holding the megaphone. be careful with this one. π
debuginfo=valβ debug info emission level:0β no debug info1β lineβtables only (for stacktraces and breakpoints)2β full debug info with variable and type information
opt-level=VALβ optimize with possible levels0β3,s(optimize for size), orz(for minimal size)
π§ ENVIRONMENT π§
some of these affect only test harness programs (generated via rustc --test); others affect all programs which link to the Rust standard library. okay so, mixed audience:
RUST_TEST_THREADSβ the test framework Rust provides executes tests in parallel. this variable sets the maximum number of threads used for this purpose. this setting is overridden by the--test-threadsoption.RUST_TEST_NOCAPTUREβ if set to a value other than"0", a synonym for the--nocaptureflag.RUST_MIN_STACKβ sets the minimum stack size for new threads.RUST_BACKTRACEβ if set to a value different than"0", produces a backtrace in the output of a program which panics. (genuinely so useful, keep her in your.zshrc, periodt π )
π EXAMPLES π
to build an executable from a source file with a main function:
$ rustc -o hello hello.rs
to build a library from a source file:
$ rustc --crate-type=lib hello-lib.rs
to build either with a crate (.rs) file:
$ rustc hello.rs
to build an executable with debug info:
$ rustc -g -o hello hello.rs
ate. every single one. π₯
π SEE ALSO π
her sister page. go read it after this, family support π
π BUGS π
see https://github.com/rust-lang/rust/issues for issues. (yes the manpage just sends you to the issue tracker. iconic honestly.)
π AUTHOR π
see https://github.com/rust-lang/rust/graphs/contributors or use this in the rust source distribution:
git log --all --format='%cN <%cE>' | sort -u
π COPYRIGHT π
this work is dualβlicensed under Apache 2.0 and MIT terms. see the COPYRIGHT file in the rust source distribution.
okay that's the whole page bestie, you're officially fluent π«Ά
sign-off szn: this is rustc version <INSERT VERSION HERE>, dated April 2019 β and yes, the manual name is literally RUSTC(1), we just folded it up here at the bottom with a little bow π
go compile something beautiful β¨π π
π¦ where this page comes from
- ubuntu jammy: rustc-1.77 1.77.2+dfsg1ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: rustc-1.77 1.77.2+dfsg1ubuntu1-0ubuntu0.24.04.1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms