RUSTC(1)
๐ธ RUSTC(1) โ the Rust compiler, bestie edition ๐ธ
okay so. this is rustc, from the RUSTC(1) manual (User Commands section, in case you were wondering where to find it). get comfy, we're doing this. ๐ซถ
โจ NAME โจ
rustc โ The Rust compiler ๐
โจ SYNOPSIS โจ
rustc [OPTIONS] INPUT
โจ DESCRIPTION โจ
bestie. this program is a compiler for the Rust language. it lives at https://www.rust-lang.org. that's the whole vibe. โจ
โจ OPTIONS โจ
-h,--helpโ prints the help message for you. slay.--cfg SPECโ configures the compilation environment.-L [KIND=]PATHโ adds a directory to the library search path ๐๏ธ. theKINDpart is optional, and it can be one of these:dependencyโ only lookup transitive dependencies herecrateโ only lookup localextern cratedirectives herenativeโ only lookup native libraries hereframeworkโ only look for OSX frameworks hereallโ look for anything here (this one's the default)
-l [KIND=]NAMEโ links the generated crate(s) to the specified libraryNAME. the optionalKINDcan bestatic,dylib, orframework. if you justโฆ don't say it,dylibis assumed.--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]โ a comma separated list of the types of crates you want the compiler to emit.--crate-name NAMEโ specify the name of the crate being built.--emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir][=PATH]โ configures the output thatrustcwill produce. each emission can also have an optional explicit outputPATHspecified for that particular emission kind. this path takes precedence over the-ooption, fyi ๐--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]โ comma separated list of compiler information to print on stdout.-gโ equivalent to-C debuginfo=2.-Oโ equivalent to-C opt-level=3.-o FILENAMEโ write output toFILENAME. it gets ignored if multiple--emitoutputs are specified which don't have an explicit path otherwise.--out-dir DIRโ write output to a compiler-chosen filename inDIR. ignored if-ois specified. defaults to the current directory.--explain OPTโ gives you a detailed explanation of an error message. so helpful honestly ๐ญ--testโ build a test harness.--target TARGETโ the target tuple for which the code is compiled. this option defaults to the host's target tuple. the target tuple 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โ print 'lint' options and default settings.-W OPT,--warn OPTโ set lint warnings.-A OPT,--allow OPTโ set lint allowed.-D OPT,--deny OPTโ set lint denied.-F OPT,--forbid OPTโ set lint forbidden.-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 ๐-V,--versionโ print version info and exit.-v,--verboseโ use verbose output.--remap-path-prefix from=toโ remap 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 match extern declarations 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. โ ๏ธ unstable means unstable, bestie.--color auto|always|neverโ configure coloring of output:autoโ colorize, if output goes to a tty (default);alwaysโ always colorize output;neverโ never colorize output.
๐ CODEGEN OPTIONS ๐
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!). ๐จ like, that's not a cute tradeoff bestie.debuginfo=valโ debug info emission level:0โ no debug info;1โ 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. iykyk.
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.
๐ฆ 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
โญ SEE ALSO โญ
๐ BUGS ๐
see https://github.com/rust-lang/rust/issues for issues. (not me manifesting bugs, it's just in the manual ๐ญ)
๐ 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.
that's the whole page, bestie ๐ this is rustc 1.99.1 (58cf8f9c3 2026-10..., dated April 2019, and it's filed under RUSTC(1) โ go build something iconic with it, and drink some water. periodt ๐
โจ๐ง๐
๐ฆ where this page comes from
- centos-stream 10: rust 1.99.1-1.el10 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- centos-stream 9: rust 1.99.1-1.el9 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- fedora 43: rust 1.99.1-2.fc43 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- fedora 44: rust 1.99.1-2.fc44 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms