]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_session/src/options.rs
Rollup merge of #99423 - GuillaumeGomez:group-css-font-rule, r=notriddle
[rust.git] / compiler / rustc_session / src / options.rs
1 use crate::config::*;
2
3 use crate::early_error;
4 use crate::lint;
5 use crate::search_paths::SearchPath;
6 use crate::utils::NativeLib;
7 use rustc_errors::LanguageIdentifier;
8 use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy, SanitizerSet};
9 use rustc_target::spec::{
10     RelocModel, RelroLevel, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
11 };
12
13 use rustc_feature::UnstableFeatures;
14 use rustc_span::edition::Edition;
15 use rustc_span::RealFileName;
16 use rustc_span::SourceFileHashAlgorithm;
17
18 use std::collections::BTreeMap;
19
20 use std::collections::hash_map::DefaultHasher;
21 use std::hash::Hasher;
22 use std::num::NonZeroUsize;
23 use std::path::PathBuf;
24 use std::str;
25
26 macro_rules! insert {
27     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => {
28         if $sub_hashes
29             .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
30             .is_some()
31         {
32             panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
33         }
34     };
35 }
36
37 macro_rules! hash_opt {
38     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [UNTRACKED]) => {{}};
39     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [TRACKED]) => {{ insert!($opt_name, $opt_expr, $sub_hashes) }};
40     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $for_crate_hash: ident, [TRACKED_NO_CRATE_HASH]) => {{
41         if !$for_crate_hash {
42             insert!($opt_name, $opt_expr, $sub_hashes)
43         }
44     }};
45     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [SUBSTRUCT]) => {{}};
46 }
47
48 macro_rules! hash_substruct {
49     ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [UNTRACKED]) => {{}};
50     ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED]) => {{}};
51     ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED_NO_CRATE_HASH]) => {{}};
52     ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [SUBSTRUCT]) => {
53         use crate::config::dep_tracking::DepTrackingHash;
54         $opt_expr.dep_tracking_hash($for_crate_hash, $error_format).hash(
55             $hasher,
56             $error_format,
57             $for_crate_hash,
58         );
59     };
60 }
61
62 macro_rules! top_level_options {
63     ( $( #[$top_level_attr:meta] )* pub struct Options { $(
64         $( #[$attr:meta] )*
65         $opt:ident : $t:ty [$dep_tracking_marker:ident],
66     )* } ) => (
67         #[derive(Clone)]
68         $( #[$top_level_attr] )*
69         pub struct Options {
70             $(
71                 $( #[$attr] )*
72                 pub $opt: $t
73             ),*
74         }
75
76         impl Options {
77             pub fn dep_tracking_hash(&self, for_crate_hash: bool) -> u64 {
78                 let mut sub_hashes = BTreeMap::new();
79                 $({
80                     hash_opt!($opt,
81                                 &self.$opt,
82                                 &mut sub_hashes,
83                                 for_crate_hash,
84                                 [$dep_tracking_marker]);
85                 })*
86                 let mut hasher = DefaultHasher::new();
87                 dep_tracking::stable_hash(sub_hashes,
88                                           &mut hasher,
89                                           self.error_format,
90                                           for_crate_hash);
91                 $({
92                     hash_substruct!($opt,
93                         &self.$opt,
94                         self.error_format,
95                         for_crate_hash,
96                         &mut hasher,
97                         [$dep_tracking_marker]);
98                 })*
99                 hasher.finish()
100             }
101         }
102     );
103 }
104
105 impl Options {
106     pub fn mir_opt_level(&self) -> usize {
107         self.unstable_opts
108             .mir_opt_level
109             .unwrap_or_else(|| if self.optimize != OptLevel::No { 2 } else { 1 })
110     }
111
112     pub fn instrument_coverage(&self) -> bool {
113         self.cg.instrument_coverage.unwrap_or(InstrumentCoverage::Off) != InstrumentCoverage::Off
114     }
115
116     pub fn instrument_coverage_except_unused_generics(&self) -> bool {
117         self.cg.instrument_coverage.unwrap_or(InstrumentCoverage::Off)
118             == InstrumentCoverage::ExceptUnusedGenerics
119     }
120
121     pub fn instrument_coverage_except_unused_functions(&self) -> bool {
122         self.cg.instrument_coverage.unwrap_or(InstrumentCoverage::Off)
123             == InstrumentCoverage::ExceptUnusedFunctions
124     }
125 }
126
127 top_level_options!(
128     /// The top-level command-line options struct.
129     ///
130     /// For each option, one has to specify how it behaves with regard to the
131     /// dependency tracking system of incremental compilation. This is done via the
132     /// square-bracketed directive after the field type. The options are:
133     ///
134     /// - `[TRACKED]`
135     /// A change in the given field will cause the compiler to completely clear the
136     /// incremental compilation cache before proceeding.
137     ///
138     /// - `[TRACKED_NO_CRATE_HASH]`
139     /// Same as `[TRACKED]`, but will not affect the crate hash. This is useful for options that only
140     /// affect the incremental cache.
141     ///
142     /// - `[UNTRACKED]`
143     /// Incremental compilation is not influenced by this option.
144     ///
145     /// - `[SUBSTRUCT]`
146     /// Second-level sub-structs containing more options.
147     ///
148     /// If you add a new option to this struct or one of the sub-structs like
149     /// `CodegenOptions`, think about how it influences incremental compilation. If in
150     /// doubt, specify `[TRACKED]`, which is always "correct" but might lead to
151     /// unnecessary re-compilation.
152     pub struct Options {
153         /// The crate config requested for the session, which may be combined
154         /// with additional crate configurations during the compile process.
155         crate_types: Vec<CrateType> [TRACKED],
156         optimize: OptLevel [TRACKED],
157         /// Include the `debug_assertions` flag in dependency tracking, since it
158         /// can influence whether overflow checks are done or not.
159         debug_assertions: bool [TRACKED],
160         debuginfo: DebugInfo [TRACKED],
161         lint_opts: Vec<(String, lint::Level)> [TRACKED_NO_CRATE_HASH],
162         lint_cap: Option<lint::Level> [TRACKED_NO_CRATE_HASH],
163         describe_lints: bool [UNTRACKED],
164         output_types: OutputTypes [TRACKED],
165         search_paths: Vec<SearchPath> [UNTRACKED],
166         libs: Vec<NativeLib> [TRACKED],
167         maybe_sysroot: Option<PathBuf> [UNTRACKED],
168
169         target_triple: TargetTriple [TRACKED],
170
171         test: bool [TRACKED],
172         error_format: ErrorOutputType [UNTRACKED],
173         diagnostic_width: Option<usize> [UNTRACKED],
174
175         /// If `Some`, enable incremental compilation, using the given
176         /// directory to store intermediate results.
177         incremental: Option<PathBuf> [UNTRACKED],
178         assert_incr_state: Option<IncrementalStateAssertion> [UNTRACKED],
179
180         unstable_opts: UnstableOptions [SUBSTRUCT],
181         prints: Vec<PrintRequest> [UNTRACKED],
182         cg: CodegenOptions [SUBSTRUCT],
183         externs: Externs [UNTRACKED],
184         crate_name: Option<String> [TRACKED],
185         /// Indicates how the compiler should treat unstable features.
186         unstable_features: UnstableFeatures [TRACKED],
187
188         /// Indicates whether this run of the compiler is actually rustdoc. This
189         /// is currently just a hack and will be removed eventually, so please
190         /// try to not rely on this too much.
191         actually_rustdoc: bool [TRACKED],
192
193         /// Control path trimming.
194         trimmed_def_paths: TrimmedDefPaths [TRACKED],
195
196         /// Specifications of codegen units / ThinLTO which are forced as a
197         /// result of parsing command line options. These are not necessarily
198         /// what rustc was invoked with, but massaged a bit to agree with
199         /// commands like `--emit llvm-ir` which they're often incompatible with
200         /// if we otherwise use the defaults of rustc.
201         cli_forced_codegen_units: Option<usize> [UNTRACKED],
202         cli_forced_thinlto_off: bool [UNTRACKED],
203
204         /// Remap source path prefixes in all output (messages, object files, debug, etc.).
205         remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH],
206         /// Base directory containing the `src/` for the Rust standard library, and
207         /// potentially `rustc` as well, if we can can find it. Right now it's always
208         /// `$sysroot/lib/rustlib/src/rust` (i.e. the `rustup` `rust-src` component).
209         ///
210         /// This directory is what the virtual `/rustc/$hash` is translated back to,
211         /// if Rust was built with path remapping to `/rustc/$hash` enabled
212         /// (the `rust.remap-debuginfo` option in `config.toml`).
213         real_rust_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH],
214
215         edition: Edition [TRACKED],
216
217         /// `true` if we're emitting JSON blobs about each artifact produced
218         /// by the compiler.
219         json_artifact_notifications: bool [TRACKED],
220
221         /// `true` if we're emitting a JSON blob containing the unused externs
222         json_unused_externs: JsonUnusedExterns [UNTRACKED],
223
224         /// `true` if we're emitting a JSON job containing a future-incompat report for lints
225         json_future_incompat: bool [TRACKED],
226
227         pretty: Option<PpMode> [UNTRACKED],
228
229         /// The (potentially remapped) working directory
230         working_dir: RealFileName [TRACKED],
231     }
232 );
233
234 /// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
235 /// macro is to define an interface that can be programmatically used by the option parser
236 /// to initialize the struct without hardcoding field names all over the place.
237 ///
238 /// The goal is to invoke this macro once with the correct fields, and then this macro generates all
239 /// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
240 /// generated code to parse an option into its respective field in the struct. There are a few
241 /// hand-written parsers for parsing specific types of values in this module.
242 macro_rules! options {
243     ($struct_name:ident, $stat:ident, $optmod:ident, $prefix:expr, $outputname:expr,
244      $($( #[$attr:meta] )* $opt:ident : $t:ty = (
245         $init:expr,
246         $parse:ident,
247         [$dep_tracking_marker:ident],
248         $desc:expr)
249      ),* ,) =>
250 (
251     #[derive(Clone)]
252     pub struct $struct_name { $(pub $opt: $t),* }
253
254     impl Default for $struct_name {
255         fn default() -> $struct_name {
256             $struct_name { $( $( #[$attr] )* $opt: $init),* }
257         }
258     }
259
260     impl $struct_name {
261         pub fn build(
262             matches: &getopts::Matches,
263             error_format: ErrorOutputType,
264         ) -> $struct_name {
265             build_options(matches, $stat, $prefix, $outputname, error_format)
266         }
267
268         fn dep_tracking_hash(&self, for_crate_hash: bool, error_format: ErrorOutputType) -> u64 {
269             let mut sub_hashes = BTreeMap::new();
270             $({
271                 hash_opt!($opt,
272                             &self.$opt,
273                             &mut sub_hashes,
274                             for_crate_hash,
275                             [$dep_tracking_marker]);
276             })*
277             let mut hasher = DefaultHasher::new();
278             dep_tracking::stable_hash(sub_hashes,
279                                         &mut hasher,
280                                         error_format,
281                                         for_crate_hash
282                                         );
283             hasher.finish()
284         }
285     }
286
287     pub const $stat: OptionDescrs<$struct_name> =
288         &[ $( (stringify!($opt), $optmod::$opt, desc::$parse, $desc) ),* ];
289
290     mod $optmod {
291     $(
292         pub(super) fn $opt(cg: &mut super::$struct_name, v: Option<&str>) -> bool {
293             super::parse::$parse(&mut redirect_field!(cg.$opt), v)
294         }
295     )*
296     }
297
298 ) }
299
300 // Sometimes different options need to build a common structure.
301 // That structure can be kept in one of the options' fields, the others become dummy.
302 macro_rules! redirect_field {
303     ($cg:ident.link_arg) => {
304         $cg.link_args
305     };
306     ($cg:ident.pre_link_arg) => {
307         $cg.pre_link_args
308     };
309     ($cg:ident.$field:ident) => {
310         $cg.$field
311     };
312 }
313
314 type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
315 type OptionDescrs<O> = &'static [(&'static str, OptionSetter<O>, &'static str, &'static str)];
316
317 fn build_options<O: Default>(
318     matches: &getopts::Matches,
319     descrs: OptionDescrs<O>,
320     prefix: &str,
321     outputname: &str,
322     error_format: ErrorOutputType,
323 ) -> O {
324     let mut op = O::default();
325     for option in matches.opt_strs(prefix) {
326         let (key, value) = match option.split_once('=') {
327             None => (option, None),
328             Some((k, v)) => (k.to_string(), Some(v)),
329         };
330
331         let option_to_lookup = key.replace('-', "_");
332         match descrs.iter().find(|(name, ..)| *name == option_to_lookup) {
333             Some((_, setter, type_desc, _)) => {
334                 if !setter(&mut op, value) {
335                     match value {
336                         None => early_error(
337                             error_format,
338                             &format!(
339                                 "{0} option `{1}` requires {2} ({3} {1}=<value>)",
340                                 outputname, key, type_desc, prefix
341                             ),
342                         ),
343                         Some(value) => early_error(
344                             error_format,
345                             &format!(
346                                 "incorrect value `{value}` for {outputname} option `{key}` - {type_desc} was expected"
347                             ),
348                         ),
349                     }
350                 }
351             }
352             None => early_error(error_format, &format!("unknown {outputname} option: `{key}`")),
353         }
354     }
355     return op;
356 }
357
358 #[allow(non_upper_case_globals)]
359 mod desc {
360     pub const parse_no_flag: &str = "no value";
361     pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
362     pub const parse_opt_bool: &str = parse_bool;
363     pub const parse_string: &str = "a string";
364     pub const parse_opt_string: &str = parse_string;
365     pub const parse_string_push: &str = parse_string;
366     pub const parse_opt_langid: &str = "a language identifier";
367     pub const parse_opt_pathbuf: &str = "a path";
368     pub const parse_list: &str = "a space-separated list of strings";
369     pub const parse_list_with_polarity: &str =
370         "a comma-separated list of strings, with elements beginning with + or -";
371     pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
372     pub const parse_number: &str = "a number";
373     pub const parse_opt_number: &str = parse_number;
374     pub const parse_threads: &str = parse_number;
375     pub const parse_passes: &str = "a space-separated list of passes, or `all`";
376     pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
377     pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
378     pub const parse_oom_strategy: &str = "either `panic` or `abort`";
379     pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
380     pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `hwaddress`, `leak`, `memory`, `memtag`, or `thread`";
381     pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
382     pub const parse_cfguard: &str =
383         "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
384     pub const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
385     pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
386     pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
387     pub const parse_optimization_fuel: &str = "crate=integer";
388     pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
389     pub const parse_instrument_coverage: &str =
390         "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
391     pub const parse_unpretty: &str = "`string` or `string=string`";
392     pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
393     pub const parse_lto: &str =
394         "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
395     pub const parse_linker_plugin_lto: &str =
396         "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
397     pub const parse_location_detail: &str =
398         "comma separated list of location details to track: `file`, `line`, or `column`";
399     pub const parse_switch_with_opt_path: &str =
400         "an optional path to the profiling data output directory";
401     pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
402     pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
403     pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
404     pub const parse_relocation_model: &str =
405         "one of supported relocation models (`rustc --print relocation-models`)";
406     pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
407     pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
408     pub const parse_target_feature: &str = parse_string;
409     pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
410     pub const parse_split_debuginfo: &str =
411         "one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
412     pub const parse_split_dwarf_kind: &str =
413         "one of supported split dwarf modes (`split` or `single`)";
414     pub const parse_gcc_ld: &str = "one of: no value, `lld`";
415     pub const parse_stack_protector: &str =
416         "one of (`none` (default), `basic`, `strong`, or `all`)";
417     pub const parse_branch_protection: &str =
418         "a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
419 }
420
421 mod parse {
422     pub(crate) use super::*;
423     use std::str::FromStr;
424
425     /// This is for boolean options that don't take a value and start with
426     /// `no-`. This style of option is deprecated.
427     pub(crate) fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
428         match v {
429             None => {
430                 *slot = true;
431                 true
432             }
433             Some(_) => false,
434         }
435     }
436
437     /// Use this for any boolean option that has a static default.
438     pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
439         match v {
440             Some("y") | Some("yes") | Some("on") | None => {
441                 *slot = true;
442                 true
443             }
444             Some("n") | Some("no") | Some("off") => {
445                 *slot = false;
446                 true
447             }
448             _ => false,
449         }
450     }
451
452     /// Use this for any boolean option that lacks a static default. (The
453     /// actions taken when such an option is not specified will depend on
454     /// other factors, such as other options, or target options.)
455     pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
456         match v {
457             Some("y") | Some("yes") | Some("on") | None => {
458                 *slot = Some(true);
459                 true
460             }
461             Some("n") | Some("no") | Some("off") => {
462                 *slot = Some(false);
463                 true
464             }
465             _ => false,
466         }
467     }
468
469     /// Use this for any string option that has a static default.
470     pub(crate) fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
471         match v {
472             Some(s) => {
473                 *slot = s.to_string();
474                 true
475             }
476             None => false,
477         }
478     }
479
480     /// Use this for any string option that lacks a static default.
481     pub(crate) fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
482         match v {
483             Some(s) => {
484                 *slot = Some(s.to_string());
485                 true
486             }
487             None => false,
488         }
489     }
490
491     /// Parse an optional language identifier, e.g. `en-US` or `zh-CN`.
492     pub(crate) fn parse_opt_langid(slot: &mut Option<LanguageIdentifier>, v: Option<&str>) -> bool {
493         match v {
494             Some(s) => {
495                 *slot = rustc_errors::LanguageIdentifier::from_str(s).ok();
496                 true
497             }
498             None => false,
499         }
500     }
501
502     pub(crate) fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
503         match v {
504             Some(s) => {
505                 *slot = Some(PathBuf::from(s));
506                 true
507             }
508             None => false,
509         }
510     }
511
512     pub(crate) fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
513         match v {
514             Some(s) => {
515                 slot.push(s.to_string());
516                 true
517             }
518             None => false,
519         }
520     }
521
522     pub(crate) fn parse_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
523         match v {
524             Some(s) => {
525                 slot.extend(s.split_whitespace().map(|s| s.to_string()));
526                 true
527             }
528             None => false,
529         }
530     }
531
532     pub(crate) fn parse_list_with_polarity(
533         slot: &mut Vec<(String, bool)>,
534         v: Option<&str>,
535     ) -> bool {
536         match v {
537             Some(s) => {
538                 for s in s.split(',') {
539                     let Some(pass_name) = s.strip_prefix(&['+', '-'][..]) else { return false };
540                     slot.push((pass_name.to_string(), &s[..1] == "+"));
541                 }
542                 true
543             }
544             None => false,
545         }
546     }
547
548     pub(crate) fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
549         if let Some(v) = v {
550             ld.line = false;
551             ld.file = false;
552             ld.column = false;
553             for s in v.split(',') {
554                 match s {
555                     "file" => ld.file = true,
556                     "line" => ld.line = true,
557                     "column" => ld.column = true,
558                     _ => return false,
559                 }
560             }
561             true
562         } else {
563             false
564         }
565     }
566
567     pub(crate) fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
568         match v {
569             Some(s) => {
570                 let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
571                 v.sort_unstable();
572                 *slot = Some(v);
573                 true
574             }
575             None => false,
576         }
577     }
578
579     pub(crate) fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
580         match v.and_then(|s| s.parse().ok()) {
581             Some(0) => {
582                 *slot = ::num_cpus::get();
583                 true
584             }
585             Some(i) => {
586                 *slot = i;
587                 true
588             }
589             None => false,
590         }
591     }
592
593     /// Use this for any numeric option that has a static default.
594     pub(crate) fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
595         match v.and_then(|s| s.parse().ok()) {
596             Some(i) => {
597                 *slot = i;
598                 true
599             }
600             None => false,
601         }
602     }
603
604     /// Use this for any numeric option that lacks a static default.
605     pub(crate) fn parse_opt_number<T: Copy + FromStr>(
606         slot: &mut Option<T>,
607         v: Option<&str>,
608     ) -> bool {
609         match v {
610             Some(s) => {
611                 *slot = s.parse().ok();
612                 slot.is_some()
613             }
614             None => false,
615         }
616     }
617
618     pub(crate) fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
619         match v {
620             Some("all") => {
621                 *slot = Passes::All;
622                 true
623             }
624             v => {
625                 let mut passes = vec![];
626                 if parse_list(&mut passes, v) {
627                     slot.extend(passes);
628                     true
629                 } else {
630                     false
631                 }
632             }
633         }
634     }
635
636     pub(crate) fn parse_opt_panic_strategy(
637         slot: &mut Option<PanicStrategy>,
638         v: Option<&str>,
639     ) -> bool {
640         match v {
641             Some("unwind") => *slot = Some(PanicStrategy::Unwind),
642             Some("abort") => *slot = Some(PanicStrategy::Abort),
643             _ => return false,
644         }
645         true
646     }
647
648     pub(crate) fn parse_panic_strategy(slot: &mut PanicStrategy, v: Option<&str>) -> bool {
649         match v {
650             Some("unwind") => *slot = PanicStrategy::Unwind,
651             Some("abort") => *slot = PanicStrategy::Abort,
652             _ => return false,
653         }
654         true
655     }
656
657     pub(crate) fn parse_oom_strategy(slot: &mut OomStrategy, v: Option<&str>) -> bool {
658         match v {
659             Some("panic") => *slot = OomStrategy::Panic,
660             Some("abort") => *slot = OomStrategy::Abort,
661             _ => return false,
662         }
663         true
664     }
665
666     pub(crate) fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
667         match v {
668             Some(s) => match s.parse::<RelroLevel>() {
669                 Ok(level) => *slot = Some(level),
670                 _ => return false,
671             },
672             _ => return false,
673         }
674         true
675     }
676
677     pub(crate) fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
678         if let Some(v) = v {
679             for s in v.split(',') {
680                 *slot |= match s {
681                     "address" => SanitizerSet::ADDRESS,
682                     "cfi" => SanitizerSet::CFI,
683                     "leak" => SanitizerSet::LEAK,
684                     "memory" => SanitizerSet::MEMORY,
685                     "memtag" => SanitizerSet::MEMTAG,
686                     "thread" => SanitizerSet::THREAD,
687                     "hwaddress" => SanitizerSet::HWADDRESS,
688                     _ => return false,
689                 }
690             }
691             true
692         } else {
693             false
694         }
695     }
696
697     pub(crate) fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
698         match v {
699             Some("2") | None => {
700                 *slot = 2;
701                 true
702             }
703             Some("1") => {
704                 *slot = 1;
705                 true
706             }
707             Some("0") => {
708                 *slot = 0;
709                 true
710             }
711             Some(_) => false,
712         }
713     }
714
715     pub(crate) fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
716         match v {
717             Some("none") => *slot = Strip::None,
718             Some("debuginfo") => *slot = Strip::Debuginfo,
719             Some("symbols") => *slot = Strip::Symbols,
720             _ => return false,
721         }
722         true
723     }
724
725     pub(crate) fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
726         if v.is_some() {
727             let mut bool_arg = None;
728             if parse_opt_bool(&mut bool_arg, v) {
729                 *slot = if bool_arg.unwrap() { CFGuard::Checks } else { CFGuard::Disabled };
730                 return true;
731             }
732         }
733
734         *slot = match v {
735             None => CFGuard::Checks,
736             Some("checks") => CFGuard::Checks,
737             Some("nochecks") => CFGuard::NoChecks,
738             Some(_) => return false,
739         };
740         true
741     }
742
743     pub(crate) fn parse_cfprotection(slot: &mut CFProtection, v: Option<&str>) -> bool {
744         if v.is_some() {
745             let mut bool_arg = None;
746             if parse_opt_bool(&mut bool_arg, v) {
747                 *slot = if bool_arg.unwrap() { CFProtection::Full } else { CFProtection::None };
748                 return true;
749             }
750         }
751
752         *slot = match v {
753             None | Some("none") => CFProtection::None,
754             Some("branch") => CFProtection::Branch,
755             Some("return") => CFProtection::Return,
756             Some("full") => CFProtection::Full,
757             Some(_) => return false,
758         };
759         true
760     }
761
762     pub(crate) fn parse_linker_flavor(slot: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
763         match v.and_then(LinkerFlavor::from_str) {
764             Some(lf) => *slot = Some(lf),
765             _ => return false,
766         }
767         true
768     }
769
770     pub(crate) fn parse_optimization_fuel(
771         slot: &mut Option<(String, u64)>,
772         v: Option<&str>,
773     ) -> bool {
774         match v {
775             None => false,
776             Some(s) => {
777                 let parts = s.split('=').collect::<Vec<_>>();
778                 if parts.len() != 2 {
779                     return false;
780                 }
781                 let crate_name = parts[0].to_string();
782                 let fuel = parts[1].parse::<u64>();
783                 if fuel.is_err() {
784                     return false;
785                 }
786                 *slot = Some((crate_name, fuel.unwrap()));
787                 true
788             }
789         }
790     }
791
792     pub(crate) fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
793         match v {
794             None => false,
795             Some(s) if s.split('=').count() <= 2 => {
796                 *slot = Some(s.to_string());
797                 true
798             }
799             _ => false,
800         }
801     }
802
803     pub(crate) fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
804         if v.is_some() {
805             let mut bool_arg = None;
806             if parse_opt_bool(&mut bool_arg, v) {
807                 *slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
808                 return true;
809             }
810         }
811
812         let Some(v) = v else {
813             *slot = Some(MirSpanview::Statement);
814             return true;
815         };
816
817         *slot = Some(match v.trim_end_matches('s') {
818             "statement" | "stmt" => MirSpanview::Statement,
819             "terminator" | "term" => MirSpanview::Terminator,
820             "block" | "basicblock" => MirSpanview::Block,
821             _ => return false,
822         });
823         true
824     }
825
826     pub(crate) fn parse_instrument_coverage(
827         slot: &mut Option<InstrumentCoverage>,
828         v: Option<&str>,
829     ) -> bool {
830         if v.is_some() {
831             let mut bool_arg = None;
832             if parse_opt_bool(&mut bool_arg, v) {
833                 *slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
834                 return true;
835             }
836         }
837
838         let Some(v) = v else {
839             *slot = Some(InstrumentCoverage::All);
840             return true;
841         };
842
843         *slot = Some(match v {
844             "all" => InstrumentCoverage::All,
845             "except-unused-generics" | "except_unused_generics" => {
846                 InstrumentCoverage::ExceptUnusedGenerics
847             }
848             "except-unused-functions" | "except_unused_functions" => {
849                 InstrumentCoverage::ExceptUnusedFunctions
850             }
851             "off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
852             _ => return false,
853         });
854         true
855     }
856
857     pub(crate) fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
858         match v {
859             Some(s) => {
860                 *slot = s.parse().ok();
861                 slot.is_some()
862             }
863             None => {
864                 *slot = NonZeroUsize::new(1);
865                 true
866             }
867         }
868     }
869
870     pub(crate) fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
871         if v.is_some() {
872             let mut bool_arg = None;
873             if parse_opt_bool(&mut bool_arg, v) {
874                 *slot = if bool_arg.unwrap() { LtoCli::Yes } else { LtoCli::No };
875                 return true;
876             }
877         }
878
879         *slot = match v {
880             None => LtoCli::NoParam,
881             Some("thin") => LtoCli::Thin,
882             Some("fat") => LtoCli::Fat,
883             Some(_) => return false,
884         };
885         true
886     }
887
888     pub(crate) fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
889         if v.is_some() {
890             let mut bool_arg = None;
891             if parse_opt_bool(&mut bool_arg, v) {
892                 *slot = if bool_arg.unwrap() {
893                     LinkerPluginLto::LinkerPluginAuto
894                 } else {
895                     LinkerPluginLto::Disabled
896                 };
897                 return true;
898             }
899         }
900
901         *slot = match v {
902             None => LinkerPluginLto::LinkerPluginAuto,
903             Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
904         };
905         true
906     }
907
908     pub(crate) fn parse_switch_with_opt_path(
909         slot: &mut SwitchWithOptPath,
910         v: Option<&str>,
911     ) -> bool {
912         *slot = match v {
913             None => SwitchWithOptPath::Enabled(None),
914             Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
915         };
916         true
917     }
918
919     pub(crate) fn parse_merge_functions(
920         slot: &mut Option<MergeFunctions>,
921         v: Option<&str>,
922     ) -> bool {
923         match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
924             Some(mergefunc) => *slot = Some(mergefunc),
925             _ => return false,
926         }
927         true
928     }
929
930     pub(crate) fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
931         match v.and_then(|s| RelocModel::from_str(s).ok()) {
932             Some(relocation_model) => *slot = Some(relocation_model),
933             None if v == Some("default") => *slot = None,
934             _ => return false,
935         }
936         true
937     }
938
939     pub(crate) fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
940         match v.and_then(|s| CodeModel::from_str(s).ok()) {
941             Some(code_model) => *slot = Some(code_model),
942             _ => return false,
943         }
944         true
945     }
946
947     pub(crate) fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
948         match v.and_then(|s| TlsModel::from_str(s).ok()) {
949             Some(tls_model) => *slot = Some(tls_model),
950             _ => return false,
951         }
952         true
953     }
954
955     pub(crate) fn parse_symbol_mangling_version(
956         slot: &mut Option<SymbolManglingVersion>,
957         v: Option<&str>,
958     ) -> bool {
959         *slot = match v {
960             Some("legacy") => Some(SymbolManglingVersion::Legacy),
961             Some("v0") => Some(SymbolManglingVersion::V0),
962             _ => return false,
963         };
964         true
965     }
966
967     pub(crate) fn parse_src_file_hash(
968         slot: &mut Option<SourceFileHashAlgorithm>,
969         v: Option<&str>,
970     ) -> bool {
971         match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
972             Some(hash_kind) => *slot = Some(hash_kind),
973             _ => return false,
974         }
975         true
976     }
977
978     pub(crate) fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
979         match v {
980             Some(s) => {
981                 if !slot.is_empty() {
982                     slot.push(',');
983                 }
984                 slot.push_str(s);
985                 true
986             }
987             None => false,
988         }
989     }
990
991     pub(crate) fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
992         match v {
993             Some("command") => *slot = Some(WasiExecModel::Command),
994             Some("reactor") => *slot = Some(WasiExecModel::Reactor),
995             _ => return false,
996         }
997         true
998     }
999
1000     pub(crate) fn parse_split_debuginfo(
1001         slot: &mut Option<SplitDebuginfo>,
1002         v: Option<&str>,
1003     ) -> bool {
1004         match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
1005             Some(e) => *slot = Some(e),
1006             _ => return false,
1007         }
1008         true
1009     }
1010
1011     pub(crate) fn parse_split_dwarf_kind(slot: &mut SplitDwarfKind, v: Option<&str>) -> bool {
1012         match v.and_then(|s| SplitDwarfKind::from_str(s).ok()) {
1013             Some(e) => *slot = e,
1014             _ => return false,
1015         }
1016         true
1017     }
1018
1019     pub(crate) fn parse_gcc_ld(slot: &mut Option<LdImpl>, v: Option<&str>) -> bool {
1020         match v {
1021             None => *slot = None,
1022             Some("lld") => *slot = Some(LdImpl::Lld),
1023             _ => return false,
1024         }
1025         true
1026     }
1027
1028     pub(crate) fn parse_stack_protector(slot: &mut StackProtector, v: Option<&str>) -> bool {
1029         match v.and_then(|s| StackProtector::from_str(s).ok()) {
1030             Some(ssp) => *slot = ssp,
1031             _ => return false,
1032         }
1033         true
1034     }
1035
1036     pub(crate) fn parse_branch_protection(
1037         slot: &mut Option<BranchProtection>,
1038         v: Option<&str>,
1039     ) -> bool {
1040         match v {
1041             Some(s) => {
1042                 let slot = slot.get_or_insert_default();
1043                 for opt in s.split(',') {
1044                     match opt {
1045                         "bti" => slot.bti = true,
1046                         "pac-ret" if slot.pac_ret.is_none() => {
1047                             slot.pac_ret = Some(PacRet { leaf: false, key: PAuthKey::A })
1048                         }
1049                         "leaf" => match slot.pac_ret.as_mut() {
1050                             Some(pac) => pac.leaf = true,
1051                             _ => return false,
1052                         },
1053                         "b-key" => match slot.pac_ret.as_mut() {
1054                             Some(pac) => pac.key = PAuthKey::B,
1055                             _ => return false,
1056                         },
1057                         _ => return false,
1058                     };
1059                 }
1060             }
1061             _ => return false,
1062         }
1063         true
1064     }
1065 }
1066
1067 options! {
1068     CodegenOptions, CG_OPTIONS, cgopts, "C", "codegen",
1069
1070     // This list is in alphabetical order.
1071     //
1072     // If you add a new option, please update:
1073     // - compiler/rustc_interface/src/tests.rs
1074     // - src/doc/rustc/src/codegen-options/index.md
1075
1076     ar: String = (String::new(), parse_string, [UNTRACKED],
1077         "this option is deprecated and does nothing"),
1078     code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
1079         "choose the code model to use (`rustc --print code-models` for details)"),
1080     codegen_units: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1081         "divide crate into N units to optimize in parallel"),
1082     control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
1083         "use Windows Control Flow Guard (default: no)"),
1084     debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
1085         "explicitly enable the `cfg(debug_assertions)` directive"),
1086     debuginfo: usize = (0, parse_number, [TRACKED],
1087         "debug info emission level (0 = no debug info, 1 = line tables only, \
1088         2 = full debug info with variable and type information; default: 0)"),
1089     default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
1090         "allow the linker to link its default libraries (default: no)"),
1091     embed_bitcode: bool = (true, parse_bool, [TRACKED],
1092         "emit bitcode in rlibs (default: yes)"),
1093     extra_filename: String = (String::new(), parse_string, [UNTRACKED],
1094         "extra data to put in each output filename"),
1095     force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
1096         "force use of the frame pointers"),
1097     force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
1098         "force use of unwind tables"),
1099     incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
1100         "enable incremental compilation"),
1101     inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
1102         "set the threshold for inlining a function"),
1103     instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1104         "instrument the generated code to support LLVM source-based code coverage \
1105         reports (note, the compiler build config must include `profiler = true`); \
1106         implies `-C symbol-mangling-version=v0`. Optional values are:
1107         `=all` (implicit value)
1108         `=except-unused-generics`
1109         `=except-unused-functions`
1110         `=off` (default)"),
1111     link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
1112         "a single extra argument to append to the linker invocation (can be used several times)"),
1113     link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
1114         "extra arguments to append to the linker invocation (space separated)"),
1115     link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED],
1116         "keep dead code at link time (useful for code coverage) (default: no)"),
1117     link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
1118         "control whether to link Rust provided C objects/libraries or rely
1119         on C toolchain installed in the system"),
1120     linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
1121         "system linker to link outputs with"),
1122     linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
1123         "linker flavor"),
1124     linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
1125         parse_linker_plugin_lto, [TRACKED],
1126         "generate build artifacts that are compatible with linker-based LTO"),
1127     llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1128         "a list of arguments to pass to LLVM (space separated)"),
1129     lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
1130         "perform LLVM link-time optimizations"),
1131     metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1132         "metadata to mangle symbol names with"),
1133     no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
1134         "give an empty list of passes to the pass manager"),
1135     no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
1136         "disable the use of the redzone"),
1137     no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
1138         "this option is deprecated and does nothing"),
1139     no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
1140         "disable loop vectorization optimization passes"),
1141     no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
1142         "disable LLVM's SLP vectorization pass"),
1143     opt_level: String = ("0".to_string(), parse_string, [TRACKED],
1144         "optimization level (0-3, s, or z; default: 0)"),
1145     overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
1146         "use overflow checks for integer arithmetic"),
1147     panic: Option<PanicStrategy> = (None, parse_opt_panic_strategy, [TRACKED],
1148         "panic strategy to compile crate with"),
1149     passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1150         "a list of extra LLVM passes to run (space separated)"),
1151     prefer_dynamic: bool = (false, parse_bool, [TRACKED],
1152         "prefer dynamic linking to static linking (default: no)"),
1153     profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
1154         parse_switch_with_opt_path, [TRACKED],
1155         "compile the program with profiling instrumentation"),
1156     profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1157         "use the given `.profdata` file for profile-guided optimization"),
1158     relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
1159         "control generation of position-independent code (PIC) \
1160         (`rustc --print relocation-models` for details)"),
1161     remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
1162         "print remarks for these optimization passes (space separated, or \"all\")"),
1163     rpath: bool = (false, parse_bool, [UNTRACKED],
1164         "set rpath values in libs/exes (default: no)"),
1165     save_temps: bool = (false, parse_bool, [UNTRACKED],
1166         "save all temporary output files during compilation (default: no)"),
1167     soft_float: bool = (false, parse_bool, [TRACKED],
1168         "use soft float ABI (*eabihf targets only) (default: no)"),
1169     split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
1170         "how to handle split-debuginfo, a platform-specific option"),
1171     strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1172         "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1173     symbol_mangling_version: Option<SymbolManglingVersion> = (None,
1174         parse_symbol_mangling_version, [TRACKED],
1175         "which mangling version to use for symbol names ('legacy' (default) or 'v0')"),
1176     target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
1177         "select target processor (`rustc --print target-cpus` for details)"),
1178     target_feature: String = (String::new(), parse_target_feature, [TRACKED],
1179         "target specific attributes. (`rustc --print target-features` for details). \
1180         This feature is unsafe."),
1181
1182     // This list is in alphabetical order.
1183     //
1184     // If you add a new option, please update:
1185     // - compiler/rustc_interface/src/tests.rs
1186     // - src/doc/rustc/src/codegen-options/index.md
1187 }
1188
1189 options! {
1190     UnstableOptions, Z_OPTIONS, dbopts, "Z", "unstable",
1191
1192     // This list is in alphabetical order.
1193     //
1194     // If you add a new option, please update:
1195     // - compiler/rustc_interface/src/tests.rs
1196     // - src/doc/unstable-book/src/compiler-flags
1197
1198     allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
1199         "only allow the listed language features to be enabled in code (space separated)"),
1200     always_encode_mir: bool = (false, parse_bool, [TRACKED],
1201         "encode MIR of all functions into the crate metadata (default: no)"),
1202     assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
1203         "make cfg(version) treat the current version as incomplete (default: no)"),
1204     asm_comments: bool = (false, parse_bool, [TRACKED],
1205         "generate comments into the assembly (may change behavior) (default: no)"),
1206     assert_incr_state: Option<String> = (None, parse_opt_string, [UNTRACKED],
1207         "assert that the incremental cache is in given state: \
1208          either `loaded` or `not-loaded`."),
1209     binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
1210         "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
1211         (default: no)"),
1212     box_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1213         "emit noalias metadata for box (default: yes)"),
1214     branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED],
1215         "set options for branch target identification and pointer authentication on AArch64"),
1216     cf_protection: CFProtection = (CFProtection::None, parse_cfprotection, [TRACKED],
1217         "instrument control-flow architecture protection"),
1218     cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
1219         "the codegen unit partitioning strategy to use"),
1220     chalk: bool = (false, parse_bool, [TRACKED],
1221         "enable the experimental Chalk-based trait solving engine"),
1222     codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
1223         "the backend to use"),
1224     combine_cgu: bool = (false, parse_bool, [TRACKED],
1225         "combine CGUs into a single one"),
1226     crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
1227         "inject the given attribute in the crate"),
1228     debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
1229         "emit discriminators and other data necessary for AutoFDO"),
1230     debug_macros: bool = (false, parse_bool, [TRACKED],
1231         "emit line numbers debug info inside macros (default: no)"),
1232     deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
1233         "deduplicate identical diagnostics (default: yes)"),
1234     dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
1235         "in dep-info output, omit targets for tracking dependencies of the dep-info files \
1236         themselves (default: no)"),
1237     dep_tasks: bool = (false, parse_bool, [UNTRACKED],
1238         "print tasks that execute and the color their dep node gets (requires debug build) \
1239         (default: no)"),
1240     dlltool: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
1241         "import library generation tool (windows-gnu only)"),
1242     dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
1243         "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
1244         (default: no)"),
1245     drop_tracking: bool = (false, parse_bool, [TRACKED],
1246         "enables drop tracking in generators (default: no)"),
1247     dual_proc_macros: bool = (false, parse_bool, [TRACKED],
1248         "load proc macros for both target and host, but only link to the target (default: no)"),
1249     dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1250         "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
1251         (default: no)"),
1252     dump_drop_tracking_cfg: Option<String> = (None, parse_opt_string, [UNTRACKED],
1253         "dump drop-tracking control-flow graph as a `.dot` file (default: no)"),
1254     dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
1255         "dump MIR state to file.
1256         `val` is used to select which passes and functions to dump. For example:
1257         `all` matches all passes and functions,
1258         `foo` matches all passes for functions whose name contains 'foo',
1259         `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
1260         `foo | bar` all passes for function names containing 'foo' or 'bar'."),
1261     dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
1262         "in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
1263         (default: no)"),
1264     dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
1265         "the directory the MIR is dumped into (default: `mir_dump`)"),
1266     dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
1267         "exclude the pass number when dumping MIR (used in tests) (default: no)"),
1268     dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
1269         "in addition to `.mir` files, create graphviz `.dot` files (and with \
1270         `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived \
1271         coverage graph) (default: no)"),
1272     dump_mir_spanview: Option<MirSpanview> = (None, parse_mir_spanview, [UNTRACKED],
1273         "in addition to `.mir` files, create `.html` files to view spans for \
1274         all `statement`s (including terminators), only `terminator` spans, or \
1275         computed `block` spans (one span encompassing a block's terminator and \
1276         all statements). If `-Z instrument-coverage` is also enabled, create \
1277         an additional `.html` file showing the computed coverage spans."),
1278     dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
1279         "version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
1280     emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
1281         "emit a section containing stack size metadata (default: no)"),
1282     emit_thin_lto: bool = (true, parse_bool, [TRACKED],
1283         "emit the bc module with thin LTO info (default: yes)"),
1284     fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
1285         "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
1286         (default: no)"),
1287     force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
1288         "force all crates to be `rustc_private` unstable (default: no)"),
1289     fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
1290         "set the optimization fuel quota for a crate"),
1291     function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
1292         "whether each function should go in its own section"),
1293     future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
1294         "forces all lints to be future incompatible, used for internal testing (default: no)"),
1295     gcc_ld: Option<LdImpl> = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"),
1296     graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
1297         "use dark-themed colors in graphviz output (default: no)"),
1298     graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
1299         "use the given `fontname` in graphviz output; can be overridden by setting \
1300         environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
1301     hir_stats: bool = (false, parse_bool, [UNTRACKED],
1302         "print some statistics about AST and HIR (default: no)"),
1303     human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
1304         "generate human-readable, predictable names for codegen units (default: no)"),
1305     identify_regions: bool = (false, parse_bool, [UNTRACKED],
1306         "display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
1307     incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
1308         "ignore spans during ICH computation -- used for testing (default: no)"),
1309     incremental_info: bool = (false, parse_bool, [UNTRACKED],
1310         "print high-level information about incremental reuse (or the lack thereof) \
1311         (default: no)"),
1312     incremental_relative_spans: bool = (false, parse_bool, [TRACKED],
1313         "hash spans relative to their parent item for incr. comp. (default: no)"),
1314     incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
1315         "verify incr. comp. hashes of green query instances (default: no)"),
1316     inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
1317         "enable MIR inlining (default: no)"),
1318     inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1319         "a default MIR inlining threshold (default: 50)"),
1320     inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1321         "inlining threshold for functions with inline hint (default: 100)"),
1322     inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
1323         "control whether `#[inline]` functions are in all CGUs"),
1324     input_stats: bool = (false, parse_bool, [UNTRACKED],
1325         "gather statistics about the input (default: no)"),
1326     instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1327         "instrument the generated code to support LLVM source-based code coverage \
1328         reports (note, the compiler build config must include `profiler = true`); \
1329         implies `-C symbol-mangling-version=v0`. Optional values are:
1330         `=all` (implicit value)
1331         `=except-unused-generics`
1332         `=except-unused-functions`
1333         `=off` (default)"),
1334     instrument_mcount: bool = (false, parse_bool, [TRACKED],
1335         "insert function instrument code for mcount-based tracing (default: no)"),
1336     keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
1337         "keep hygiene data after analysis (default: no)"),
1338     link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
1339         "link native libraries in the linker invocation (default: yes)"),
1340     link_only: bool = (false, parse_bool, [TRACKED],
1341         "link the `.rlink` file generated by `-Z no-link` (default: no)"),
1342     llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1343         "a list LLVM plugins to enable (space separated)"),
1344     llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
1345         "generate JSON tracing data file from LLVM data (default: no)"),
1346     location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
1347         "comma separated list of location details to be tracked when using caller_location \
1348         valid options are `file`, `line`, and `column` (default: all)"),
1349     ls: bool = (false, parse_bool, [UNTRACKED],
1350         "list the symbols defined by a library crate (default: no)"),
1351     macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1352         "show macro backtraces (default: no)"),
1353     merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
1354         "control the operation of the MergeFunctions LLVM pass, taking \
1355         the same values as the target option of the same name"),
1356     meta_stats: bool = (false, parse_bool, [UNTRACKED],
1357         "gather metadata statistics (default: no)"),
1358     mir_emit_retag: bool = (false, parse_bool, [TRACKED],
1359         "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
1360         (default: no)"),
1361     mir_enable_passes: Vec<(String, bool)> = (Vec::new(), parse_list_with_polarity, [TRACKED],
1362         "use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be \
1363         enabled, overriding all other checks. Passes that are not specified are enabled or \
1364         disabled by other flags as usual."),
1365     mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
1366         "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
1367     move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
1368         "the size at which the `large_assignments` lint starts to be emitted"),
1369     mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1370         "emit noalias metadata for mutable references (default: yes)"),
1371     new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
1372         "use new LLVM pass manager (default: no)"),
1373     nll_facts: bool = (false, parse_bool, [UNTRACKED],
1374         "dump facts from NLL analysis into side files (default: no)"),
1375     nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
1376         "the directory the NLL facts are dumped into (default: `nll-facts`)"),
1377     no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
1378         "parse and expand the source, but run no analysis"),
1379     no_codegen: bool = (false, parse_no_flag, [TRACKED_NO_CRATE_HASH],
1380         "run all passes except codegen; no output"),
1381     no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
1382         "omit DWARF address ranges that give faster lookups"),
1383     no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
1384         "execute lints separately; allows benchmarking individual lints"),
1385     no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
1386         "disable the 'leak check' for subtyping; unsound, but useful for tests"),
1387     no_link: bool = (false, parse_no_flag, [TRACKED],
1388         "compile without linking"),
1389     no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
1390         "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1391     no_unique_section_names: bool = (false, parse_bool, [TRACKED],
1392         "do not use unique names for text and data sections when -Z function-sections is used"),
1393     no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
1394         "prevent automatic injection of the profiler_builtins crate"),
1395     normalize_docs: bool = (false, parse_bool, [TRACKED],
1396         "normalize associated items in rustdoc when generating documentation"),
1397     oom: OomStrategy = (OomStrategy::Abort, parse_oom_strategy, [TRACKED],
1398         "panic strategy for out-of-memory handling"),
1399     osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
1400         "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
1401     diagnostic_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1402         "set the current output width for diagnostic truncation"),
1403     panic_abort_tests: bool = (false, parse_bool, [TRACKED],
1404         "support compiling tests with panic=abort (default: no)"),
1405     panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
1406         "panic strategy for panics in drops"),
1407     parse_only: bool = (false, parse_bool, [UNTRACKED],
1408         "parse only; do not compile, assemble, or link (default: no)"),
1409     perf_stats: bool = (false, parse_bool, [UNTRACKED],
1410         "print some performance-related statistics (default: no)"),
1411     pick_stable_methods_before_any_unstable: bool = (true, parse_bool, [TRACKED],
1412         "try to pick stable methods first before picking any unstable methods (default: yes)"),
1413     plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
1414         "whether to use the PLT when calling into shared libraries;
1415         only has effect for PIC code on systems with ELF binaries
1416         (default: PLT is disabled if full relro is enabled)"),
1417     polonius: bool = (false, parse_bool, [TRACKED],
1418         "enable polonius-based borrow-checker (default: no)"),
1419     polymorphize: bool = (false, parse_bool, [TRACKED],
1420           "perform polymorphization analysis"),
1421     pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
1422         "a single extra argument to prepend the linker invocation (can be used several times)"),
1423     pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
1424         "extra arguments to prepend to the linker invocation (space separated)"),
1425     precise_enum_drop_elaboration: bool = (true, parse_bool, [TRACKED],
1426         "use a more precise version of drop elaboration for matches on enums (default: yes). \
1427         This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
1428         See #77382 and #74551."),
1429     print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
1430         "make rustc print the total optimization fuel used by a crate"),
1431     print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1432         "print the LLVM optimization passes being run (default: no)"),
1433     print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
1434         "print the result of the monomorphization collection pass"),
1435     print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
1436         "print layout information for each type encountered (default: no)"),
1437     proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1438          "show backtraces for panics during proc-macro execution (default: no)"),
1439     profile: bool = (false, parse_bool, [TRACKED],
1440         "insert profiling code (default: no)"),
1441     profile_closures: bool = (false, parse_no_flag, [UNTRACKED],
1442         "profile size of closures"),
1443     profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1444         "file path to emit profiling data at runtime when using 'profile' \
1445         (default based on relative source path)"),
1446     profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
1447         "name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
1448     profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1449         "use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
1450     query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1451         "enable queries of the dependency graph for regression testing (default: no)"),
1452     randomize_layout: bool = (false, parse_bool, [TRACKED],
1453         "randomize the layout of types (default: no)"),
1454     layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
1455         "seed layout randomization"),
1456     relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
1457         "whether ELF relocations can be relaxed"),
1458     relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
1459         "choose which RELRO level to use"),
1460     remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1461         "remap paths under the current working directory to this path prefix"),
1462     simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1463         "simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
1464         to rust's source base directory. only meant for testing purposes"),
1465     report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
1466         "immediately print bugs registered with `delay_span_bug` (default: no)"),
1467     sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1468         "use a sanitizer"),
1469     sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
1470         "enable origins tracking in MemorySanitizer"),
1471     sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1472         "enable recovery for selected sanitizers"),
1473     saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
1474         "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
1475         the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
1476     save_analysis: bool = (false, parse_bool, [UNTRACKED],
1477         "write syntax and type analysis (in JSON format) information, in \
1478         addition to normal output (default: no)"),
1479     self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
1480         parse_switch_with_opt_path, [UNTRACKED],
1481         "run the self profiler and output the raw event data"),
1482     /// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1483     self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
1484         "specify the events recorded by the self profiler;
1485         for example: `-Z self-profile-events=default,query-keys`
1486         all options: none, all, default, generic-activity, query-provider, query-cache-hit
1487                      query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes"),
1488     self_profile_counter: String = ("wall-time".to_string(), parse_string, [UNTRACKED],
1489         "counter used by the self profiler (default: `wall-time`), one of:
1490         `wall-time` (monotonic clock, i.e. `std::time::Instant`)
1491         `instructions:u` (retired instructions, userspace-only)
1492         `instructions-minus-irqs:u` (subtracting hardware interrupt counts for extra accuracy)"
1493     ),
1494     share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
1495         "make the current crate share its generic instantiations"),
1496     show_span: Option<String> = (None, parse_opt_string, [TRACKED],
1497         "show spans for compiler debugging (expr|pat|ty)"),
1498     span_debug: bool = (false, parse_bool, [UNTRACKED],
1499         "forward proc_macro::Span's `Debug` impl to `Span`"),
1500     /// o/w tests have closure@path
1501     span_free_formats: bool = (false, parse_bool, [UNTRACKED],
1502         "exclude spans when debug-printing compiler state (default: no)"),
1503     src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
1504         "hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
1505     stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED],
1506         "control stack smash protection strategy (`rustc --print stack-protector-strategies` for details)"),
1507     strict_init_checks: bool = (false, parse_bool, [TRACKED],
1508         "control if mem::uninitialized and mem::zeroed panic on more UB"),
1509     strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1510         "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1511     split_dwarf_kind: SplitDwarfKind = (SplitDwarfKind::Split, parse_split_dwarf_kind, [TRACKED],
1512         "split dwarf variant (only if -Csplit-debuginfo is enabled and on relevant platform)
1513         (default: `split`)
1514
1515         `split`: sections which do not require relocation are written into a DWARF object (`.dwo`)
1516                  file which is ignored by the linker
1517         `single`: sections which do not require relocation are written into object file but ignored
1518                   by the linker"),
1519     split_dwarf_inlining: bool = (true, parse_bool, [TRACKED],
1520         "provide minimal debug info in the object/executable to facilitate online \
1521          symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF"),
1522     symbol_mangling_version: Option<SymbolManglingVersion> = (None,
1523         parse_symbol_mangling_version, [TRACKED],
1524         "which mangling version to use for symbol names ('legacy' (default) or 'v0')"),
1525     teach: bool = (false, parse_bool, [TRACKED],
1526         "show extended diagnostic help (default: no)"),
1527     temps_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
1528         "the directory the intermediate files are written to"),
1529     // Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved
1530     // alongside query results and changes to translation options can affect diagnostics - so
1531     // translation options should be tracked.
1532     translate_lang: Option<LanguageIdentifier> = (None, parse_opt_langid, [TRACKED],
1533         "language identifier for diagnostic output"),
1534     translate_additional_ftl: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1535         "additional fluent translation to preferentially use (for testing translation)"),
1536     translate_directionality_markers: bool = (false, parse_bool, [TRACKED],
1537         "emit directionality isolation markers in translated diagnostics"),
1538     tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
1539         "select processor to schedule for (`rustc --print target-cpus` for details)"),
1540     thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
1541         "enable ThinLTO when possible"),
1542     thir_unsafeck: bool = (false, parse_bool, [TRACKED],
1543         "use the THIR unsafety checker (default: no)"),
1544     /// We default to 1 here since we want to behave like
1545     /// a sequential compiler for now. This'll likely be adjusted
1546     /// in the future. Note that -Zthreads=0 is the way to get
1547     /// the num_cpus behavior.
1548     threads: usize = (1, parse_threads, [UNTRACKED],
1549         "use a thread pool with N threads"),
1550     time: bool = (false, parse_bool, [UNTRACKED],
1551         "measure time of rustc processes (default: no)"),
1552     time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1553         "measure time of each LLVM pass (default: no)"),
1554     time_passes: bool = (false, parse_bool, [UNTRACKED],
1555         "measure time of each rustc pass (default: no)"),
1556     tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
1557         "choose the TLS model to use (`rustc --print tls-models` for details)"),
1558     trace_macros: bool = (false, parse_bool, [UNTRACKED],
1559         "for every macro invocation, print its name and arguments (default: no)"),
1560     translate_remapped_path_to_local_path: bool = (true, parse_bool, [TRACKED],
1561         "translate remapped paths into local paths when possible (default: yes)"),
1562     trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
1563         "generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
1564     treat_err_as_bug: Option<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED],
1565         "treat error number `val` that occurs as bug"),
1566     trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
1567         "in diagnostics, use heuristics to shorten paths referring to items"),
1568     ui_testing: bool = (false, parse_bool, [UNTRACKED],
1569         "emit compiler diagnostics in a form suitable for UI testing (default: no)"),
1570     uninit_const_chunk_threshold: usize = (16, parse_number, [TRACKED],
1571         "allow generating const initializers with mixed init/uninit chunks, \
1572         and set the maximum number of chunks for which this is allowed (default: 16)"),
1573     unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
1574         "take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
1575     unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1576         "present the input source, unstable (and less-pretty) variants;
1577         `normal`, `identified`,
1578         `expanded`, `expanded,identified`,
1579         `expanded,hygiene` (with internal representations),
1580         `ast-tree` (raw AST before expansion),
1581         `ast-tree,expanded` (raw AST after expansion),
1582         `hir` (the HIR), `hir,identified`,
1583         `hir,typed` (HIR with types for each node),
1584         `hir-tree` (dump the raw HIR),
1585         `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
1586     unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
1587         "enable unsound and buggy MIR optimizations (default: no)"),
1588     /// This name is kind of confusing: Most unstable options enable something themselves, while
1589     /// this just allows "normal" options to be feature-gated.
1590     unstable_options: bool = (false, parse_bool, [UNTRACKED],
1591         "adds unstable command line options to rustc interface (default: no)"),
1592     use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
1593         "use legacy .ctors section for initializers rather than .init_array"),
1594     validate_mir: bool = (false, parse_bool, [UNTRACKED],
1595         "validate MIR after each transformation"),
1596     verbose: bool = (false, parse_bool, [UNTRACKED],
1597         "in general, enable more debug printouts (default: no)"),
1598     verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
1599         "verify LLVM IR (default: no)"),
1600     virtual_function_elimination: bool = (false, parse_bool, [TRACKED],
1601         "enables dead virtual function elimination optimization. \
1602         Requires `-Clto[=[fat,yes]]`"),
1603     wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
1604         "whether to build a wasi command or reactor"),
1605
1606     // This list is in alphabetical order.
1607     //
1608     // If you add a new option, please update:
1609     // - compiler/rustc_interface/src/tests.rs
1610 }
1611
1612 #[derive(Clone, Hash, PartialEq, Eq, Debug)]
1613 pub enum WasiExecModel {
1614     Command,
1615     Reactor,
1616 }
1617
1618 #[derive(Clone, Copy, Hash)]
1619 pub enum LdImpl {
1620     Lld,
1621 }