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