DOKK / manpages / debian 10 / rustc-mozilla / rustc.1.en
RUSTC(1) User Commands RUSTC(1)

rustc - The Rust compiler

rustc [OPTIONS] INPUT

This program is a compiler for the Rust language, available at https://www.rust-lang.org.

Display the help message.
Configure the compilation environment.
Add a directory to the library search path. The optional KIND can be one of:
only lookup transitive dependencies here
only lookup local `extern crate` directives here
only lookup native libraries here
only look for OSX frameworks here
look for anything here (the default)
Link the generated crate(s) to the specified library NAME. The optional KIND can be one of static, dylib, or framework. If omitted, dylib is assumed.
--crate-type [bin|lib|rlib|dylib|cdylib|staticlib]
Comma separated list of types of crates for the compiler to emit.
--crate-name NAME
Specify the name of the crate being built.
Configure the output that rustc will produce. Each emission may also have an optional explicit output PATH specified for that particular emission kind. This path takes precedence over the -o option.
Comma separated list of compiler information to print on stdout.
Equivalent to -C debuginfo=2.
Equivalent to -C opt-level=2.
Write output to FILENAME. Ignored if multiple --emit outputs are specified which don't have an explicit path otherwise.
Write output to compiler‐chosen filename in DIR. Ignored if -o is specified. Defaults to the current directory.
Provide a detailed explanation of an error message.
Build a test harness.
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.
Print 'lint' options and default settings.
Set lint warnings.
Set lint allowed.
Set lint denied.
Set lint forbidden.
Set a codegen‐related flag to the value specified. Use -C help to print available flags. See CODEGEN OPTIONS below.
Print version info and exit.
Use verbose output.
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.

Specify where an external rust library is located. These should match extern declarations in the crate's source code.
Override the system root.
Set internal debugging options. Use -Z help to print available options.
Configure coloring of output:
colorize, if output goes to a tty (default);
always colorize output;
never colorize output.

Path to the linker utility to use when linking libraries, executables, and objects.
A space‐separated list of extra arguments to pass to the linker when the linker is invoked.
Perform LLVM link‐time optimizations.
Selects a target processor. If the value is 'help', then a list of available CPUs is printed.
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.
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.
A space‐separated list of arguments to pass through to LLVM.
If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated throughout compilation in the output directory.
If specified, then the rpath value for dynamic libraries will be set in either dynamic library or executable outputs.
Suppresses pre‐population of the LLVM pass manager that is run over the module.
Suppresses running the loop vectorization LLVM pass, regardless of optimization level.
Suppresses running the LLVM SLP vectorization pass, regardless of optimization level.
Generates software floating point library calls instead of hardware instructions.
Prefers dynamic linking to static linking.
Force usage of an external assembler rather than LLVM's integrated one.
Disable the use of the redzone.
The relocation model to use. (Default: pic)
Choose the code model to use.
Metadata to mangle symbol names with.
Extra data to put in each output filename.
Divide crate into n units to optimize in parallel.
Print remarks for these optimization passes (space separated, or "all").
Disable checks for stack exhaustion (a memory‐safety hazard!).
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.
Optimize with possible levels 0–3, s (optimize for size), or z (for minimal size)

Some of these affect only test harness programs (generated via rustc --test); others affect all programs which link to the Rust standard library.

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.

If set to a value other than "0", a synonym for the --nocapture flag.

Sets the minimum stack size for new threads.

If set to a value different than "0", produces a backtrace in the output of a program which panics.

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

rustdoc(1)

See https://github.com/rust-lang/rust/issues for issues.

See https://github.com/rust-lang/rust/graphs/contributors or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution.

This work is dual‐licensed under Apache 2.0 and MIT terms. See COPYRIGHT file in the rust source distribution.

August 2022 rustc 1.59.0