3 use crate::early_error;
5 use crate::search_paths::SearchPath;
6 use crate::utils::NativeLibraryKind;
8 use rustc_target::spec::TargetTriple;
9 use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
11 use rustc_feature::UnstableFeatures;
12 use rustc_span::edition::Edition;
14 use std::collections::BTreeMap;
16 use std::collections::hash_map::DefaultHasher;
17 use std::hash::Hasher;
18 use std::path::PathBuf;
21 macro_rules! hash_option {
22 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [UNTRACKED]) => {{}};
23 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [TRACKED]) => {{
25 .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
28 panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
33 macro_rules! top_level_options {
34 (pub struct Options { $(
35 $opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
43 pub fn dep_tracking_hash(&self) -> u64 {
44 let mut sub_hashes = BTreeMap::new();
49 [$dep_tracking_marker $($warn_val,
51 self.error_format)*]);
53 let mut hasher = DefaultHasher::new();
54 dep_tracking::stable_hash(sub_hashes,
63 // The top-level command-line options struct.
65 // For each option, one has to specify how it behaves with regard to the
66 // dependency tracking system of incremental compilation. This is done via the
67 // square-bracketed directive after the field type. The options are:
70 // A change in the given field will cause the compiler to completely clear the
71 // incremental compilation cache before proceeding.
74 // Incremental compilation is not influenced by this option.
76 // If you add a new option to this struct or one of the sub-structs like
77 // `CodegenOptions`, think about how it influences incremental compilation. If in
78 // doubt, specify [TRACKED], which is always "correct" but might lead to
79 // unnecessary re-compilation.
82 // The crate config requested for the session, which may be combined
83 // with additional crate configurations during the compile process.
84 crate_types: Vec<CrateType> [TRACKED],
85 optimize: OptLevel [TRACKED],
86 // Include the `debug_assertions` flag in dependency tracking, since it
87 // can influence whether overflow checks are done or not.
88 debug_assertions: bool [TRACKED],
89 debuginfo: DebugInfo [TRACKED],
90 lint_opts: Vec<(String, lint::Level)> [TRACKED],
91 lint_cap: Option<lint::Level> [TRACKED],
92 describe_lints: bool [UNTRACKED],
93 output_types: OutputTypes [TRACKED],
94 search_paths: Vec<SearchPath> [UNTRACKED],
95 libs: Vec<(String, Option<String>, Option<NativeLibraryKind>)> [TRACKED],
96 maybe_sysroot: Option<PathBuf> [UNTRACKED],
98 target_triple: TargetTriple [TRACKED],
100 test: bool [TRACKED],
101 error_format: ErrorOutputType [UNTRACKED],
103 // If `Some`, enable incremental compilation, using the given
104 // directory to store intermediate results.
105 incremental: Option<PathBuf> [UNTRACKED],
107 debugging_opts: DebuggingOptions [TRACKED],
108 prints: Vec<PrintRequest> [UNTRACKED],
109 // Determines which borrow checker(s) to run. This is the parsed, sanitized
110 // version of `debugging_opts.borrowck`, which is just a plain string.
111 borrowck_mode: BorrowckMode [UNTRACKED],
112 cg: CodegenOptions [TRACKED],
113 externs: Externs [UNTRACKED],
114 crate_name: Option<String> [TRACKED],
115 // An optional name to use as the crate for std during std injection,
116 // written `extern crate name as std`. Defaults to `std`. Used by
117 // out-of-tree drivers.
118 alt_std_name: Option<String> [TRACKED],
119 // Indicates how the compiler should treat unstable features.
120 unstable_features: UnstableFeatures [TRACKED],
122 // Indicates whether this run of the compiler is actually rustdoc. This
123 // is currently just a hack and will be removed eventually, so please
124 // try to not rely on this too much.
125 actually_rustdoc: bool [TRACKED],
127 // Specifications of codegen units / ThinLTO which are forced as a
128 // result of parsing command line options. These are not necessarily
129 // what rustc was invoked with, but massaged a bit to agree with
130 // commands like `--emit llvm-ir` which they're often incompatible with
131 // if we otherwise use the defaults of rustc.
132 cli_forced_codegen_units: Option<usize> [UNTRACKED],
133 cli_forced_thinlto_off: bool [UNTRACKED],
135 // Remap source path prefixes in all output (messages, object files, debug, etc.).
136 remap_path_prefix: Vec<(PathBuf, PathBuf)> [UNTRACKED],
138 edition: Edition [TRACKED],
140 // `true` if we're emitting JSON blobs about each artifact produced
142 json_artifact_notifications: bool [TRACKED],
144 pretty: Option<PpMode> [UNTRACKED],
148 /// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
149 /// macro is to define an interface that can be programmatically used by the option parser
150 /// to initialize the struct without hardcoding field names all over the place.
152 /// The goal is to invoke this macro once with the correct fields, and then this macro generates all
153 /// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
154 /// generated code to parse an option into its respective field in the struct. There are a few
155 /// hand-written parsers for parsing specific types of values in this module.
156 macro_rules! options {
157 ($struct_name:ident, $setter_name:ident, $defaultfn:ident,
158 $buildfn:ident, $prefix:expr, $outputname:expr,
159 $stat:ident, $mod_desc:ident, $mod_set:ident,
160 $($opt:ident : $t:ty = (
163 [$dep_tracking_marker:ident $(($dep_warn_val:expr, $dep_warn_text:expr))*],
168 pub struct $struct_name { $(pub $opt: $t),* }
170 pub fn $defaultfn() -> $struct_name {
171 $struct_name { $($opt: $init),* }
174 pub fn $buildfn(matches: &getopts::Matches, error_format: ErrorOutputType) -> $struct_name
176 let mut op = $defaultfn();
177 for option in matches.opt_strs($prefix) {
178 let mut iter = option.splitn(2, '=');
179 let key = iter.next().unwrap();
180 let value = iter.next();
181 let option_to_lookup = key.replace("-", "_");
182 let mut found = false;
183 for &(candidate, setter, opt_type_desc, _) in $stat {
184 if option_to_lookup != candidate { continue }
185 if !setter(&mut op, value) {
186 match (value, opt_type_desc) {
187 (Some(..), None) => {
188 early_error(error_format, &format!("{} option `{}` takes no \
189 value", $outputname, key))
191 (None, Some(type_desc)) => {
192 early_error(error_format, &format!("{0} option `{1}` requires \
193 {2} ({3} {1}=<value>)",
197 (Some(value), Some(type_desc)) => {
198 early_error(error_format, &format!("incorrect value `{}` for {} \
199 option `{}` - {} was expected",
203 (None, None) => panic!()
210 early_error(error_format, &format!("unknown {} option: `{}`",
217 impl dep_tracking::DepTrackingHash for $struct_name {
218 fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
219 let mut sub_hashes = BTreeMap::new();
224 [$dep_tracking_marker $($dep_warn_val,
228 dep_tracking::stable_hash(sub_hashes, hasher, error_format);
232 pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
233 pub const $stat: &[(&str, $setter_name, Option<&str>, &str)] =
234 &[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
236 #[allow(non_upper_case_globals, dead_code)]
238 pub const parse_bool: Option<&str> = None;
239 pub const parse_opt_bool: Option<&str> =
240 Some("one of: `y`, `yes`, `on`, `n`, `no`, or `off`");
241 pub const parse_string: Option<&str> = Some("a string");
242 pub const parse_string_push: Option<&str> = Some("a string");
243 pub const parse_pathbuf_push: Option<&str> = Some("a path");
244 pub const parse_opt_string: Option<&str> = Some("a string");
245 pub const parse_opt_pathbuf: Option<&str> = Some("a path");
246 pub const parse_list: Option<&str> = Some("a space-separated list of strings");
247 pub const parse_opt_list: Option<&str> = Some("a space-separated list of strings");
248 pub const parse_opt_comma_list: Option<&str> = Some("a comma-separated list of strings");
249 pub const parse_threads: Option<&str> = Some("a number");
250 pub const parse_uint: Option<&str> = Some("a number");
251 pub const parse_passes: Option<&str> =
252 Some("a space-separated list of passes, or `all`");
253 pub const parse_opt_uint: Option<&str> =
255 pub const parse_panic_strategy: Option<&str> =
256 Some("either `unwind` or `abort`");
257 pub const parse_relro_level: Option<&str> =
258 Some("one of: `full`, `partial`, or `off`");
259 pub const parse_sanitizer: Option<&str> =
260 Some("one of: `address`, `leak`, `memory` or `thread`");
261 pub const parse_sanitizer_list: Option<&str> =
262 Some("comma separated list of sanitizers");
263 pub const parse_sanitizer_memory_track_origins: Option<&str> = None;
264 pub const parse_cfguard: Option<&str> =
265 Some("either `disabled`, `nochecks`, or `checks`");
266 pub const parse_linker_flavor: Option<&str> =
267 Some(::rustc_target::spec::LinkerFlavor::one_of());
268 pub const parse_optimization_fuel: Option<&str> =
269 Some("crate=integer");
270 pub const parse_unpretty: Option<&str> =
271 Some("`string` or `string=string`");
272 pub const parse_treat_err_as_bug: Option<&str> =
273 Some("either no value or a number bigger than 0");
274 pub const parse_lto: Option<&str> =
275 Some("either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
277 pub const parse_linker_plugin_lto: Option<&str> =
278 Some("either a boolean (`yes`, `no`, `on`, `off`, etc), \
279 or the path to the linker plugin");
280 pub const parse_switch_with_opt_path: Option<&str> =
281 Some("an optional path to the profiling data output directory");
282 pub const parse_merge_functions: Option<&str> =
283 Some("one of: `disabled`, `trampolines`, or `aliases`");
284 pub const parse_symbol_mangling_version: Option<&str> =
285 Some("either `legacy` or `v0` (RFC 2603)");
290 use super::{$struct_name, Passes, Sanitizer, LtoCli, LinkerPluginLto, SwitchWithOptPath,
291 SymbolManglingVersion, CFGuard};
292 use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
293 use std::path::PathBuf;
294 use std::str::FromStr;
297 pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
298 $parse(&mut cg.$opt, v)
302 /// Set a flag to true. Note that it cannot set the flag to false, so
303 /// using this parser in combination with a flag that defaults to true
304 /// is useless; the flag will always be true.
305 fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
308 None => { *slot = true; true }
312 fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
316 "n" | "no" | "off" => {
319 "y" | "yes" | "on" => {
322 _ => { return false; }
327 None => { *slot = Some(true); true }
331 fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
333 Some(s) => { *slot = Some(s.to_string()); true },
338 fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
340 Some(s) => { *slot = Some(PathBuf::from(s)); true },
345 fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
347 Some(s) => { *slot = s.to_string(); true },
352 fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
354 Some(s) => { slot.push(s.to_string()); true },
359 fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
361 Some(s) => { slot.push(PathBuf::from(s)); true },
366 fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
370 slot.extend(s.split_whitespace().map(|s| s.to_string()));
377 fn parse_opt_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
381 let v = s.split_whitespace().map(|s| s.to_string()).collect();
389 fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
393 let v = s.split(',').map(|s| s.to_string()).collect();
401 fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
402 match v.and_then(|s| s.parse().ok()) {
403 Some(0) => { *slot = ::num_cpus::get(); true },
404 Some(i) => { *slot = i; true },
409 fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
410 match v.and_then(|s| s.parse().ok()) {
411 Some(i) => { *slot = i; true },
416 fn parse_opt_uint(slot: &mut Option<usize>, v: Option<&str>) -> bool {
418 Some(s) => { *slot = s.parse().ok(); slot.is_some() }
419 None => { *slot = None; false }
423 fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
430 let mut passes = vec![];
431 if parse_list(&mut passes, v) {
432 *slot = Passes::Some(passes);
441 fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
443 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
444 Some("abort") => *slot = Some(PanicStrategy::Abort),
450 fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
453 match s.parse::<RelroLevel>() {
454 Ok(level) => *slot = Some(level),
463 fn parse_sanitizer(slot: &mut Option<Sanitizer>, v: Option<&str>) -> bool {
464 if let Some(Ok(s)) = v.map(str::parse) {
472 fn parse_sanitizer_list(slot: &mut Vec<Sanitizer>, v: Option<&str>) -> bool {
474 for s in v.split(',').map(str::parse) {
476 if !slot.contains(&s) {
489 fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
490 match v.map(|s| s.parse()) {
495 Some(Ok(i)) if i <= 2 => {
505 fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
507 Some("disabled") => *slot = CFGuard::Disabled,
508 Some("nochecks") => *slot = CFGuard::NoChecks,
509 Some("checks") => *slot = CFGuard::Checks,
515 fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
516 match v.and_then(LinkerFlavor::from_str) {
517 Some(lf) => *slote = Some(lf),
523 fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
527 let parts = s.split('=').collect::<Vec<_>>();
528 if parts.len() != 2 { return false; }
529 let crate_name = parts[0].to_string();
530 let fuel = parts[1].parse::<u64>();
531 if fuel.is_err() { return false; }
532 *slot = Some((crate_name, fuel.unwrap()));
538 fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
541 Some(s) if s.split('=').count() <= 2 => {
542 *slot = Some(s.to_string());
549 fn parse_treat_err_as_bug(slot: &mut Option<usize>, v: Option<&str>) -> bool {
551 Some(s) => { *slot = s.parse().ok().filter(|&x| x != 0); slot.unwrap_or(0) != 0 }
552 None => { *slot = Some(1); true }
556 fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
558 let mut bool_arg = None;
559 if parse_opt_bool(&mut bool_arg, v) {
560 *slot = if bool_arg.unwrap() {
570 None => LtoCli::NoParam,
571 Some("thin") => LtoCli::Thin,
572 Some("fat") => LtoCli::Fat,
573 Some(_) => return false,
578 fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
580 let mut bool_arg = None;
581 if parse_opt_bool(&mut bool_arg, v) {
582 *slot = if bool_arg.unwrap() {
583 LinkerPluginLto::LinkerPluginAuto
585 LinkerPluginLto::Disabled
592 None => LinkerPluginLto::LinkerPluginAuto,
593 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
598 fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
600 None => SwitchWithOptPath::Enabled(None),
601 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
606 fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
607 match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
608 Some(mergefunc) => *slot = Some(mergefunc),
614 fn parse_symbol_mangling_version(
615 slot: &mut SymbolManglingVersion,
619 Some("legacy") => SymbolManglingVersion::Legacy,
620 Some("v0") => SymbolManglingVersion::V0,
628 options! {CodegenOptions, CodegenSetter, basic_codegen_options,
629 build_codegen_options, "C", "codegen",
630 CG_OPTIONS, cg_type_desc, cgsetters,
631 ar: Option<String> = (None, parse_opt_string, [UNTRACKED],
632 "this option is deprecated and does nothing"),
633 linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
634 "system linker to link outputs with"),
635 link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
636 "a single extra argument to append to the linker invocation (can be used several times)"),
637 link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
638 "extra arguments to append to the linker invocation (space separated)"),
639 link_dead_code: bool = (false, parse_bool, [UNTRACKED],
640 "don't let linker strip dead code (turning it on can be used for code coverage)"),
641 lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
642 "perform LLVM link-time optimizations"),
643 target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
644 "select target processor (`rustc --print target-cpus` for details)"),
645 target_feature: String = (String::new(), parse_string, [TRACKED],
646 "target specific attributes. (`rustc --print target-features` for details). \
647 This feature is unsafe."),
648 passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
649 "a list of extra LLVM passes to run (space separated)"),
650 llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
651 "a list of arguments to pass to LLVM (space separated)"),
652 save_temps: bool = (false, parse_bool, [UNTRACKED],
653 "save all temporary output files during compilation"),
654 rpath: bool = (false, parse_bool, [UNTRACKED],
655 "set rpath values in libs/exes"),
656 overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
657 "use overflow checks for integer arithmetic"),
658 no_prepopulate_passes: bool = (false, parse_bool, [TRACKED],
659 "don't pre-populate the pass manager with a list of passes"),
660 no_vectorize_loops: bool = (false, parse_bool, [TRACKED],
661 "don't run the loop vectorization optimization passes"),
662 no_vectorize_slp: bool = (false, parse_bool, [TRACKED],
663 "don't run LLVM's SLP vectorization pass"),
664 soft_float: bool = (false, parse_bool, [TRACKED],
665 "use soft float ABI (*eabihf targets only)"),
666 prefer_dynamic: bool = (false, parse_bool, [TRACKED],
667 "prefer dynamic linking to static linking"),
668 no_integrated_as: bool = (false, parse_bool, [TRACKED],
669 "use an external assembler rather than LLVM's integrated one"),
670 no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
671 "disable the use of the redzone"),
672 relocation_model: Option<String> = (None, parse_opt_string, [TRACKED],
673 "choose the relocation model to use (`rustc --print relocation-models` for details)"),
674 code_model: Option<String> = (None, parse_opt_string, [TRACKED],
675 "choose the code model to use (`rustc --print code-models` for details)"),
676 metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
677 "metadata to mangle symbol names with"),
678 extra_filename: String = (String::new(), parse_string, [UNTRACKED],
679 "extra data to put in each output filename"),
680 codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
681 "divide crate into N units to optimize in parallel"),
682 remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
683 "print remarks for these optimization passes (space separated, or \"all\")"),
684 no_stack_check: bool = (false, parse_bool, [UNTRACKED],
685 "the `--no-stack-check` flag is deprecated and does nothing"),
686 debuginfo: Option<usize> = (None, parse_opt_uint, [TRACKED],
687 "debug info emission level, 0 = no debug info, 1 = line tables only, \
688 2 = full debug info with variable and type information"),
689 opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
690 "optimize with possible levels 0-3, s, or z"),
691 force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
692 "force use of the frame pointers"),
693 debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
694 "explicitly enable the `cfg(debug_assertions)` directive"),
695 inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
696 "set the threshold for inlining a function (default: 225)"),
697 panic: Option<PanicStrategy> = (None, parse_panic_strategy,
698 [TRACKED], "panic strategy to compile crate with"),
699 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
700 "enable incremental compilation"),
701 default_linker_libraries: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
702 "allow the linker to link its default libraries"),
703 linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
705 linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
706 parse_linker_plugin_lto, [TRACKED],
707 "generate build artifacts that are compatible with linker-based LTO."),
708 profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
709 parse_switch_with_opt_path, [TRACKED],
710 "compile the program with profiling instrumentation"),
711 profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
712 "use the given `.profdata` file for profile-guided optimization"),
715 options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
716 build_debugging_options, "Z", "debugging",
717 DB_OPTIONS, db_type_desc, dbsetters,
718 codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
719 "the backend to use"),
720 verbose: bool = (false, parse_bool, [UNTRACKED],
721 "in general, enable more debug printouts"),
722 span_free_formats: bool = (false, parse_bool, [UNTRACKED],
723 "when debug-printing compiler state, do not include spans"), // o/w tests have closure@path
724 identify_regions: bool = (false, parse_bool, [UNTRACKED],
725 "make unnamed regions display as '# (where # is some non-ident unique id)"),
726 borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
727 "select which borrowck is used (`mir` or `migrate`)"),
728 time_passes: bool = (false, parse_bool, [UNTRACKED],
729 "measure time of each rustc pass"),
730 time: bool = (false, parse_bool, [UNTRACKED],
731 "measure time of rustc processes"),
732 time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
733 "measure time of each LLVM pass"),
734 llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
735 "generate JSON tracing data file from LLVM data"),
736 input_stats: bool = (false, parse_bool, [UNTRACKED],
737 "gather statistics about the input"),
738 asm_comments: bool = (false, parse_bool, [TRACKED],
739 "generate comments into the assembly (may change behavior)"),
740 verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
742 borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
743 "gather borrowck statistics"),
744 no_landing_pads: bool = (false, parse_bool, [TRACKED],
745 "omit landing pads for unwinding"),
746 fewer_names: bool = (false, parse_bool, [TRACKED],
747 "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"),
748 meta_stats: bool = (false, parse_bool, [UNTRACKED],
749 "gather metadata statistics"),
750 print_link_args: bool = (false, parse_bool, [UNTRACKED],
751 "print the arguments passed to the linker"),
752 print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
753 "prints the LLVM optimization passes being run"),
754 ast_json: bool = (false, parse_bool, [UNTRACKED],
755 "print the AST as JSON and halt"),
756 // We default to 1 here since we want to behave like
757 // a sequential compiler for now. This'll likely be adjusted
758 // in the future. Note that -Zthreads=0 is the way to get
759 // the num_cpus behavior.
760 threads: usize = (1, parse_threads, [UNTRACKED],
761 "use a thread pool with N threads"),
762 ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
763 "print the pre-expansion AST as JSON and halt"),
764 ls: bool = (false, parse_bool, [UNTRACKED],
765 "list the symbols defined by a library crate"),
766 save_analysis: bool = (false, parse_bool, [UNTRACKED],
767 "write syntax and type analysis (in JSON format) information, in \
768 addition to normal output"),
769 print_region_graph: bool = (false, parse_bool, [UNTRACKED],
770 "prints region inference graph. \
771 Use with RUST_REGION_GRAPH=help for more info"),
772 parse_only: bool = (false, parse_bool, [UNTRACKED],
773 "parse only; do not compile, assemble, or link"),
774 dual_proc_macros: bool = (false, parse_bool, [TRACKED],
775 "load proc macros for both target and host, but only link to the target"),
776 no_codegen: bool = (false, parse_bool, [TRACKED],
777 "run all passes except codegen; no output"),
778 treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
779 "treat error number `val` that occurs as bug"),
780 report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
781 "immediately print bugs registered with `delay_span_bug`"),
782 macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
783 "show macro backtraces"),
784 teach: bool = (false, parse_bool, [TRACKED],
785 "show extended diagnostic help"),
786 terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
787 "set the current terminal width"),
788 panic_abort_tests: bool = (false, parse_bool, [TRACKED],
789 "support compiling tests with panic=abort"),
790 dep_tasks: bool = (false, parse_bool, [UNTRACKED],
791 "print tasks that execute and the color their dep node gets (requires debug build)"),
792 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
793 "enable incremental compilation (experimental)"),
794 incremental_queries: bool = (true, parse_bool, [UNTRACKED],
795 "enable incremental compilation support for queries (experimental)"),
796 incremental_info: bool = (false, parse_bool, [UNTRACKED],
797 "print high-level information about incremental reuse (or the lack thereof)"),
798 incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED],
799 "dump hash information in textual format to stdout"),
800 incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
801 "verify incr. comp. hashes of green query instances"),
802 incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
803 "ignore spans during ICH computation -- used for testing"),
804 instrument_mcount: bool = (false, parse_bool, [TRACKED],
805 "insert function instrument code for mcount-based tracing"),
806 dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
807 "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
808 query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
809 "enable queries of the dependency graph for regression testing"),
810 no_analysis: bool = (false, parse_bool, [UNTRACKED],
811 "parse and expand the source, but run no analysis"),
812 unstable_options: bool = (false, parse_bool, [UNTRACKED],
813 "adds unstable command line options to rustc interface"),
814 force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
815 "force overflow checks on or off"),
816 trace_macros: bool = (false, parse_bool, [UNTRACKED],
817 "for every macro invocation, print its name and arguments"),
818 debug_macros: bool = (false, parse_bool, [TRACKED],
819 "emit line numbers debug info inside macros"),
820 generate_arange_section: bool = (true, parse_bool, [TRACKED],
821 "generate DWARF address ranges for faster lookups"),
822 keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
823 "don't clear the hygiene data after analysis"),
824 keep_ast: bool = (false, parse_bool, [UNTRACKED],
825 "keep the AST after lowering it to HIR"),
826 show_span: Option<String> = (None, parse_opt_string, [TRACKED],
827 "show spans for compiler debugging (expr|pat|ty)"),
828 print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
829 "print layout information for each type encountered"),
830 print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
831 "print the result of the monomorphization collection pass"),
832 mir_opt_level: usize = (1, parse_uint, [TRACKED],
833 "set the MIR optimization level (0-3, default: 1)"),
834 mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
835 "emit noalias metadata for mutable references (default: no)"),
836 dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
837 "dump MIR state to file.
838 `val` is used to select which passes and functions to dump. For example:
839 `all` matches all passes and functions,
840 `foo` matches all passes for functions whose name contains 'foo',
841 `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
842 `foo | bar` all passes for function names containing 'foo' or 'bar'."),
844 dump_mir_dir: String = (String::from("mir_dump"), parse_string, [UNTRACKED],
845 "the directory the MIR is dumped into"),
846 dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
847 "in addition to `.mir` files, create graphviz `.dot` files"),
848 dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
849 "if set, exclude the pass number when dumping MIR (used in tests)"),
850 mir_emit_retag: bool = (false, parse_bool, [TRACKED],
851 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0"),
852 perf_stats: bool = (false, parse_bool, [UNTRACKED],
853 "print some performance-related statistics"),
854 query_stats: bool = (false, parse_bool, [UNTRACKED],
855 "print some statistics about the query system"),
856 hir_stats: bool = (false, parse_bool, [UNTRACKED],
857 "print some statistics about AST and HIR"),
858 always_encode_mir: bool = (false, parse_bool, [TRACKED],
859 "encode MIR of all functions into the crate metadata"),
860 json_rendered: Option<String> = (None, parse_opt_string, [UNTRACKED],
861 "describes how to render the `rendered` field of json diagnostics"),
862 unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
863 "take the breaks off const evaluation. NOTE: this is unsound"),
864 osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
865 "pass `-install_name @rpath/...` to the macOS linker"),
866 sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
868 sanitizer_recover: Vec<Sanitizer> = (vec![], parse_sanitizer_list, [TRACKED],
869 "Enable recovery for selected sanitizers"),
870 sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
871 "Enable origins tracking in MemorySanitizer"),
872 fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
873 "set the optimization fuel quota for a crate"),
874 print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
875 "make rustc print the total optimization fuel used by a crate"),
876 force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
877 "force all crates to be `rustc_private` unstable"),
878 pre_link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
879 "a single extra argument to prepend the linker invocation (can be used several times)"),
880 pre_link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
881 "extra arguments to prepend to the linker invocation (space separated)"),
882 profile: bool = (false, parse_bool, [TRACKED],
883 "insert profiling code"),
884 relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
885 "choose which RELRO level to use"),
886 nll_facts: bool = (false, parse_bool, [UNTRACKED],
887 "dump facts from NLL analysis into side files"),
888 dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
889 "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting)."),
890 polonius: bool = (false, parse_bool, [UNTRACKED],
891 "enable polonius-based borrow-checker"),
892 codegen_time_graph: bool = (false, parse_bool, [UNTRACKED],
893 "generate a graphical HTML report of time spent in codegen and LLVM"),
894 thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
895 "enable ThinLTO when possible"),
896 inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
897 "control whether `#[inline]` functions are in all CGUs"),
898 tls_model: Option<String> = (None, parse_opt_string, [TRACKED],
899 "choose the TLS model to use (`rustc --print tls-models` for details)"),
900 saturating_float_casts: bool = (false, parse_bool, [TRACKED],
901 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
902 the max/min integer respectively, and NaN is mapped to 0"),
903 human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
904 "generate human-readable, predictable names for codegen units"),
905 dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
906 "in dep-info output, omit targets for tracking dependencies of the dep-info files \
908 unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
909 "present the input source, unstable (and less-pretty) variants;
910 valid types are any of the types for `--pretty`, as well as:
911 `expanded`, `expanded,identified`,
912 `expanded,hygiene` (with internal representations),
913 `everybody_loops` (all function bodies replaced with `loop {}`),
914 `hir` (the HIR), `hir,identified`,
915 `hir,typed` (HIR with types for each node),
916 `hir-tree` (dump the raw HIR),
917 `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
918 run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
919 "run `dsymutil` and delete intermediate object files"),
920 ui_testing: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
921 "format compiler diagnostics in a way that's better suitable for UI testing"),
922 embed_bitcode: bool = (false, parse_bool, [TRACKED],
923 "embed LLVM bitcode in object files"),
924 strip_debuginfo_if_disabled: Option<bool> = (None, parse_opt_bool, [TRACKED],
925 "tell the linker to strip debuginfo when building without debuginfo enabled."),
926 share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
927 "make the current crate share its generic instantiations"),
928 no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED],
929 "don't run LLVM in parallel (while keeping codegen-units and ThinLTO)"),
930 no_leak_check: bool = (false, parse_bool, [UNTRACKED],
931 "disables the 'leak check' for subtyping; unsound, but useful for tests"),
932 no_interleave_lints: bool = (false, parse_bool, [UNTRACKED],
933 "don't interleave execution of lints; allows benchmarking individual lints"),
934 crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
935 "inject the given attribute in the crate"),
936 self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
937 parse_switch_with_opt_path, [UNTRACKED],
938 "run the self profiler and output the raw event data"),
939 // keep this in sync with the event filter names in librustc_data_structures/profiling.rs
940 self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
941 "specifies which kinds of events get recorded by the self profiler;
942 for example: `-Z self-profile-events=default,query-keys`
943 all options: none, all, default, generic-activity, query-provider, query-cache-hit
944 query-blocked, incr-cache-load, query-keys, function-args, args, llvm"),
945 emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
946 "emits a section containing stack size metadata"),
947 plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
948 "whether to use the PLT when calling into shared libraries;
949 only has effect for PIC code on systems with ELF binaries
950 (default: PLT is disabled if full relro is enabled)"),
951 merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
952 "control the operation of the MergeFunctions LLVM pass, taking
953 the same values as the target option of the same name"),
954 allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
955 "only allow the listed language features to be enabled in code (space separated)"),
956 symbol_mangling_version: SymbolManglingVersion = (SymbolManglingVersion::Legacy,
957 parse_symbol_mangling_version, [TRACKED],
958 "which mangling version to use for symbol names"),
959 binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
960 "include artifacts (sysroot, crate dependencies) used during compilation in dep-info"),
961 insert_sideeffect: bool = (false, parse_bool, [TRACKED],
962 "fix undefined behavior when a thread doesn't eventually make progress \
963 (such as entering an empty infinite loop) by inserting llvm.sideeffect"),
964 deduplicate_diagnostics: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
965 "deduplicate identical diagnostics"),
966 control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [UNTRACKED],
967 "use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)"),
968 no_link: bool = (false, parse_bool, [TRACKED],
969 "compile without linking"),
970 link_only: bool = (false, parse_bool, [TRACKED],
971 "link the `.rlink` file generated by `-Z no-link`"),
972 new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
973 "use new LLVM pass manager"),