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 ๐Ÿ—‚๏ธ. the KIND part is optional, and it can be one of these:
    • dependency โ€” only lookup transitive dependencies here
    • crate โ€” only lookup local extern crate directives here
    • native โ€” only lookup native libraries here
    • framework โ€” only look for OSX frameworks here
    • all โ€” look for anything here (this one's the default)
  • -l [KIND=]NAME โ€” links the generated crate(s) to the specified library NAME. the optional KIND can be static, dylib, or framework. if you justโ€ฆ don't say it, dylib is 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 that rustc will produce. each emission can also have an optional explicit output PATH specified for that particular emission kind. this path takes precedence over the -o option, 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 to FILENAME. it gets ignored if multiple --emit outputs are specified which don't have an explicit path otherwise.
  • --out-dir DIR โ€” write output to a compiler-chosen filename in DIR. ignored if -o is 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 help to 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. the from=to parameter is scanned from right to left, so from may contain '=', but to may 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 help to 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 through llc -mcpu=help.
  • passes=val โ€” a space-separated list of extra LLVM passes to run. a value of 'list' will cause rustc to 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 into n units 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 levels 0โ€“3, s (optimize for size), or z (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-threads option.
  • RUST_TEST_NOCAPTURE โ€” if set to a value other than "0", a synonym for the --nocapture flag.
  • 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 โญ

rustdoc(1)

๐Ÿ’€ 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

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