Skip to content

Commit 3e3fd73

Browse files
committed
Disallow values for -C no-* and -Z no-* options again.
With the exception of `-C no-redzone`, because that could take a value before this PR. This partially undoes one of the earlier commits in this PR, which added the ability to take a value to all boolean options that lacked it. The help output for these options looks like this: ``` -C no-vectorize-slp=val -- disable LLVM's SLP vectorization pass ``` The "=val" part is a lie, but hopefully this will be fixed in the future.
1 parent dc06539 commit 3e3fd73

File tree

2 files changed

+40
-41
lines changed

2 files changed

+40
-41
lines changed

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

+6-17
Original file line numberDiff line numberDiff line change
@@ -180,30 +180,19 @@ If not specified, overflow checks are enabled if
180180

181181
## no-prepopulate-passes
182182

183-
This flag controls whether the pass manager uses a pre-populated list of
184-
passes. It takes one of the following values:
185-
186-
* `y`, `yes`, `on`, or no value: use an empty list of passes.
187-
* `n`, `no`, or `off`: use a pre-populated list of passes (the default).
183+
This flag tells the pass manager to use an empty list of passes, instead of the
184+
usual pre-populated list of passes.
188185

189186
## no-vectorize-loops
190187

191-
This flag controls whether `rustc` will attempt to [vectorize
192-
loops](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer). It takes
193-
one of the following values:
194-
195-
* `y`, `yes`, `on`, or no value: disable loop vectorization.
196-
* `n`, `no`, or `off`: enable loop vectorization (the default).
188+
This flag disables [loop
189+
vectorization](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer).
197190

198191
## no-vectorize-slp
199192

200-
This flag controls whether `rustc` will attempt to vectorize code using
193+
This flag disables vectorization using
201194
[superword-level
202195
parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer).
203-
It takes one of the following values:
204-
205-
* `y`, `yes`, `on`, or no value: disable SLP vectorization.
206-
* `n`, `no`, or `off`: enable SLP vectorization (the default).
207196

208197
## soft-float
209198

@@ -309,7 +298,7 @@ This flag controls the optimization level.
309298
* `2`: some optimizations.
310299
* `3`: all optimizations.
311300
* `s`: optimize for binary size.
312-
* `z`: optimize for binary size, but also turn off loop vectorization..
301+
* `z`: optimize for binary size, but also turn off loop vectorization.
313302

314303
Note: The [`-O` flag][option-o-optimize] is an alias for `-C opt-level=2`.
315304

src/librustc_session/options.rs

+34-24
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ macro_rules! options {
231231

232232
#[allow(non_upper_case_globals, dead_code)]
233233
mod $mod_desc {
234+
pub const parse_no_flag: &str = "no value";
234235
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
235236
pub const parse_opt_bool: &str = parse_bool;
236237
pub const parse_string: &str = "a string";
@@ -288,6 +289,15 @@ macro_rules! options {
288289
}
289290
)*
290291

292+
/// This is for boolean options that don't take a value and start with
293+
/// `no-`. This style of option is deprecated.
294+
fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
295+
match v {
296+
None => { *slot = true; true }
297+
Some(_) => false,
298+
}
299+
}
300+
291301
/// Use this for any boolean option that has a static default.
292302
fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
293303
match v {
@@ -640,12 +650,12 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
640650
"set rpath values in libs/exes (default: no)"),
641651
overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
642652
"use overflow checks for integer arithmetic"),
643-
no_prepopulate_passes: bool = (false, parse_bool, [TRACKED],
644-
"give an empty list of passes to the pass manager (default: no)"),
645-
no_vectorize_loops: bool = (false, parse_bool, [TRACKED],
646-
"disable loop vectorization optimization passes (default: no)"),
647-
no_vectorize_slp: bool = (false, parse_bool, [TRACKED],
648-
"disable LLVM's SLP vectorization pass (default: no)"),
653+
no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
654+
"give an empty list of passes to the pass manager"),
655+
no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
656+
"disable loop vectorization optimization passes"),
657+
no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
658+
"disable LLVM's SLP vectorization pass"),
649659
soft_float: bool = (false, parse_bool, [TRACKED],
650660
"use soft float ABI (*eabihf targets only) (default: no)"),
651661
prefer_dynamic: bool = (false, parse_bool, [TRACKED],
@@ -664,7 +674,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
664674
"divide crate into N units to optimize in parallel"),
665675
remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
666676
"print remarks for these optimization passes (space separated, or \"all\")"),
667-
no_stack_check: bool = (false, parse_bool, [UNTRACKED],
677+
no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
668678
"this option is deprecated and does nothing"),
669679
debuginfo: usize = (0, parse_uint, [TRACKED],
670680
"debug info emission level (0 = no debug info, 1 = line tables only, \
@@ -725,8 +735,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
725735
"verify LLVM IR (default: no)"),
726736
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
727737
"gather borrowck statistics (default: no)"),
728-
no_landing_pads: bool = (false, parse_bool, [TRACKED],
729-
"omit landing pads for unwinding (default: no)"),
738+
no_landing_pads: bool = (false, parse_no_flag, [TRACKED],
739+
"omit landing pads for unwinding"),
730740
fewer_names: bool = (false, parse_bool, [TRACKED],
731741
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
732742
(default: no)"),
@@ -758,8 +768,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
758768
"parse only; do not compile, assemble, or link (default: no)"),
759769
dual_proc_macros: bool = (false, parse_bool, [TRACKED],
760770
"load proc macros for both target and host, but only link to the target (default: no)"),
761-
no_codegen: bool = (false, parse_bool, [TRACKED],
762-
"run all passes except codegen; no output (default: no)"),
771+
no_codegen: bool = (false, parse_no_flag, [TRACKED],
772+
"run all passes except codegen; no output"),
763773
treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
764774
"treat error number `val` that occurs as bug"),
765775
report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
@@ -789,8 +799,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
789799
(default: no)"),
790800
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
791801
"enable queries of the dependency graph for regression testing (default: no)"),
792-
no_analysis: bool = (false, parse_bool, [UNTRACKED],
793-
"parse and expand the source, but run no analysis (default: no)"),
802+
no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
803+
"parse and expand the source, but run no analysis"),
794804
unstable_options: bool = (false, parse_bool, [UNTRACKED],
795805
"adds unstable command line options to rustc interface (default: no)"),
796806
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
@@ -799,8 +809,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
799809
"for every macro invocation, print its name and arguments (default: no)"),
800810
debug_macros: bool = (false, parse_bool, [TRACKED],
801811
"emit line numbers debug info inside macros (default: no)"),
802-
no_generate_arange_section: bool = (false, parse_bool, [TRACKED],
803-
"omit DWARF address ranges that give faster lookups (default: no)"),
812+
no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
813+
"omit DWARF address ranges that give faster lookups"),
804814
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
805815
"keep hygiene data after analysis (default: no)"),
806816
show_span: Option<String> = (None, parse_opt_string, [TRACKED],
@@ -862,7 +872,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
862872
"extra arguments to prepend to the linker invocation (space separated)"),
863873
profile: bool = (false, parse_bool, [TRACKED],
864874
"insert profiling code (default: no)"),
865-
no_profiler_runtime: bool = (false, parse_bool, [TRACKED],
875+
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
866876
"prevent automatic injection of the profiler_builtins crate"),
867877
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
868878
"choose which RELRO level to use"),
@@ -911,12 +921,12 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
911921
(default: no)"),
912922
share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
913923
"make the current crate share its generic instantiations"),
914-
no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED],
915-
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO) (default: no)"),
916-
no_leak_check: bool = (false, parse_bool, [UNTRACKED],
917-
"disable the 'leak check' for subtyping; unsound, but useful for tests (default: no)"),
918-
no_interleave_lints: bool = (false, parse_bool, [UNTRACKED],
919-
"execute lints separately; allows benchmarking individual lints (default: no)"),
924+
no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
925+
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
926+
no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
927+
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
928+
no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
929+
"execute lints separately; allows benchmarking individual lints"),
920930
crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
921931
"inject the given attribute in the crate"),
922932
self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
@@ -953,8 +963,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
953963
"deduplicate identical diagnostics (default: yes)"),
954964
control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [UNTRACKED],
955965
"use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)"),
956-
no_link: bool = (false, parse_bool, [TRACKED],
957-
"compile without linking (default: no)"),
966+
no_link: bool = (false, parse_no_flag, [TRACKED],
967+
"compile without linking"),
958968
link_only: bool = (false, parse_bool, [TRACKED],
959969
"link the `.rlink` file generated by `-Z no-link` (default: no)"),
960970
new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED],

0 commit comments

Comments
 (0)