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