]>
Commit | Line | Data |
---|---|---|
83c7162d XL |
1 | # Codegen options |
2 | ||
3 | All of these options are passed to `rustc` via the `-C` flag, short for "codegen." You can see | |
4 | a version of this list for your exact compiler by running `rustc -C help`. | |
5 | ||
6 | ## ar | |
7 | ||
8 | This option is deprecated and does nothing. | |
9 | ||
f9f354fc | 10 | ## code-model |
83c7162d | 11 | |
f9f354fc XL |
12 | This option lets you choose which code model to use. \ |
13 | Code models put constraints on address ranges that the program and its symbols may use. \ | |
14 | With smaller address ranges machine instructions | |
3dfed10e | 15 | may be able to use more compact addressing modes. |
f9f354fc XL |
16 | |
17 | The specific ranges depend on target architectures and addressing modes available to them. \ | |
18 | For x86 more detailed description of its code models can be found in | |
19 | [System V Application Binary Interface](https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf) | |
20 | specification. | |
21 | ||
22 | Supported values for this option are: | |
23 | ||
24 | - `tiny` - Tiny code model. | |
25 | - `small` - Small code model. This is the default model for majority of supported targets. | |
26 | - `kernel` - Kernel code model. | |
27 | - `medium` - Medium code model. | |
28 | - `large` - Large code model. | |
29 | ||
30 | Supported values can also be discovered by running `rustc --print code-models`. | |
31 | ||
32 | ## codegen-units | |
33 | ||
34 | This flag controls how many code generation units the crate is split into. It | |
35 | takes an integer greater than 0. | |
36 | ||
37 | When a crate is split into multiple codegen units, LLVM is able to process | |
38 | them in parallel. Increasing parallelism may speed up compile times, but may | |
39 | also produce slower code. Setting this to 1 may improve the performance of | |
40 | generated code, but may be slower to compile. | |
41 | ||
42 | The default value, if not specified, is 16 for non-incremental builds. For | |
43 | incremental builds the default is 256 which allows caching to be more granular. | |
44 | ||
3dfed10e XL |
45 | ## control-flow-guard |
46 | ||
1b1a35ee XL |
47 | This flag controls whether LLVM enables the Windows [Control Flow |
48 | Guard](https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard) | |
49 | platform security feature. This flag is currently ignored for non-Windows targets. | |
3dfed10e XL |
50 | It takes one of the following values: |
51 | ||
52 | * `y`, `yes`, `on`, `checks`, or no value: enable Control Flow Guard. | |
1b1a35ee | 53 | * `nochecks`: emit Control Flow Guard metadata without runtime enforcement checks (this |
3dfed10e XL |
54 | should only be used for testing purposes as it does not provide security enforcement). |
55 | * `n`, `no`, `off`: do not enable Control Flow Guard (the default). | |
56 | ||
f9f354fc XL |
57 | ## debug-assertions |
58 | ||
59 | This flag lets you turn `cfg(debug_assertions)` [conditional | |
60 | compilation](../../reference/conditional-compilation.md#debug_assertions) on | |
61 | or off. It takes one of the following values: | |
62 | ||
63 | * `y`, `yes`, `on`, or no value: enable debug-assertions. | |
64 | * `n`, `no`, or `off`: disable debug-assertions. | |
65 | ||
66 | If not specified, debug assertions are automatically enabled only if the | |
67 | [opt-level](#opt-level) is 0. | |
68 | ||
69 | ## debuginfo | |
70 | ||
71 | This flag controls the generation of debug information. It takes one of the | |
72 | following values: | |
73 | ||
74 | * `0`: no debug info at all (the default). | |
75 | * `1`: line tables only. | |
76 | * `2`: full debug info. | |
77 | ||
78 | Note: The [`-g` flag][option-g-debug] is an alias for `-C debuginfo=2`. | |
79 | ||
80 | ## default-linker-libraries | |
81 | ||
82 | This flag controls whether or not the linker includes its default libraries. | |
83 | It takes one of the following values: | |
84 | ||
85 | * `y`, `yes`, `on`, or no value: include default libraries (the default). | |
86 | * `n`, `no`, or `off`: exclude default libraries. | |
87 | ||
88 | For example, for gcc flavor linkers, this issues the `-nodefaultlibs` flag to | |
89 | the linker. | |
90 | ||
91 | ## embed-bitcode | |
92 | ||
93 | This flag controls whether or not the compiler embeds LLVM bitcode into object | |
94 | files. It takes one of the following values: | |
95 | ||
96 | * `y`, `yes`, `on`, or no value: put bitcode in rlibs (the default). | |
97 | * `n`, `no`, or `off`: omit bitcode from rlibs. | |
98 | ||
99 | LLVM bitcode is required when rustc is performing link-time optimization (LTO). | |
100 | It is also required on some targets like iOS ones where vendors look for LLVM | |
101 | bitcode. Embedded bitcode will appear in rustc-generated object files inside of | |
102 | a section whose name is defined by the target platform. Most of the time this is | |
103 | `.llvmbc`. | |
104 | ||
105 | The use of `-C embed-bitcode=no` can significantly improve compile times and | |
106 | reduce generated file sizes if your compilation does not actually need bitcode | |
107 | (e.g. if you're not compiling for iOS or you're not performing LTO). For these | |
108 | reasons, Cargo uses `-C embed-bitcode=no` whenever possible. Likewise, if you | |
109 | are building directly with `rustc` we recommend using `-C embed-bitcode=no` | |
110 | whenever you are not using LTO. | |
111 | ||
112 | If combined with `-C lto`, `-C embed-bitcode=no` will cause `rustc` to abort | |
113 | at start-up, because the combination is invalid. | |
114 | ||
115 | > **Note**: if you're building Rust code with LTO then you probably don't even | |
116 | > need the `embed-bitcode` option turned on. You'll likely want to use | |
117 | > `-Clinker-plugin-lto` instead which skips generating object files entirely and | |
118 | > simply replaces object files with LLVM bitcode. The only purpose for | |
119 | > `-Cembed-bitcode` is when you're generating an rlib that is both being used | |
120 | > with and without LTO. For example Rust's standard library ships with embedded | |
121 | > bitcode since users link to it both with and without LTO. | |
122 | > | |
123 | > This also may make you wonder why the default is `yes` for this option. The | |
124 | > reason for that is that it's how it was for rustc 1.44 and prior. In 1.45 this | |
125 | > option was added to turn off what had always been the default. | |
126 | ||
127 | ## extra-filename | |
128 | ||
129 | This option allows you to put extra data in each output filename. It takes a | |
130 | string to add as a suffix to the filename. See the [`--emit` | |
131 | flag][option-emit] for more information. | |
132 | ||
133 | ## force-frame-pointers | |
134 | ||
135 | This flag forces the use of frame pointers. It takes one of the following | |
136 | values: | |
137 | ||
138 | * `y`, `yes`, `on`, or no value: force-enable frame pointers. | |
139 | * `n`, `no`, or `off`: do not force-enable frame pointers. This does | |
140 | not necessarily mean frame pointers will be removed. | |
141 | ||
142 | The default behaviour, if frame pointers are not force-enabled, depends on the | |
143 | target. | |
144 | ||
145 | ## force-unwind-tables | |
146 | ||
147 | This flag forces the generation of unwind tables. It takes one of the following | |
148 | values: | |
149 | ||
150 | * `y`, `yes`, `on`, or no value: Unwind tables are forced to be generated. | |
151 | * `n`, `no`, or `off`: Unwind tables are not forced to be generated. If unwind | |
152 | tables are required by the target or `-C panic=unwind`, an error will be | |
153 | emitted. | |
154 | ||
155 | The default if not specified depends on the target. | |
156 | ||
157 | ## incremental | |
158 | ||
159 | This flag allows you to enable incremental compilation, which allows `rustc` | |
160 | to save information after compiling a crate to be reused when recompiling the | |
161 | crate, improving re-compile times. This takes a path to a directory where | |
162 | incremental files will be stored. | |
163 | ||
164 | ## inline-threshold | |
165 | ||
166 | This option lets you set the default threshold for inlining a function. It | |
167 | takes an unsigned integer as a value. Inlining is based on a cost model, where | |
168 | a higher threshold will allow more inlining. | |
169 | ||
170 | The default depends on the [opt-level](#opt-level): | |
171 | ||
172 | | opt-level | Threshold | | |
173 | |-----------|-----------| | |
174 | | 0 | N/A, only inlines always-inline functions | | |
175 | | 1 | N/A, only inlines always-inline functions and LLVM lifetime intrinsics | | |
176 | | 2 | 225 | | |
177 | | 3 | 275 | | |
178 | | s | 75 | | |
179 | | z | 25 | | |
83c7162d | 180 | |
60c5eb7d | 181 | ## link-arg |
83c7162d XL |
182 | |
183 | This flag lets you append a single extra argument to the linker invocation. | |
184 | ||
185 | "Append" is significant; you can pass this flag multiple times to add multiple arguments. | |
186 | ||
187 | ## link-args | |
188 | ||
189 | This flag lets you append multiple extra arguments to the linker invocation. The | |
190 | options should be separated by spaces. | |
191 | ||
f9f354fc XL |
192 | ## link-dead-code |
193 | ||
194 | This flag controls whether the linker will keep dead code. It takes one of | |
195 | the following values: | |
196 | ||
197 | * `y`, `yes`, `on`, or no value: keep dead code. | |
198 | * `n`, `no`, or `off`: remove dead code (the default). | |
199 | ||
200 | An example of when this flag might be useful is when trying to construct code coverage | |
201 | metrics. | |
202 | ||
1b1a35ee XL |
203 | ## link-self-contained |
204 | ||
205 | On targets that support it this flag controls whether the linker will use libraries and objects | |
206 | shipped with Rust instead or those in the system. | |
207 | It takes one of the following values: | |
208 | ||
209 | * no value: rustc will use heuristic to disable self-contained mode if system has necessary tools. | |
210 | * `y`, `yes`, `on`: use only libraries/objects shipped with Rust. | |
211 | * `n`, `no`, or `off`: rely on the user or the linker to provide non-Rust libraries/objects. | |
212 | ||
213 | This allows overriding cases when detection fails or user wants to use shipped libraries. | |
214 | ||
f9f354fc XL |
215 | ## linker |
216 | ||
217 | This flag controls which linker `rustc` invokes to link your code. It takes a | |
218 | path to the linker executable. If this flag is not specified, the linker will | |
219 | be inferred based on the target. See also the [linker-flavor](#linker-flavor) | |
220 | flag for another way to specify the linker. | |
221 | ||
0731742a XL |
222 | ## linker-flavor |
223 | ||
ba9703b0 XL |
224 | This flag controls the linker flavor used by `rustc`. If a linker is given with |
225 | the [`-C linker` flag](#linker), then the linker flavor is inferred from the | |
226 | value provided. If no linker is given then the linker flavor is used to | |
227 | determine the linker to use. Every `rustc` target defaults to some linker | |
228 | flavor. Valid options are: | |
229 | ||
230 | * `em`: use [Emscripten `emcc`](https://emscripten.org/docs/tools_reference/emcc.html). | |
231 | * `gcc`: use the `cc` executable, which is typically gcc or clang on many systems. | |
232 | * `ld`: use the `ld` executable. | |
233 | * `msvc`: use the `link.exe` executable from Microsoft Visual Studio MSVC. | |
234 | * `ptx-linker`: use | |
60c5eb7d XL |
235 | [`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker) for Nvidia |
236 | NVPTX GPGPU support. | |
ba9703b0 | 237 | * `wasm-ld`: use the [`wasm-ld`](https://lld.llvm.org/WebAssembly.html) |
60c5eb7d | 238 | executable, a port of LLVM `lld` for WebAssembly. |
ba9703b0 | 239 | * `ld64.lld`: use the LLVM `lld` executable with the [`-flavor darwin` |
60c5eb7d | 240 | flag][lld-flavor] for Apple's `ld`. |
ba9703b0 | 241 | * `ld.lld`: use the LLVM `lld` executable with the [`-flavor gnu` |
60c5eb7d | 242 | flag][lld-flavor] for GNU binutils' `ld`. |
ba9703b0 | 243 | * `lld-link`: use the LLVM `lld` executable with the [`-flavor link` |
60c5eb7d XL |
244 | flag][lld-flavor] for Microsoft's `link.exe`. |
245 | ||
246 | [lld-flavor]: https://lld.llvm.org/Driver.html | |
0731742a | 247 | |
f9f354fc | 248 | ## linker-plugin-lto |
83c7162d | 249 | |
f9f354fc XL |
250 | This flag defers LTO optimizations to the linker. See |
251 | [linker-plugin-LTO](../linker-plugin-lto.md) for more details. It takes one of | |
ba9703b0 XL |
252 | the following values: |
253 | ||
f9f354fc XL |
254 | * `y`, `yes`, `on`, or no value: enable linker plugin LTO. |
255 | * `n`, `no`, or `off`: disable linker plugin LTO (the default). | |
256 | * A path to the linker plugin. | |
83c7162d | 257 | |
f9f354fc XL |
258 | More specifically this flag will cause the compiler to replace its typical |
259 | object file output with LLVM bitcode files. For example an rlib produced with | |
260 | `-Clinker-plugin-lto` will still have `*.o` files in it, but they'll all be LLVM | |
261 | bitcode instead of actual machine code. It is expected that the native platform | |
262 | linker is capable of loading these LLVM bitcode files and generating code at | |
263 | link time (typically after performing optimizations). | |
264 | ||
265 | Note that rustc can also read its own object files produced with | |
266 | `-Clinker-plugin-lto`. If an rlib is only ever going to get used later with a | |
267 | `-Clto` compilation then you can pass `-Clinker-plugin-lto` to speed up | |
268 | compilation and avoid generating object files that aren't used. | |
269 | ||
270 | ## llvm-args | |
271 | ||
272 | This flag can be used to pass a list of arguments directly to LLVM. | |
273 | ||
274 | The list must be separated by spaces. | |
275 | ||
276 | Pass `--help` to see a list of options. | |
83c7162d XL |
277 | |
278 | ## lto | |
279 | ||
ba9703b0 | 280 | This flag controls whether LLVM uses [link time |
60c5eb7d XL |
281 | optimizations](https://llvm.org/docs/LinkTimeOptimization.html) to produce |
282 | better optimized code, using whole-program analysis, at the cost of longer | |
ba9703b0 | 283 | linking time. It takes one of the following values: |
83c7162d | 284 | |
ba9703b0 | 285 | * `y`, `yes`, `on`, `fat`, or no value: perform "fat" LTO which attempts to |
60c5eb7d | 286 | perform optimizations across all crates within the dependency graph. |
ba9703b0 XL |
287 | * `n`, `no`, `off`: disables LTO. |
288 | * `thin`: perform ["thin" | |
60c5eb7d XL |
289 | LTO](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html). |
290 | This is similar to "fat", but takes substantially less time to run while | |
291 | still achieving performance gains similar to "fat". | |
292 | ||
293 | If `-C lto` is not specified, then the compiler will attempt to perform "thin | |
294 | local LTO" which performs "thin" LTO on the local crate only across its | |
295 | [codegen units](#codegen-units). When `-C lto` is not specified, LTO is | |
296 | disabled if codegen units is 1 or optimizations are disabled ([`-C | |
297 | opt-level=0`](#opt-level)). That is: | |
298 | ||
299 | * When `-C lto` is not specified: | |
ba9703b0 XL |
300 | * `codegen-units=1`: disable LTO. |
301 | * `opt-level=0`: disable LTO. | |
60c5eb7d | 302 | * When `-C lto=true`: |
ba9703b0 | 303 | * `lto=true`: 16 codegen units, perform fat LTO across crates. |
60c5eb7d XL |
304 | * `codegen-units=1` + `lto=true`: 1 codegen unit, fat LTO across crates. |
305 | ||
306 | See also [linker-plugin-lto](#linker-plugin-lto) for cross-language LTO. | |
307 | ||
f9f354fc | 308 | ## metadata |
83c7162d | 309 | |
f9f354fc XL |
310 | This option allows you to control the metadata used for symbol mangling. This |
311 | takes a space-separated list of strings. Mangled symbols will incorporate a | |
312 | hash of the metadata. This may be used, for example, to differentiate symbols | |
313 | between two different versions of the same crate being linked. | |
60c5eb7d | 314 | |
f9f354fc | 315 | ## no-prepopulate-passes |
60c5eb7d | 316 | |
f9f354fc XL |
317 | This flag tells the pass manager to use an empty list of passes, instead of the |
318 | usual pre-populated list of passes. | |
60c5eb7d | 319 | |
f9f354fc | 320 | ## no-redzone |
e74abb32 | 321 | |
f9f354fc XL |
322 | This flag allows you to disable [the |
323 | red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). It takes one | |
324 | of the following values: | |
83c7162d | 325 | |
f9f354fc XL |
326 | * `y`, `yes`, `on`, or no value: disable the red zone. |
327 | * `n`, `no`, or `off`: enable the red zone. | |
83c7162d | 328 | |
f9f354fc | 329 | The default behaviour, if the flag is not specified, depends on the target. |
83c7162d | 330 | |
f9f354fc | 331 | ## no-stack-check |
60c5eb7d | 332 | |
f9f354fc | 333 | This option is deprecated and does nothing. |
83c7162d | 334 | |
f9f354fc | 335 | ## no-vectorize-loops |
83c7162d | 336 | |
f9f354fc XL |
337 | This flag disables [loop |
338 | vectorization](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer). | |
83c7162d | 339 | |
f9f354fc | 340 | ## no-vectorize-slp |
60c5eb7d | 341 | |
f9f354fc XL |
342 | This flag disables vectorization using |
343 | [superword-level | |
344 | parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer). | |
83c7162d | 345 | |
f9f354fc | 346 | ## opt-level |
ba9703b0 | 347 | |
f9f354fc | 348 | This flag controls the optimization level. |
83c7162d | 349 | |
f9f354fc XL |
350 | * `0`: no optimizations, also turns on |
351 | [`cfg(debug_assertions)`](#debug-assertions) (the default). | |
352 | * `1`: basic optimizations. | |
353 | * `2`: some optimizations. | |
354 | * `3`: all optimizations. | |
355 | * `s`: optimize for binary size. | |
356 | * `z`: optimize for binary size, but also turn off loop vectorization. | |
83c7162d | 357 | |
f9f354fc | 358 | Note: The [`-O` flag][option-o-optimize] is an alias for `-C opt-level=2`. |
ba9703b0 | 359 | |
f9f354fc | 360 | The default is `0`. |
83c7162d XL |
361 | |
362 | ## overflow-checks | |
363 | ||
60c5eb7d XL |
364 | This flag allows you to control the behavior of [runtime integer |
365 | overflow](../../reference/expressions/operator-expr.md#overflow). When | |
366 | overflow-checks are enabled, a panic will occur on overflow. This flag takes | |
367 | one of the following values: | |
83c7162d | 368 | |
ba9703b0 XL |
369 | * `y`, `yes`, `on`, or no value: enable overflow checks. |
370 | * `n`, `no`, or `off`: disable overflow checks. | |
60c5eb7d XL |
371 | |
372 | If not specified, overflow checks are enabled if | |
373 | [debug-assertions](#debug-assertions) are enabled, disabled otherwise. | |
83c7162d | 374 | |
f9f354fc | 375 | ## panic |
83c7162d | 376 | |
f9f354fc | 377 | This option lets you control what happens when the code panics. |
83c7162d | 378 | |
f9f354fc XL |
379 | * `abort`: terminate the process upon panic |
380 | * `unwind`: unwind the stack upon panic | |
83c7162d | 381 | |
f9f354fc | 382 | If not specified, the default depends on the target. |
83c7162d | 383 | |
f9f354fc | 384 | ## passes |
83c7162d | 385 | |
f9f354fc XL |
386 | This flag can be used to add extra [LLVM |
387 | passes](http://llvm.org/docs/Passes.html) to the compilation. | |
83c7162d | 388 | |
f9f354fc | 389 | The list must be separated by spaces. |
ba9703b0 | 390 | |
f9f354fc | 391 | See also the [`no-prepopulate-passes`](#no-prepopulate-passes) flag. |
83c7162d XL |
392 | |
393 | ## prefer-dynamic | |
394 | ||
395 | By default, `rustc` prefers to statically link dependencies. This option will | |
60c5eb7d XL |
396 | indicate that dynamic linking should be used if possible if both a static and |
397 | dynamic versions of a library are available. There is an internal algorithm | |
398 | for determining whether or not it is possible to statically or dynamically | |
399 | link with a dependency. For example, `cdylib` crate types may only use static | |
ba9703b0 | 400 | linkage. This flag takes one of the following values: |
83c7162d | 401 | |
ba9703b0 XL |
402 | * `y`, `yes`, `on`, or no value: use dynamic linking. |
403 | * `n`, `no`, or `off`: use static linking (the default). | |
83c7162d | 404 | |
f9f354fc | 405 | ## profile-generate |
83c7162d | 406 | |
f9f354fc XL |
407 | This flag allows for creating instrumented binaries that will collect |
408 | profiling data for use with profile-guided optimization (PGO). The flag takes | |
409 | an optional argument which is the path to a directory into which the | |
410 | instrumented binary will emit the collected data. See the chapter on | |
411 | [profile-guided optimization] for more information. | |
60c5eb7d | 412 | |
f9f354fc | 413 | ## profile-use |
83c7162d | 414 | |
f9f354fc XL |
415 | This flag specifies the profiling data file to be used for profile-guided |
416 | optimization (PGO). The flag takes a mandatory argument which is the path | |
417 | to a valid `.profdata` file. See the chapter on | |
418 | [profile-guided optimization] for more information. | |
83c7162d XL |
419 | |
420 | ## relocation-model | |
421 | ||
f9f354fc XL |
422 | This option controls generation of |
423 | [position-independent code (PIC)](https://en.wikipedia.org/wiki/Position-independent_code). | |
83c7162d | 424 | |
f9f354fc | 425 | Supported values for this option are: |
83c7162d | 426 | |
f9f354fc | 427 | #### Primary relocation models |
83c7162d | 428 | |
f9f354fc | 429 | - `static` - non-relocatable code, machine instructions may use absolute addressing modes. |
83c7162d | 430 | |
f9f354fc XL |
431 | - `pic` - fully relocatable position independent code, |
432 | machine instructions need to use relative addressing modes. \ | |
433 | Equivalent to the "uppercase" `-fPIC` or `-fPIE` options in other compilers, | |
434 | depending on the produced crate types. \ | |
435 | This is the default model for majority of supported targets. | |
83c7162d | 436 | |
f9f354fc | 437 | #### Special relocation models |
83c7162d | 438 | |
f9f354fc XL |
439 | - `dynamic-no-pic` - relocatable external references, non-relocatable code. \ |
440 | Only makes sense on Darwin and is rarely used. \ | |
441 | If StackOverflow tells you to use this as an opt-out of PIC or PIE, don't believe it, | |
442 | use `-C relocation-model=static` instead. | |
443 | - `ropi`, `rwpi` and `ropi-rwpi` - relocatable code and read-only data, relocatable read-write data, | |
444 | and combination of both, respectively. \ | |
445 | Only makes sense for certain embedded ARM targets. | |
446 | - `default` - relocation model default to the current target. \ | |
447 | Only makes sense as an override for some other explicitly specified relocation model | |
448 | previously set on the command line. | |
83c7162d | 449 | |
f9f354fc | 450 | Supported values can also be discovered by running `rustc --print relocation-models`. |
83c7162d | 451 | |
f9f354fc | 452 | #### Linking effects |
83c7162d | 453 | |
f9f354fc | 454 | In addition to codegen effects, `relocation-model` has effects during linking. |
83c7162d | 455 | |
f9f354fc XL |
456 | If the relocation model is `pic` and the current target supports position-independent executables |
457 | (PIE), the linker will be instructed (`-pie`) to produce one. \ | |
458 | If the target doesn't support both position-independent and statically linked executables, | |
459 | then `-C target-feature=+crt-static` "wins" over `-C relocation-model=pic`, | |
460 | and the linker is instructed (`-static`) to produce a statically linked | |
461 | but not position-independent executable. | |
83c7162d XL |
462 | |
463 | ## remark | |
464 | ||
60c5eb7d | 465 | This flag lets you print remarks for optimization passes. |
83c7162d XL |
466 | |
467 | The list of passes should be separated by spaces. | |
468 | ||
469 | `all` will remark on every pass. | |
470 | ||
f9f354fc | 471 | ## rpath |
60c5eb7d | 472 | |
f9f354fc XL |
473 | This flag controls whether [`rpath`](https://en.wikipedia.org/wiki/Rpath) is |
474 | enabled. It takes one of the following values: | |
83c7162d | 475 | |
f9f354fc XL |
476 | * `y`, `yes`, `on`, or no value: enable rpath. |
477 | * `n`, `no`, or `off`: disable rpath (the default). | |
83c7162d | 478 | |
f9f354fc | 479 | ## save-temps |
83c7162d | 480 | |
f9f354fc XL |
481 | This flag controls whether temporary files generated during compilation are |
482 | deleted once compilation finishes. It takes one of the following values: | |
83c7162d | 483 | |
f9f354fc XL |
484 | * `y`, `yes`, `on`, or no value: save temporary files. |
485 | * `n`, `no`, or `off`: delete temporary files (the default). | |
60c5eb7d | 486 | |
f9f354fc | 487 | ## soft-float |
83c7162d | 488 | |
f9f354fc XL |
489 | This option controls whether `rustc` generates code that emulates floating |
490 | point instructions in software. It takes one of the following values: | |
dc9dc135 | 491 | |
f9f354fc XL |
492 | * `y`, `yes`, `on`, or no value: use soft floats. |
493 | * `n`, `no`, or `off`: use hardware floats (the default). | |
dc9dc135 | 494 | |
f9f354fc | 495 | ## target-cpu |
dc9dc135 | 496 | |
f9f354fc | 497 | This instructs `rustc` to generate code specifically for a particular processor. |
dc9dc135 | 498 | |
f9f354fc XL |
499 | You can run `rustc --print target-cpus` to see the valid options to pass |
500 | here. Additionally, `native` can be passed to use the processor of the host | |
501 | machine. Each target has a default base CPU. | |
416331ca | 502 | |
f9f354fc | 503 | ## target-feature |
60c5eb7d | 504 | |
f9f354fc XL |
505 | Individual targets will support different features; this flag lets you control |
506 | enabling or disabling a feature. Each feature should be prefixed with a `+` to | |
507 | enable it or `-` to disable it. | |
60c5eb7d | 508 | |
f9f354fc XL |
509 | Features from multiple `-C target-feature` options are combined. \ |
510 | Multiple features can be specified in a single option by separating them | |
511 | with commas - `-C target-feature=+x,-y`. \ | |
512 | If some feature is specified more than once with both `+` and `-`, | |
513 | then values passed later override values passed earlier. \ | |
514 | For example, `-C target-feature=+x,-y,+z -Ctarget-feature=-x,+y` | |
515 | is equivalent to `-C target-feature=-x,+y,+z`. | |
60c5eb7d | 516 | |
f9f354fc XL |
517 | To see the valid options and an example of use, run `rustc --print |
518 | target-features`. | |
60c5eb7d | 519 | |
f9f354fc XL |
520 | Using this flag is unsafe and might result in [undefined runtime |
521 | behavior](../targets/known-issues.md). | |
60c5eb7d | 522 | |
f9f354fc XL |
523 | See also the [`target_feature` |
524 | attribute](../../reference/attributes/codegen.md#the-target_feature-attribute) | |
525 | for controlling features per-function. | |
60c5eb7d | 526 | |
f9f354fc XL |
527 | This also supports the feature `+crt-static` and `-crt-static` to control |
528 | [static C runtime linkage](../../reference/linkage.html#static-and-dynamic-c-runtimes). | |
60c5eb7d | 529 | |
f9f354fc XL |
530 | Each target and [`target-cpu`](#target-cpu) has a default set of enabled |
531 | features. | |
60c5eb7d | 532 | |
60c5eb7d XL |
533 | [option-emit]: ../command-line-arguments.md#option-emit |
534 | [option-o-optimize]: ../command-line-arguments.md#option-o-optimize | |
416331ca | 535 | [profile-guided optimization]: ../profile-guided-optimization.md |
60c5eb7d | 536 | [option-g-debug]: ../command-line-arguments.md#option-g-debug |