Skip to content

Commit cb6a199

Browse files
committed
add codegen options section
1 parent 142c52f commit cb6a199

File tree

1 file changed

+208
-0
lines changed
  • src/doc/rustc/src/codegen-options

1 file changed

+208
-0
lines changed
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,209 @@
11
# 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+
10+
## linker
11+
12+
This flag lets you control which linker `rustc` invokes to link your code.
13+
14+
## link-arg=val
15+
16+
This flag lets you append a single extra argument to the linker invocation.
17+
18+
"Append" is significant; you can pass this flag multiple times to add multiple arguments.
19+
20+
## link-args
21+
22+
This flag lets you append multiple extra arguments to the linker invocation. The
23+
options should be separated by spaces.
24+
25+
## link-dead-code
26+
27+
Normally, the linker will remove dead code. This flag disables this behavior.
28+
29+
An example of when this flag might be useful is when trying to construct code coverage
30+
metrics.
31+
32+
## lto
33+
34+
This flag instructs LLVM to use [link time
35+
optimizations](https://llvm.org/docs/LinkTimeOptimization.html).
36+
37+
It takes one of two values, `thin` and `fat`. 'thin' LTO [is a new feature of
38+
LLVM](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html),
39+
'fat' referring to the classic version of LTO.
40+
41+
## target-cpu
42+
43+
This instructs `rustc` to generate code specifically for a particular processor.
44+
45+
You can run `rustc --print target-cpus` to see the valid options to pass
46+
here. Additionally, `native` can be passed to use the processor of the host
47+
machine.
48+
49+
## target-feature
50+
51+
Individual targets will support different features; this flag lets you control
52+
enabling or disabling a feature.
53+
54+
To see the valid options and an example of use, run `rustc --print
55+
target-features`.
56+
57+
## passes
58+
59+
This flag can be used to add extra LLVM passes to the compilation.
60+
61+
The list must be separated by spaces.
62+
63+
## llvm-args
64+
65+
This flag can be used to pass a list of arguments directly to LLVM.
66+
67+
The list must be separated by spaces.
68+
69+
## save-temps
70+
71+
`rustc` will generate temporary files during compilation; normally it will
72+
delete them after it's done with its work. This option will cause them to be
73+
preserved instead of removed.
74+
75+
## rpath
76+
77+
This option allows you to set the value of
78+
[`rpath`](https://en.wikipedia.org/wiki/Rpath).
79+
80+
## overflow-checks
81+
82+
This flag allows you to control the behavior of integer overflow. This flag
83+
can be passed many options:
84+
85+
* To turn overflow checks on: `y`, `yes`, or `on`.
86+
* To turn overflow checks off: `n`, `no`, or `off`.
87+
88+
## no-prepopulate-passes
89+
90+
The pass manager comes pre-populated with a list of passes; this flag
91+
ensures that list is empty.
92+
93+
## no-vectorize-loops
94+
95+
By default, `rustc` will attempt to [vectorize
96+
loops](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer). This
97+
flag will turn that behavior off.
98+
99+
## no-vectorize-slp
100+
101+
By default, `rustc` will attempt to vectorize loops using [superword-level
102+
parallism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer). This
103+
flag will turn that behavior off.
104+
105+
## soft-float
106+
107+
This option will make `rustc` generate code using "soft floats." By default,
108+
a lot of hardware supports floating point instructions, and so the code generated
109+
will take advantage of this. "soft floats" emulate floating point instructions
110+
in software.
111+
112+
## prefer-dynamic
113+
114+
By default, `rustc` prefers to statically link dependencies. This option will
115+
make it use dynamic linking instead.
116+
117+
## no-integrated-as
118+
119+
LLVM comes with an internal assembler; this option will let you use an
120+
external assembler instead.
121+
122+
## no-redzone
123+
124+
This flag allows you to disable [the
125+
red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). This flag can
126+
be passed many options:
127+
128+
* To enable the red zone: `y`, `yes`, or `on`.
129+
* To disable it: `n`, `no`, or `off`.
130+
131+
## relocation-model
132+
133+
This option lets you choose which relocation model to use.
134+
135+
To find the valid options for this flag, run `rustc --print relocation-models`.
136+
137+
## code-model=val
138+
139+
This option lets you choose which code model to use.
140+
141+
To find the valid options for this flag, run `rustc --print code-models`.
142+
143+
## metadata
144+
145+
This option allows you to control the metadata used for symbol mangling.
146+
147+
## extra-filename
148+
149+
This option allows you to put extra data in each output filename.
150+
151+
## codegen-units
152+
153+
This flag lets you control how many threads are used when doing
154+
code generation.
155+
156+
Increasing paralellism may speed up compile times, but may also
157+
produce slower code.
158+
159+
## remark
160+
161+
This flag lets you print remarks for these optimization passes.
162+
163+
The list of passes should be separated by spaces.
164+
165+
`all` will remark on every pass.
166+
167+
## no-stack-check
168+
169+
This option is deprecated and does nothing.
170+
171+
## debuginfo
172+
173+
This flag lets you control debug information:
174+
175+
* `0`: no debug info at all
176+
* `1`: line tables only
177+
* `2`: full debug info
178+
179+
## opt-level
180+
181+
This flag lets you control the optimization level.
182+
183+
* `0`: no optimizations
184+
* `1`: basic optimizations
185+
* `2`: some optimizations
186+
* `3`: all optimizations
187+
* `s`: optimize for binary size
188+
* `z`: optimize for binary size, but also turn off loop vectorization.
189+
190+
## debug-assertions
191+
192+
This flag lets you turn `cfg(debug_assertions)` on or off.
193+
194+
## inline-threshold
195+
196+
This option lets you set the threshold for inlining a function.
197+
198+
The default is 225.
199+
200+
## panic
201+
202+
This option lets you control what happens when the code panics.
203+
204+
* `abort`: terminate the process upon panic
205+
* `unwind`: unwind the stack upon panic
206+
207+
## incremental
208+
209+
This flag allows you to enable incremental compilation.

0 commit comments

Comments
 (0)