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::RealFileName;
14 use rustc_span::SourceFileHashAlgorithm;
16 use std::collections::BTreeMap;
18 use std::collections::hash_map::DefaultHasher;
19 use std::hash::Hasher;
20 use std::num::NonZeroUsize;
21 use std::path::PathBuf;
25 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => {
27 .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
30 panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
35 macro_rules! hash_opt {
36 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [UNTRACKED]) => {{}};
37 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [TRACKED]) => {{ insert!($opt_name, $opt_expr, $sub_hashes) }};
38 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $for_crate_hash: ident, [TRACKED_NO_CRATE_HASH]) => {{
40 insert!($opt_name, $opt_expr, $sub_hashes)
43 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [SUBSTRUCT]) => {{}};
46 macro_rules! hash_substruct {
47 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [UNTRACKED]) => {{}};
48 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED]) => {{}};
49 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED_NO_CRATE_HASH]) => {{}};
50 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [SUBSTRUCT]) => {
51 use crate::config::dep_tracking::DepTrackingHash;
52 $opt_expr.dep_tracking_hash($for_crate_hash, $error_format).hash(
60 macro_rules! top_level_options {
61 ( $( #[$top_level_attr:meta] )* pub struct Options { $(
63 $opt:ident : $t:ty [$dep_tracking_marker:ident],
66 $( #[$top_level_attr] )*
75 pub fn dep_tracking_hash(&self, for_crate_hash: bool) -> u64 {
76 let mut sub_hashes = BTreeMap::new();
82 [$dep_tracking_marker]);
84 let mut hasher = DefaultHasher::new();
85 dep_tracking::stable_hash(sub_hashes,
95 [$dep_tracking_marker]);
104 /// The top-level command-line options struct.
106 /// For each option, one has to specify how it behaves with regard to the
107 /// dependency tracking system of incremental compilation. This is done via the
108 /// square-bracketed directive after the field type. The options are:
111 /// A change in the given field will cause the compiler to completely clear the
112 /// incremental compilation cache before proceeding.
114 /// - `[TRACKED_NO_CRATE_HASH]`
115 /// Same as `[TRACKED]`, but will not affect the crate hash. This is useful for options that only
116 /// affect the incremental cache.
119 /// Incremental compilation is not influenced by this option.
122 /// Second-level sub-structs containing more options.
124 /// If you add a new option to this struct or one of the sub-structs like
125 /// `CodegenOptions`, think about how it influences incremental compilation. If in
126 /// doubt, specify `[TRACKED]`, which is always "correct" but might lead to
127 /// unnecessary re-compilation.
129 /// The crate config requested for the session, which may be combined
130 /// with additional crate configurations during the compile process.
131 crate_types: Vec<CrateType> [TRACKED],
132 optimize: OptLevel [TRACKED],
133 /// Include the `debug_assertions` flag in dependency tracking, since it
134 /// can influence whether overflow checks are done or not.
135 debug_assertions: bool [TRACKED],
136 debuginfo: DebugInfo [TRACKED],
137 lint_opts: Vec<(String, lint::Level)> [TRACKED_NO_CRATE_HASH],
138 lint_cap: Option<lint::Level> [TRACKED_NO_CRATE_HASH],
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],
208 /// The (potentially remapped) working directory
209 working_dir: RealFileName [TRACKED],
213 /// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
214 /// macro is to define an interface that can be programmatically used by the option parser
215 /// to initialize the struct without hardcoding field names all over the place.
217 /// The goal is to invoke this macro once with the correct fields, and then this macro generates all
218 /// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
219 /// generated code to parse an option into its respective field in the struct. There are a few
220 /// hand-written parsers for parsing specific types of values in this module.
221 macro_rules! options {
222 ($struct_name:ident, $stat:ident, $prefix:expr, $outputname:expr,
223 $($( #[$attr:meta] )* $opt:ident : $t:ty = (
226 [$dep_tracking_marker:ident],
231 pub struct $struct_name { $(pub $opt: $t),* }
233 impl Default for $struct_name {
234 fn default() -> $struct_name {
235 $struct_name { $( $( #[$attr] )* $opt: $init),* }
241 matches: &getopts::Matches,
242 error_format: ErrorOutputType,
244 build_options(matches, $stat, $prefix, $outputname, error_format)
247 fn dep_tracking_hash(&self, for_crate_hash: bool, error_format: ErrorOutputType) -> u64 {
248 let mut sub_hashes = BTreeMap::new();
254 [$dep_tracking_marker]);
256 let mut hasher = DefaultHasher::new();
257 dep_tracking::stable_hash(sub_hashes,
266 pub const $stat: OptionDescrs<$struct_name> =
267 &[ $( (stringify!($opt), $opt, desc::$parse, $desc) ),* ];
270 fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
271 parse::$parse(&mut redirect_field!(cg.$opt), v)
277 // Sometimes different options need to build a common structure.
278 // That structure can be kept in one of the options' fields, the others become dummy.
279 macro_rules! redirect_field {
280 ($cg:ident.link_arg) => {
283 ($cg:ident.pre_link_arg) => {
286 ($cg:ident.$field:ident) => {
291 type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
292 type OptionDescrs<O> = &'static [(&'static str, OptionSetter<O>, &'static str, &'static str)];
294 fn build_options<O: Default>(
295 matches: &getopts::Matches,
296 descrs: OptionDescrs<O>,
299 error_format: ErrorOutputType,
301 let mut op = O::default();
302 for option in matches.opt_strs(prefix) {
303 let (key, value) = match option.split_once('=') {
304 None => (option, None),
305 Some((k, v)) => (k.to_string(), Some(v)),
308 let option_to_lookup = key.replace("-", "_");
309 match descrs.iter().find(|(name, ..)| *name == option_to_lookup) {
310 Some((_, setter, type_desc, _)) => {
311 if !setter(&mut op, value) {
316 "{0} option `{1}` requires {2} ({3} {1}=<value>)",
317 outputname, key, type_desc, prefix
320 Some(value) => early_error(
323 "incorrect value `{}` for {} option `{}` - {} was expected",
324 value, outputname, key, type_desc
330 None => early_error(error_format, &format!("unknown {} option: `{}`", outputname, key)),
336 #[allow(non_upper_case_globals)]
338 pub const parse_no_flag: &str = "no value";
339 pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
340 pub const parse_opt_bool: &str = parse_bool;
341 pub const parse_string: &str = "a string";
342 pub const parse_opt_string: &str = parse_string;
343 pub const parse_string_push: &str = parse_string;
344 pub const parse_opt_pathbuf: &str = "a path";
345 pub const parse_list: &str = "a space-separated list of strings";
346 pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
347 pub const parse_number: &str = "a number";
348 pub const parse_opt_number: &str = parse_number;
349 pub const parse_threads: &str = parse_number;
350 pub const parse_passes: &str = "a space-separated list of passes, or `all`";
351 pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
352 pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
353 pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
354 pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `hwaddress`, `leak`, `memory` or `thread`";
355 pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
356 pub const parse_cfguard: &str =
357 "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
358 pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
359 pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
360 pub const parse_optimization_fuel: &str = "crate=integer";
361 pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
362 pub const parse_instrument_coverage: &str =
363 "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
364 pub const parse_unpretty: &str = "`string` or `string=string`";
365 pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
366 pub const parse_lto: &str =
367 "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
368 pub const parse_linker_plugin_lto: &str =
369 "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
370 pub const parse_location_detail: &str =
371 "comma seperated list of location details to track: `file`, `line`, or `column`";
372 pub const parse_switch_with_opt_path: &str =
373 "an optional path to the profiling data output directory";
374 pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
375 pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
376 pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
377 pub const parse_relocation_model: &str =
378 "one of supported relocation models (`rustc --print relocation-models`)";
379 pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
380 pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
381 pub const parse_target_feature: &str = parse_string;
382 pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
383 pub const parse_split_debuginfo: &str =
384 "one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
385 pub const parse_gcc_ld: &str = "one of: no value, `lld`";
390 use std::str::FromStr;
392 /// This is for boolean options that don't take a value and start with
393 /// `no-`. This style of option is deprecated.
394 crate fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
404 /// Use this for any boolean option that has a static default.
405 crate fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
407 Some("y") | Some("yes") | Some("on") | None => {
411 Some("n") | Some("no") | Some("off") => {
419 /// Use this for any boolean option that lacks a static default. (The
420 /// actions taken when such an option is not specified will depend on
421 /// other factors, such as other options, or target options.)
422 crate fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
424 Some("y") | Some("yes") | Some("on") | None => {
428 Some("n") | Some("no") | Some("off") => {
436 /// Use this for any string option that has a static default.
437 crate fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
440 *slot = s.to_string();
447 /// Use this for any string option that lacks a static default.
448 crate fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
451 *slot = Some(s.to_string());
458 crate fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
461 *slot = Some(PathBuf::from(s));
468 crate fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
471 slot.push(s.to_string());
478 crate fn parse_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
481 slot.extend(s.split_whitespace().map(|s| s.to_string()));
488 crate fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
493 for s in v.split(',') {
495 "file" => ld.file = true,
496 "line" => ld.line = true,
497 "column" => ld.column = true,
507 crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
510 let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
519 crate fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
520 match v.and_then(|s| s.parse().ok()) {
522 *slot = ::num_cpus::get();
533 /// Use this for any numeric option that has a static default.
534 crate fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
535 match v.and_then(|s| s.parse().ok()) {
544 /// Use this for any numeric option that lacks a static default.
545 crate fn parse_opt_number<T: Copy + FromStr>(slot: &mut Option<T>, v: Option<&str>) -> bool {
548 *slot = s.parse().ok();
555 crate fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
562 let mut passes = vec![];
563 if parse_list(&mut passes, v) {
564 *slot = Passes::Some(passes);
573 crate fn parse_opt_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
575 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
576 Some("abort") => *slot = Some(PanicStrategy::Abort),
582 crate fn parse_panic_strategy(slot: &mut PanicStrategy, v: Option<&str>) -> bool {
584 Some("unwind") => *slot = PanicStrategy::Unwind,
585 Some("abort") => *slot = PanicStrategy::Abort,
591 crate fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
593 Some(s) => match s.parse::<RelroLevel>() {
594 Ok(level) => *slot = Some(level),
602 crate fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
604 for s in v.split(',') {
606 "address" => SanitizerSet::ADDRESS,
607 "cfi" => SanitizerSet::CFI,
608 "leak" => SanitizerSet::LEAK,
609 "memory" => SanitizerSet::MEMORY,
610 "thread" => SanitizerSet::THREAD,
611 "hwaddress" => SanitizerSet::HWADDRESS,
621 crate fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
623 Some("2") | None => {
639 crate fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
641 Some("none") => *slot = Strip::None,
642 Some("debuginfo") => *slot = Strip::Debuginfo,
643 Some("symbols") => *slot = Strip::Symbols,
649 crate fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
651 let mut bool_arg = None;
652 if parse_opt_bool(&mut bool_arg, v) {
653 *slot = if bool_arg.unwrap() { CFGuard::Checks } else { CFGuard::Disabled };
659 None => CFGuard::Checks,
660 Some("checks") => CFGuard::Checks,
661 Some("nochecks") => CFGuard::NoChecks,
662 Some(_) => return false,
667 crate fn parse_linker_flavor(slot: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
668 match v.and_then(LinkerFlavor::from_str) {
669 Some(lf) => *slot = Some(lf),
675 crate fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
679 let parts = s.split('=').collect::<Vec<_>>();
680 if parts.len() != 2 {
683 let crate_name = parts[0].to_string();
684 let fuel = parts[1].parse::<u64>();
688 *slot = Some((crate_name, fuel.unwrap()));
694 crate fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
697 Some(s) if s.split('=').count() <= 2 => {
698 *slot = Some(s.to_string());
705 crate fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
707 let mut bool_arg = None;
708 if parse_opt_bool(&mut bool_arg, v) {
709 *slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
716 *slot = Some(MirSpanview::Statement);
722 *slot = Some(match v.trim_end_matches('s') {
723 "statement" | "stmt" => MirSpanview::Statement,
724 "terminator" | "term" => MirSpanview::Terminator,
725 "block" | "basicblock" => MirSpanview::Block,
731 crate fn parse_instrument_coverage(
732 slot: &mut Option<InstrumentCoverage>,
736 let mut bool_arg = None;
737 if parse_opt_bool(&mut bool_arg, v) {
738 *slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
745 *slot = Some(InstrumentCoverage::All);
751 *slot = Some(match v {
752 "all" => InstrumentCoverage::All,
753 "except-unused-generics" | "except_unused_generics" => {
754 InstrumentCoverage::ExceptUnusedGenerics
756 "except-unused-functions" | "except_unused_functions" => {
757 InstrumentCoverage::ExceptUnusedFunctions
759 "off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
765 crate fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
768 *slot = s.parse().ok();
772 *slot = NonZeroUsize::new(1);
778 crate fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
780 let mut bool_arg = None;
781 if parse_opt_bool(&mut bool_arg, v) {
782 *slot = if bool_arg.unwrap() { LtoCli::Yes } else { LtoCli::No };
788 None => LtoCli::NoParam,
789 Some("thin") => LtoCli::Thin,
790 Some("fat") => LtoCli::Fat,
791 Some(_) => return false,
796 crate fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
798 let mut bool_arg = None;
799 if parse_opt_bool(&mut bool_arg, v) {
800 *slot = if bool_arg.unwrap() {
801 LinkerPluginLto::LinkerPluginAuto
803 LinkerPluginLto::Disabled
810 None => LinkerPluginLto::LinkerPluginAuto,
811 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
816 crate fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
818 None => SwitchWithOptPath::Enabled(None),
819 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
824 crate fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
825 match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
826 Some(mergefunc) => *slot = Some(mergefunc),
832 crate fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
833 match v.and_then(|s| RelocModel::from_str(s).ok()) {
834 Some(relocation_model) => *slot = Some(relocation_model),
835 None if v == Some("default") => *slot = None,
841 crate fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
842 match v.and_then(|s| CodeModel::from_str(s).ok()) {
843 Some(code_model) => *slot = Some(code_model),
849 crate fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
850 match v.and_then(|s| TlsModel::from_str(s).ok()) {
851 Some(tls_model) => *slot = Some(tls_model),
857 crate fn parse_symbol_mangling_version(
858 slot: &mut Option<SymbolManglingVersion>,
862 Some("legacy") => Some(SymbolManglingVersion::Legacy),
863 Some("v0") => Some(SymbolManglingVersion::V0),
869 crate fn parse_src_file_hash(
870 slot: &mut Option<SourceFileHashAlgorithm>,
873 match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
874 Some(hash_kind) => *slot = Some(hash_kind),
880 crate fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
883 if !slot.is_empty() {
893 crate fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
895 Some("command") => *slot = Some(WasiExecModel::Command),
896 Some("reactor") => *slot = Some(WasiExecModel::Reactor),
902 crate fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
903 match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
904 Some(e) => *slot = Some(e),
910 crate fn parse_gcc_ld(slot: &mut Option<LdImpl>, v: Option<&str>) -> bool {
912 None => *slot = None,
913 Some("lld") => *slot = Some(LdImpl::Lld),
921 CodegenOptions, CG_OPTIONS, "C", "codegen",
923 // This list is in alphabetical order.
925 // If you add a new option, please update:
926 // - compiler/rustc_interface/src/tests.rs
927 // - src/doc/rustc/src/codegen-options/index.md
929 ar: String = (String::new(), parse_string, [UNTRACKED],
930 "this option is deprecated and does nothing"),
931 code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
932 "choose the code model to use (`rustc --print code-models` for details)"),
933 codegen_units: Option<usize> = (None, parse_opt_number, [UNTRACKED],
934 "divide crate into N units to optimize in parallel"),
935 control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
936 "use Windows Control Flow Guard (default: no)"),
937 debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
938 "explicitly enable the `cfg(debug_assertions)` directive"),
939 debuginfo: usize = (0, parse_number, [TRACKED],
940 "debug info emission level (0 = no debug info, 1 = line tables only, \
941 2 = full debug info with variable and type information; default: 0)"),
942 default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
943 "allow the linker to link its default libraries (default: no)"),
944 embed_bitcode: bool = (true, parse_bool, [TRACKED],
945 "emit bitcode in rlibs (default: yes)"),
946 extra_filename: String = (String::new(), parse_string, [UNTRACKED],
947 "extra data to put in each output filename"),
948 force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
949 "force use of the frame pointers"),
950 force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
951 "force use of unwind tables"),
952 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
953 "enable incremental compilation"),
954 inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
955 "set the threshold for inlining a function"),
956 link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
957 "a single extra argument to append to the linker invocation (can be used several times)"),
958 link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
959 "extra arguments to append to the linker invocation (space separated)"),
960 link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED],
961 "keep dead code at link time (useful for code coverage) (default: no)"),
962 link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
963 "control whether to link Rust provided C objects/libraries or rely
964 on C toolchain installed in the system"),
965 linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
966 "system linker to link outputs with"),
967 linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
969 linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
970 parse_linker_plugin_lto, [TRACKED],
971 "generate build artifacts that are compatible with linker-based LTO"),
972 llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
973 "a list of arguments to pass to LLVM (space separated)"),
974 lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
975 "perform LLVM link-time optimizations"),
976 metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
977 "metadata to mangle symbol names with"),
978 no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
979 "give an empty list of passes to the pass manager"),
980 no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
981 "disable the use of the redzone"),
982 no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
983 "this option is deprecated and does nothing"),
984 no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
985 "disable loop vectorization optimization passes"),
986 no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
987 "disable LLVM's SLP vectorization pass"),
988 opt_level: String = ("0".to_string(), parse_string, [TRACKED],
989 "optimization level (0-3, s, or z; default: 0)"),
990 overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
991 "use overflow checks for integer arithmetic"),
992 panic: Option<PanicStrategy> = (None, parse_opt_panic_strategy, [TRACKED],
993 "panic strategy to compile crate with"),
994 passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
995 "a list of extra LLVM passes to run (space separated)"),
996 prefer_dynamic: bool = (false, parse_bool, [TRACKED],
997 "prefer dynamic linking to static linking (default: no)"),
998 profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
999 parse_switch_with_opt_path, [TRACKED],
1000 "compile the program with profiling instrumentation"),
1001 profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1002 "use the given `.profdata` file for profile-guided optimization"),
1003 relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
1004 "control generation of position-independent code (PIC) \
1005 (`rustc --print relocation-models` for details)"),
1006 remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
1007 "print remarks for these optimization passes (space separated, or \"all\")"),
1008 rpath: bool = (false, parse_bool, [UNTRACKED],
1009 "set rpath values in libs/exes (default: no)"),
1010 save_temps: bool = (false, parse_bool, [UNTRACKED],
1011 "save all temporary output files during compilation (default: no)"),
1012 soft_float: bool = (false, parse_bool, [TRACKED],
1013 "use soft float ABI (*eabihf targets only) (default: no)"),
1014 split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
1015 "how to handle split-debuginfo, a platform-specific option"),
1016 target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
1017 "select target processor (`rustc --print target-cpus` for details)"),
1018 target_feature: String = (String::new(), parse_target_feature, [TRACKED],
1019 "target specific attributes. (`rustc --print target-features` for details). \
1020 This feature is unsafe."),
1022 // This list is in alphabetical order.
1024 // If you add a new option, please update:
1025 // - compiler/rustc_interface/src/tests.rs
1026 // - src/doc/rustc/src/codegen-options/index.md
1030 DebuggingOptions, DB_OPTIONS, "Z", "debugging",
1032 // This list is in alphabetical order.
1034 // If you add a new option, please update:
1035 // - compiler/rustc_interface/src/tests.rs
1037 allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
1038 "only allow the listed language features to be enabled in code (space separated)"),
1039 always_encode_mir: bool = (false, parse_bool, [TRACKED],
1040 "encode MIR of all functions into the crate metadata (default: no)"),
1041 assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
1042 "make cfg(version) treat the current version as incomplete (default: no)"),
1043 asm_comments: bool = (false, parse_bool, [TRACKED],
1044 "generate comments into the assembly (may change behavior) (default: no)"),
1045 ast_json: bool = (false, parse_bool, [UNTRACKED],
1046 "print the AST as JSON and halt (default: no)"),
1047 ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
1048 "print the pre-expansion AST as JSON and halt (default: no)"),
1049 binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
1050 "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
1052 borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
1053 "select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
1054 cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
1055 "the codegen unit partitioning strategy to use"),
1056 chalk: bool = (false, parse_bool, [TRACKED],
1057 "enable the experimental Chalk-based trait solving engine"),
1058 codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
1059 "the backend to use"),
1060 combine_cgu: bool = (false, parse_bool, [TRACKED],
1061 "combine CGUs into a single one"),
1062 crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
1063 "inject the given attribute in the crate"),
1064 debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
1065 "emit discriminators and other data necessary for AutoFDO"),
1066 debug_macros: bool = (false, parse_bool, [TRACKED],
1067 "emit line numbers debug info inside macros (default: no)"),
1068 deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
1069 "deduplicate identical diagnostics (default: yes)"),
1070 dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
1071 "in dep-info output, omit targets for tracking dependencies of the dep-info files \
1072 themselves (default: no)"),
1073 dep_tasks: bool = (false, parse_bool, [UNTRACKED],
1074 "print tasks that execute and the color their dep node gets (requires debug build) \
1076 dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
1077 "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
1079 dual_proc_macros: bool = (false, parse_bool, [TRACKED],
1080 "load proc macros for both target and host, but only link to the target (default: no)"),
1081 dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1082 "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
1084 dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
1085 "dump MIR state to file.
1086 `val` is used to select which passes and functions to dump. For example:
1087 `all` matches all passes and functions,
1088 `foo` matches all passes for functions whose name contains 'foo',
1089 `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
1090 `foo | bar` all passes for function names containing 'foo' or 'bar'."),
1091 dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
1092 "in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
1094 dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
1095 "the directory the MIR is dumped into (default: `mir_dump`)"),
1096 dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
1097 "exclude the pass number when dumping MIR (used in tests) (default: no)"),
1098 dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
1099 "in addition to `.mir` files, create graphviz `.dot` files (and with \
1100 `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived \
1101 coverage graph) (default: no)"),
1102 dump_mir_spanview: Option<MirSpanview> = (None, parse_mir_spanview, [UNTRACKED],
1103 "in addition to `.mir` files, create `.html` files to view spans for \
1104 all `statement`s (including terminators), only `terminator` spans, or \
1105 computed `block` spans (one span encompassing a block's terminator and \
1106 all statements). If `-Z instrument-coverage` is also enabled, create \
1107 an additional `.html` file showing the computed coverage spans."),
1108 emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED],
1109 "emits a future-incompatibility report for lints (RFC 2834)"),
1110 emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
1111 "emit a section containing stack size metadata (default: no)"),
1112 fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
1113 "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
1115 force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
1116 "force overflow checks on or off"),
1117 force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
1118 "force all crates to be `rustc_private` unstable (default: no)"),
1119 fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
1120 "set the optimization fuel quota for a crate"),
1121 function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
1122 "whether each function should go in its own section"),
1123 future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
1124 "forces all lints to be future incompatible, used for internal testing (default: no)"),
1125 gcc_ld: Option<LdImpl> = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"),
1126 graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
1127 "use dark-themed colors in graphviz output (default: no)"),
1128 graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
1129 "use the given `fontname` in graphviz output; can be overridden by setting \
1130 environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
1131 hir_stats: bool = (false, parse_bool, [UNTRACKED],
1132 "print some statistics about AST and HIR (default: no)"),
1133 human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
1134 "generate human-readable, predictable names for codegen units (default: no)"),
1135 identify_regions: bool = (false, parse_bool, [UNTRACKED],
1136 "display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
1137 incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
1138 "ignore spans during ICH computation -- used for testing (default: no)"),
1139 incremental_info: bool = (false, parse_bool, [UNTRACKED],
1140 "print high-level information about incremental reuse (or the lack thereof) \
1142 incremental_relative_spans: bool = (false, parse_bool, [TRACKED],
1143 "hash spans relative to their parent item for incr. comp. (default: no)"),
1144 incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
1145 "verify incr. comp. hashes of green query instances (default: no)"),
1146 inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
1147 "enable MIR inlining (default: no)"),
1148 inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1149 "a default MIR inlining threshold (default: 50)"),
1150 inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1151 "inlining threshold for functions with inline hint (default: 100)"),
1152 inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
1153 "control whether `#[inline]` functions are in all CGUs"),
1154 input_stats: bool = (false, parse_bool, [UNTRACKED],
1155 "gather statistics about the input (default: no)"),
1156 instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1157 "instrument the generated code to support LLVM source-based code coverage \
1158 reports (note, the compiler build config must include `profiler = true`); \
1159 implies `-Z symbol-mangling-version=v0`. Optional values are:
1160 `=all` (implicit value)
1161 `=except-unused-generics`
1162 `=except-unused-functions`
1164 instrument_mcount: bool = (false, parse_bool, [TRACKED],
1165 "insert function instrument code for mcount-based tracing (default: no)"),
1166 keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
1167 "keep hygiene data after analysis (default: no)"),
1168 link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
1169 "link native libraries in the linker invocation (default: yes)"),
1170 link_only: bool = (false, parse_bool, [TRACKED],
1171 "link the `.rlink` file generated by `-Z no-link` (default: no)"),
1172 llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1173 "a list LLVM plugins to enable (space separated)"),
1174 llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
1175 "generate JSON tracing data file from LLVM data (default: no)"),
1176 location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
1177 "comma seperated list of location details to be tracked when using caller_location \
1178 valid options are `file`, `line`, and `column` (default: all)"),
1179 ls: bool = (false, parse_bool, [UNTRACKED],
1180 "list the symbols defined by a library crate (default: no)"),
1181 macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1182 "show macro backtraces (default: no)"),
1183 merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
1184 "control the operation of the MergeFunctions LLVM pass, taking \
1185 the same values as the target option of the same name"),
1186 meta_stats: bool = (false, parse_bool, [UNTRACKED],
1187 "gather metadata statistics (default: no)"),
1188 mir_emit_retag: bool = (false, parse_bool, [TRACKED],
1189 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
1191 mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
1192 "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
1193 move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
1194 "the size at which the `large_assignments` lint starts to be emitted"),
1195 mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1196 "emit noalias metadata for mutable references (default: yes)"),
1197 new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
1198 "use new LLVM pass manager (default: no)"),
1199 nll_facts: bool = (false, parse_bool, [UNTRACKED],
1200 "dump facts from NLL analysis into side files (default: no)"),
1201 nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
1202 "the directory the NLL facts are dumped into (default: `nll-facts`)"),
1203 no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
1204 "parse and expand the source, but run no analysis"),
1205 no_codegen: bool = (false, parse_no_flag, [TRACKED_NO_CRATE_HASH],
1206 "run all passes except codegen; no output"),
1207 no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
1208 "omit DWARF address ranges that give faster lookups"),
1209 no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
1210 "execute lints separately; allows benchmarking individual lints"),
1211 no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
1212 "disable the 'leak check' for subtyping; unsound, but useful for tests"),
1213 no_link: bool = (false, parse_no_flag, [TRACKED],
1214 "compile without linking"),
1215 no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
1216 "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1217 no_unique_section_names: bool = (false, parse_bool, [TRACKED],
1218 "do not use unique names for text and data sections when -Z function-sections is used"),
1219 no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
1220 "prevent automatic injection of the profiler_builtins crate"),
1221 normalize_docs: bool = (false, parse_bool, [TRACKED],
1222 "normalize associated items in rustdoc when generating documentation"),
1223 osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
1224 "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
1225 panic_abort_tests: bool = (false, parse_bool, [TRACKED],
1226 "support compiling tests with panic=abort (default: no)"),
1227 panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
1228 "panic strategy for panics in drops"),
1229 parse_only: bool = (false, parse_bool, [UNTRACKED],
1230 "parse only; do not compile, assemble, or link (default: no)"),
1231 partially_uninit_const_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1232 "allow generating const initializers with mixed init/uninit bytes, \
1233 and set the maximum total size of a const allocation for which this is allowed (default: never)"),
1234 perf_stats: bool = (false, parse_bool, [UNTRACKED],
1235 "print some performance-related statistics (default: no)"),
1236 plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
1237 "whether to use the PLT when calling into shared libraries;
1238 only has effect for PIC code on systems with ELF binaries
1239 (default: PLT is disabled if full relro is enabled)"),
1240 polonius: bool = (false, parse_bool, [TRACKED],
1241 "enable polonius-based borrow-checker (default: no)"),
1242 polymorphize: bool = (false, parse_bool, [TRACKED],
1243 "perform polymorphization analysis"),
1244 pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
1245 "a single extra argument to prepend the linker invocation (can be used several times)"),
1246 pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
1247 "extra arguments to prepend to the linker invocation (space separated)"),
1248 precise_enum_drop_elaboration: bool = (true, parse_bool, [TRACKED],
1249 "use a more precise version of drop elaboration for matches on enums (default: yes). \
1250 This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
1251 See #77382 and #74551."),
1252 print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
1253 "make rustc print the total optimization fuel used by a crate"),
1254 print_link_args: bool = (false, parse_bool, [UNTRACKED],
1255 "print the arguments passed to the linker (default: no)"),
1256 print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1257 "print the LLVM optimization passes being run (default: no)"),
1258 print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
1259 "print the result of the monomorphization collection pass"),
1260 print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
1261 "print layout information for each type encountered (default: no)"),
1262 proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
1263 "show backtraces for panics during proc-macro execution (default: no)"),
1264 profile: bool = (false, parse_bool, [TRACKED],
1265 "insert profiling code (default: no)"),
1266 profile_closures: bool = (false, parse_no_flag, [UNTRACKED],
1267 "profile size of closures"),
1268 profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1269 "file path to emit profiling data at runtime when using 'profile' \
1270 (default based on relative source path)"),
1271 profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
1272 "name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
1273 profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1274 "use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
1275 query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
1276 "enable queries of the dependency graph for regression testing (default: no)"),
1277 query_stats: bool = (false, parse_bool, [UNTRACKED],
1278 "print some statistics about the query system (default: no)"),
1279 randomize_layout: bool = (false, parse_bool, [TRACKED],
1280 "randomize the layout of types (default: no)"),
1281 relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
1282 "whether ELF relocations can be relaxed"),
1283 relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
1284 "choose which RELRO level to use"),
1285 remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1286 "remap paths under the current working directory to this path prefix"),
1287 simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
1288 "simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
1289 to rust's source base directory. only meant for testing purposes"),
1290 report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
1291 "immediately print bugs registered with `delay_span_bug` (default: no)"),
1292 sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1294 sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
1295 "enable origins tracking in MemorySanitizer"),
1296 sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
1297 "enable recovery for selected sanitizers"),
1298 saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
1299 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
1300 the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
1301 save_analysis: bool = (false, parse_bool, [UNTRACKED],
1302 "write syntax and type analysis (in JSON format) information, in \
1303 addition to normal output (default: no)"),
1304 self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
1305 parse_switch_with_opt_path, [UNTRACKED],
1306 "run the self profiler and output the raw event data"),
1307 /// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1308 self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
1309 "specify the events recorded by the self profiler;
1310 for example: `-Z self-profile-events=default,query-keys`
1311 all options: none, all, default, generic-activity, query-provider, query-cache-hit
1312 query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes"),
1313 share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
1314 "make the current crate share its generic instantiations"),
1315 show_span: Option<String> = (None, parse_opt_string, [TRACKED],
1316 "show spans for compiler debugging (expr|pat|ty)"),
1317 span_debug: bool = (false, parse_bool, [UNTRACKED],
1318 "forward proc_macro::Span's `Debug` impl to `Span`"),
1319 /// o/w tests have closure@path
1320 span_free_formats: bool = (false, parse_bool, [UNTRACKED],
1321 "exclude spans when debug-printing compiler state (default: no)"),
1322 src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
1323 "hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
1324 strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
1325 "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1326 split_dwarf_inlining: bool = (true, parse_bool, [UNTRACKED],
1327 "provide minimal debug info in the object/executable to facilitate online \
1328 symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF"),
1329 symbol_mangling_version: Option<SymbolManglingVersion> = (None,
1330 parse_symbol_mangling_version, [TRACKED],
1331 "which mangling version to use for symbol names ('legacy' (default) or 'v0')"),
1332 teach: bool = (false, parse_bool, [TRACKED],
1333 "show extended diagnostic help (default: no)"),
1334 terminal_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1335 "set the current terminal width"),
1336 tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
1337 "select processor to schedule for (`rustc --print target-cpus` for details)"),
1338 thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
1339 "enable ThinLTO when possible"),
1340 thir_unsafeck: bool = (false, parse_bool, [TRACKED],
1341 "use the THIR unsafety checker (default: no)"),
1342 /// We default to 1 here since we want to behave like
1343 /// a sequential compiler for now. This'll likely be adjusted
1344 /// in the future. Note that -Zthreads=0 is the way to get
1345 /// the num_cpus behavior.
1346 threads: usize = (1, parse_threads, [UNTRACKED],
1347 "use a thread pool with N threads"),
1348 time: bool = (false, parse_bool, [UNTRACKED],
1349 "measure time of rustc processes (default: no)"),
1350 time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
1351 "measure time of each LLVM pass (default: no)"),
1352 time_passes: bool = (false, parse_bool, [UNTRACKED],
1353 "measure time of each rustc pass (default: no)"),
1354 tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
1355 "choose the TLS model to use (`rustc --print tls-models` for details)"),
1356 trace_macros: bool = (false, parse_bool, [UNTRACKED],
1357 "for every macro invocation, print its name and arguments (default: no)"),
1358 trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
1359 "generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
1360 treat_err_as_bug: Option<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED],
1361 "treat error number `val` that occurs as bug"),
1362 trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
1363 "in diagnostics, use heuristics to shorten paths referring to items"),
1364 ui_testing: bool = (false, parse_bool, [UNTRACKED],
1365 "emit compiler diagnostics in a form suitable for UI testing (default: no)"),
1366 unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
1367 "take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
1368 unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1369 "present the input source, unstable (and less-pretty) variants;
1370 `normal`, `identified`,
1371 `expanded`, `expanded,identified`,
1372 `expanded,hygiene` (with internal representations),
1373 `everybody_loops` (all function bodies replaced with `loop {}`),
1374 `ast-tree` (raw AST before expansion),
1375 `ast-tree,expanded` (raw AST after expansion),
1376 `hir` (the HIR), `hir,identified`,
1377 `hir,typed` (HIR with types for each node),
1378 `hir-tree` (dump the raw HIR),
1379 `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
1380 unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
1381 "enable unsound and buggy MIR optimizations (default: no)"),
1382 unstable_options: bool = (false, parse_bool, [UNTRACKED],
1383 "adds unstable command line options to rustc interface (default: no)"),
1384 use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
1385 "use legacy .ctors section for initializers rather than .init_array"),
1386 validate_mir: bool = (false, parse_bool, [UNTRACKED],
1387 "validate MIR after each transformation"),
1388 verbose: bool = (false, parse_bool, [UNTRACKED],
1389 "in general, enable more debug printouts (default: no)"),
1390 verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
1391 "verify LLVM IR (default: no)"),
1392 wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
1393 "whether to build a wasi command or reactor"),
1395 // This list is in alphabetical order.
1397 // If you add a new option, please update:
1398 // - compiler/rustc_interface/src/tests.rs
1401 #[derive(Clone, Hash, PartialEq, Eq, Debug)]
1402 pub enum WasiExecModel {
1407 #[derive(Clone, Copy, Hash)]