308 lines (287 sloc) 8.1 KB
.TH RUSTC "1" "August 2016" "rustc 1.12.0" "User Commands"
rustc \- The Rust compiler
.B rustc
This program is a compiler for the Rust language, available at https://www.rust\-lang.org.
\fB\-h\fR, \fB\-\-help\fR
Display the help message.
\fB\-\-cfg\fR \fISPEC\fR
Configure the compilation environment.
\fB\-L\fR [\fIKIND\fR=]\fIPATH\fR
Add a directory to the library search path.
The optional \fIKIND\fR can be one of:
only lookup transitive dependencies here
.B crate
only lookup local `extern crate` directives here
.B native
only lookup native libraries here
.B framework
only look for OSX frameworks here
.B all
look for anything here (the default)
\fB\-l\fR [\fIKIND\fR=]\fINAME\fR
Link the generated crate(s) to the specified library \fINAME\fR.
The optional \fIKIND\fR can be one of \fIstatic\fR, \fIdylib\fR, or
If omitted, \fIdylib\fR is assumed.
\fB\-\-crate\-type\fR [bin|lib|rlib|dylib|cdylib|staticlib]
Comma separated list of types of crates for the compiler to emit.
\fB\-\-crate\-name\fR \fINAME\fR
Specify the name of the crate being built.
\fB\-\-emit\fR [asm|llvm\-bc|llvm\-ir|obj|link|dep\-info][=\fIPATH\fR]
Configure the output that \fBrustc\fR will produce. Each emission may also have
an optional explicit output \fIPATH\fR specified for that particular emission
kind. This path takes precedence over the \fB-o\fR option.
\fB\-\-print\fR [crate\-name|file\-names|sysroot]
Comma separated list of compiler information to print on stdout.
Equivalent to \fI\-C\ debuginfo=2\fR.
Equivalent to \fI\-C\ opt\-level=2\fR.
\fB\-o\fR \fIFILENAME\fR
Write output to \fIFILENAME\fR. Ignored if multiple \fI\-\-emit\fR outputs are specified which
don't have an explicit path otherwise.
\fB\-\-out\-dir\fR \fIDIR\fR
Write output to compiler\[hy]chosen filename in \fIDIR\fR. Ignored if \fI\-o\fR is specified.
Defaults to the current directory.
\fB\-\-explain\fR \fIOPT\fR
Provide a detailed explanation of an error message.
Build a test harness.
\fB\-\-target\fR \fITARGET\fR
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:
.B <arch>
x86, arm, thumb, mips, etc.
.B <sub>
for example on ARM: v5, v6m, v7a, v7m, etc.
.B <vendor>
pc, apple, nvidia, ibm, etc.
.B <sys>
none, linux, win32, darwin, cuda, etc.
.B <abi>
eabi, gnu, android, macho, elf, etc.
\fB\-W help\fR
Print 'lint' options and default settings.
\fB\-W\fR \fIOPT\fR, \fB\-\-warn\fR \fIOPT\fR
Set lint warnings.
\fB\-A\fR \fIOPT\fR, \fB\-\-allow\fR \fIOPT\fR
Set lint allowed.
\fB\-D\fR \fIOPT\fR, \fB\-\-deny\fR \fIOPT\fR
Set lint denied.
\fB\-F\fR \fIOPT\fR, \fB\-\-forbid\fR \fIOPT\fR
Set lint forbidden.
\fB\-C\fR \fIFLAG\fR[=\fIVAL\fR], \fB\-\-codegen\fR \fIFLAG\fR[=\fIVAL\fR]
Set a codegen\[hy]related flag to the value specified.
Use \fI\-C help\fR to print available flags.
\fB\-V\fR, \fB\-\-version\fR
Print version info and exit.
\fB\-v\fR, \fB\-\-verbose\fR
Use verbose output.
\fB\-\-extern\fR \fINAME\fR=\fIPATH\fR
Specify where an external rust library is located. These should match
\fIextern\fR declarations in the crate's source code.
\fB\-\-sysroot\fR \fIPATH\fR
Override the system root.
\fB\-Z\fR \fIFLAG\fR
Set internal debugging options.
Use \fI\-Z help\fR to print available options.
\fB\-\-color\fR auto|always|never
Configure coloring of output:
.B auto
colorize, if output goes to a tty (default);
.B always
always colorize output;
.B never
never colorize output.
Path to the archive utility to use when assembling archives.
Path to the linker utility to use when linking libraries, executables, and
\fBlink\-args\fR='\fI\-flag1 \-flag2\fR'
A space\[hy]separated list of extra arguments to pass to the linker when the linker
is invoked.
Perform LLVM link\[hy]time optimizations.
Selects a target processor.
If the value is 'help', then a list of available CPUs is printed.
A comma\[hy]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 \fIllc -mcpu=help\fR.
A space\[hy]separated list of extra LLVM passes to run.
A value of 'list' will cause \fBrustc\fR to print all known passes and
The passes specified are appended at the end of the normal pass manager.
\fBllvm\-args\fR='\fI\-arg1\fR \fI\-arg2\fR'
A space\[hy]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\[hy]population of the LLVM pass manager that is run over the module.
Suppresses running the loop vectorization LLVM pass, regardless of optimization
Suppresses running the LLVM SLP vectorization pass, regardless of optimization
Generates software floating point library calls instead of hardware
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: \fIpic\fR)
Choose the code model to use.
Metadata to mangle symbol names with.
Extra data to put in each output filename.
Divide crate into \fIn\fR units to optimize in parallel.
Print remarks for these optimization passes (space separated, or "all").
Disable checks for stack exhaustion (a memory\[hy]safety hazard!).
Debug info emission level:
.B 0
no debug info;
.B 1
line\[hy]tables only (for stacktraces and breakpoints);
.B 2
full debug info with variable and type information.
Optimize with possible levels 0\[en]3
Some of these affect the output of the compiler, while others affect programs
which link to the 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
.BR 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\[hy]licensed under Apache\ 2.0 and MIT terms.
See \fICOPYRIGHT\fR file in the rust source distribution.