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