]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_session/src/options.rs
Rollup merge of #76002 - richkadel:llvm-coverage-map-gen-6b.3, 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::NativeLibKind;
7
8 use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
9 use rustc_target::spec::{RelocModel, RelroLevel, TargetTriple, TlsModel};
10
11 use rustc_feature::UnstableFeatures;
12 use rustc_span::edition::Edition;
13 use rustc_span::SourceFileHashAlgorithm;
14
15 use std::collections::BTreeMap;
16
17 use std::collections::hash_map::DefaultHasher;
18 use std::hash::Hasher;
19 use std::path::PathBuf;
20 use std::str;
21
22 macro_rules! hash_option {
23     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [UNTRACKED]) => {{}};
24     ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [TRACKED]) => {{
25         if $sub_hashes
26             .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
27             .is_some()
28         {
29             panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
30         }
31     }};
32 }
33
34 macro_rules! top_level_options {
35     (pub struct Options { $(
36         $opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
37     )* } ) => (
38         #[derive(Clone)]
39         pub struct Options {
40             $(pub $opt: $t),*
41         }
42
43         impl Options {
44             pub fn dep_tracking_hash(&self) -> u64 {
45                 let mut sub_hashes = BTreeMap::new();
46                 $({
47                     hash_option!($opt,
48                                  &self.$opt,
49                                  &mut sub_hashes,
50                                  [$dep_tracking_marker $($warn_val,
51                                                          $warn_text,
52                                                          self.error_format)*]);
53                 })*
54                 let mut hasher = DefaultHasher::new();
55                 dep_tracking::stable_hash(sub_hashes,
56                                           &mut hasher,
57                                           self.error_format);
58                 hasher.finish()
59             }
60         }
61     );
62 }
63
64 // The top-level command-line options struct.
65 //
66 // For each option, one has to specify how it behaves with regard to the
67 // dependency tracking system of incremental compilation. This is done via the
68 // square-bracketed directive after the field type. The options are:
69 //
70 // [TRACKED]
71 // A change in the given field will cause the compiler to completely clear the
72 // incremental compilation cache before proceeding.
73 //
74 // [UNTRACKED]
75 // Incremental compilation is not influenced by this option.
76 //
77 // If you add a new option to this struct or one of the sub-structs like
78 // `CodegenOptions`, think about how it influences incremental compilation. If in
79 // doubt, specify [TRACKED], which is always "correct" but might lead to
80 // unnecessary re-compilation.
81 top_level_options!(
82     pub struct Options {
83         // The crate config requested for the session, which may be combined
84         // with additional crate configurations during the compile process.
85         crate_types: Vec<CrateType> [TRACKED],
86         optimize: OptLevel [TRACKED],
87         // Include the `debug_assertions` flag in dependency tracking, since it
88         // can influence whether overflow checks are done or not.
89         debug_assertions: bool [TRACKED],
90         debuginfo: DebugInfo [TRACKED],
91         lint_opts: Vec<(String, lint::Level)> [TRACKED],
92         lint_cap: Option<lint::Level> [TRACKED],
93         describe_lints: bool [UNTRACKED],
94         output_types: OutputTypes [TRACKED],
95         search_paths: Vec<SearchPath> [UNTRACKED],
96         libs: Vec<(String, Option<String>, NativeLibKind)> [TRACKED],
97         maybe_sysroot: Option<PathBuf> [UNTRACKED],
98
99         target_triple: TargetTriple [TRACKED],
100
101         test: bool [TRACKED],
102         error_format: ErrorOutputType [UNTRACKED],
103
104         // If `Some`, enable incremental compilation, using the given
105         // directory to store intermediate results.
106         incremental: Option<PathBuf> [UNTRACKED],
107
108         debugging_opts: DebuggingOptions [TRACKED],
109         prints: Vec<PrintRequest> [UNTRACKED],
110         // Determines which borrow checker(s) to run. This is the parsed, sanitized
111         // version of `debugging_opts.borrowck`, which is just a plain string.
112         borrowck_mode: BorrowckMode [UNTRACKED],
113         cg: CodegenOptions [TRACKED],
114         externs: Externs [UNTRACKED],
115         crate_name: Option<String> [TRACKED],
116         // An optional name to use as the crate for std during std injection,
117         // written `extern crate name as std`. Defaults to `std`. Used by
118         // out-of-tree drivers.
119         alt_std_name: Option<String> [TRACKED],
120         // Indicates how the compiler should treat unstable features.
121         unstable_features: UnstableFeatures [TRACKED],
122
123         // Indicates whether this run of the compiler is actually rustdoc. This
124         // is currently just a hack and will be removed eventually, so please
125         // try to not rely on this too much.
126         actually_rustdoc: bool [TRACKED],
127
128         // Specifications of codegen units / ThinLTO which are forced as a
129         // result of parsing command line options. These are not necessarily
130         // what rustc was invoked with, but massaged a bit to agree with
131         // commands like `--emit llvm-ir` which they're often incompatible with
132         // if we otherwise use the defaults of rustc.
133         cli_forced_codegen_units: Option<usize> [UNTRACKED],
134         cli_forced_thinlto_off: bool [UNTRACKED],
135
136         // Remap source path prefixes in all output (messages, object files, debug, etc.).
137         remap_path_prefix: Vec<(PathBuf, PathBuf)> [UNTRACKED],
138
139         edition: Edition [TRACKED],
140
141         // `true` if we're emitting JSON blobs about each artifact produced
142         // by the compiler.
143         json_artifact_notifications: bool [TRACKED],
144
145         pretty: Option<PpMode> [UNTRACKED],
146     }
147 );
148
149 /// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
150 /// macro is to define an interface that can be programmatically used by the option parser
151 /// to initialize the struct without hardcoding field names all over the place.
152 ///
153 /// The goal is to invoke this macro once with the correct fields, and then this macro generates all
154 /// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
155 /// generated code to parse an option into its respective field in the struct. There are a few
156 /// hand-written parsers for parsing specific types of values in this module.
157 macro_rules! options {
158     ($struct_name:ident, $setter_name:ident, $defaultfn:ident,
159      $buildfn:ident, $prefix:expr, $outputname:expr,
160      $stat:ident, $mod_desc:ident, $mod_set:ident,
161      $($opt:ident : $t:ty = (
162         $init:expr,
163         $parse:ident,
164         [$dep_tracking_marker:ident $(($dep_warn_val:expr, $dep_warn_text:expr))*],
165         $desc:expr)
166      ),* ,) =>
167 (
168     #[derive(Clone)]
169     pub struct $struct_name { $(pub $opt: $t),* }
170
171     pub fn $defaultfn() -> $struct_name {
172         $struct_name { $($opt: $init),* }
173     }
174
175     pub fn $buildfn(matches: &getopts::Matches, error_format: ErrorOutputType) -> $struct_name
176     {
177         let mut op = $defaultfn();
178         for option in matches.opt_strs($prefix) {
179             let mut iter = option.splitn(2, '=');
180             let key = iter.next().unwrap();
181             let value = iter.next();
182             let option_to_lookup = key.replace("-", "_");
183             let mut found = false;
184             for &(candidate, setter, type_desc, _) in $stat {
185                 if option_to_lookup != candidate { continue }
186                 if !setter(&mut op, value) {
187                     match value {
188                         None => {
189                             early_error(error_format, &format!("{0} option `{1}` requires \
190                                                                 {2} ({3} {1}=<value>)",
191                                                                $outputname, key,
192                                                                type_desc, $prefix))
193                         }
194                         Some(value) => {
195                             early_error(error_format, &format!("incorrect value `{}` for {} \
196                                                                 option `{}` - {} was expected",
197                                                                value, $outputname,
198                                                                key, type_desc))
199                         }
200                     }
201                 }
202                 found = true;
203                 break;
204             }
205             if !found {
206                 early_error(error_format, &format!("unknown {} option: `{}`",
207                                                    $outputname, key));
208             }
209         }
210         return op;
211     }
212
213     impl dep_tracking::DepTrackingHash for $struct_name {
214         fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
215             let mut sub_hashes = BTreeMap::new();
216             $({
217                 hash_option!($opt,
218                              &self.$opt,
219                              &mut sub_hashes,
220                              [$dep_tracking_marker $($dep_warn_val,
221                                                      $dep_warn_text,
222                                                      error_format)*]);
223             })*
224             dep_tracking::stable_hash(sub_hashes, hasher, error_format);
225         }
226     }
227
228     pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
229     pub const $stat: &[(&str, $setter_name, &str, &str)] =
230         &[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
231
232     #[allow(non_upper_case_globals, dead_code)]
233     mod $mod_desc {
234         pub const parse_no_flag: &str = "no value";
235         pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
236         pub const parse_opt_bool: &str = parse_bool;
237         pub const parse_string: &str = "a string";
238         pub const parse_opt_string: &str = parse_string;
239         pub const parse_string_push: &str = parse_string;
240         pub const parse_opt_pathbuf: &str = "a path";
241         pub const parse_pathbuf_push: &str = parse_opt_pathbuf;
242         pub const parse_list: &str = "a space-separated list of strings";
243         pub const parse_opt_list: &str = parse_list;
244         pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
245         pub const parse_uint: &str = "a number";
246         pub const parse_opt_uint: &str = parse_uint;
247         pub const parse_threads: &str = parse_uint;
248         pub const parse_passes: &str = "a space-separated list of passes, or `all`";
249         pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
250         pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
251         pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `leak`, `memory` or `thread`";
252         pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
253         pub const parse_cfguard: &str =
254             "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
255         pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
256         pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
257         pub const parse_optimization_fuel: &str = "crate=integer";
258         pub const parse_unpretty: &str = "`string` or `string=string`";
259         pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
260         pub const parse_lto: &str =
261             "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
262         pub const parse_linker_plugin_lto: &str =
263             "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
264         pub const parse_switch_with_opt_path: &str =
265             "an optional path to the profiling data output directory";
266         pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
267         pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
268         pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
269         pub const parse_relocation_model: &str =
270             "one of supported relocation models (`rustc --print relocation-models`)";
271         pub const parse_code_model: &str =
272             "one of supported code models (`rustc --print code-models`)";
273         pub const parse_tls_model: &str =
274             "one of supported TLS models (`rustc --print tls-models`)";
275         pub const parse_target_feature: &str = parse_string;
276     }
277
278     #[allow(dead_code)]
279     mod $mod_set {
280         use super::*;
281         use std::str::FromStr;
282
283         // Sometimes different options need to build a common structure.
284         // That structure can kept in one of the options' fields, the others become dummy.
285         macro_rules! redirect_field {
286             ($cg:ident.link_arg) => { $cg.link_args };
287             ($cg:ident.pre_link_arg) => { $cg.pre_link_args };
288             ($cg:ident.$field:ident) => { $cg.$field };
289         }
290
291         $(
292             pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
293                 $parse(&mut redirect_field!(cg.$opt), v)
294             }
295         )*
296
297         /// This is for boolean options that don't take a value and start with
298         /// `no-`. This style of option is deprecated.
299         fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
300             match v {
301                 None => { *slot = true; true }
302                 Some(_) => false,
303             }
304         }
305
306         /// Use this for any boolean option that has a static default.
307         fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
308             match v {
309                 Some("y") | Some("yes") | Some("on") | None => { *slot = true; true }
310                 Some("n") | Some("no") | Some("off") => { *slot = false; true }
311                 _ => false,
312             }
313         }
314
315         /// Use this for any boolean option that lacks a static default. (The
316         /// actions taken when such an option is not specified will depend on
317         /// other factors, such as other options, or target options.)
318         fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
319             match v {
320                 Some("y") | Some("yes") | Some("on") | None => { *slot = Some(true); true }
321                 Some("n") | Some("no") | Some("off") => { *slot = Some(false); true }
322                 _ => false,
323             }
324         }
325
326         /// Use this for any string option that has a static default.
327         fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
328             match v {
329                 Some(s) => { *slot = s.to_string(); true },
330                 None => false,
331             }
332         }
333
334         /// Use this for any string option that lacks a static default.
335         fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
336             match v {
337                 Some(s) => { *slot = Some(s.to_string()); true },
338                 None => false,
339             }
340         }
341
342         fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
343             match v {
344                 Some(s) => { *slot = Some(PathBuf::from(s)); true },
345                 None => false,
346             }
347         }
348
349         fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
350             match v {
351                 Some(s) => { slot.push(s.to_string()); true },
352                 None => false,
353             }
354         }
355
356         fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
357             match v {
358                 Some(s) => { slot.push(PathBuf::from(s)); true },
359                 None => false,
360             }
361         }
362
363         fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
364                       -> bool {
365             match v {
366                 Some(s) => {
367                     slot.extend(s.split_whitespace().map(|s| s.to_string()));
368                     true
369                 },
370                 None => false,
371             }
372         }
373
374         fn parse_opt_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
375                       -> bool {
376             match v {
377                 Some(s) => {
378                     let v = s.split_whitespace().map(|s| s.to_string()).collect();
379                     *slot = Some(v);
380                     true
381                 },
382                 None => false,
383             }
384         }
385
386         fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
387                       -> bool {
388             match v {
389                 Some(s) => {
390                     let v = s.split(',').map(|s| s.to_string()).collect();
391                     *slot = Some(v);
392                     true
393                 },
394                 None => false,
395             }
396         }
397
398         fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
399             match v.and_then(|s| s.parse().ok()) {
400                 Some(0) => { *slot = ::num_cpus::get(); true },
401                 Some(i) => { *slot = i; true },
402                 None => false
403             }
404         }
405
406         /// Use this for any uint option that has a static default.
407         fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
408             match v.and_then(|s| s.parse().ok()) {
409                 Some(i) => { *slot = i; true },
410                 None => false
411             }
412         }
413
414         /// Use this for any uint option that lacks a static default.
415         fn parse_opt_uint(slot: &mut Option<usize>, v: Option<&str>) -> bool {
416             match v {
417                 Some(s) => { *slot = s.parse().ok(); slot.is_some() }
418                 None => false
419             }
420         }
421
422         fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
423             match v {
424                 Some("all") => {
425                     *slot = Passes::All;
426                     true
427                 }
428                 v => {
429                     let mut passes = vec![];
430                     if parse_list(&mut passes, v) {
431                         *slot = Passes::Some(passes);
432                         true
433                     } else {
434                         false
435                     }
436                 }
437             }
438         }
439
440         fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
441             match v {
442                 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
443                 Some("abort") => *slot = Some(PanicStrategy::Abort),
444                 _ => return false
445             }
446             true
447         }
448
449         fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
450             match v {
451                 Some(s) => {
452                     match s.parse::<RelroLevel>() {
453                         Ok(level) => *slot = Some(level),
454                         _ => return false
455                     }
456                 },
457                 _ => return false
458             }
459             true
460         }
461
462         fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
463             if let Some(v) = v {
464                 for s in v.split(',') {
465                     *slot |= match s {
466                         "address" => SanitizerSet::ADDRESS,
467                         "leak" => SanitizerSet::LEAK,
468                         "memory" => SanitizerSet::MEMORY,
469                         "thread" => SanitizerSet::THREAD,
470                         _ => return false,
471                     }
472                 }
473                 true
474             } else {
475                 false
476             }
477         }
478
479         fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
480             match v {
481                 Some("2") | None => { *slot = 2; true }
482                 Some("1") => { *slot = 1; true }
483                 Some("0") => { *slot = 0; true }
484                 Some(_) => false,
485             }
486         }
487
488         fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
489             match v {
490                 Some("none") => *slot = Strip::None,
491                 Some("debuginfo") => *slot = Strip::Debuginfo,
492                 Some("symbols") => *slot = Strip::Symbols,
493                 _ => return false,
494             }
495             true
496         }
497
498         fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
499             if v.is_some() {
500                 let mut bool_arg = None;
501                 if parse_opt_bool(&mut bool_arg, v) {
502                     *slot = if bool_arg.unwrap() {
503                         CFGuard::Checks
504                     } else {
505                         CFGuard::Disabled
506                     };
507                     return true
508                 }
509             }
510
511             *slot = match v {
512                 None => CFGuard::Checks,
513                 Some("checks") => CFGuard::Checks,
514                 Some("nochecks") => CFGuard::NoChecks,
515                 Some(_) => return false,
516             };
517             true
518         }
519
520         fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
521             match v.and_then(LinkerFlavor::from_str) {
522                 Some(lf) => *slote = Some(lf),
523                 _ => return false,
524             }
525             true
526         }
527
528         fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
529             match v {
530                 None => false,
531                 Some(s) => {
532                     let parts = s.split('=').collect::<Vec<_>>();
533                     if parts.len() != 2 { return false; }
534                     let crate_name = parts[0].to_string();
535                     let fuel = parts[1].parse::<u64>();
536                     if fuel.is_err() { return false; }
537                     *slot = Some((crate_name, fuel.unwrap()));
538                     true
539                 }
540             }
541         }
542
543         fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
544             match v {
545                 None => false,
546                 Some(s) if s.split('=').count() <= 2 => {
547                     *slot = Some(s.to_string());
548                     true
549                 }
550                 _ => false,
551             }
552         }
553
554         fn parse_treat_err_as_bug(slot: &mut Option<usize>, v: Option<&str>) -> bool {
555             match v {
556                 Some(s) => { *slot = s.parse().ok().filter(|&x| x != 0); slot.unwrap_or(0) != 0 }
557                 None => { *slot = Some(1); true }
558             }
559         }
560
561         fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
562             if v.is_some() {
563                 let mut bool_arg = None;
564                 if parse_opt_bool(&mut bool_arg, v) {
565                     *slot = if bool_arg.unwrap() {
566                         LtoCli::Yes
567                     } else {
568                         LtoCli::No
569                     };
570                     return true
571                 }
572             }
573
574             *slot = match v {
575                 None => LtoCli::NoParam,
576                 Some("thin") => LtoCli::Thin,
577                 Some("fat") => LtoCli::Fat,
578                 Some(_) => return false,
579             };
580             true
581         }
582
583         fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
584             if v.is_some() {
585                 let mut bool_arg = None;
586                 if parse_opt_bool(&mut bool_arg, v) {
587                     *slot = if bool_arg.unwrap() {
588                         LinkerPluginLto::LinkerPluginAuto
589                     } else {
590                         LinkerPluginLto::Disabled
591                     };
592                     return true
593                 }
594             }
595
596             *slot = match v {
597                 None => LinkerPluginLto::LinkerPluginAuto,
598                 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
599             };
600             true
601         }
602
603         fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
604             *slot = match v {
605                 None => SwitchWithOptPath::Enabled(None),
606                 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
607             };
608             true
609         }
610
611         fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
612             match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
613                 Some(mergefunc) => *slot = Some(mergefunc),
614                 _ => return false,
615             }
616             true
617         }
618
619         fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
620             match v.and_then(|s| RelocModel::from_str(s).ok()) {
621                 Some(relocation_model) => *slot = Some(relocation_model),
622                 None if v == Some("default") => *slot = None,
623                 _ => return false,
624             }
625             true
626         }
627
628         fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
629             match v.and_then(|s| CodeModel::from_str(s).ok()) {
630                 Some(code_model) => *slot = Some(code_model),
631                 _ => return false,
632             }
633             true
634         }
635
636         fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
637             match v.and_then(|s| TlsModel::from_str(s).ok()) {
638                 Some(tls_model) => *slot = Some(tls_model),
639                 _ => return false,
640             }
641             true
642         }
643
644         fn parse_symbol_mangling_version(
645             slot: &mut SymbolManglingVersion,
646             v: Option<&str>,
647         ) -> bool {
648             *slot = match v {
649                 Some("legacy") => SymbolManglingVersion::Legacy,
650                 Some("v0") => SymbolManglingVersion::V0,
651                 _ => return false,
652             };
653             true
654         }
655
656         fn parse_src_file_hash(slot: &mut Option<SourceFileHashAlgorithm>, v: Option<&str>) -> bool {
657             match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
658                 Some(hash_kind) => *slot = Some(hash_kind),
659                 _ => return false,
660             }
661             true
662         }
663
664         fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
665             match v {
666                 Some(s) => {
667                     if !slot.is_empty() {
668                         slot.push_str(",");
669                     }
670                     slot.push_str(s);
671                     true
672                 }
673                 None => false,
674             }
675         }
676     }
677 ) }
678
679 options! {CodegenOptions, CodegenSetter, basic_codegen_options,
680           build_codegen_options, "C", "codegen",
681           CG_OPTIONS, cg_type_desc, cgsetters,
682
683     // This list is in alphabetical order.
684     //
685     // If you add a new option, please update:
686     // - src/librustc_interface/tests.rs
687     // - src/doc/rustc/src/codegen-options/index.md
688
689     ar: String = (String::new(), parse_string, [UNTRACKED],
690         "this option is deprecated and does nothing"),
691     code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
692         "choose the code model to use (`rustc --print code-models` for details)"),
693     codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
694         "divide crate into N units to optimize in parallel"),
695     control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
696         "use Windows Control Flow Guard (default: no)"),
697     debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
698         "explicitly enable the `cfg(debug_assertions)` directive"),
699     debuginfo: usize = (0, parse_uint, [TRACKED],
700         "debug info emission level (0 = no debug info, 1 = line tables only, \
701         2 = full debug info with variable and type information; default: 0)"),
702     default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
703         "allow the linker to link its default libraries (default: no)"),
704     embed_bitcode: bool = (true, parse_bool, [TRACKED],
705         "emit bitcode in rlibs (default: yes)"),
706     extra_filename: String = (String::new(), parse_string, [UNTRACKED],
707         "extra data to put in each output filename"),
708     force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
709         "force use of the frame pointers"),
710     force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
711         "force use of unwind tables"),
712     incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
713         "enable incremental compilation"),
714     inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
715         "set the threshold for inlining a function"),
716     link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
717         "a single extra argument to append to the linker invocation (can be used several times)"),
718     link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
719         "extra arguments to append to the linker invocation (space separated)"),
720     link_dead_code: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
721         "keep dead code at link time (useful for code coverage) (default: no)"),
722     linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
723         "system linker to link outputs with"),
724     linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
725         "linker flavor"),
726     linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
727         parse_linker_plugin_lto, [TRACKED],
728         "generate build artifacts that are compatible with linker-based LTO"),
729     llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
730         "a list of arguments to pass to LLVM (space separated)"),
731     lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
732         "perform LLVM link-time optimizations"),
733     metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
734         "metadata to mangle symbol names with"),
735     no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
736         "give an empty list of passes to the pass manager"),
737     no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
738         "disable the use of the redzone"),
739     no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
740         "this option is deprecated and does nothing"),
741     no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
742         "disable loop vectorization optimization passes"),
743     no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
744         "disable LLVM's SLP vectorization pass"),
745     opt_level: String = ("0".to_string(), parse_string, [TRACKED],
746         "optimization level (0-3, s, or z; default: 0)"),
747     overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
748         "use overflow checks for integer arithmetic"),
749     panic: Option<PanicStrategy> = (None, parse_panic_strategy, [TRACKED],
750         "panic strategy to compile crate with"),
751     passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
752         "a list of extra LLVM passes to run (space separated)"),
753     prefer_dynamic: bool = (false, parse_bool, [TRACKED],
754         "prefer dynamic linking to static linking (default: no)"),
755     profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
756         parse_switch_with_opt_path, [TRACKED],
757         "compile the program with profiling instrumentation"),
758     profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
759         "use the given `.profdata` file for profile-guided optimization"),
760     relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
761         "control generation of position-independent code (PIC) \
762         (`rustc --print relocation-models` for details)"),
763     remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
764         "print remarks for these optimization passes (space separated, or \"all\")"),
765     rpath: bool = (false, parse_bool, [UNTRACKED],
766         "set rpath values in libs/exes (default: no)"),
767     save_temps: bool = (false, parse_bool, [UNTRACKED],
768         "save all temporary output files during compilation (default: no)"),
769     soft_float: bool = (false, parse_bool, [TRACKED],
770         "use soft float ABI (*eabihf targets only) (default: no)"),
771     target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
772         "select target processor (`rustc --print target-cpus` for details)"),
773     target_feature: String = (String::new(), parse_target_feature, [TRACKED],
774         "target specific attributes. (`rustc --print target-features` for details). \
775         This feature is unsafe."),
776
777     // This list is in alphabetical order.
778     //
779     // If you add a new option, please update:
780     // - src/librustc_interface/tests.rs
781     // - src/doc/rustc/src/codegen-options/index.md
782 }
783
784 options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
785           build_debugging_options, "Z", "debugging",
786           DB_OPTIONS, db_type_desc, dbsetters,
787
788     // This list is in alphabetical order.
789     //
790     // If you add a new option, please update:
791     // - src/librustc_interface/tests.rs
792
793     allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
794         "only allow the listed language features to be enabled in code (space separated)"),
795     always_encode_mir: bool = (false, parse_bool, [TRACKED],
796         "encode MIR of all functions into the crate metadata (default: no)"),
797     asm_comments: bool = (false, parse_bool, [TRACKED],
798         "generate comments into the assembly (may change behavior) (default: no)"),
799     ast_json: bool = (false, parse_bool, [UNTRACKED],
800         "print the AST as JSON and halt (default: no)"),
801     ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
802         "print the pre-expansion AST as JSON and halt (default: no)"),
803     binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
804         "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
805         (default: no)"),
806     borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
807         "select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
808     borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
809         "gather borrowck statistics (default: no)"),
810     cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
811         "the codegen unit partitioning strategy to use"),
812     chalk: bool = (false, parse_bool, [TRACKED],
813         "enable the experimental Chalk-based trait solving engine"),
814     codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
815         "the backend to use"),
816     crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
817         "inject the given attribute in the crate"),
818     debug_macros: bool = (false, parse_bool, [TRACKED],
819         "emit line numbers debug info inside macros (default: no)"),
820     deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
821         "deduplicate identical diagnostics (default: yes)"),
822     dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
823         "in dep-info output, omit targets for tracking dependencies of the dep-info files \
824         themselves (default: no)"),
825     dep_tasks: bool = (false, parse_bool, [UNTRACKED],
826         "print tasks that execute and the color their dep node gets (requires debug build) \
827         (default: no)"),
828     dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
829         "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
830         (default: no)"),
831     dual_proc_macros: bool = (false, parse_bool, [TRACKED],
832         "load proc macros for both target and host, but only link to the target (default: no)"),
833     dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
834         "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
835         (default: no)"),
836     dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
837         "dump MIR state to file.
838         `val` is used to select which passes and functions to dump. For example:
839         `all` matches all passes and functions,
840         `foo` matches all passes for functions whose name contains 'foo',
841         `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
842         `foo | bar` all passes for function names containing 'foo' or 'bar'."),
843     dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
844         "in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
845         (default: no)"),
846     dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
847         "the directory the MIR is dumped into (default: `mir_dump`)"),
848     dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
849         "exclude the pass number when dumping MIR (used in tests) (default: no)"),
850     dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
851         "in addition to `.mir` files, create graphviz `.dot` files (default: no)"),
852     emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
853         "emit a section containing stack size metadata (default: no)"),
854     fewer_names: bool = (false, parse_bool, [TRACKED],
855         "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
856         (default: no)"),
857     force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
858         "force overflow checks on or off"),
859     force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
860         "force all crates to be `rustc_private` unstable (default: no)"),
861     fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
862         "set the optimization fuel quota for a crate"),
863     hir_stats: bool = (false, parse_bool, [UNTRACKED],
864         "print some statistics about AST and HIR (default: no)"),
865     human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
866         "generate human-readable, predictable names for codegen units (default: no)"),
867     identify_regions: bool = (false, parse_bool, [UNTRACKED],
868         "display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
869     incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
870         "ignore spans during ICH computation -- used for testing (default: no)"),
871     incremental_info: bool = (false, parse_bool, [UNTRACKED],
872         "print high-level information about incremental reuse (or the lack thereof) \
873         (default: no)"),
874     incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
875         "verify incr. comp. hashes of green query instances (default: no)"),
876     inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
877         "control whether `#[inline]` functions are in all CGUs"),
878     input_stats: bool = (false, parse_bool, [UNTRACKED],
879         "gather statistics about the input (default: no)"),
880     insert_sideeffect: bool = (false, parse_bool, [TRACKED],
881         "fix undefined behavior when a thread doesn't eventually make progress \
882         (such as entering an empty infinite loop) by inserting llvm.sideeffect \
883         (default: no)"),
884     instrument_coverage: bool = (false, parse_bool, [TRACKED],
885         "instrument the generated code to support LLVM source-based code coverage \
886         reports (note, the compiler build config must include `profiler = true`, \
887         and is mutually exclusive with `-C profile-generate`/`-C profile-use`); \
888         implies `-C link-dead-code` (unless targeting MSVC, or explicitly disabled) \
889         and `-Z symbol-mangling-version=v0`; disables/overrides some Rust \
890         optimizations (default: no)"),
891     instrument_mcount: bool = (false, parse_bool, [TRACKED],
892         "insert function instrument code for mcount-based tracing (default: no)"),
893     keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
894         "keep hygiene data after analysis (default: no)"),
895     link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
896         "link native libraries in the linker invocation (default: yes)"),
897     link_self_contained: Option<bool> = (None, parse_opt_bool, [TRACKED],
898         "control whether to link Rust provided C objects/libraries or rely
899          on C toolchain installed in the system"),
900     link_only: bool = (false, parse_bool, [TRACKED],
901         "link the `.rlink` file generated by `-Z no-link` (default: no)"),
902     llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
903         "generate JSON tracing data file from LLVM data (default: no)"),
904     ls: bool = (false, parse_bool, [UNTRACKED],
905         "list the symbols defined by a library crate (default: no)"),
906     macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
907         "show macro backtraces (default: no)"),
908     merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
909         "control the operation of the MergeFunctions LLVM pass, taking \
910         the same values as the target option of the same name"),
911     meta_stats: bool = (false, parse_bool, [UNTRACKED],
912         "gather metadata statistics (default: no)"),
913     mir_emit_retag: bool = (false, parse_bool, [TRACKED],
914         "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
915         (default: no)"),
916     mir_opt_level: usize = (1, parse_uint, [TRACKED],
917         "MIR optimization level (0-3; default: 1)"),
918     mutable_noalias: bool = (false, parse_bool, [TRACKED],
919         "emit noalias metadata for mutable references (default: no)"),
920     new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED],
921         "use new LLVM pass manager (default: no)"),
922     nll_facts: bool = (false, parse_bool, [UNTRACKED],
923         "dump facts from NLL analysis into side files (default: no)"),
924     no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
925         "parse and expand the source, but run no analysis"),
926     no_codegen: bool = (false, parse_no_flag, [TRACKED],
927         "run all passes except codegen; no output"),
928     no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
929         "omit DWARF address ranges that give faster lookups"),
930     no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
931         "execute lints separately; allows benchmarking individual lints"),
932     no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
933         "disable the 'leak check' for subtyping; unsound, but useful for tests"),
934     no_link: bool = (false, parse_no_flag, [TRACKED],
935         "compile without linking"),
936     no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
937         "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
938     no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
939         "prevent automatic injection of the profiler_builtins crate"),
940     osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
941         "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
942     panic_abort_tests: bool = (false, parse_bool, [TRACKED],
943         "support compiling tests with panic=abort (default: no)"),
944     parse_only: bool = (false, parse_bool, [UNTRACKED],
945         "parse only; do not compile, assemble, or link (default: no)"),
946     perf_stats: bool = (false, parse_bool, [UNTRACKED],
947         "print some performance-related statistics (default: no)"),
948     plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
949         "whether to use the PLT when calling into shared libraries;
950         only has effect for PIC code on systems with ELF binaries
951         (default: PLT is disabled if full relro is enabled)"),
952     polonius: bool = (false, parse_bool, [UNTRACKED],
953         "enable polonius-based borrow-checker (default: no)"),
954     polymorphize: bool = (false, parse_bool, [TRACKED],
955           "perform polymorphization analysis"),
956     pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
957         "a single extra argument to prepend the linker invocation (can be used several times)"),
958     pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
959         "extra arguments to prepend to the linker invocation (space separated)"),
960     print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
961         "make rustc print the total optimization fuel used by a crate"),
962     print_link_args: bool = (false, parse_bool, [UNTRACKED],
963         "print the arguments passed to the linker (default: no)"),
964     print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
965         "print the LLVM optimization passes being run (default: no)"),
966     print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
967         "print the result of the monomorphization collection pass"),
968     print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
969         "print layout information for each type encountered (default: no)"),
970     proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
971          "show backtraces for panics during proc-macro execution (default: no)"),
972     profile: bool = (false, parse_bool, [TRACKED],
973         "insert profiling code (default: no)"),
974     profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
975         "file path to emit profiling data at runtime when using 'profile' \
976         (default based on relative source path)"),
977     query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
978         "enable queries of the dependency graph for regression testing (default: no)"),
979     query_stats: bool = (false, parse_bool, [UNTRACKED],
980         "print some statistics about the query system (default: no)"),
981     relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
982         "choose which RELRO level to use"),
983     report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
984         "immediately print bugs registered with `delay_span_bug` (default: no)"),
985     // The default historical behavior was to always run dsymutil, so we're
986     // preserving that temporarily, but we're likely to switch the default
987     // soon.
988     run_dsymutil: bool = (true, parse_bool, [TRACKED],
989         "if on Mac, run `dsymutil` and delete intermediate object files (default: yes)"),
990     sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
991         "use a sanitizer"),
992     sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
993         "enable origins tracking in MemorySanitizer"),
994     sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
995         "enable recovery for selected sanitizers"),
996     saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
997         "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
998         the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
999     save_analysis: bool = (false, parse_bool, [UNTRACKED],
1000         "write syntax and type analysis (in JSON format) information, in \
1001         addition to normal output (default: no)"),
1002     self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
1003         parse_switch_with_opt_path, [UNTRACKED],
1004         "run the self profiler and output the raw event data"),
1005     // keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1006     self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
1007         "specify the events recorded by the self profiler;
1008         for example: `-Z self-profile-events=default,query-keys`
1009         all options: none, all, default, generic-activity, query-provider, query-cache-hit
1010                      query-blocked, incr-cache-load, query-keys, function-args, args, llvm"),
1011     share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
1012         "make the current crate share its generic instantiations"),
1013     show_span: Option<String> = (None, parse_opt_string, [TRACKED],
1014         "show spans for compiler debugging (expr|pat|ty)"),
1015     span_debug: bool = (false, parse_bool, [UNTRACKED],
1016         "forward proc_macro::Span's `Debug` impl to `Span`"),
1017     // o/w tests have closure@path
1018     span_free_formats: bool = (false, parse_bool, [UNTRACKED],
1019         "exclude spans when debug-printing compiler state (default: no)"),
1020     src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
1021         "hash algorithm of source files in debug info (`md5`, or `sha1`)"),
1022     strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1023         "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1024     symbol_mangling_version: SymbolManglingVersion = (SymbolManglingVersion::Legacy,
1025         parse_symbol_mangling_version, [TRACKED],
1026         "which mangling version to use for symbol names"),
1027     teach: bool = (false, parse_bool, [TRACKED],
1028         "show extended diagnostic help (default: no)"),
1029     terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
1030         "set the current terminal width"),
1031     thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
1032         "enable ThinLTO when possible"),
1033     // We default to 1 here since we want to behave like
1034     // a sequential compiler for now. This'll likely be adjusted
1035     // in the future. Note that -Zthreads=0 is the way to get
1036     // the num_cpus behavior.
1037     threads: usize = (1, parse_threads, [UNTRACKED],
1038         "use a thread pool with N threads"),
1039     time: bool = (false, parse_bool, [UNTRACKED],
1040         "measure time of rustc processes (default: no)"),
1041     time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1042         "measure time of each LLVM pass (default: no)"),
1043     time_passes: bool = (false, parse_bool, [UNTRACKED],
1044         "measure time of each rustc pass (default: no)"),
1045     tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
1046         "choose the TLS model to use (`rustc --print tls-models` for details)"),
1047     trace_macros: bool = (false, parse_bool, [UNTRACKED],
1048         "for every macro invocation, print its name and arguments (default: no)"),
1049     treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
1050         "treat error number `val` that occurs as bug"),
1051     ui_testing: bool = (false, parse_bool, [UNTRACKED],
1052         "emit compiler diagnostics in a form suitable for UI testing (default: no)"),
1053     unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
1054         "take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
1055     unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1056         "present the input source, unstable (and less-pretty) variants;
1057         valid types are any of the types for `--pretty`, as well as:
1058         `expanded`, `expanded,identified`,
1059         `expanded,hygiene` (with internal representations),
1060         `everybody_loops` (all function bodies replaced with `loop {}`),
1061         `hir` (the HIR), `hir,identified`,
1062         `hir,typed` (HIR with types for each node),
1063         `hir-tree` (dump the raw HIR),
1064         `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
1065     unstable_options: bool = (false, parse_bool, [UNTRACKED],
1066         "adds unstable command line options to rustc interface (default: no)"),
1067     use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
1068         "use legacy .ctors section for initializers rather than .init_array"),
1069     validate_mir: bool = (false, parse_bool, [UNTRACKED],
1070         "validate MIR after each transformation"),
1071     verbose: bool = (false, parse_bool, [UNTRACKED],
1072         "in general, enable more debug printouts (default: no)"),
1073     verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
1074         "verify LLVM IR (default: no)"),
1075
1076     // This list is in alphabetical order.
1077     //
1078     // If you add a new option, please update:
1079     // - src/librustc_interface/tests.rs
1080 }