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 fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
305 None => { *slot = true; true }
309 fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
313 "n" | "no" | "off" => {
316 "y" | "yes" | "on" => {
319 _ => { return false; }
324 None => { *slot = Some(true); true }
328 fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
330 Some(s) => { *slot = Some(s.to_string()); true },
335 fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
337 Some(s) => { *slot = Some(PathBuf::from(s)); true },
342 fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
344 Some(s) => { *slot = s.to_string(); true },
349 fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
351 Some(s) => { slot.push(s.to_string()); true },
356 fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
358 Some(s) => { slot.push(PathBuf::from(s)); true },
363 fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
367 slot.extend(s.split_whitespace().map(|s| s.to_string()));
374 fn parse_opt_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
378 let v = s.split_whitespace().map(|s| s.to_string()).collect();
386 fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
390 let v = s.split(',').map(|s| s.to_string()).collect();
398 fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
399 match v.and_then(|s| s.parse().ok()) {
400 Some(0) => { *slot = ::num_cpus::get(); true },
401 Some(i) => { *slot = i; true },
406 fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
407 match v.and_then(|s| s.parse().ok()) {
408 Some(i) => { *slot = i; true },
413 fn parse_opt_uint(slot: &mut Option<usize>, v: Option<&str>) -> bool {
415 Some(s) => { *slot = s.parse().ok(); slot.is_some() }
416 None => { *slot = None; false }
420 fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
427 let mut passes = vec![];
428 if parse_list(&mut passes, v) {
429 *slot = Passes::Some(passes);
438 fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
440 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
441 Some("abort") => *slot = Some(PanicStrategy::Abort),
447 fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
450 match s.parse::<RelroLevel>() {
451 Ok(level) => *slot = Some(level),
460 fn parse_sanitizer(slot: &mut Option<Sanitizer>, v: Option<&str>) -> bool {
461 if let Some(Ok(s)) = v.map(str::parse) {
469 fn parse_sanitizer_list(slot: &mut Vec<Sanitizer>, v: Option<&str>) -> bool {
471 for s in v.split(',').map(str::parse) {
473 if !slot.contains(&s) {
486 fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
487 match v.map(|s| s.parse()) {
492 Some(Ok(i)) if i <= 2 => {
502 fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
504 Some("disabled") => *slot = CFGuard::Disabled,
505 Some("nochecks") => *slot = CFGuard::NoChecks,
506 Some("checks") => *slot = CFGuard::Checks,
512 fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
513 match v.and_then(LinkerFlavor::from_str) {
514 Some(lf) => *slote = Some(lf),
520 fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
524 let parts = s.split('=').collect::<Vec<_>>();
525 if parts.len() != 2 { return false; }
526 let crate_name = parts[0].to_string();
527 let fuel = parts[1].parse::<u64>();
528 if fuel.is_err() { return false; }
529 *slot = Some((crate_name, fuel.unwrap()));
535 fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
538 Some(s) if s.split('=').count() <= 2 => {
539 *slot = Some(s.to_string());
546 fn parse_treat_err_as_bug(slot: &mut Option<usize>, v: Option<&str>) -> bool {
548 Some(s) => { *slot = s.parse().ok().filter(|&x| x != 0); slot.unwrap_or(0) != 0 }
549 None => { *slot = Some(1); true }
553 fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
555 let mut bool_arg = None;
556 if parse_opt_bool(&mut bool_arg, v) {
557 *slot = if bool_arg.unwrap() {
567 None => LtoCli::NoParam,
568 Some("thin") => LtoCli::Thin,
569 Some("fat") => LtoCli::Fat,
570 Some(_) => return false,
575 fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
577 let mut bool_arg = None;
578 if parse_opt_bool(&mut bool_arg, v) {
579 *slot = if bool_arg.unwrap() {
580 LinkerPluginLto::LinkerPluginAuto
582 LinkerPluginLto::Disabled
589 None => LinkerPluginLto::LinkerPluginAuto,
590 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
595 fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
597 None => SwitchWithOptPath::Enabled(None),
598 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
603 fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
604 match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
605 Some(mergefunc) => *slot = Some(mergefunc),
611 fn parse_symbol_mangling_version(
612 slot: &mut SymbolManglingVersion,
616 Some("legacy") => SymbolManglingVersion::Legacy,
617 Some("v0") => SymbolManglingVersion::V0,
625 options! {CodegenOptions, CodegenSetter, basic_codegen_options,
626 build_codegen_options, "C", "codegen",
627 CG_OPTIONS, cg_type_desc, cgsetters,
628 ar: Option<String> = (None, parse_opt_string, [UNTRACKED],
629 "this option is deprecated and does nothing"),
630 linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
631 "system linker to link outputs with"),
632 link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
633 "a single extra argument to append to the linker invocation (can be used several times)"),
634 link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
635 "extra arguments to append to the linker invocation (space separated)"),
636 link_dead_code: bool = (false, parse_bool, [UNTRACKED],
637 "don't let linker strip dead code (turning it on can be used for code coverage)"),
638 lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
639 "perform LLVM link-time optimizations"),
640 target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
641 "select target processor (`rustc --print target-cpus` for details)"),
642 target_feature: String = (String::new(), parse_string, [TRACKED],
643 "target specific attributes. (`rustc --print target-features` for details). \
644 This feature is unsafe."),
645 passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
646 "a list of extra LLVM passes to run (space separated)"),
647 llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
648 "a list of arguments to pass to LLVM (space separated)"),
649 save_temps: bool = (false, parse_bool, [UNTRACKED],
650 "save all temporary output files during compilation"),
651 rpath: bool = (false, parse_bool, [UNTRACKED],
652 "set rpath values in libs/exes"),
653 overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
654 "use overflow checks for integer arithmetic"),
655 no_prepopulate_passes: bool = (false, parse_bool, [TRACKED],
656 "don't pre-populate the pass manager with a list of passes"),
657 no_vectorize_loops: bool = (false, parse_bool, [TRACKED],
658 "don't run the loop vectorization optimization passes"),
659 no_vectorize_slp: bool = (false, parse_bool, [TRACKED],
660 "don't run LLVM's SLP vectorization pass"),
661 soft_float: bool = (false, parse_bool, [TRACKED],
662 "use soft float ABI (*eabihf targets only)"),
663 prefer_dynamic: bool = (false, parse_bool, [TRACKED],
664 "prefer dynamic linking to static linking"),
665 no_integrated_as: bool = (false, parse_bool, [TRACKED],
666 "use an external assembler rather than LLVM's integrated one"),
667 no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
668 "disable the use of the redzone"),
669 relocation_model: Option<String> = (None, parse_opt_string, [TRACKED],
670 "choose the relocation model to use (`rustc --print relocation-models` for details)"),
671 code_model: Option<String> = (None, parse_opt_string, [TRACKED],
672 "choose the code model to use (`rustc --print code-models` for details)"),
673 metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
674 "metadata to mangle symbol names with"),
675 extra_filename: String = (String::new(), parse_string, [UNTRACKED],
676 "extra data to put in each output filename"),
677 codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
678 "divide crate into N units to optimize in parallel"),
679 remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
680 "print remarks for these optimization passes (space separated, or \"all\")"),
681 no_stack_check: bool = (false, parse_bool, [UNTRACKED],
682 "the `--no-stack-check` flag is deprecated and does nothing"),
683 debuginfo: Option<usize> = (None, parse_opt_uint, [TRACKED],
684 "debug info emission level, 0 = no debug info, 1 = line tables only, \
685 2 = full debug info with variable and type information"),
686 opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
687 "optimize with possible levels 0-3, s, or z"),
688 force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
689 "force use of the frame pointers"),
690 debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
691 "explicitly enable the `cfg(debug_assertions)` directive"),
692 inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
693 "set the threshold for inlining a function (default: 225)"),
694 panic: Option<PanicStrategy> = (None, parse_panic_strategy,
695 [TRACKED], "panic strategy to compile crate with"),
696 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
697 "enable incremental compilation"),
698 default_linker_libraries: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
699 "allow the linker to link its default libraries"),
700 linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
702 linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
703 parse_linker_plugin_lto, [TRACKED],
704 "generate build artifacts that are compatible with linker-based LTO."),
705 profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
706 parse_switch_with_opt_path, [TRACKED],
707 "compile the program with profiling instrumentation"),
708 profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
709 "use the given `.profdata` file for profile-guided optimization"),
712 options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
713 build_debugging_options, "Z", "debugging",
714 DB_OPTIONS, db_type_desc, dbsetters,
715 codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
716 "the backend to use"),
717 verbose: bool = (false, parse_bool, [UNTRACKED],
718 "in general, enable more debug printouts"),
719 span_free_formats: bool = (false, parse_bool, [UNTRACKED],
720 "when debug-printing compiler state, do not include spans"), // o/w tests have closure@path
721 identify_regions: bool = (false, parse_bool, [UNTRACKED],
722 "make unnamed regions display as '# (where # is some non-ident unique id)"),
723 borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
724 "select which borrowck is used (`mir` or `migrate`)"),
725 time_passes: bool = (false, parse_bool, [UNTRACKED],
726 "measure time of each rustc pass"),
727 time: bool = (false, parse_bool, [UNTRACKED],
728 "measure time of rustc processes"),
729 time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
730 "measure time of each LLVM pass"),
731 llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
732 "generate JSON tracing data file from LLVM data"),
733 input_stats: bool = (false, parse_bool, [UNTRACKED],
734 "gather statistics about the input"),
735 asm_comments: bool = (false, parse_bool, [TRACKED],
736 "generate comments into the assembly (may change behavior)"),
737 verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
739 borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
740 "gather borrowck statistics"),
741 no_landing_pads: bool = (false, parse_bool, [TRACKED],
742 "omit landing pads for unwinding"),
743 fewer_names: bool = (false, parse_bool, [TRACKED],
744 "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"),
745 meta_stats: bool = (false, parse_bool, [UNTRACKED],
746 "gather metadata statistics"),
747 print_link_args: bool = (false, parse_bool, [UNTRACKED],
748 "print the arguments passed to the linker"),
749 print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
750 "prints the LLVM optimization passes being run"),
751 ast_json: bool = (false, parse_bool, [UNTRACKED],
752 "print the AST as JSON and halt"),
753 // We default to 1 here since we want to behave like
754 // a sequential compiler for now. This'll likely be adjusted
755 // in the future. Note that -Zthreads=0 is the way to get
756 // the num_cpus behavior.
757 threads: usize = (1, parse_threads, [UNTRACKED],
758 "use a thread pool with N threads"),
759 ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
760 "print the pre-expansion AST as JSON and halt"),
761 ls: bool = (false, parse_bool, [UNTRACKED],
762 "list the symbols defined by a library crate"),
763 save_analysis: bool = (false, parse_bool, [UNTRACKED],
764 "write syntax and type analysis (in JSON format) information, in \
765 addition to normal output"),
766 print_region_graph: bool = (false, parse_bool, [UNTRACKED],
767 "prints region inference graph. \
768 Use with RUST_REGION_GRAPH=help for more info"),
769 parse_only: bool = (false, parse_bool, [UNTRACKED],
770 "parse only; do not compile, assemble, or link"),
771 dual_proc_macros: bool = (false, parse_bool, [TRACKED],
772 "load proc macros for both target and host, but only link to the target"),
773 no_codegen: bool = (false, parse_bool, [TRACKED],
774 "run all passes except codegen; no output"),
775 treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
776 "treat error number `val` that occurs as bug"),
777 report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
778 "immediately print bugs registered with `delay_span_bug`"),
779 macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
780 "show macro backtraces"),
781 teach: bool = (false, parse_bool, [TRACKED],
782 "show extended diagnostic help"),
783 terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
784 "set the current terminal width"),
785 panic_abort_tests: bool = (false, parse_bool, [TRACKED],
786 "support compiling tests with panic=abort"),
787 dep_tasks: bool = (false, parse_bool, [UNTRACKED],
788 "print tasks that execute and the color their dep node gets (requires debug build)"),
789 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
790 "enable incremental compilation (experimental)"),
791 incremental_queries: bool = (true, parse_bool, [UNTRACKED],
792 "enable incremental compilation support for queries (experimental)"),
793 incremental_info: bool = (false, parse_bool, [UNTRACKED],
794 "print high-level information about incremental reuse (or the lack thereof)"),
795 incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED],
796 "dump hash information in textual format to stdout"),
797 incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
798 "verify incr. comp. hashes of green query instances"),
799 incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
800 "ignore spans during ICH computation -- used for testing"),
801 instrument_mcount: bool = (false, parse_bool, [TRACKED],
802 "insert function instrument code for mcount-based tracing"),
803 dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
804 "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
805 query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
806 "enable queries of the dependency graph for regression testing"),
807 no_analysis: bool = (false, parse_bool, [UNTRACKED],
808 "parse and expand the source, but run no analysis"),
809 unstable_options: bool = (false, parse_bool, [UNTRACKED],
810 "adds unstable command line options to rustc interface"),
811 force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
812 "force overflow checks on or off"),
813 trace_macros: bool = (false, parse_bool, [UNTRACKED],
814 "for every macro invocation, print its name and arguments"),
815 debug_macros: bool = (false, parse_bool, [TRACKED],
816 "emit line numbers debug info inside macros"),
817 generate_arange_section: bool = (true, parse_bool, [TRACKED],
818 "generate DWARF address ranges for faster lookups"),
819 keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
820 "don't clear the hygiene data after analysis"),
821 keep_ast: bool = (false, parse_bool, [UNTRACKED],
822 "keep the AST after lowering it to HIR"),
823 show_span: Option<String> = (None, parse_opt_string, [TRACKED],
824 "show spans for compiler debugging (expr|pat|ty)"),
825 print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
826 "print layout information for each type encountered"),
827 print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
828 "print the result of the monomorphization collection pass"),
829 mir_opt_level: usize = (1, parse_uint, [TRACKED],
830 "set the MIR optimization level (0-3, default: 1)"),
831 mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
832 "emit noalias metadata for mutable references (default: no)"),
833 dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
834 "dump MIR state to file.
835 `val` is used to select which passes and functions to dump. For example:
836 `all` matches all passes and functions,
837 `foo` matches all passes for functions whose name contains 'foo',
838 `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
839 `foo | bar` all passes for function names containing 'foo' or 'bar'."),
841 dump_mir_dir: String = (String::from("mir_dump"), parse_string, [UNTRACKED],
842 "the directory the MIR is dumped into"),
843 dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
844 "in addition to `.mir` files, create graphviz `.dot` files"),
845 dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
846 "if set, exclude the pass number when dumping MIR (used in tests)"),
847 mir_emit_retag: bool = (false, parse_bool, [TRACKED],
848 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0"),
849 perf_stats: bool = (false, parse_bool, [UNTRACKED],
850 "print some performance-related statistics"),
851 query_stats: bool = (false, parse_bool, [UNTRACKED],
852 "print some statistics about the query system"),
853 hir_stats: bool = (false, parse_bool, [UNTRACKED],
854 "print some statistics about AST and HIR"),
855 always_encode_mir: bool = (false, parse_bool, [TRACKED],
856 "encode MIR of all functions into the crate metadata"),
857 json_rendered: Option<String> = (None, parse_opt_string, [UNTRACKED],
858 "describes how to render the `rendered` field of json diagnostics"),
859 unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
860 "take the breaks off const evaluation. NOTE: this is unsound"),
861 osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
862 "pass `-install_name @rpath/...` to the macOS linker"),
863 sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
865 sanitizer_recover: Vec<Sanitizer> = (vec![], parse_sanitizer_list, [TRACKED],
866 "Enable recovery for selected sanitizers"),
867 sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
868 "Enable origins tracking in MemorySanitizer"),
869 fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
870 "set the optimization fuel quota for a crate"),
871 print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
872 "make rustc print the total optimization fuel used by a crate"),
873 force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
874 "force all crates to be `rustc_private` unstable"),
875 pre_link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
876 "a single extra argument to prepend the linker invocation (can be used several times)"),
877 pre_link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
878 "extra arguments to prepend to the linker invocation (space separated)"),
879 profile: bool = (false, parse_bool, [TRACKED],
880 "insert profiling code"),
881 relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
882 "choose which RELRO level to use"),
883 nll_facts: bool = (false, parse_bool, [UNTRACKED],
884 "dump facts from NLL analysis into side files"),
885 dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
886 "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting)."),
887 polonius: bool = (false, parse_bool, [UNTRACKED],
888 "enable polonius-based borrow-checker"),
889 codegen_time_graph: bool = (false, parse_bool, [UNTRACKED],
890 "generate a graphical HTML report of time spent in codegen and LLVM"),
891 thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
892 "enable ThinLTO when possible"),
893 inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
894 "control whether `#[inline]` functions are in all CGUs"),
895 tls_model: Option<String> = (None, parse_opt_string, [TRACKED],
896 "choose the TLS model to use (`rustc --print tls-models` for details)"),
897 saturating_float_casts: bool = (false, parse_bool, [TRACKED],
898 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
899 the max/min integer respectively, and NaN is mapped to 0"),
900 human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
901 "generate human-readable, predictable names for codegen units"),
902 dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
903 "in dep-info output, omit targets for tracking dependencies of the dep-info files \
905 unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
906 "present the input source, unstable (and less-pretty) variants;
907 valid types are any of the types for `--pretty`, as well as:
908 `expanded`, `expanded,identified`,
909 `expanded,hygiene` (with internal representations),
910 `everybody_loops` (all function bodies replaced with `loop {}`),
911 `hir` (the HIR), `hir,identified`,
912 `hir,typed` (HIR with types for each node),
913 `hir-tree` (dump the raw HIR),
914 `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
915 run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
916 "run `dsymutil` and delete intermediate object files"),
917 ui_testing: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
918 "format compiler diagnostics in a way that's better suitable for UI testing"),
919 embed_bitcode: bool = (false, parse_bool, [TRACKED],
920 "embed LLVM bitcode in object files"),
921 strip_debuginfo_if_disabled: Option<bool> = (None, parse_opt_bool, [TRACKED],
922 "tell the linker to strip debuginfo when building without debuginfo enabled."),
923 share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
924 "make the current crate share its generic instantiations"),
925 chalk: bool = (false, parse_bool, [TRACKED],
926 "enable the experimental Chalk-based trait solving engine"),
927 no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED],
928 "don't run LLVM in parallel (while keeping codegen-units and ThinLTO)"),
929 no_leak_check: bool = (false, parse_bool, [UNTRACKED],
930 "disables the 'leak check' for subtyping; unsound, but useful for tests"),
931 no_interleave_lints: bool = (false, parse_bool, [UNTRACKED],
932 "don't interleave execution of lints; allows benchmarking individual lints"),
933 crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
934 "inject the given attribute in the crate"),
935 self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
936 parse_switch_with_opt_path, [UNTRACKED],
937 "run the self profiler and output the raw event data"),
938 // keep this in sync with the event filter names in librustc_data_structures/profiling.rs
939 self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
940 "specifies which kinds of events get recorded by the self profiler;
941 for example: `-Z self-profile-events=default,query-keys`
942 all options: none, all, default, generic-activity, query-provider, query-cache-hit
943 query-blocked, incr-cache-load, query-keys, function-args, args, llvm"),
944 emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
945 "emits a section containing stack size metadata"),
946 plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
947 "whether to use the PLT when calling into shared libraries;
948 only has effect for PIC code on systems with ELF binaries
949 (default: PLT is disabled if full relro is enabled)"),
950 merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
951 "control the operation of the MergeFunctions LLVM pass, taking
952 the same values as the target option of the same name"),
953 allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
954 "only allow the listed language features to be enabled in code (space separated)"),
955 symbol_mangling_version: SymbolManglingVersion = (SymbolManglingVersion::Legacy,
956 parse_symbol_mangling_version, [TRACKED],
957 "which mangling version to use for symbol names"),
958 binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
959 "include artifacts (sysroot, crate dependencies) used during compilation in dep-info"),
960 insert_sideeffect: bool = (false, parse_bool, [TRACKED],
961 "fix undefined behavior when a thread doesn't eventually make progress \
962 (such as entering an empty infinite loop) by inserting llvm.sideeffect"),
963 deduplicate_diagnostics: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
964 "deduplicate identical diagnostics"),
965 control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [UNTRACKED],
966 "use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)"),
967 no_link: bool = (false, parse_bool, [TRACKED],
968 "compile without linking"),
969 link_only: bool = (false, parse_bool, [TRACKED],
970 "link the `.rlink` file generated by `-Z no-link`"),
971 new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
972 "use new LLVM pass manager"),