3 use crate::early_error;
5 use crate::search_paths::SearchPath;
6 use crate::utils::NativeLibKind;
8 use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy, SanitizerSet};
9 use rustc_target::spec::{RelocModel, RelroLevel, SplitDebuginfo, TargetTriple, TlsModel};
11 use rustc_feature::UnstableFeatures;
12 use rustc_span::edition::Edition;
13 use rustc_span::SourceFileHashAlgorithm;
15 use std::collections::BTreeMap;
17 use std::collections::hash_map::DefaultHasher;
18 use std::hash::Hasher;
19 use std::num::NonZeroUsize;
20 use std::path::PathBuf;
23 macro_rules! hash_option {
24 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [UNTRACKED]) => {{}};
25 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [TRACKED]) => {{
27 .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
30 panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
35 macro_rules! top_level_options {
36 (pub struct Options { $(
37 $opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
45 pub fn dep_tracking_hash(&self) -> u64 {
46 let mut sub_hashes = BTreeMap::new();
51 [$dep_tracking_marker $($warn_val,
53 self.error_format)*]);
55 let mut hasher = DefaultHasher::new();
56 dep_tracking::stable_hash(sub_hashes,
65 // The top-level command-line options struct.
67 // For each option, one has to specify how it behaves with regard to the
68 // dependency tracking system of incremental compilation. This is done via the
69 // square-bracketed directive after the field type. The options are:
72 // A change in the given field will cause the compiler to completely clear the
73 // incremental compilation cache before proceeding.
76 // Incremental compilation is not influenced by this option.
78 // If you add a new option to this struct or one of the sub-structs like
79 // `CodegenOptions`, think about how it influences incremental compilation. If in
80 // doubt, specify [TRACKED], which is always "correct" but might lead to
81 // unnecessary re-compilation.
84 // The crate config requested for the session, which may be combined
85 // with additional crate configurations during the compile process.
86 crate_types: Vec<CrateType> [TRACKED],
87 optimize: OptLevel [TRACKED],
88 // Include the `debug_assertions` flag in dependency tracking, since it
89 // can influence whether overflow checks are done or not.
90 debug_assertions: bool [TRACKED],
91 debuginfo: DebugInfo [TRACKED],
92 lint_opts: Vec<(String, lint::Level)> [TRACKED],
93 lint_cap: Option<lint::Level> [TRACKED],
94 describe_lints: bool [UNTRACKED],
95 output_types: OutputTypes [TRACKED],
96 search_paths: Vec<SearchPath> [UNTRACKED],
97 libs: Vec<(String, Option<String>, NativeLibKind)> [TRACKED],
98 maybe_sysroot: Option<PathBuf> [UNTRACKED],
100 target_triple: TargetTriple [TRACKED],
102 test: bool [TRACKED],
103 error_format: ErrorOutputType [UNTRACKED],
105 // If `Some`, enable incremental compilation, using the given
106 // directory to store intermediate results.
107 incremental: Option<PathBuf> [UNTRACKED],
109 debugging_opts: DebuggingOptions [TRACKED],
110 prints: Vec<PrintRequest> [UNTRACKED],
111 // Determines which borrow checker(s) to run. This is the parsed, sanitized
112 // version of `debugging_opts.borrowck`, which is just a plain string.
113 borrowck_mode: BorrowckMode [UNTRACKED],
114 cg: CodegenOptions [TRACKED],
115 externs: Externs [UNTRACKED],
116 extern_dep_specs: ExternDepSpecs [UNTRACKED],
117 crate_name: Option<String> [TRACKED],
118 // An optional name to use as the crate for std during std injection,
119 // written `extern crate name as std`. Defaults to `std`. Used by
120 // out-of-tree drivers.
121 alt_std_name: Option<String> [TRACKED],
122 // Indicates how the compiler should treat unstable features.
123 unstable_features: UnstableFeatures [TRACKED],
125 // Indicates whether this run of the compiler is actually rustdoc. This
126 // is currently just a hack and will be removed eventually, so please
127 // try to not rely on this too much.
128 actually_rustdoc: bool [TRACKED],
130 // Control path trimming.
131 trimmed_def_paths: TrimmedDefPaths [TRACKED],
133 // Specifications of codegen units / ThinLTO which are forced as a
134 // result of parsing command line options. These are not necessarily
135 // what rustc was invoked with, but massaged a bit to agree with
136 // commands like `--emit llvm-ir` which they're often incompatible with
137 // if we otherwise use the defaults of rustc.
138 cli_forced_codegen_units: Option<usize> [UNTRACKED],
139 cli_forced_thinlto_off: bool [UNTRACKED],
141 // Remap source path prefixes in all output (messages, object files, debug, etc.).
142 remap_path_prefix: Vec<(PathBuf, PathBuf)> [UNTRACKED],
144 edition: Edition [TRACKED],
146 // `true` if we're emitting JSON blobs about each artifact produced
148 json_artifact_notifications: bool [TRACKED],
150 pretty: Option<PpMode> [UNTRACKED],
154 /// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
155 /// macro is to define an interface that can be programmatically used by the option parser
156 /// to initialize the struct without hardcoding field names all over the place.
158 /// The goal is to invoke this macro once with the correct fields, and then this macro generates all
159 /// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
160 /// generated code to parse an option into its respective field in the struct. There are a few
161 /// hand-written parsers for parsing specific types of values in this module.
162 macro_rules! options {
163 ($struct_name:ident, $setter_name:ident, $defaultfn:ident,
164 $buildfn:ident, $prefix:expr, $outputname:expr,
165 $stat:ident, $mod_desc:ident, $mod_set:ident,
166 $($opt:ident : $t:ty = (
169 [$dep_tracking_marker:ident $(($dep_warn_val:expr, $dep_warn_text:expr))*],
174 pub struct $struct_name { $(pub $opt: $t),* }
176 pub fn $defaultfn() -> $struct_name {
177 $struct_name { $($opt: $init),* }
180 pub fn $buildfn(matches: &getopts::Matches, error_format: ErrorOutputType) -> $struct_name
182 let mut op = $defaultfn();
183 for option in matches.opt_strs($prefix) {
184 let (key, value) = match option.split_once('=') {
185 None => (option, None),
186 Some((k, v)) => (k.to_string(), Some(v)),
188 let option_to_lookup = key.replace("-", "_");
189 let mut found = false;
190 for &(candidate, setter, type_desc, _) in $stat {
191 if option_to_lookup != candidate { continue }
192 if !setter(&mut op, value) {
195 early_error(error_format, &format!("{0} option `{1}` requires \
196 {2} ({3} {1}=<value>)",
201 early_error(error_format, &format!("incorrect value `{}` for {} \
202 option `{}` - {} was expected",
212 early_error(error_format, &format!("unknown {} option: `{}`",
219 impl dep_tracking::DepTrackingHash for $struct_name {
220 fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
221 let mut sub_hashes = BTreeMap::new();
226 [$dep_tracking_marker $($dep_warn_val,
230 dep_tracking::stable_hash(sub_hashes, hasher, error_format);
234 pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
235 pub const $stat: &[(&str, $setter_name, &str, &str)] =
236 &[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
238 #[allow(non_upper_case_globals, dead_code)]
240 pub const parse_no_flag: &str = "no value";
241 pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
242 pub const parse_opt_bool: &str = parse_bool;
243 pub const parse_string: &str = "a string";
244 pub const parse_opt_string: &str = parse_string;
245 pub const parse_string_push: &str = parse_string;
246 pub const parse_opt_pathbuf: &str = "a path";
247 pub const parse_pathbuf_push: &str = parse_opt_pathbuf;
248 pub const parse_list: &str = "a space-separated list of strings";
249 pub const parse_opt_list: &str = parse_list;
250 pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
251 pub const parse_uint: &str = "a number";
252 pub const parse_opt_uint: &str = parse_uint;
253 pub const parse_threads: &str = parse_uint;
254 pub const parse_passes: &str = "a space-separated list of passes, or `all`";
255 pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
256 pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
257 pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
258 pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
259 pub const parse_cfguard: &str =
260 "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
261 pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
262 pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
263 pub const parse_optimization_fuel: &str = "crate=integer";
264 pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
265 pub const parse_instrument_coverage: &str = "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
266 pub const parse_unpretty: &str = "`string` or `string=string`";
267 pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
268 pub const parse_lto: &str =
269 "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
270 pub const parse_linker_plugin_lto: &str =
271 "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
272 pub const parse_switch_with_opt_path: &str =
273 "an optional path to the profiling data output directory";
274 pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
275 pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
276 pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
277 pub const parse_relocation_model: &str =
278 "one of supported relocation models (`rustc --print relocation-models`)";
279 pub const parse_code_model: &str =
280 "one of supported code models (`rustc --print code-models`)";
281 pub const parse_tls_model: &str =
282 "one of supported TLS models (`rustc --print tls-models`)";
283 pub const parse_target_feature: &str = parse_string;
284 pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
285 pub const parse_split_debuginfo: &str =
286 "one of supported split-debuginfo modes (`off` or `dsymutil`)";
292 use std::str::FromStr;
294 // Sometimes different options need to build a common structure.
295 // That structure can kept in one of the options' fields, the others become dummy.
296 macro_rules! redirect_field {
297 ($cg:ident.link_arg) => { $cg.link_args };
298 ($cg:ident.pre_link_arg) => { $cg.pre_link_args };
299 ($cg:ident.$field:ident) => { $cg.$field };
303 pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
304 $parse(&mut redirect_field!(cg.$opt), v)
308 /// This is for boolean options that don't take a value and start with
309 /// `no-`. This style of option is deprecated.
310 fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
312 None => { *slot = true; true }
317 /// Use this for any boolean option that has a static default.
318 fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
320 Some("y") | Some("yes") | Some("on") | None => { *slot = true; true }
321 Some("n") | Some("no") | Some("off") => { *slot = false; true }
326 /// Use this for any boolean option that lacks a static default. (The
327 /// actions taken when such an option is not specified will depend on
328 /// other factors, such as other options, or target options.)
329 fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
331 Some("y") | Some("yes") | Some("on") | None => { *slot = Some(true); true }
332 Some("n") | Some("no") | Some("off") => { *slot = Some(false); true }
337 /// Use this for any string option that has a static default.
338 fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
340 Some(s) => { *slot = s.to_string(); true },
345 /// Use this for any string option that lacks a static default.
346 fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
348 Some(s) => { *slot = Some(s.to_string()); true },
353 fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
355 Some(s) => { *slot = Some(PathBuf::from(s)); true },
360 fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
362 Some(s) => { slot.push(s.to_string()); true },
367 fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
369 Some(s) => { slot.push(PathBuf::from(s)); true },
374 fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
378 slot.extend(s.split_whitespace().map(|s| s.to_string()));
385 fn parse_opt_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
389 let v = s.split_whitespace().map(|s| s.to_string()).collect();
397 fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
401 let v = s.split(',').map(|s| s.to_string()).collect();
409 fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
410 match v.and_then(|s| s.parse().ok()) {
411 Some(0) => { *slot = ::num_cpus::get(); true },
412 Some(i) => { *slot = i; true },
417 /// Use this for any uint option that has a static default.
418 fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
419 match v.and_then(|s| s.parse().ok()) {
420 Some(i) => { *slot = i; true },
425 /// Use this for any uint option that lacks a static default.
426 fn parse_opt_uint(slot: &mut Option<usize>, v: Option<&str>) -> bool {
428 Some(s) => { *slot = s.parse().ok(); slot.is_some() }
433 fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
440 let mut passes = vec![];
441 if parse_list(&mut passes, v) {
442 *slot = Passes::Some(passes);
451 fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
453 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
454 Some("abort") => *slot = Some(PanicStrategy::Abort),
460 fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
463 match s.parse::<RelroLevel>() {
464 Ok(level) => *slot = Some(level),
473 fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
475 for s in v.split(',') {
477 "address" => SanitizerSet::ADDRESS,
478 "leak" => SanitizerSet::LEAK,
479 "memory" => SanitizerSet::MEMORY,
480 "thread" => SanitizerSet::THREAD,
481 "hwaddress" => SanitizerSet::HWADDRESS,
491 fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
493 Some("2") | None => { *slot = 2; true }
494 Some("1") => { *slot = 1; true }
495 Some("0") => { *slot = 0; true }
500 fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
502 Some("none") => *slot = Strip::None,
503 Some("debuginfo") => *slot = Strip::Debuginfo,
504 Some("symbols") => *slot = Strip::Symbols,
510 fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
512 let mut bool_arg = None;
513 if parse_opt_bool(&mut bool_arg, v) {
514 *slot = if bool_arg.unwrap() {
524 None => CFGuard::Checks,
525 Some("checks") => CFGuard::Checks,
526 Some("nochecks") => CFGuard::NoChecks,
527 Some(_) => return false,
532 fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
533 match v.and_then(LinkerFlavor::from_str) {
534 Some(lf) => *slote = Some(lf),
540 fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
544 let parts = s.split('=').collect::<Vec<_>>();
545 if parts.len() != 2 { return false; }
546 let crate_name = parts[0].to_string();
547 let fuel = parts[1].parse::<u64>();
548 if fuel.is_err() { return false; }
549 *slot = Some((crate_name, fuel.unwrap()));
555 fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
558 Some(s) if s.split('=').count() <= 2 => {
559 *slot = Some(s.to_string());
566 fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
568 let mut bool_arg = None;
569 if parse_opt_bool(&mut bool_arg, v) {
570 *slot = if bool_arg.unwrap() {
571 Some(MirSpanview::Statement)
581 *slot = Some(MirSpanview::Statement);
587 *slot = Some(match v.trim_end_matches("s") {
588 "statement" | "stmt" => MirSpanview::Statement,
589 "terminator" | "term" => MirSpanview::Terminator,
590 "block" | "basicblock" => MirSpanview::Block,
596 fn parse_instrument_coverage(slot: &mut Option<InstrumentCoverage>, v: Option<&str>) -> bool {
598 let mut bool_arg = None;
599 if parse_opt_bool(&mut bool_arg, v) {
600 *slot = if bool_arg.unwrap() {
601 Some(InstrumentCoverage::All)
611 *slot = Some(InstrumentCoverage::All);
617 *slot = Some(match v {
618 "all" => InstrumentCoverage::All,
619 "except-unused-generics" | "except_unused_generics" => {
620 InstrumentCoverage::ExceptUnusedGenerics
622 "except-unused-functions" | "except_unused_functions" => {
623 InstrumentCoverage::ExceptUnusedFunctions
625 "off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
631 fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
633 Some(s) => { *slot = s.parse().ok(); slot.is_some() }
634 None => { *slot = NonZeroUsize::new(1); true }
638 fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
640 let mut bool_arg = None;
641 if parse_opt_bool(&mut bool_arg, v) {
642 *slot = if bool_arg.unwrap() {
652 None => LtoCli::NoParam,
653 Some("thin") => LtoCli::Thin,
654 Some("fat") => LtoCli::Fat,
655 Some(_) => return false,
660 fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
662 let mut bool_arg = None;
663 if parse_opt_bool(&mut bool_arg, v) {
664 *slot = if bool_arg.unwrap() {
665 LinkerPluginLto::LinkerPluginAuto
667 LinkerPluginLto::Disabled
674 None => LinkerPluginLto::LinkerPluginAuto,
675 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
680 fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
682 None => SwitchWithOptPath::Enabled(None),
683 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
688 fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
689 match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
690 Some(mergefunc) => *slot = Some(mergefunc),
696 fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
697 match v.and_then(|s| RelocModel::from_str(s).ok()) {
698 Some(relocation_model) => *slot = Some(relocation_model),
699 None if v == Some("default") => *slot = None,
705 fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
706 match v.and_then(|s| CodeModel::from_str(s).ok()) {
707 Some(code_model) => *slot = Some(code_model),
713 fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
714 match v.and_then(|s| TlsModel::from_str(s).ok()) {
715 Some(tls_model) => *slot = Some(tls_model),
721 fn parse_symbol_mangling_version(
722 slot: &mut Option<SymbolManglingVersion>,
726 Some("legacy") => Some(SymbolManglingVersion::Legacy),
727 Some("v0") => Some(SymbolManglingVersion::V0),
733 fn parse_src_file_hash(slot: &mut Option<SourceFileHashAlgorithm>, v: Option<&str>) -> bool {
734 match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
735 Some(hash_kind) => *slot = Some(hash_kind),
741 fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
744 if !slot.is_empty() {
754 fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
756 Some("command") => *slot = Some(WasiExecModel::Command),
757 Some("reactor") => *slot = Some(WasiExecModel::Reactor),
763 fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
764 match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
765 Some(e) => *slot = Some(e),
773 options! {CodegenOptions, CodegenSetter, basic_codegen_options,
774 build_codegen_options, "C", "codegen",
775 CG_OPTIONS, cg_type_desc, cgsetters,
777 // This list is in alphabetical order.
779 // If you add a new option, please update:
780 // - compiler/rustc_interface/src/tests.rs
781 // - src/doc/rustc/src/codegen-options/index.md
783 ar: String = (String::new(), parse_string, [UNTRACKED],
784 "this option is deprecated and does nothing"),
785 code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
786 "choose the code model to use (`rustc --print code-models` for details)"),
787 codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
788 "divide crate into N units to optimize in parallel"),
789 control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
790 "use Windows Control Flow Guard (default: no)"),
791 debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
792 "explicitly enable the `cfg(debug_assertions)` directive"),
793 debuginfo: usize = (0, parse_uint, [TRACKED],
794 "debug info emission level (0 = no debug info, 1 = line tables only, \
795 2 = full debug info with variable and type information; default: 0)"),
796 default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
797 "allow the linker to link its default libraries (default: no)"),
798 embed_bitcode: bool = (true, parse_bool, [TRACKED],
799 "emit bitcode in rlibs (default: yes)"),
800 extra_filename: String = (String::new(), parse_string, [UNTRACKED],
801 "extra data to put in each output filename"),
802 force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
803 "force use of the frame pointers"),
804 force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
805 "force use of unwind tables"),
806 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
807 "enable incremental compilation"),
808 inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
809 "set the threshold for inlining a function"),
810 link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
811 "a single extra argument to append to the linker invocation (can be used several times)"),
812 link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
813 "extra arguments to append to the linker invocation (space separated)"),
814 link_dead_code: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
815 "keep dead code at link time (useful for code coverage) (default: no)"),
816 link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
817 "control whether to link Rust provided C objects/libraries or rely
818 on C toolchain installed in the system"),
819 linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
820 "system linker to link outputs with"),
821 linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
823 linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
824 parse_linker_plugin_lto, [TRACKED],
825 "generate build artifacts that are compatible with linker-based LTO"),
826 llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
827 "a list of arguments to pass to LLVM (space separated)"),
828 lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
829 "perform LLVM link-time optimizations"),
830 metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
831 "metadata to mangle symbol names with"),
832 no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
833 "give an empty list of passes to the pass manager"),
834 no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
835 "disable the use of the redzone"),
836 no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
837 "this option is deprecated and does nothing"),
838 no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
839 "disable loop vectorization optimization passes"),
840 no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
841 "disable LLVM's SLP vectorization pass"),
842 opt_level: String = ("0".to_string(), parse_string, [TRACKED],
843 "optimization level (0-3, s, or z; default: 0)"),
844 overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
845 "use overflow checks for integer arithmetic"),
846 panic: Option<PanicStrategy> = (None, parse_panic_strategy, [TRACKED],
847 "panic strategy to compile crate with"),
848 passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
849 "a list of extra LLVM passes to run (space separated)"),
850 prefer_dynamic: bool = (false, parse_bool, [TRACKED],
851 "prefer dynamic linking to static linking (default: no)"),
852 profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
853 parse_switch_with_opt_path, [TRACKED],
854 "compile the program with profiling instrumentation"),
855 profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
856 "use the given `.profdata` file for profile-guided optimization"),
857 relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
858 "control generation of position-independent code (PIC) \
859 (`rustc --print relocation-models` for details)"),
860 remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
861 "print remarks for these optimization passes (space separated, or \"all\")"),
862 rpath: bool = (false, parse_bool, [UNTRACKED],
863 "set rpath values in libs/exes (default: no)"),
864 save_temps: bool = (false, parse_bool, [UNTRACKED],
865 "save all temporary output files during compilation (default: no)"),
866 soft_float: bool = (false, parse_bool, [TRACKED],
867 "use soft float ABI (*eabihf targets only) (default: no)"),
868 split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
869 "how to handle split-debuginfo, a platform-specific option"),
870 target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
871 "select target processor (`rustc --print target-cpus` for details)"),
872 target_feature: String = (String::new(), parse_target_feature, [TRACKED],
873 "target specific attributes. (`rustc --print target-features` for details). \
874 This feature is unsafe."),
876 // This list is in alphabetical order.
878 // If you add a new option, please update:
879 // - compiler/rustc_interface/src/tests.rs
880 // - src/doc/rustc/src/codegen-options/index.md
883 options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
884 build_debugging_options, "Z", "debugging",
885 DB_OPTIONS, db_type_desc, dbsetters,
887 // This list is in alphabetical order.
889 // If you add a new option, please update:
890 // - compiler/rustc_interface/src/tests.rs
892 allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
893 "only allow the listed language features to be enabled in code (space separated)"),
894 always_encode_mir: bool = (false, parse_bool, [TRACKED],
895 "encode MIR of all functions into the crate metadata (default: no)"),
896 assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
897 "make cfg(version) treat the current version as incomplete (default: no)"),
898 asm_comments: bool = (false, parse_bool, [TRACKED],
899 "generate comments into the assembly (may change behavior) (default: no)"),
900 ast_json: bool = (false, parse_bool, [UNTRACKED],
901 "print the AST as JSON and halt (default: no)"),
902 ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
903 "print the pre-expansion AST as JSON and halt (default: no)"),
904 binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
905 "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
907 borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
908 "select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
909 cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
910 "the codegen unit partitioning strategy to use"),
911 chalk: bool = (false, parse_bool, [TRACKED],
912 "enable the experimental Chalk-based trait solving engine"),
913 codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
914 "the backend to use"),
915 combine_cgu: bool = (false, parse_bool, [TRACKED],
916 "combine CGUs into a single one"),
917 crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
918 "inject the given attribute in the crate"),
919 debug_macros: bool = (false, parse_bool, [TRACKED],
920 "emit line numbers debug info inside macros (default: no)"),
921 deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
922 "deduplicate identical diagnostics (default: yes)"),
923 dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
924 "in dep-info output, omit targets for tracking dependencies of the dep-info files \
925 themselves (default: no)"),
926 dep_tasks: bool = (false, parse_bool, [UNTRACKED],
927 "print tasks that execute and the color their dep node gets (requires debug build) \
929 dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
930 "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
932 dual_proc_macros: bool = (false, parse_bool, [TRACKED],
933 "load proc macros for both target and host, but only link to the target (default: no)"),
934 dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
935 "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
937 dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
938 "dump MIR state to file.
939 `val` is used to select which passes and functions to dump. For example:
940 `all` matches all passes and functions,
941 `foo` matches all passes for functions whose name contains 'foo',
942 `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
943 `foo | bar` all passes for function names containing 'foo' or 'bar'."),
944 dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
945 "in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
947 dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
948 "the directory the MIR is dumped into (default: `mir_dump`)"),
949 dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
950 "exclude the pass number when dumping MIR (used in tests) (default: no)"),
951 dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
952 "in addition to `.mir` files, create graphviz `.dot` files (and with \
953 `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived \
954 coverage graph) (default: no)"),
955 dump_mir_spanview: Option<MirSpanview> = (None, parse_mir_spanview, [UNTRACKED],
956 "in addition to `.mir` files, create `.html` files to view spans for \
957 all `statement`s (including terminators), only `terminator` spans, or \
958 computed `block` spans (one span encompassing a block's terminator and \
959 all statements). If `-Z instrument-coverage` is also enabled, create \
960 an additional `.html` file showing the computed coverage spans."),
961 emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED],
962 "emits a future-incompatibility report for lints (RFC 2834)"),
963 emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
964 "emit a section containing stack size metadata (default: no)"),
965 fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
966 "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
968 force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
969 "force overflow checks on or off"),
970 force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
971 "force all crates to be `rustc_private` unstable (default: no)"),
972 fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
973 "set the optimization fuel quota for a crate"),
974 function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
975 "whether each function should go in its own section"),
976 graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
977 "use dark-themed colors in graphviz output (default: no)"),
978 graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
979 "use the given `fontname` in graphviz output; can be overridden by setting \
980 environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
981 hir_stats: bool = (false, parse_bool, [UNTRACKED],
982 "print some statistics about AST and HIR (default: no)"),
983 human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
984 "generate human-readable, predictable names for codegen units (default: no)"),
985 identify_regions: bool = (false, parse_bool, [UNTRACKED],
986 "display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
987 incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
988 "ignore spans during ICH computation -- used for testing (default: no)"),
989 incremental_info: bool = (false, parse_bool, [UNTRACKED],
990 "print high-level information about incremental reuse (or the lack thereof) \
992 incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
993 "verify incr. comp. hashes of green query instances (default: no)"),
994 inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
995 "enable MIR inlining (default: no)"),
996 inline_mir_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
997 "a default MIR inlining threshold (default: 50)"),
998 inline_mir_hint_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
999 "inlining threshold for functions with inline hint (default: 100)"),
1000 inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
1001 "control whether `#[inline]` functions are in all CGUs"),
1002 input_stats: bool = (false, parse_bool, [UNTRACKED],
1003 "gather statistics about the input (default: no)"),
1004 instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1005 "instrument the generated code to support LLVM source-based code coverage \
1006 reports (note, the compiler build config must include `profiler = true`, \
1007 and is mutually exclusive with `-C profile-generate`/`-C profile-use`); \
1008 implies `-Z symbol-mangling-version=v0`; disables/overrides some Rust \
1009 optimizations. Optional values are: `=all` (default coverage), \
1010 `=except-unused-generics`, `=except-unused-functions`, or `=off` \
1011 (default: instrument-coverage=off)"),
1012 instrument_mcount: bool = (false, parse_bool, [TRACKED],
1013 "insert function instrument code for mcount-based tracing (default: no)"),
1014 keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
1015 "keep hygiene data after analysis (default: no)"),
1016 link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
1017 "link native libraries in the linker invocation (default: yes)"),
1018 link_only: bool = (false, parse_bool, [TRACKED],
1019 "link the `.rlink` file generated by `-Z no-link` (default: no)"),
1020 llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
1021 "generate JSON tracing data file from LLVM data (default: no)"),
1022 ls: bool = (false, parse_bool, [UNTRACKED],
1023 "list the symbols defined by a library crate (default: no)"),
1024 macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1025 "show macro backtraces (default: no)"),
1026 merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
1027 "control the operation of the MergeFunctions LLVM pass, taking \
1028 the same values as the target option of the same name"),
1029 meta_stats: bool = (false, parse_bool, [UNTRACKED],
1030 "gather metadata statistics (default: no)"),
1031 mir_emit_retag: bool = (false, parse_bool, [TRACKED],
1032 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
1034 mir_opt_level: Option<usize> = (None, parse_opt_uint, [TRACKED],
1035 "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
1036 mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1037 "emit noalias metadata for mutable references (default: yes for LLVM >= 12, otherwise no)"),
1038 new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED],
1039 "use new LLVM pass manager (default: no)"),
1040 nll_facts: bool = (false, parse_bool, [UNTRACKED],
1041 "dump facts from NLL analysis into side files (default: no)"),
1042 nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
1043 "the directory the NLL facts are dumped into (default: `nll-facts`)"),
1044 no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
1045 "parse and expand the source, but run no analysis"),
1046 no_codegen: bool = (false, parse_no_flag, [TRACKED],
1047 "run all passes except codegen; no output"),
1048 no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
1049 "omit DWARF address ranges that give faster lookups"),
1050 no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
1051 "execute lints separately; allows benchmarking individual lints"),
1052 no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
1053 "disable the 'leak check' for subtyping; unsound, but useful for tests"),
1054 no_link: bool = (false, parse_no_flag, [TRACKED],
1055 "compile without linking"),
1056 no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
1057 "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1058 no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
1059 "prevent automatic injection of the profiler_builtins crate"),
1060 normalize_docs: bool = (false, parse_bool, [TRACKED],
1061 "normalize associated items in rustdoc when generating documentation"),
1062 osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
1063 "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
1064 panic_abort_tests: bool = (false, parse_bool, [TRACKED],
1065 "support compiling tests with panic=abort (default: no)"),
1066 parse_only: bool = (false, parse_bool, [UNTRACKED],
1067 "parse only; do not compile, assemble, or link (default: no)"),
1068 perf_stats: bool = (false, parse_bool, [UNTRACKED],
1069 "print some performance-related statistics (default: no)"),
1070 plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
1071 "whether to use the PLT when calling into shared libraries;
1072 only has effect for PIC code on systems with ELF binaries
1073 (default: PLT is disabled if full relro is enabled)"),
1074 polonius: bool = (false, parse_bool, [TRACKED],
1075 "enable polonius-based borrow-checker (default: no)"),
1076 polymorphize: bool = (false, parse_bool, [TRACKED],
1077 "perform polymorphization analysis"),
1078 pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
1079 "a single extra argument to prepend the linker invocation (can be used several times)"),
1080 pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
1081 "extra arguments to prepend to the linker invocation (space separated)"),
1082 precise_enum_drop_elaboration: bool = (true, parse_bool, [TRACKED],
1083 "use a more precise version of drop elaboration for matches on enums (default: yes). \
1084 This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
1085 See #77382 and #74551."),
1086 print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
1087 "make rustc print the total optimization fuel used by a crate"),
1088 print_link_args: bool = (false, parse_bool, [UNTRACKED],
1089 "print the arguments passed to the linker (default: no)"),
1090 print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1091 "print the LLVM optimization passes being run (default: no)"),
1092 print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
1093 "print the result of the monomorphization collection pass"),
1094 print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
1095 "print layout information for each type encountered (default: no)"),
1096 proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1097 "show backtraces for panics during proc-macro execution (default: no)"),
1098 profile: bool = (false, parse_bool, [TRACKED],
1099 "insert profiling code (default: no)"),
1100 profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1101 "file path to emit profiling data at runtime when using 'profile' \
1102 (default based on relative source path)"),
1103 query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1104 "enable queries of the dependency graph for regression testing (default: no)"),
1105 query_stats: bool = (false, parse_bool, [UNTRACKED],
1106 "print some statistics about the query system (default: no)"),
1107 relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
1108 "whether ELF relocations can be relaxed"),
1109 relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
1110 "choose which RELRO level to use"),
1111 report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
1112 "immediately print bugs registered with `delay_span_bug` (default: no)"),
1113 sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1115 sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
1116 "enable origins tracking in MemorySanitizer"),
1117 sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1118 "enable recovery for selected sanitizers"),
1119 saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
1120 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
1121 the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
1122 save_analysis: bool = (false, parse_bool, [UNTRACKED],
1123 "write syntax and type analysis (in JSON format) information, in \
1124 addition to normal output (default: no)"),
1125 self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
1126 parse_switch_with_opt_path, [UNTRACKED],
1127 "run the self profiler and output the raw event data"),
1128 // keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1129 self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
1130 "specify the events recorded by the self profiler;
1131 for example: `-Z self-profile-events=default,query-keys`
1132 all options: none, all, default, generic-activity, query-provider, query-cache-hit
1133 query-blocked, incr-cache-load, query-keys, function-args, args, llvm"),
1134 share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
1135 "make the current crate share its generic instantiations"),
1136 show_span: Option<String> = (None, parse_opt_string, [TRACKED],
1137 "show spans for compiler debugging (expr|pat|ty)"),
1138 span_debug: bool = (false, parse_bool, [UNTRACKED],
1139 "forward proc_macro::Span's `Debug` impl to `Span`"),
1140 // o/w tests have closure@path
1141 span_free_formats: bool = (false, parse_bool, [UNTRACKED],
1142 "exclude spans when debug-printing compiler state (default: no)"),
1143 src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
1144 "hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
1145 strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1146 "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1147 split_dwarf_inlining: bool = (true, parse_bool, [UNTRACKED],
1148 "provide minimal debug info in the object/executable to facilitate online \
1149 symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF"),
1150 symbol_mangling_version: Option<SymbolManglingVersion> = (None,
1151 parse_symbol_mangling_version, [TRACKED],
1152 "which mangling version to use for symbol names ('legacy' (default) or 'v0')"),
1153 teach: bool = (false, parse_bool, [TRACKED],
1154 "show extended diagnostic help (default: no)"),
1155 terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
1156 "set the current terminal width"),
1157 tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
1158 "select processor to schedule for (`rustc --print target-cpus` for details)"),
1159 thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
1160 "enable ThinLTO when possible"),
1161 // We default to 1 here since we want to behave like
1162 // a sequential compiler for now. This'll likely be adjusted
1163 // in the future. Note that -Zthreads=0 is the way to get
1164 // the num_cpus behavior.
1165 threads: usize = (1, parse_threads, [UNTRACKED],
1166 "use a thread pool with N threads"),
1167 time: bool = (false, parse_bool, [UNTRACKED],
1168 "measure time of rustc processes (default: no)"),
1169 time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1170 "measure time of each LLVM pass (default: no)"),
1171 time_passes: bool = (false, parse_bool, [UNTRACKED],
1172 "measure time of each rustc pass (default: no)"),
1173 tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
1174 "choose the TLS model to use (`rustc --print tls-models` for details)"),
1175 trace_macros: bool = (false, parse_bool, [UNTRACKED],
1176 "for every macro invocation, print its name and arguments (default: no)"),
1177 trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
1178 "generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
1179 treat_err_as_bug: Option<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED],
1180 "treat error number `val` that occurs as bug"),
1181 trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
1182 "in diagnostics, use heuristics to shorten paths referring to items"),
1183 ui_testing: bool = (false, parse_bool, [UNTRACKED],
1184 "emit compiler diagnostics in a form suitable for UI testing (default: no)"),
1185 unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
1186 "take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
1187 unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1188 "present the input source, unstable (and less-pretty) variants;
1189 valid types are any of the types for `--pretty`, as well as:
1190 `expanded`, `expanded,identified`,
1191 `expanded,hygiene` (with internal representations),
1192 `everybody_loops` (all function bodies replaced with `loop {}`),
1193 `ast-tree` (raw AST before expansion),
1194 `ast-tree,expanded` (raw AST after expansion),
1195 `hir` (the HIR), `hir,identified`,
1196 `hir,typed` (HIR with types for each node),
1197 `hir-tree` (dump the raw HIR),
1198 `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
1199 unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
1200 "enable unsound and buggy MIR optimizations (default: no)"),
1201 unstable_options: bool = (false, parse_bool, [UNTRACKED],
1202 "adds unstable command line options to rustc interface (default: no)"),
1203 use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
1204 "use legacy .ctors section for initializers rather than .init_array"),
1205 validate_mir: bool = (false, parse_bool, [UNTRACKED],
1206 "validate MIR after each transformation"),
1207 verbose: bool = (false, parse_bool, [UNTRACKED],
1208 "in general, enable more debug printouts (default: no)"),
1209 verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
1210 "verify LLVM IR (default: no)"),
1211 wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
1212 "whether to build a wasi command or reactor"),
1214 // This list is in alphabetical order.
1216 // If you add a new option, please update:
1217 // - compiler/rustc_interface/src/tests.rs
1220 #[derive(Clone, Hash)]
1221 pub enum WasiExecModel {