3 use crate::early_error;
5 use crate::search_paths::SearchPath;
6 use crate::utils::NativeLib;
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;
24 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => {
26 .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
29 panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
34 macro_rules! hash_opt {
35 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [UNTRACKED]) => {{}};
36 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [TRACKED]) => {{ insert!($opt_name, $opt_expr, $sub_hashes) }};
37 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $for_crate_hash: ident, [TRACKED_NO_CRATE_HASH]) => {{
39 insert!($opt_name, $opt_expr, $sub_hashes)
42 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [SUBSTRUCT]) => {{}};
45 macro_rules! hash_substruct {
46 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [UNTRACKED]) => {{}};
47 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED]) => {{}};
48 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED_NO_CRATE_HASH]) => {{}};
49 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [SUBSTRUCT]) => {
50 use crate::config::dep_tracking::DepTrackingHash;
51 $opt_expr.dep_tracking_hash($for_crate_hash, $error_format).hash(
59 macro_rules! top_level_options {
60 ( $( #[$top_level_attr:meta] )* pub struct Options { $(
62 $opt:ident : $t:ty [$dep_tracking_marker:ident],
65 $( #[$top_level_attr] )*
74 pub fn dep_tracking_hash(&self, for_crate_hash: bool) -> u64 {
75 let mut sub_hashes = BTreeMap::new();
81 [$dep_tracking_marker]);
83 let mut hasher = DefaultHasher::new();
84 dep_tracking::stable_hash(sub_hashes,
94 [$dep_tracking_marker]);
103 /// The top-level command-line options struct.
105 /// For each option, one has to specify how it behaves with regard to the
106 /// dependency tracking system of incremental compilation. This is done via the
107 /// square-bracketed directive after the field type. The options are:
110 /// A change in the given field will cause the compiler to completely clear the
111 /// incremental compilation cache before proceeding.
113 /// - `[TRACKED_NO_CRATE_HASH]`
114 /// Same as `[TRACKED]`, but will not affect the crate hash. This is useful for options that only
115 /// affect the incremental cache.
118 /// Incremental compilation is not influenced by this option.
121 /// Second-level sub-structs containing more options.
123 /// If you add a new option to this struct or one of the sub-structs like
124 /// `CodegenOptions`, think about how it influences incremental compilation. If in
125 /// doubt, specify `[TRACKED]`, which is always "correct" but might lead to
126 /// unnecessary re-compilation.
128 /// The crate config requested for the session, which may be combined
129 /// with additional crate configurations during the compile process.
130 crate_types: Vec<CrateType> [TRACKED],
131 optimize: OptLevel [TRACKED],
132 /// Include the `debug_assertions` flag in dependency tracking, since it
133 /// can influence whether overflow checks are done or not.
134 debug_assertions: bool [TRACKED],
135 debuginfo: DebugInfo [TRACKED],
136 lint_opts: Vec<(String, lint::Level)> [TRACKED],
137 lint_cap: Option<lint::Level> [TRACKED],
138 force_warns: Vec<String> [TRACKED],
139 describe_lints: bool [UNTRACKED],
140 output_types: OutputTypes [TRACKED],
141 search_paths: Vec<SearchPath> [UNTRACKED],
142 libs: Vec<NativeLib> [TRACKED],
143 maybe_sysroot: Option<PathBuf> [UNTRACKED],
145 target_triple: TargetTriple [TRACKED],
147 test: bool [TRACKED],
148 error_format: ErrorOutputType [UNTRACKED],
150 /// If `Some`, enable incremental compilation, using the given
151 /// directory to store intermediate results.
152 incremental: Option<PathBuf> [UNTRACKED],
154 debugging_opts: DebuggingOptions [SUBSTRUCT],
155 prints: Vec<PrintRequest> [UNTRACKED],
156 /// Determines which borrow checker(s) to run. This is the parsed, sanitized
157 /// version of `debugging_opts.borrowck`, which is just a plain string.
158 borrowck_mode: BorrowckMode [UNTRACKED],
159 cg: CodegenOptions [SUBSTRUCT],
160 externs: Externs [UNTRACKED],
161 extern_dep_specs: ExternDepSpecs [UNTRACKED],
162 crate_name: Option<String> [TRACKED],
163 /// An optional name to use as the crate for std during std injection,
164 /// written `extern crate name as std`. Defaults to `std`. Used by
165 /// out-of-tree drivers.
166 alt_std_name: Option<String> [TRACKED],
167 /// Indicates how the compiler should treat unstable features.
168 unstable_features: UnstableFeatures [TRACKED],
170 /// Indicates whether this run of the compiler is actually rustdoc. This
171 /// is currently just a hack and will be removed eventually, so please
172 /// try to not rely on this too much.
173 actually_rustdoc: bool [TRACKED],
175 /// Control path trimming.
176 trimmed_def_paths: TrimmedDefPaths [TRACKED],
178 /// Specifications of codegen units / ThinLTO which are forced as a
179 /// result of parsing command line options. These are not necessarily
180 /// what rustc was invoked with, but massaged a bit to agree with
181 /// commands like `--emit llvm-ir` which they're often incompatible with
182 /// if we otherwise use the defaults of rustc.
183 cli_forced_codegen_units: Option<usize> [UNTRACKED],
184 cli_forced_thinlto_off: bool [UNTRACKED],
186 /// Remap source path prefixes in all output (messages, object files, debug, etc.).
187 remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH],
188 /// Base directory containing the `src/` for the Rust standard library, and
189 /// potentially `rustc` as well, if we can can find it. Right now it's always
190 /// `$sysroot/lib/rustlib/src/rust` (i.e. the `rustup` `rust-src` component).
192 /// This directory is what the virtual `/rustc/$hash` is translated back to,
193 /// if Rust was built with path remapping to `/rustc/$hash` enabled
194 /// (the `rust.remap-debuginfo` option in `config.toml`).
195 real_rust_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH],
197 edition: Edition [TRACKED],
199 /// `true` if we're emitting JSON blobs about each artifact produced
201 json_artifact_notifications: bool [TRACKED],
203 /// `true` if we're emitting a JSON blob containing the unused externs
204 json_unused_externs: bool [UNTRACKED],
206 pretty: Option<PpMode> [UNTRACKED],
210 /// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
211 /// macro is to define an interface that can be programmatically used by the option parser
212 /// to initialize the struct without hardcoding field names all over the place.
214 /// The goal is to invoke this macro once with the correct fields, and then this macro generates all
215 /// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
216 /// generated code to parse an option into its respective field in the struct. There are a few
217 /// hand-written parsers for parsing specific types of values in this module.
218 macro_rules! options {
219 ($struct_name:ident, $stat:ident, $prefix:expr, $outputname:expr,
220 $($( #[$attr:meta] )* $opt:ident : $t:ty = (
223 [$dep_tracking_marker:ident],
228 pub struct $struct_name { $(pub $opt: $t),* }
230 impl Default for $struct_name {
231 fn default() -> $struct_name {
232 $struct_name { $( $( #[$attr] )* $opt: $init),* }
238 matches: &getopts::Matches,
239 error_format: ErrorOutputType,
241 build_options(matches, $stat, $prefix, $outputname, error_format)
244 fn dep_tracking_hash(&self, for_crate_hash: bool, error_format: ErrorOutputType) -> u64 {
245 let mut sub_hashes = BTreeMap::new();
251 [$dep_tracking_marker]);
253 let mut hasher = DefaultHasher::new();
254 dep_tracking::stable_hash(sub_hashes,
263 pub const $stat: OptionDescrs<$struct_name> =
264 &[ $( (stringify!($opt), $opt, desc::$parse, $desc) ),* ];
267 fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
268 parse::$parse(&mut redirect_field!(cg.$opt), v)
274 // Sometimes different options need to build a common structure.
275 // That structure can be kept in one of the options' fields, the others become dummy.
276 macro_rules! redirect_field {
277 ($cg:ident.link_arg) => {
280 ($cg:ident.pre_link_arg) => {
283 ($cg:ident.$field:ident) => {
288 type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
289 type OptionDescrs<O> = &'static [(&'static str, OptionSetter<O>, &'static str, &'static str)];
291 fn build_options<O: Default>(
292 matches: &getopts::Matches,
293 descrs: OptionDescrs<O>,
296 error_format: ErrorOutputType,
298 let mut op = O::default();
299 for option in matches.opt_strs(prefix) {
300 let (key, value) = match option.split_once('=') {
301 None => (option, None),
302 Some((k, v)) => (k.to_string(), Some(v)),
305 let option_to_lookup = key.replace("-", "_");
306 match descrs.iter().find(|(name, ..)| *name == option_to_lookup) {
307 Some((_, setter, type_desc, _)) => {
308 if !setter(&mut op, value) {
313 "{0} option `{1}` requires {2} ({3} {1}=<value>)",
314 outputname, key, type_desc, prefix
317 Some(value) => early_error(
320 "incorrect value `{}` for {} option `{}` - {} was expected",
321 value, outputname, key, type_desc
327 None => early_error(error_format, &format!("unknown {} option: `{}`", outputname, key)),
333 #[allow(non_upper_case_globals)]
335 pub const parse_no_flag: &str = "no value";
336 pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
337 pub const parse_opt_bool: &str = parse_bool;
338 pub const parse_string: &str = "a string";
339 pub const parse_opt_string: &str = parse_string;
340 pub const parse_string_push: &str = parse_string;
341 pub const parse_opt_pathbuf: &str = "a path";
342 pub const parse_list: &str = "a space-separated list of strings";
343 pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
344 pub const parse_number: &str = "a number";
345 pub const parse_opt_number: &str = parse_number;
346 pub const parse_threads: &str = parse_number;
347 pub const parse_passes: &str = "a space-separated list of passes, or `all`";
348 pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
349 pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
350 pub const parse_sanitizers: &str =
351 "comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
352 pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
353 pub const parse_cfguard: &str =
354 "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
355 pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
356 pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
357 pub const parse_optimization_fuel: &str = "crate=integer";
358 pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
359 pub const parse_instrument_coverage: &str =
360 "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
361 pub const parse_unpretty: &str = "`string` or `string=string`";
362 pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
363 pub const parse_lto: &str =
364 "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
365 pub const parse_linker_plugin_lto: &str =
366 "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
367 pub const parse_switch_with_opt_path: &str =
368 "an optional path to the profiling data output directory";
369 pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
370 pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
371 pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
372 pub const parse_relocation_model: &str =
373 "one of supported relocation models (`rustc --print relocation-models`)";
374 pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
375 pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
376 pub const parse_target_feature: &str = parse_string;
377 pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
378 pub const parse_split_debuginfo: &str =
379 "one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
380 pub const parse_gcc_ld: &str = "one of: no value, `lld`";
385 use std::str::FromStr;
387 /// This is for boolean options that don't take a value and start with
388 /// `no-`. This style of option is deprecated.
389 crate fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
399 /// Use this for any boolean option that has a static default.
400 crate fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
402 Some("y") | Some("yes") | Some("on") | None => {
406 Some("n") | Some("no") | Some("off") => {
414 /// Use this for any boolean option that lacks a static default. (The
415 /// actions taken when such an option is not specified will depend on
416 /// other factors, such as other options, or target options.)
417 crate fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
419 Some("y") | Some("yes") | Some("on") | None => {
423 Some("n") | Some("no") | Some("off") => {
431 /// Use this for any string option that has a static default.
432 crate fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
435 *slot = s.to_string();
442 /// Use this for any string option that lacks a static default.
443 crate fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
446 *slot = Some(s.to_string());
453 crate fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
456 *slot = Some(PathBuf::from(s));
463 crate fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
466 slot.push(s.to_string());
473 crate fn parse_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
476 slot.extend(s.split_whitespace().map(|s| s.to_string()));
483 crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
486 let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
495 crate fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
496 match v.and_then(|s| s.parse().ok()) {
498 *slot = ::num_cpus::get();
509 /// Use this for any numeric option that has a static default.
510 crate fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
511 match v.and_then(|s| s.parse().ok()) {
520 /// Use this for any numeric option that lacks a static default.
521 crate fn parse_opt_number<T: Copy + FromStr>(slot: &mut Option<T>, v: Option<&str>) -> bool {
524 *slot = s.parse().ok();
531 crate fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
538 let mut passes = vec![];
539 if parse_list(&mut passes, v) {
540 *slot = Passes::Some(passes);
549 crate fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
551 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
552 Some("abort") => *slot = Some(PanicStrategy::Abort),
558 crate fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
560 Some(s) => match s.parse::<RelroLevel>() {
561 Ok(level) => *slot = Some(level),
569 crate fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
571 for s in v.split(',') {
573 "address" => SanitizerSet::ADDRESS,
574 "leak" => SanitizerSet::LEAK,
575 "memory" => SanitizerSet::MEMORY,
576 "thread" => SanitizerSet::THREAD,
577 "hwaddress" => SanitizerSet::HWADDRESS,
587 crate fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
589 Some("2") | None => {
605 crate fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
607 Some("none") => *slot = Strip::None,
608 Some("debuginfo") => *slot = Strip::Debuginfo,
609 Some("symbols") => *slot = Strip::Symbols,
615 crate fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
617 let mut bool_arg = None;
618 if parse_opt_bool(&mut bool_arg, v) {
619 *slot = if bool_arg.unwrap() { CFGuard::Checks } else { CFGuard::Disabled };
625 None => CFGuard::Checks,
626 Some("checks") => CFGuard::Checks,
627 Some("nochecks") => CFGuard::NoChecks,
628 Some(_) => return false,
633 crate fn parse_linker_flavor(slot: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
634 match v.and_then(LinkerFlavor::from_str) {
635 Some(lf) => *slot = Some(lf),
641 crate fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
645 let parts = s.split('=').collect::<Vec<_>>();
646 if parts.len() != 2 {
649 let crate_name = parts[0].to_string();
650 let fuel = parts[1].parse::<u64>();
654 *slot = Some((crate_name, fuel.unwrap()));
660 crate fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
663 Some(s) if s.split('=').count() <= 2 => {
664 *slot = Some(s.to_string());
671 crate fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
673 let mut bool_arg = None;
674 if parse_opt_bool(&mut bool_arg, v) {
675 *slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
682 *slot = Some(MirSpanview::Statement);
688 *slot = Some(match v.trim_end_matches("s") {
689 "statement" | "stmt" => MirSpanview::Statement,
690 "terminator" | "term" => MirSpanview::Terminator,
691 "block" | "basicblock" => MirSpanview::Block,
697 crate fn parse_instrument_coverage(
698 slot: &mut Option<InstrumentCoverage>,
702 let mut bool_arg = None;
703 if parse_opt_bool(&mut bool_arg, v) {
704 *slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
711 *slot = Some(InstrumentCoverage::All);
717 *slot = Some(match v {
718 "all" => InstrumentCoverage::All,
719 "except-unused-generics" | "except_unused_generics" => {
720 InstrumentCoverage::ExceptUnusedGenerics
722 "except-unused-functions" | "except_unused_functions" => {
723 InstrumentCoverage::ExceptUnusedFunctions
725 "off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
731 crate fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
734 *slot = s.parse().ok();
738 *slot = NonZeroUsize::new(1);
744 crate fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
746 let mut bool_arg = None;
747 if parse_opt_bool(&mut bool_arg, v) {
748 *slot = if bool_arg.unwrap() { LtoCli::Yes } else { LtoCli::No };
754 None => LtoCli::NoParam,
755 Some("thin") => LtoCli::Thin,
756 Some("fat") => LtoCli::Fat,
757 Some(_) => return false,
762 crate fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
764 let mut bool_arg = None;
765 if parse_opt_bool(&mut bool_arg, v) {
766 *slot = if bool_arg.unwrap() {
767 LinkerPluginLto::LinkerPluginAuto
769 LinkerPluginLto::Disabled
776 None => LinkerPluginLto::LinkerPluginAuto,
777 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
782 crate fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
784 None => SwitchWithOptPath::Enabled(None),
785 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
790 crate fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
791 match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
792 Some(mergefunc) => *slot = Some(mergefunc),
798 crate fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
799 match v.and_then(|s| RelocModel::from_str(s).ok()) {
800 Some(relocation_model) => *slot = Some(relocation_model),
801 None if v == Some("default") => *slot = None,
807 crate fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
808 match v.and_then(|s| CodeModel::from_str(s).ok()) {
809 Some(code_model) => *slot = Some(code_model),
815 crate fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
816 match v.and_then(|s| TlsModel::from_str(s).ok()) {
817 Some(tls_model) => *slot = Some(tls_model),
823 crate fn parse_symbol_mangling_version(
824 slot: &mut Option<SymbolManglingVersion>,
828 Some("legacy") => Some(SymbolManglingVersion::Legacy),
829 Some("v0") => Some(SymbolManglingVersion::V0),
835 crate fn parse_src_file_hash(
836 slot: &mut Option<SourceFileHashAlgorithm>,
839 match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
840 Some(hash_kind) => *slot = Some(hash_kind),
846 crate fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
849 if !slot.is_empty() {
859 crate fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
861 Some("command") => *slot = Some(WasiExecModel::Command),
862 Some("reactor") => *slot = Some(WasiExecModel::Reactor),
868 crate fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
869 match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
870 Some(e) => *slot = Some(e),
876 crate fn parse_gcc_ld(slot: &mut Option<LdImpl>, v: Option<&str>) -> bool {
878 None => *slot = None,
879 Some("lld") => *slot = Some(LdImpl::Lld),
887 CodegenOptions, CG_OPTIONS, "C", "codegen",
889 // This list is in alphabetical order.
891 // If you add a new option, please update:
892 // - compiler/rustc_interface/src/tests.rs
893 // - src/doc/rustc/src/codegen-options/index.md
895 ar: String = (String::new(), parse_string, [UNTRACKED],
896 "this option is deprecated and does nothing"),
897 code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
898 "choose the code model to use (`rustc --print code-models` for details)"),
899 codegen_units: Option<usize> = (None, parse_opt_number, [UNTRACKED],
900 "divide crate into N units to optimize in parallel"),
901 control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
902 "use Windows Control Flow Guard (default: no)"),
903 debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
904 "explicitly enable the `cfg(debug_assertions)` directive"),
905 debuginfo: usize = (0, parse_number, [TRACKED],
906 "debug info emission level (0 = no debug info, 1 = line tables only, \
907 2 = full debug info with variable and type information; default: 0)"),
908 default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
909 "allow the linker to link its default libraries (default: no)"),
910 embed_bitcode: bool = (true, parse_bool, [TRACKED],
911 "emit bitcode in rlibs (default: yes)"),
912 extra_filename: String = (String::new(), parse_string, [UNTRACKED],
913 "extra data to put in each output filename"),
914 force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
915 "force use of the frame pointers"),
916 force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
917 "force use of unwind tables"),
918 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
919 "enable incremental compilation"),
920 inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
921 "set the threshold for inlining a function"),
922 link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
923 "a single extra argument to append to the linker invocation (can be used several times)"),
924 link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
925 "extra arguments to append to the linker invocation (space separated)"),
926 link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED],
927 "keep dead code at link time (useful for code coverage) (default: no)"),
928 link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
929 "control whether to link Rust provided C objects/libraries or rely
930 on C toolchain installed in the system"),
931 linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
932 "system linker to link outputs with"),
933 linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
935 linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
936 parse_linker_plugin_lto, [TRACKED],
937 "generate build artifacts that are compatible with linker-based LTO"),
938 llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
939 "a list of arguments to pass to LLVM (space separated)"),
940 lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
941 "perform LLVM link-time optimizations"),
942 metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
943 "metadata to mangle symbol names with"),
944 no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
945 "give an empty list of passes to the pass manager"),
946 no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
947 "disable the use of the redzone"),
948 no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
949 "this option is deprecated and does nothing"),
950 no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
951 "disable loop vectorization optimization passes"),
952 no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
953 "disable LLVM's SLP vectorization pass"),
954 opt_level: String = ("0".to_string(), parse_string, [TRACKED],
955 "optimization level (0-3, s, or z; default: 0)"),
956 overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
957 "use overflow checks for integer arithmetic"),
958 panic: Option<PanicStrategy> = (None, parse_panic_strategy, [TRACKED],
959 "panic strategy to compile crate with"),
960 passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
961 "a list of extra LLVM passes to run (space separated)"),
962 prefer_dynamic: bool = (false, parse_bool, [TRACKED],
963 "prefer dynamic linking to static linking (default: no)"),
964 profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
965 parse_switch_with_opt_path, [TRACKED],
966 "compile the program with profiling instrumentation"),
967 profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
968 "use the given `.profdata` file for profile-guided optimization"),
969 relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
970 "control generation of position-independent code (PIC) \
971 (`rustc --print relocation-models` for details)"),
972 remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
973 "print remarks for these optimization passes (space separated, or \"all\")"),
974 rpath: bool = (false, parse_bool, [UNTRACKED],
975 "set rpath values in libs/exes (default: no)"),
976 save_temps: bool = (false, parse_bool, [UNTRACKED],
977 "save all temporary output files during compilation (default: no)"),
978 soft_float: bool = (false, parse_bool, [TRACKED],
979 "use soft float ABI (*eabihf targets only) (default: no)"),
980 split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
981 "how to handle split-debuginfo, a platform-specific option"),
982 target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
983 "select target processor (`rustc --print target-cpus` for details)"),
984 target_feature: String = (String::new(), parse_target_feature, [TRACKED],
985 "target specific attributes. (`rustc --print target-features` for details). \
986 This feature is unsafe."),
988 // This list is in alphabetical order.
990 // If you add a new option, please update:
991 // - compiler/rustc_interface/src/tests.rs
992 // - src/doc/rustc/src/codegen-options/index.md
996 DebuggingOptions, DB_OPTIONS, "Z", "debugging",
998 // This list is in alphabetical order.
1000 // If you add a new option, please update:
1001 // - compiler/rustc_interface/src/tests.rs
1003 allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
1004 "only allow the listed language features to be enabled in code (space separated)"),
1005 always_encode_mir: bool = (false, parse_bool, [TRACKED],
1006 "encode MIR of all functions into the crate metadata (default: no)"),
1007 assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
1008 "make cfg(version) treat the current version as incomplete (default: no)"),
1009 asm_comments: bool = (false, parse_bool, [TRACKED],
1010 "generate comments into the assembly (may change behavior) (default: no)"),
1011 ast_json: bool = (false, parse_bool, [UNTRACKED],
1012 "print the AST as JSON and halt (default: no)"),
1013 ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
1014 "print the pre-expansion AST as JSON and halt (default: no)"),
1015 binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
1016 "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
1018 borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
1019 "select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
1020 cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
1021 "the codegen unit partitioning strategy to use"),
1022 chalk: bool = (false, parse_bool, [TRACKED],
1023 "enable the experimental Chalk-based trait solving engine"),
1024 codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
1025 "the backend to use"),
1026 combine_cgu: bool = (false, parse_bool, [TRACKED],
1027 "combine CGUs into a single one"),
1028 crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
1029 "inject the given attribute in the crate"),
1030 debug_macros: bool = (false, parse_bool, [TRACKED],
1031 "emit line numbers debug info inside macros (default: no)"),
1032 deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
1033 "deduplicate identical diagnostics (default: yes)"),
1034 dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
1035 "in dep-info output, omit targets for tracking dependencies of the dep-info files \
1036 themselves (default: no)"),
1037 dep_tasks: bool = (false, parse_bool, [UNTRACKED],
1038 "print tasks that execute and the color their dep node gets (requires debug build) \
1040 dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
1041 "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
1043 dual_proc_macros: bool = (false, parse_bool, [TRACKED],
1044 "load proc macros for both target and host, but only link to the target (default: no)"),
1045 dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1046 "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
1048 dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
1049 "dump MIR state to file.
1050 `val` is used to select which passes and functions to dump. For example:
1051 `all` matches all passes and functions,
1052 `foo` matches all passes for functions whose name contains 'foo',
1053 `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
1054 `foo | bar` all passes for function names containing 'foo' or 'bar'."),
1055 dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
1056 "in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
1058 dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
1059 "the directory the MIR is dumped into (default: `mir_dump`)"),
1060 dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
1061 "exclude the pass number when dumping MIR (used in tests) (default: no)"),
1062 dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
1063 "in addition to `.mir` files, create graphviz `.dot` files (and with \
1064 `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived \
1065 coverage graph) (default: no)"),
1066 dump_mir_spanview: Option<MirSpanview> = (None, parse_mir_spanview, [UNTRACKED],
1067 "in addition to `.mir` files, create `.html` files to view spans for \
1068 all `statement`s (including terminators), only `terminator` spans, or \
1069 computed `block` spans (one span encompassing a block's terminator and \
1070 all statements). If `-Z instrument-coverage` is also enabled, create \
1071 an additional `.html` file showing the computed coverage spans."),
1072 emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED],
1073 "emits a future-incompatibility report for lints (RFC 2834)"),
1074 emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
1075 "emit a section containing stack size metadata (default: no)"),
1076 fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
1077 "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
1079 force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
1080 "force overflow checks on or off"),
1081 force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
1082 "force all crates to be `rustc_private` unstable (default: no)"),
1083 fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
1084 "set the optimization fuel quota for a crate"),
1085 function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
1086 "whether each function should go in its own section"),
1087 gcc_ld: Option<LdImpl> = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"),
1088 graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
1089 "use dark-themed colors in graphviz output (default: no)"),
1090 graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
1091 "use the given `fontname` in graphviz output; can be overridden by setting \
1092 environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
1093 hir_stats: bool = (false, parse_bool, [UNTRACKED],
1094 "print some statistics about AST and HIR (default: no)"),
1095 human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
1096 "generate human-readable, predictable names for codegen units (default: no)"),
1097 identify_regions: bool = (false, parse_bool, [UNTRACKED],
1098 "display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
1099 incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
1100 "ignore spans during ICH computation -- used for testing (default: no)"),
1101 incremental_info: bool = (false, parse_bool, [UNTRACKED],
1102 "print high-level information about incremental reuse (or the lack thereof) \
1104 incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
1105 "verify incr. comp. hashes of green query instances (default: no)"),
1106 inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
1107 "enable MIR inlining (default: no)"),
1108 inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1109 "a default MIR inlining threshold (default: 50)"),
1110 inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1111 "inlining threshold for functions with inline hint (default: 100)"),
1112 inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
1113 "control whether `#[inline]` functions are in all CGUs"),
1114 input_stats: bool = (false, parse_bool, [UNTRACKED],
1115 "gather statistics about the input (default: no)"),
1116 instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1117 "instrument the generated code to support LLVM source-based code coverage \
1118 reports (note, the compiler build config must include `profiler = true`); \
1119 implies `-Z symbol-mangling-version=v0`. Optional values are:
1120 `=all` (implicit value)
1121 `=except-unused-generics`
1122 `=except-unused-functions`
1124 instrument_mcount: bool = (false, parse_bool, [TRACKED],
1125 "insert function instrument code for mcount-based tracing (default: no)"),
1126 keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
1127 "keep hygiene data after analysis (default: no)"),
1128 link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
1129 "link native libraries in the linker invocation (default: yes)"),
1130 link_only: bool = (false, parse_bool, [TRACKED],
1131 "link the `.rlink` file generated by `-Z no-link` (default: no)"),
1132 llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1133 "a list LLVM plugins to enable (space separated)"),
1134 llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
1135 "generate JSON tracing data file from LLVM data (default: no)"),
1136 ls: bool = (false, parse_bool, [UNTRACKED],
1137 "list the symbols defined by a library crate (default: no)"),
1138 macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1139 "show macro backtraces (default: no)"),
1140 merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
1141 "control the operation of the MergeFunctions LLVM pass, taking \
1142 the same values as the target option of the same name"),
1143 meta_stats: bool = (false, parse_bool, [UNTRACKED],
1144 "gather metadata statistics (default: no)"),
1145 mir_emit_retag: bool = (false, parse_bool, [TRACKED],
1146 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
1148 mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
1149 "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
1150 mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1151 "emit noalias metadata for mutable references (default: yes for LLVM >= 12, otherwise no)"),
1152 new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
1153 "use new LLVM pass manager (default: no)"),
1154 nll_facts: bool = (false, parse_bool, [UNTRACKED],
1155 "dump facts from NLL analysis into side files (default: no)"),
1156 nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
1157 "the directory the NLL facts are dumped into (default: `nll-facts`)"),
1158 no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
1159 "parse and expand the source, but run no analysis"),
1160 no_codegen: bool = (false, parse_no_flag, [TRACKED_NO_CRATE_HASH],
1161 "run all passes except codegen; no output"),
1162 no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
1163 "omit DWARF address ranges that give faster lookups"),
1164 no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
1165 "execute lints separately; allows benchmarking individual lints"),
1166 no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
1167 "disable the 'leak check' for subtyping; unsound, but useful for tests"),
1168 no_link: bool = (false, parse_no_flag, [TRACKED],
1169 "compile without linking"),
1170 no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
1171 "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1172 normalize_docs: bool = (false, parse_bool, [TRACKED],
1173 "normalize associated items in rustdoc when generating documentation"),
1174 osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
1175 "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
1176 panic_abort_tests: bool = (false, parse_bool, [TRACKED],
1177 "support compiling tests with panic=abort (default: no)"),
1178 parse_only: bool = (false, parse_bool, [UNTRACKED],
1179 "parse only; do not compile, assemble, or link (default: no)"),
1180 perf_stats: bool = (false, parse_bool, [UNTRACKED],
1181 "print some performance-related statistics (default: no)"),
1182 plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
1183 "whether to use the PLT when calling into shared libraries;
1184 only has effect for PIC code on systems with ELF binaries
1185 (default: PLT is disabled if full relro is enabled)"),
1186 polonius: bool = (false, parse_bool, [TRACKED],
1187 "enable polonius-based borrow-checker (default: no)"),
1188 polymorphize: bool = (false, parse_bool, [TRACKED],
1189 "perform polymorphization analysis"),
1190 pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
1191 "a single extra argument to prepend the linker invocation (can be used several times)"),
1192 pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
1193 "extra arguments to prepend to the linker invocation (space separated)"),
1194 precise_enum_drop_elaboration: bool = (true, parse_bool, [TRACKED],
1195 "use a more precise version of drop elaboration for matches on enums (default: yes). \
1196 This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
1197 See #77382 and #74551."),
1198 print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
1199 "make rustc print the total optimization fuel used by a crate"),
1200 print_link_args: bool = (false, parse_bool, [UNTRACKED],
1201 "print the arguments passed to the linker (default: no)"),
1202 print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1203 "print the LLVM optimization passes being run (default: no)"),
1204 print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
1205 "print the result of the monomorphization collection pass"),
1206 print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
1207 "print layout information for each type encountered (default: no)"),
1208 proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1209 "show backtraces for panics during proc-macro execution (default: no)"),
1210 profile: bool = (false, parse_bool, [TRACKED],
1211 "insert profiling code (default: no)"),
1212 profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1213 "file path to emit profiling data at runtime when using 'profile' \
1214 (default based on relative source path)"),
1215 profiler_runtime: Option<String> = (Some(String::from("profiler_builtins")), parse_opt_string, [TRACKED],
1216 "name of the profiler runtime crate to automatically inject, or None to disable"),
1217 query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1218 "enable queries of the dependency graph for regression testing (default: no)"),
1219 query_stats: bool = (false, parse_bool, [UNTRACKED],
1220 "print some statistics about the query system (default: no)"),
1221 relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
1222 "whether ELF relocations can be relaxed"),
1223 relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
1224 "choose which RELRO level to use"),
1225 simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1226 "simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
1227 to rust's source base directory. only meant for testing purposes"),
1228 report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
1229 "immediately print bugs registered with `delay_span_bug` (default: no)"),
1230 sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1232 sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
1233 "enable origins tracking in MemorySanitizer"),
1234 sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1235 "enable recovery for selected sanitizers"),
1236 saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
1237 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
1238 the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
1239 save_analysis: bool = (false, parse_bool, [UNTRACKED],
1240 "write syntax and type analysis (in JSON format) information, in \
1241 addition to normal output (default: no)"),
1242 self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
1243 parse_switch_with_opt_path, [UNTRACKED],
1244 "run the self profiler and output the raw event data"),
1245 /// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1246 self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
1247 "specify the events recorded by the self profiler;
1248 for example: `-Z self-profile-events=default,query-keys`
1249 all options: none, all, default, generic-activity, query-provider, query-cache-hit
1250 query-blocked, incr-cache-load, query-keys, function-args, args, llvm"),
1251 share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
1252 "make the current crate share its generic instantiations"),
1253 show_span: Option<String> = (None, parse_opt_string, [TRACKED],
1254 "show spans for compiler debugging (expr|pat|ty)"),
1255 span_debug: bool = (false, parse_bool, [UNTRACKED],
1256 "forward proc_macro::Span's `Debug` impl to `Span`"),
1257 /// o/w tests have closure@path
1258 span_free_formats: bool = (false, parse_bool, [UNTRACKED],
1259 "exclude spans when debug-printing compiler state (default: no)"),
1260 src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
1261 "hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
1262 strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1263 "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1264 split_dwarf_inlining: bool = (true, parse_bool, [UNTRACKED],
1265 "provide minimal debug info in the object/executable to facilitate online \
1266 symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF"),
1267 symbol_mangling_version: Option<SymbolManglingVersion> = (None,
1268 parse_symbol_mangling_version, [TRACKED],
1269 "which mangling version to use for symbol names ('legacy' (default) or 'v0')"),
1270 teach: bool = (false, parse_bool, [TRACKED],
1271 "show extended diagnostic help (default: no)"),
1272 terminal_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1273 "set the current terminal width"),
1274 tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
1275 "select processor to schedule for (`rustc --print target-cpus` for details)"),
1276 thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
1277 "enable ThinLTO when possible"),
1278 thir_unsafeck: bool = (false, parse_bool, [TRACKED],
1279 "use the work-in-progress THIR unsafety checker. NOTE: this is unsound (default: no)"),
1280 /// We default to 1 here since we want to behave like
1281 /// a sequential compiler for now. This'll likely be adjusted
1282 /// in the future. Note that -Zthreads=0 is the way to get
1283 /// the num_cpus behavior.
1284 threads: usize = (1, parse_threads, [UNTRACKED],
1285 "use a thread pool with N threads"),
1286 time: bool = (false, parse_bool, [UNTRACKED],
1287 "measure time of rustc processes (default: no)"),
1288 time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1289 "measure time of each LLVM pass (default: no)"),
1290 time_passes: bool = (false, parse_bool, [UNTRACKED],
1291 "measure time of each rustc pass (default: no)"),
1292 tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
1293 "choose the TLS model to use (`rustc --print tls-models` for details)"),
1294 trace_macros: bool = (false, parse_bool, [UNTRACKED],
1295 "for every macro invocation, print its name and arguments (default: no)"),
1296 trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
1297 "generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
1298 treat_err_as_bug: Option<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED],
1299 "treat error number `val` that occurs as bug"),
1300 trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
1301 "in diagnostics, use heuristics to shorten paths referring to items"),
1302 ui_testing: bool = (false, parse_bool, [UNTRACKED],
1303 "emit compiler diagnostics in a form suitable for UI testing (default: no)"),
1304 unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
1305 "take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
1306 unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1307 "present the input source, unstable (and less-pretty) variants;
1308 valid types are any of the types for `--pretty`, as well as:
1309 `expanded`, `expanded,identified`,
1310 `expanded,hygiene` (with internal representations),
1311 `everybody_loops` (all function bodies replaced with `loop {}`),
1312 `ast-tree` (raw AST before expansion),
1313 `ast-tree,expanded` (raw AST after expansion),
1314 `hir` (the HIR), `hir,identified`,
1315 `hir,typed` (HIR with types for each node),
1316 `hir-tree` (dump the raw HIR),
1317 `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
1318 unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
1319 "enable unsound and buggy MIR optimizations (default: no)"),
1320 unstable_options: bool = (false, parse_bool, [UNTRACKED],
1321 "adds unstable command line options to rustc interface (default: no)"),
1322 use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
1323 "use legacy .ctors section for initializers rather than .init_array"),
1324 validate_mir: bool = (false, parse_bool, [UNTRACKED],
1325 "validate MIR after each transformation"),
1326 verbose: bool = (false, parse_bool, [UNTRACKED],
1327 "in general, enable more debug printouts (default: no)"),
1328 verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
1329 "verify LLVM IR (default: no)"),
1330 wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
1331 "whether to build a wasi command or reactor"),
1333 // This list is in alphabetical order.
1335 // If you add a new option, please update:
1336 // - compiler/rustc_interface/src/tests.rs
1339 #[derive(Clone, Hash, PartialEq, Eq, Debug)]
1340 pub enum WasiExecModel {
1345 #[derive(Clone, Copy, Hash)]