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