1 .TH RUSTC "1" "<INSERT DATE HERE>" "rustc <INSERT VERSION HERE>" "User Commands"
3 rustc \- The Rust compiler
6 [\fIOPTIONS\fR] \fIINPUT\fR
9 This program is a compiler for the Rust language, available at https://www.rust\-lang.org.
14 \fB\-h\fR, \fB\-\-help\fR
15 Display the help message.
17 \fB\-\-cfg\fR \fISPEC\fR
18 Configure the compilation environment.
20 \fB\-L\fR [\fIKIND\fR=]\fIPATH\fR
21 Add a directory to the library search path.
22 The optional \fIKIND\fR can be one of:
26 only lookup transitive dependencies here
29 only lookup local `extern crate` directives here
32 only lookup native libraries here
35 only look for OSX frameworks here
38 look for anything here (the default)
41 \fB\-l\fR [\fIKIND\fR=]\fINAME\fR
42 Link the generated crate(s) to the specified library \fINAME\fR.
43 The optional \fIKIND\fR can be one of \fIstatic\fR, \fIdylib\fR, or
45 If omitted, \fIdylib\fR is assumed.
47 \fB\-\-crate\-type\fR [bin|lib|rlib|dylib|cdylib|staticlib]
48 Comma separated list of types of crates for the compiler to emit.
50 \fB\-\-crate\-name\fR \fINAME\fR
51 Specify the name of the crate being built.
53 \fB\-\-emit\fR [asm|llvm\-bc|llvm\-ir|obj|link|dep\-info|mir][=\fIPATH\fR]
54 Configure the output that \fBrustc\fR will produce. Each emission may also have
55 an optional explicit output \fIPATH\fR specified for that particular emission
56 kind. This path takes precedence over the \fB-o\fR option.
58 \fB\-\-print\fR [crate\-name|\:file\-names|\:sysroot|\:cfg|\:target\-list|\:target\-cpus|\:target\-features|\:relocation\-models|\:code\-models|\:tls\-models|\:target\-spec\-json|\:native\-static\-libs]
59 Comma separated list of compiler information to print on stdout.
62 Equivalent to \fI\-C\ debuginfo=2\fR.
65 Equivalent to \fI\-C\ opt\-level=2\fR.
67 \fB\-o\fR \fIFILENAME\fR
68 Write output to \fIFILENAME\fR. Ignored if multiple \fI\-\-emit\fR outputs are specified which
69 don't have an explicit path otherwise.
71 \fB\-\-out\-dir\fR \fIDIR\fR
72 Write output to compiler\[hy]chosen filename in \fIDIR\fR. Ignored if \fI\-o\fR is specified.
73 Defaults to the current directory.
75 \fB\-\-explain\fR \fIOPT\fR
76 Provide a detailed explanation of an error message.
81 \fB\-\-target\fR \fITARGET\fR
82 Target triple for which the code is compiled. This option defaults to the host’s target
83 triple. The target triple has the general format <arch><sub>\-<vendor>\-<sys>\-<abi>, where:
87 x86, arm, thumb, mips, etc.
90 for example on ARM: v5, v6m, v7a, v7m, etc.
93 pc, apple, nvidia, ibm, etc.
96 none, linux, win32, darwin, cuda, etc.
99 eabi, gnu, android, macho, elf, etc.
103 Print 'lint' options and default settings.
105 \fB\-W\fR \fIOPT\fR, \fB\-\-warn\fR \fIOPT\fR
108 \fB\-A\fR \fIOPT\fR, \fB\-\-allow\fR \fIOPT\fR
111 \fB\-D\fR \fIOPT\fR, \fB\-\-deny\fR \fIOPT\fR
114 \fB\-F\fR \fIOPT\fR, \fB\-\-forbid\fR \fIOPT\fR
117 \fB\-C\fR \fIFLAG\fR[=\fIVAL\fR], \fB\-\-codegen\fR \fIFLAG\fR[=\fIVAL\fR]
118 Set a codegen\[hy]related flag to the value specified.
119 Use \fI\-C help\fR to print available flags.
120 See CODEGEN OPTIONS below.
122 \fB\-V\fR, \fB\-\-version\fR
123 Print version info and exit.
125 \fB\-v\fR, \fB\-\-verbose\fR
128 \fB\-\-remap\-path\-prefix\fR \fIfrom\fR=\fIto\fR
129 Remap source path prefixes in all output, including compiler diagnostics, debug information,
130 macro expansions, etc. The \fIfrom\fR=\fIto\fR parameter is scanned from right to left, so \fIfrom\fR
131 may contain '=', but \fIto\fR may not.
133 This is useful for normalizing build products, for example by removing the current directory out of
134 pathnames emitted into the object files. The replacement is purely textual, with no consideration of
135 the current system's pathname syntax. For example \fI\-\-remap\-path\-prefix foo=bar\fR will
136 match \fBfoo/lib.rs\fR but not \fB./foo/lib.rs\fR.
138 \fB\-\-extern\fR \fINAME\fR=\fIPATH\fR
139 Specify where an external rust library is located. These should match
140 \fIextern\fR declarations in the crate's source code.
142 \fB\-\-sysroot\fR \fIPATH\fR
143 Override the system root.
146 Set internal debugging options.
147 Use \fI\-Z help\fR to print available options.
149 \fB\-\-color\fR auto|always|never
150 Configure coloring of output:
154 colorize, if output goes to a tty (default);
157 always colorize output;
160 never colorize output.
166 \fBlinker\fR=\fI/path/to/cc\fR
167 Path to the linker utility to use when linking libraries, executables, and
170 \fBlink\-args\fR='\fI\-flag1 \-flag2\fR'
171 A space\[hy]separated list of extra arguments to pass to the linker when the linker
175 Perform LLVM link\[hy]time optimizations.
177 \fBtarget\-cpu\fR=\fIhelp\fR
178 Selects a target processor.
179 If the value is 'help', then a list of available CPUs is printed.
181 \fBtarget\-feature\fR='\fI+feature1\fR,\fI\-feature2\fR'
182 A comma\[hy]separated list of features to enable or disable for the target.
183 A preceding '+' enables a feature while a preceding '\-' disables it.
184 Available features can be discovered through \fIllc -mcpu=help\fR.
186 \fBpasses\fR=\fIval\fR
187 A space\[hy]separated list of extra LLVM passes to run.
188 A value of 'list' will cause \fBrustc\fR to print all known passes and
190 The passes specified are appended at the end of the normal pass manager.
192 \fBllvm\-args\fR='\fI\-arg1\fR \fI\-arg2\fR'
193 A space\[hy]separated list of arguments to pass through to LLVM.
196 If specified, the compiler will save more files (.bc, .o, .no\-opt.bc) generated
197 throughout compilation in the output directory.
200 If specified, then the rpath value for dynamic libraries will be set in
201 either dynamic library or executable outputs.
203 \fBno\-prepopulate\-passes\fR
204 Suppresses pre\[hy]population of the LLVM pass manager that is run over the module.
206 \fBno\-vectorize\-loops\fR
207 Suppresses running the loop vectorization LLVM pass, regardless of optimization
210 \fBno\-vectorize\-slp\fR
211 Suppresses running the LLVM SLP vectorization pass, regardless of optimization
215 Generates software floating point library calls instead of hardware
218 \fBprefer\-dynamic\fR
219 Prefers dynamic linking to static linking.
221 \fBno\-integrated\-as\fR
222 Force usage of an external assembler rather than LLVM's integrated one.
225 Disable the use of the redzone.
227 \fBrelocation\-model\fR=[pic,static,dynamic\-no\-pic]
228 The relocation model to use.
231 \fBcode\-model\fR=[small,kernel,medium,large]
232 Choose the code model to use.
234 \fBmetadata\fR=\fIval\fR
235 Metadata to mangle symbol names with.
237 \fBextra\-filename\fR=\fIval\fR
238 Extra data to put in each output filename.
240 \fBcodegen\-units\fR=\fIn\fR
241 Divide crate into \fIn\fR units to optimize in parallel.
243 \fBremark\fR=\fIval\fR
244 Print remarks for these optimization passes (space separated, or "all").
246 \fBno\-stack\-check\fR
247 Disable checks for stack exhaustion (a memory\[hy]safety hazard!).
249 \fBdebuginfo\fR=\fIval\fR
250 Debug info emission level:
257 line\[hy]tables only (for stacktraces and breakpoints);
260 full debug info with variable and type information.
263 \fBopt\-level\fR=\fIVAL\fR
264 Optimize with possible levels 0\[en]3
268 Some of these affect the output of the compiler, while others affect programs
269 which link to the standard library.
272 \fBRUST_TEST_THREADS\fR
273 The test framework Rust provides executes tests in parallel. This variable sets
274 the maximum number of threads used for this purpose. This setting is overridden
275 by the --test-threads option.
278 \fBRUST_TEST_NOCAPTURE\fR
279 If set to a value other than "0", a synonym for the --nocapture flag.
283 Sets the minimum stack size for new threads.
287 If set to a value different than "0", produces a backtrace in the output of a program which panics.
290 To build an executable from a source file with a main function:
291 $ rustc \-o hello hello.rs
293 To build a library from a source file:
294 $ rustc \-\-crate\-type=lib hello\-lib.rs
296 To build either with a crate (.rs) file:
299 To build an executable with debug info:
300 $ rustc \-g \-o hello hello.rs
307 See https://github.com/rust\-lang/rust/issues for issues.
310 See https://github.com/rust\-lang/rust/graphs/contributors or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution.
313 This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.
314 See \fICOPYRIGHT\fR file in the rust source distribution.