Skip to content

Commit 8ce3f84

Browse files
committed
Auto merge of #70729 - nnethercote:a-big-options-clean-up, r=petrochenkov
A big options clean-up Lots of improvements here. r? @Centril
2 parents 4ca5fd2 + 3e3fd73 commit 8ce3f84

File tree

12 files changed

+339
-379
lines changed

12 files changed

+339
-379
lines changed

src/doc/rustc/src/codegen-options/index.md

+89-83
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ This option is deprecated and does nothing.
99

1010
## linker
1111

12-
This flag lets you control which linker `rustc` invokes to link your code. It
13-
takes a path to the linker executable. If this flag is not specified, the
14-
linker will be inferred based on the target. See also the
15-
[linker-flavor](#linker-flavor) flag for another way to specify the linker.
12+
This flag controls which linker `rustc` invokes to link your code. It takes a
13+
path to the linker executable. If this flag is not specified, the linker will
14+
be inferred based on the target. See also the [linker-flavor](#linker-flavor)
15+
flag for another way to specify the linker.
1616

1717
## link-arg
1818

@@ -27,49 +27,52 @@ options should be separated by spaces.
2727

2828
## linker-flavor
2929

30-
This flag lets you control the linker flavor used by `rustc`. If a linker is given with the
31-
[`-C linker` flag](#linker), then the linker flavor is inferred from the value provided. If no
32-
linker is given then the linker flavor is used to determine the linker to use. Every `rustc` target
33-
defaults to some linker flavor. Valid options are:
34-
35-
* `em`: Uses [Emscripten `emcc`](https://emscripten.org/docs/tools_reference/emcc.html).
36-
* `gcc`: Uses the `cc` executable, which is typically gcc or clang on many systems.
37-
* `ld`: Uses the `ld` executable.
38-
* `msvc`: Uses the `link.exe` executable from Microsoft Visual Studio MSVC.
39-
* `ptx-linker`: Uses
30+
This flag controls the linker flavor used by `rustc`. If a linker is given with
31+
the [`-C linker` flag](#linker), then the linker flavor is inferred from the
32+
value provided. If no linker is given then the linker flavor is used to
33+
determine the linker to use. Every `rustc` target defaults to some linker
34+
flavor. Valid options are:
35+
36+
* `em`: use [Emscripten `emcc`](https://emscripten.org/docs/tools_reference/emcc.html).
37+
* `gcc`: use the `cc` executable, which is typically gcc or clang on many systems.
38+
* `ld`: use the `ld` executable.
39+
* `msvc`: use the `link.exe` executable from Microsoft Visual Studio MSVC.
40+
* `ptx-linker`: use
4041
[`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker) for Nvidia
4142
NVPTX GPGPU support.
42-
* `wasm-ld`: Uses the [`wasm-ld`](https://lld.llvm.org/WebAssembly.html)
43+
* `wasm-ld`: use the [`wasm-ld`](https://lld.llvm.org/WebAssembly.html)
4344
executable, a port of LLVM `lld` for WebAssembly.
44-
* `ld64.lld`: Uses the LLVM `lld` executable with the [`-flavor darwin`
45+
* `ld64.lld`: use the LLVM `lld` executable with the [`-flavor darwin`
4546
flag][lld-flavor] for Apple's `ld`.
46-
* `ld.lld`: Uses the LLVM `lld` executable with the [`-flavor gnu`
47+
* `ld.lld`: use the LLVM `lld` executable with the [`-flavor gnu`
4748
flag][lld-flavor] for GNU binutils' `ld`.
48-
* `lld-link`: Uses the LLVM `lld` executable with the [`-flavor link`
49+
* `lld-link`: use the LLVM `lld` executable with the [`-flavor link`
4950
flag][lld-flavor] for Microsoft's `link.exe`.
5051

5152
[lld-flavor]: https://lld.llvm.org/Driver.html
5253

5354
## link-dead-code
5455

55-
Normally, the linker will remove dead code. This flag disables this behavior.
56+
This flag controls whether the linker will keep dead code. It takes one of
57+
the following values:
58+
59+
* `y`, `yes`, `on`, or no value: keep dead code.
60+
* `n`, `no`, or `off`: remove dead code (the default).
5661

5762
An example of when this flag might be useful is when trying to construct code coverage
5863
metrics.
5964

6065
## lto
6166

62-
This flag instructs LLVM to use [link time
67+
This flag controls whether LLVM uses [link time
6368
optimizations](https://llvm.org/docs/LinkTimeOptimization.html) to produce
6469
better optimized code, using whole-program analysis, at the cost of longer
65-
linking time.
70+
linking time. It takes one of the following values:
6671

67-
This flag may take one of the following values:
68-
69-
* `y`, `yes`, `on`, `fat`, or no value: Performs "fat" LTO which attempts to
72+
* `y`, `yes`, `on`, `fat`, or no value: perform "fat" LTO which attempts to
7073
perform optimizations across all crates within the dependency graph.
71-
* `n`, `no`, `off`: Disables LTO.
72-
* `thin`: Performs ["thin"
74+
* `n`, `no`, `off`: disables LTO.
75+
* `thin`: perform ["thin"
7376
LTO](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html).
7477
This is similar to "fat", but takes substantially less time to run while
7578
still achieving performance gains similar to "fat".
@@ -81,22 +84,22 @@ disabled if codegen units is 1 or optimizations are disabled ([`-C
8184
opt-level=0`](#opt-level)). That is:
8285

8386
* When `-C lto` is not specified:
84-
* `codegen-units=1`: Disables LTO.
85-
* `opt-level=0`: Disables LTO.
87+
* `codegen-units=1`: disable LTO.
88+
* `opt-level=0`: disable LTO.
8689
* When `-C lto=true`:
87-
* `lto=true`: 16 codegen units, performs fat LTO across crates.
90+
* `lto=true`: 16 codegen units, perform fat LTO across crates.
8891
* `codegen-units=1` + `lto=true`: 1 codegen unit, fat LTO across crates.
8992

9093
See also [linker-plugin-lto](#linker-plugin-lto) for cross-language LTO.
9194

9295
## linker-plugin-lto
9396

94-
Defers LTO optimizations to the linker. See
95-
[linkger-plugin-LTO](../linker-plugin-lto.md) for more details. Takes one of
97+
This flag defers LTO optimizations to the linker. See
98+
[linker-plugin-LTO](../linker-plugin-lto.md) for more details. It takes one of
9699
the following values:
97100

98-
* `y`, `yes`, `on`, or no value: Enabled.
99-
* `n`, `no`, or `off`: Disabled (default).
101+
* `y`, `yes`, `on`, or no value: enable linker plugin LTO.
102+
* `n`, `no`, or `off`: disable linker plugin LTO (the default).
100103
* A path to the linker plugin.
101104

102105
## target-cpu
@@ -148,14 +151,19 @@ Pass `--help` to see a list of options.
148151

149152
## save-temps
150153

151-
`rustc` will generate temporary files during compilation; normally it will
152-
delete them after it's done with its work. This option will cause them to be
153-
preserved instead of removed.
154+
This flag controls whether temporary files generated during compilation are
155+
deleted once compilation finishes. It takes one of the following values:
156+
157+
* `y`, `yes`, `on`, or no value: save temporary files.
158+
* `n`, `no`, or `off`: delete temporary files (the default).
154159

155160
## rpath
156161

157-
This option allows you to enable
158-
[`rpath`](https://en.wikipedia.org/wiki/Rpath).
162+
This flag controls whether [`rpath`](https://en.wikipedia.org/wiki/Rpath) is
163+
enabled. It takes one of the following values:
164+
165+
* `y`, `yes`, `on`, or no value: enable rpath.
166+
* `n`, `no`, or `off`: disable rpath (the default).
159167

160168
## overflow-checks
161169

@@ -164,35 +172,35 @@ overflow](../../reference/expressions/operator-expr.md#overflow). When
164172
overflow-checks are enabled, a panic will occur on overflow. This flag takes
165173
one of the following values:
166174

167-
* `y`, `yes`, `on`, or no value: Enable overflow checks.
168-
* `n`, `no`, or `off`: Disable overflow checks.
175+
* `y`, `yes`, `on`, or no value: enable overflow checks.
176+
* `n`, `no`, or `off`: disable overflow checks.
169177

170178
If not specified, overflow checks are enabled if
171179
[debug-assertions](#debug-assertions) are enabled, disabled otherwise.
172180

173181
## no-prepopulate-passes
174182

175-
The pass manager comes pre-populated with a list of passes; this flag
176-
ensures that list is empty.
183+
This flag tells the pass manager to use an empty list of passes, instead of the
184+
usual pre-populated list of passes.
177185

178186
## no-vectorize-loops
179187

180-
By default, `rustc` will attempt to [vectorize
181-
loops](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer). This
182-
flag will turn that behavior off.
188+
This flag disables [loop
189+
vectorization](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer).
183190

184191
## no-vectorize-slp
185192

186-
By default, `rustc` will attempt to vectorize code using [superword-level
187-
parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer). This
188-
flag will turn that behavior off.
193+
This flag disables vectorization using
194+
[superword-level
195+
parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer).
189196

190197
## soft-float
191198

192-
This option will make `rustc` generate code using "soft floats." By default,
193-
a lot of hardware supports floating point instructions, and so the code generated
194-
will take advantage of this. "soft floats" emulate floating point instructions
195-
in software.
199+
This option controls whether `rustc` generates code that emulates floating
200+
point instructions in software. It takes one of the following values:
201+
202+
* `y`, `yes`, `on`, or no value: use soft floats.
203+
* `n`, `no`, or `off`: use hardware floats (the default).
196204

197205
## prefer-dynamic
198206

@@ -201,24 +209,21 @@ indicate that dynamic linking should be used if possible if both a static and
201209
dynamic versions of a library are available. There is an internal algorithm
202210
for determining whether or not it is possible to statically or dynamically
203211
link with a dependency. For example, `cdylib` crate types may only use static
204-
linkage.
212+
linkage. This flag takes one of the following values:
205213

206-
## no-integrated-as
207-
208-
`rustc` normally uses the LLVM internal assembler to create object code. This
209-
flag will disable the internal assembler and emit assembly code to be
210-
translated using an external assembler, currently the linker such as `cc`.
214+
* `y`, `yes`, `on`, or no value: use dynamic linking.
215+
* `n`, `no`, or `off`: use static linking (the default).
211216

212217
## no-redzone
213218

214219
This flag allows you to disable [the
215-
red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). This flag can
216-
be passed one of the following options:
220+
red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). It takes one
221+
of the following values:
217222

218-
* `y`, `yes`, `on`, or no value: Disables the red zone.
219-
* `n`, `no`, or `off`: Enables the red zone.
223+
* `y`, `yes`, `on`, or no value: disable the red zone.
224+
* `n`, `no`, or `off`: enable the red zone.
220225

221-
The default if not specified depends on the target.
226+
The default behaviour, if the flag is not specified, depends on the target.
222227

223228
## relocation-model
224229

@@ -257,7 +262,7 @@ them in parallel. Increasing parallelism may speed up compile times, but may
257262
also produce slower code. Setting this to 1 may improve the performance of
258263
generated code, but may be slower to compile.
259264

260-
The default, if not specified, is 16 for non-incremental builds. For
265+
The default value, if not specified, is 16 for non-incremental builds. For
261266
incremental builds the default is 256 which allows caching to be more granular.
262267

263268
## remark
@@ -274,23 +279,25 @@ This option is deprecated and does nothing.
274279

275280
## debuginfo
276281

277-
This flag lets you control debug information:
282+
This flag controls the generation of debug information. It takes one of the
283+
following values:
278284

279-
* `0`: no debug info at all (default)
280-
* `1`: line tables only
281-
* `2`: full debug info
285+
* `0`: no debug info at all (the default).
286+
* `1`: line tables only.
287+
* `2`: full debug info.
282288

283289
Note: The [`-g` flag][option-g-debug] is an alias for `-C debuginfo=2`.
284290

285291
## opt-level
286292

287-
This flag lets you control the optimization level.
293+
This flag controls the optimization level.
288294

289-
* `0`: no optimizations, also turns on [`cfg(debug_assertions)`](#debug-assertions).
290-
* `1`: basic optimizations
291-
* `2`: some optimizations
292-
* `3`: all optimizations
293-
* `s`: optimize for binary size
295+
* `0`: no optimizations, also turns on
296+
[`cfg(debug_assertions)`](#debug-assertions) (the default).
297+
* `1`: basic optimizations.
298+
* `2`: some optimizations.
299+
* `3`: all optimizations.
300+
* `s`: optimize for binary size.
294301
* `z`: optimize for binary size, but also turn off loop vectorization.
295302

296303
Note: The [`-O` flag][option-o-optimize] is an alias for `-C opt-level=2`.
@@ -303,8 +310,8 @@ This flag lets you turn `cfg(debug_assertions)` [conditional
303310
compilation](../../reference/conditional-compilation.md#debug_assertions) on
304311
or off. It takes one of the following values:
305312

306-
* `y`, `yes`, `on`, or no value: Enable debug-assertions.
307-
* `n`, `no`, or `off`: Disable debug-assertions.
313+
* `y`, `yes`, `on`, or no value: enable debug-assertions.
314+
* `n`, `no`, or `off`: disable debug-assertions.
308315

309316
If not specified, debug assertions are automatically enabled only if the
310317
[opt-level](#opt-level) is 0.
@@ -362,25 +369,24 @@ to a valid `.profdata` file. See the chapter on
362369
This flag forces the use of frame pointers. It takes one of the following
363370
values:
364371

365-
* `y`, `yes`, `on`, or no value: Frame pointers are forced to be enabled.
366-
* `n`, `no`, or `off`: Frame pointers are not forced to be enabled. This does
372+
* `y`, `yes`, `on`, or no value: force-enable frame pointers.
373+
* `n`, `no`, or `off`: do not force-enable frame pointers. This does
367374
not necessarily mean frame pointers will be removed.
368375

369-
The default if not specified depends on the target.
376+
The default behaviour, if frame pointers are not force-enabled, depends on the
377+
target.
370378

371379
## default-linker-libraries
372380

373381
This flag controls whether or not the linker includes its default libraries.
374382
It takes one of the following values:
375383

376-
* `y`, `yes`, `on`, or no value: Default libraries are included.
377-
* `n`, `no`, or `off`: Default libraries are **not** included.
384+
* `y`, `yes`, `on`, or no value: include default libraries (the default).
385+
* `n`, `no`, or `off`: exclude default libraries.
378386

379387
For example, for gcc flavor linkers, this issues the `-nodefaultlibs` flag to
380388
the linker.
381389

382-
The default is `yes` if not specified.
383-
384390
[option-emit]: ../command-line-arguments.md#option-emit
385391
[option-o-optimize]: ../command-line-arguments.md#option-o-optimize
386392
[profile-guided optimization]: ../profile-guided-optimization.md

src/librustc_codegen_llvm/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub(crate) fn should_use_new_llvm_pass_manager(config: &ModuleConfig) -> bool {
347347
}
348348

349349
// The new pass manager is disabled by default.
350-
config.new_llvm_pass_manager.unwrap_or(false)
350+
config.new_llvm_pass_manager
351351
}
352352

353353
pub(crate) unsafe fn optimize_with_new_llvm_pass_manager(

src/librustc_codegen_ssa/back/link.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -858,18 +858,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
858858
// *not* running dsymutil then the object files are the only source of truth
859859
// for debug information, so we must preserve them.
860860
if sess.target.target.options.is_like_osx {
861-
match sess.opts.debugging_opts.run_dsymutil {
862-
// dsymutil is not being run, preserve objects
863-
Some(false) => return true,
864-
865-
// dsymutil is being run, no need to preserve the objects
866-
Some(true) => return false,
867-
868-
// The default historical behavior was to always run dsymutil, so
869-
// we're preserving that temporarily, but we're likely to switch the
870-
// default soon.
871-
None => return false,
872-
}
861+
return !sess.opts.debugging_opts.run_dsymutil;
873862
}
874863

875864
false
@@ -1324,11 +1313,11 @@ fn link_local_crate_native_libs_and_dependent_crate_libs<'a, B: ArchiveBuilder<'
13241313
// If -Zlink-native-libraries=false is set, then the assumption is that an
13251314
// external build system already has the native dependencies defined, and it
13261315
// will provide them to the linker itself.
1327-
if sess.opts.debugging_opts.link_native_libraries.unwrap_or(true) {
1316+
if sess.opts.debugging_opts.link_native_libraries {
13281317
add_local_native_libraries(cmd, sess, codegen_results);
13291318
}
13301319
add_upstream_rust_crates::<B>(cmd, sess, codegen_results, crate_type, tmpdir);
1331-
if sess.opts.debugging_opts.link_native_libraries.unwrap_or(true) {
1320+
if sess.opts.debugging_opts.link_native_libraries {
13321321
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
13331322
}
13341323
}
@@ -1534,9 +1523,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
15341523
// OBJECT-FILES-NO, AUDIT-ORDER
15351524
// We want to prevent the compiler from accidentally leaking in any system libraries,
15361525
// so by default we tell linkers not to link to any default libraries.
1537-
if !sess.opts.cg.default_linker_libraries.unwrap_or(false)
1538-
&& sess.target.target.options.no_default_libraries
1539-
{
1526+
if !sess.opts.cg.default_linker_libraries && sess.target.target.options.no_default_libraries {
15401527
cmd.no_default_libraries();
15411528
}
15421529

src/librustc_codegen_ssa/back/linker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'a> Linker for GccLinker<'a> {
384384
// If we are building without debuginfo enabled and we were called with
385385
// `-Zstrip-debuginfo-if-disabled=yes`, tell the linker to strip any debuginfo
386386
// found when linking to get rid of symbols from libstd.
387-
if let Some(true) = self.sess.opts.debugging_opts.strip_debuginfo_if_disabled {
387+
if self.sess.opts.debugging_opts.strip_debuginfo_if_disabled {
388388
self.linker_arg("-S");
389389
}
390390
};

src/librustc_codegen_ssa/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub struct ModuleConfig {
115115
pub vectorize_slp: bool,
116116
pub merge_functions: bool,
117117
pub inline_threshold: Option<usize>,
118-
pub new_llvm_pass_manager: Option<bool>,
118+
pub new_llvm_pass_manager: bool,
119119
}
120120

121121
impl ModuleConfig {

0 commit comments

Comments
 (0)