]> git.lizzy.rs Git - rust.git/blob - man/rustc.1
Auto merge of #27836 - alexcrichton:rename-cstring-raw, r=bluss
[rust.git] / man / rustc.1
1 .TH RUSTC "1" "August 2015" "rustc 1.2.0" "User Commands"
2 .SH NAME
3 rustc \- The Rust compiler
4 .SH SYNOPSIS
5 .B rustc
6 [\fIOPTIONS\fR] \fIINPUT\fR
7
8 .SH DESCRIPTION
9 This program is a compiler for the Rust language, available at
10 .UR https://www.rust\-lang.org
11 .UE .
12
13 .SH OPTIONS
14
15 .TP
16 \fB\-h\fR, \fB\-\-help\fR
17 Display the help message.
18 .TP
19 \fB\-\-cfg\fR \fISPEC\fR
20 Configure the compilation environment.
21 .TP
22 \fB\-L\fR [\fIKIND\fR=]\fIPATH\fR
23 Add a directory to the library search path.
24 The optional \fIKIND\fR can be one of:
25 .RS
26 .TP
27 \fBdependency\fR
28 only lookup transitive dependencies here
29 .TP
30 .B crate
31 only lookup local `extern crate` directives here
32 .TP
33 .B native
34 only lookup native libraries here
35 .TP
36 .B framework
37 only look for OSX frameworks here
38 .TP
39 .B all
40 look for anything here (the default)
41 .RE
42 .TP
43 \fB\-l\fR [\fIKIND\fR=]\fINAME\fR
44 Link the generated crate(s) to the specified library \fINAME\fR.
45 The optional \fIKIND\fR can be one of \fIstatic\fR, \fIdylib\fR, or
46 \fIframework\fR.
47 If omitted, \fIdylib\fR is assumed.
48 .TP
49 \fB\-\-crate\-type\fR [bin|lib|rlib|dylib|staticlib]
50 Comma separated list of types of crates for the compiler to emit.
51 .TP
52 \fB\-\-crate\-name\fR \fINAME\fR
53 Specify the name of the crate being built.
54 .TP
55 \fB\-\-emit\fR [asm|llvm\-bc|llvm\-ir|obj|link|dep\-info]
56 Configure the output that \fBrustc\fR will produce.
57 .TP
58 \fB\-\-print\fR [crate\-name|file\-names|sysroot]
59 Comma separated list of compiler information to print on stdout.
60 .TP
61 \fB\-g\fR
62 Equivalent to \fI\-C\ debuginfo=2\fR.
63 .TP
64 \fB\-O\fR
65 Equivalent to \fI\-C\ opt\-level=2\fR.
66 .TP
67 \fB\-o\fR \fIFILENAME\fR
68 Write output to \fIFILENAME\fR.
69 Ignored if multiple \fI\-\-emit\fR outputs are specified.
70 .TP
71 \fB\-\-out\-dir\fR \fIDIR\fR
72 Write output to compiler\[hy]chosen filename in \fIDIR\fR.
73 Ignored if \fI\-o\fR is specified.
74 Defaults to the current directory.
75 .TP
76 \fB\-\-explain\fR \fIOPT\fR
77 Provide a detailed explanation of an error message.
78 .TP
79 \fB\-\-test\fR
80 Build a test harness.
81 .TP
82 \fB\-\-target\fR \fITRIPLE\fR
83 Target triple \fIcpu\fR\-\fImanufacturer\fR\-\fIkernel\fR[\-\fIos\fR]
84 to compile for (see chapter 3.4 of
85 .UR http://www.sourceware.org/autobook/
86 .UE
87 for details).
88 .TP
89 \fB\-W help\fR
90 Print 'lint' options and default settings.
91 .TP
92 \fB\-W\fR \fIOPT\fR, \fB\-\-warn\fR \fIOPT\fR
93 Set lint warnings.
94 .TP
95 \fB\-A\fR \fIOPT\fR, \fB\-\-allow\fR \fIOPT\fR
96 Set lint allowed.
97 .TP
98 \fB\-D\fR \fIOPT\fR, \fB\-\-deny\fR \fIOPT\fR
99 Set lint denied.
100 .TP
101 \fB\-F\fR \fIOPT\fR, \fB\-\-forbid\fR \fIOPT\fR
102 Set lint forbidden.
103 .TP
104 \fB\-C\fR \fIFLAG\fR[=\fIVAL\fR], \fB\-\-codegen\fR \fIFLAG\fR[=\fIVAL\fR]
105 Set a codegen\[hy]related flag to the value specified.
106 Use \fI\-C help\fR to print available flags.
107 See CODEGEN OPTIONS below.
108 .TP
109 \fB\-V\fR, \fB\-\-version\fR
110 Print version info and exit.
111 .TP
112 \fB\-v\fR, \fB\-\-verbose\fR
113 Use verbose output.
114 .TP
115 \fB\-\-extern\fR \fINAME\fR=\fIPATH\fR
116 Specify where an external rust library is located. These should match
117 \fIextern\fR declarations in the crate's source code.
118 .TP
119 \fB\-\-sysroot\fR \fIPATH\fR
120 Override the system root.
121 .TP
122 \fB\-Z\fR \fIFLAG\fR
123 Set internal debugging options.
124 Use \fI\-Z help\fR to print available options.
125 .TP
126 \fB\-\-color\fR auto|always|never
127 Configure coloring of output:
128 .RS
129 .TP
130 .B auto
131 colorize, if output goes to a tty (default);
132 .TP
133 .B always
134 always colorize output;
135 .TP
136 .B never
137 never colorize output.
138 .RE
139
140 .SH CODEGEN OPTIONS
141
142 .TP
143 \fBar\fR=\fI/path/to/ar\fR
144 Path to the archive utility to use when assembling archives.
145 .TP
146 \fBlinker\fR=\fI/path/to/cc\fR
147 Path to the linker utility to use when linking libraries, executables, and
148 objects.
149 .TP
150 \fBlink\-args\fR='\fI\-flag1 \-flag2\fR'
151 A space\[hy]separated list of extra arguments to pass to the linker when the linker
152 is invoked.
153 .TP
154 \fBlto\fR
155 Perform LLVM link\[hy]time optimizations.
156 .TP
157 \fBtarget\-cpu\fR=\fIhelp\fR
158 Selects a target processor.
159 If the value is 'help', then a list of available CPUs is printed.
160 .TP
161 \fBtarget\-feature\fR='\fI+feature1\fR,\fI\-feature2\fR'
162 A comma\[hy]separated list of features to enable or disable for the target.
163 A preceding '+' enables a feature while a preceding '\-' disables it.
164 Available features can be discovered through \fIllc -mcpu=help\fR.
165 .TP
166 \fBpasses\fR=\fIval\fR
167 A space\[hy]separated list of extra LLVM passes to run.
168 A value of 'list' will cause \fBrustc\fR to print all known passes and
169 exit.
170 The passes specified are appended at the end of the normal pass manager.
171 .TP
172 \fBllvm\-args\fR='\fI\-arg1\fR \fI\-arg2\fR'
173 A space\[hy]separated list of arguments to pass through to LLVM.
174 .TP
175 \fBsave\-temps\fR
176 If specified, the compiler will save more files (.bc, .o, .no\-opt.bc) generated
177 throughout compilation in the output directory.
178 .TP
179 \fBrpath\fR
180 If specified, then the rpath value for dynamic libraries will be set in
181 either dynamic library or executable outputs.
182 .TP
183 \fBno\-prepopulate\-passes\fR
184 Suppresses pre\[hy]population of the LLVM pass manager that is run over the module.
185 .TP
186 \fBno\-vectorize\-loops\fR
187 Suppresses running the loop vectorization LLVM pass, regardless of optimization
188 level.
189 .TP
190 \fBno\-vectorize\-slp\fR
191 Suppresses running the LLVM SLP vectorization pass, regardless of optimization
192 level.
193 .TP
194 \fBsoft\-float\fR
195 Generates software floating point library calls instead of hardware
196 instructions.
197 .TP
198 \fBprefer\-dynamic\fR
199 Prefers dynamic linking to static linking.
200 .TP
201 \fBno\-integrated\-as\fR
202 Force usage of an external assembler rather than LLVM's integrated one.
203 .TP
204 \fBno\-redzone\fR
205 Disable the use of the redzone.
206 .TP
207 \fBrelocation\-model\fR=[pic,static,dynamic\-no\-pic]
208 The relocation model to use.
209 (Default: \fIpic\fR)
210 .TP
211 \fBcode\-model\fR=[small,kernel,medium,large]
212 Choose the code model to use.
213 .TP
214 \fBmetadata\fR=\fIval\fR
215 Metadata to mangle symbol names with.
216 .TP
217 \fBextra\-filename\fR=\fIval\fR
218 Extra data to put in each output filename.
219 .TP
220 \fBcodegen\-units\fR=\fIn\fR
221 Divide crate into \fIn\fR units to optimize in parallel.
222 .TP
223 \fBremark\fR=\fIval\fR
224 Print remarks for these optimization passes (space separated, or "all").
225 .TP
226 \fBno\-stack\-check\fR
227 Disable checks for stack exhaustion (a memory\[hy]safety hazard!).
228 .TP
229 \fBdebuginfo\fR=\fIval\fR
230 Debug info emission level:
231 .RS
232 .TP
233 .B 0
234 no debug info;
235 .TP
236 .B 1
237 line\[hy]tables only (for stacktraces and breakpoints);
238 .TP
239 .B 2
240 full debug info with variable and type information.
241 .RE
242 .TP
243 \fBopt\-level\fR=\fIVAL\fR
244 Optimize with possible levels 0\[en]3
245
246 .SH ENVIRONMENT
247
248 Some of these affect the output of the compiler, while others affect programs
249 which link to the standard library.
250
251 .TP
252 \fBRUST_TEST_THREADS\fR
253 The test framework Rust provides executes tests in parallel. This variable sets
254 the maximum number of threads used for this purpose.
255
256 .TP
257 \fBRUST_TEST_NOCAPTURE\fR
258 A synonym for the --nocapture flag.
259
260 .TP
261 \fBRUST_MIN_STACK\fR
262 Sets the minimum stack size for new threads.
263
264 .TP
265 \fBRUST_BACKTRACE\fR
266 If set, produces a backtrace in the output of a program which panics.
267
268 .SH "EXAMPLES"
269 To build an executable from a source file with a main function:
270     $ rustc \-o hello hello.rs
271
272 To build a library from a source file:
273     $ rustc \-\-crate\-type=lib hello\-lib.rs
274
275 To build either with a crate (.rs) file:
276     $ rustc hello.rs
277
278 To build an executable with debug info:
279     $ rustc \-g \-o hello hello.rs
280
281 .SH "SEE ALSO"
282
283 .BR rustdoc (1)
284
285 .SH "BUGS"
286 See
287 .UR https://github.com/rust\-lang/rust/issues
288 .UE
289 for issues.
290
291 .SH "AUTHOR"
292 See \fIAUTHORS.txt\fR in the Rust source distribution.
293
294 .SH "COPYRIGHT"
295 This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.
296 See \fICOPYRIGHT\fR file in the rust source distribution.