1use std::collections::BTreeMap;
2use std::num::{IntErrorKind, NonZero};
3use std::path::PathBuf;
4use std::str;
5
6use rustc_abi::Align;
7use rustc_data_structures::fx::FxIndexMap;
8use rustc_data_structures::profiling::TimePassesFormat;
9use rustc_data_structures::stable_hasher::StableHasher;
10use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl};
11use rustc_feature::UnstableFeatures;
12use rustc_hashes::Hash64;
13use rustc_macros::{BlobDecodable, Encodable};
14use rustc_span::edition::Edition;
15use rustc_span::{RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm};
16use rustc_target::spec::{
17 CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
18 RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility,
19 TargetTuple, TlsModel,
20};
21
22use crate::config::*;
23use crate::search_paths::SearchPath;
24use crate::utils::NativeLib;
25use crate::{EarlyDiagCtxt, Session, lint};
26
27macro_rules! insert {
28 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => {
29 if $sub_hashes
30 .insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
31 .is_some()
32 {
33 panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
34 }
35 };
36}
37
38macro_rules! hash_opt {
39 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [UNTRACKED]) => {{}};
40 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [TRACKED]) => {{ insert!($opt_name, $opt_expr, $sub_hashes) }};
41 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $for_crate_hash: ident, [TRACKED_NO_CRATE_HASH]) => {{
42 if !$for_crate_hash {
43 insert!($opt_name, $opt_expr, $sub_hashes)
44 }
45 }};
46 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, $_for_crate_hash: ident, [SUBSTRUCT]) => {{}};
47}
48
49macro_rules! hash_substruct {
50 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [UNTRACKED]) => {{}};
51 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED]) => {{}};
52 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [TRACKED_NO_CRATE_HASH]) => {{}};
53 ($opt_name:ident, $opt_expr:expr, $error_format:expr, $for_crate_hash:expr, $hasher:expr, [SUBSTRUCT]) => {
54 use crate::config::dep_tracking::DepTrackingHash;
55 $opt_expr.dep_tracking_hash($for_crate_hash, $error_format).hash(
56 $hasher,
57 $error_format,
58 $for_crate_hash,
59 );
60 };
61}
62
63pub struct ExtendedTargetModifierInfo {
68 pub prefix: String,
70 pub name: String,
72 pub tech_value: String,
74}
75
76#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, BlobDecodable)]
79pub struct TargetModifier {
80 pub opt: OptionsTargetModifiers,
82 pub value_name: String,
84}
85
86mod target_modifier_consistency_check {
87 use super::*;
88 pub(super) fn sanitizer(l: &TargetModifier, r: Option<&TargetModifier>) -> bool {
89 let mut lparsed: SanitizerSet = Default::default();
90 let lval = if l.value_name.is_empty() { None } else { Some(l.value_name.as_str()) };
91 parse::parse_sanitizers(&mut lparsed, lval);
92
93 let mut rparsed: SanitizerSet = Default::default();
94 let rval = r.filter(|v| !v.value_name.is_empty()).map(|v| v.value_name.as_str());
95 parse::parse_sanitizers(&mut rparsed, rval);
96
97 let tmod_sanitizers = SanitizerSet::MEMORY
101 | SanitizerSet::THREAD
102 | SanitizerSet::HWADDRESS
103 | SanitizerSet::CFI
104 | SanitizerSet::MEMTAG
105 | SanitizerSet::SHADOWCALLSTACK
106 | SanitizerSet::KCFI
107 | SanitizerSet::KERNELADDRESS
108 | SanitizerSet::SAFESTACK
109 | SanitizerSet::DATAFLOW;
110
111 lparsed & tmod_sanitizers == rparsed & tmod_sanitizers
112 }
113 pub(super) fn sanitizer_cfi_normalize_integers(
114 sess: &Session,
115 l: &TargetModifier,
116 r: Option<&TargetModifier>,
117 ) -> bool {
118 if sess.sanitizers().contains(SanitizerSet::KCFI) {
120 if let Some(r) = r {
121 return l.extend().tech_value == r.extend().tech_value;
122 } else {
123 return false;
124 }
125 }
126 true
127 }
128}
129
130impl TargetModifier {
131 pub fn extend(&self) -> ExtendedTargetModifierInfo {
132 self.opt.reparse(&self.value_name)
133 }
134 pub fn consistent(&self, sess: &Session, other: Option<&TargetModifier>) -> bool {
137 assert!(other.is_none() || self.opt == other.unwrap().opt);
138 match self.opt {
139 OptionsTargetModifiers::UnstableOptions(unstable) => match unstable {
140 UnstableOptionsTargetModifiers::sanitizer => {
141 return target_modifier_consistency_check::sanitizer(self, other);
142 }
143 UnstableOptionsTargetModifiers::sanitizer_cfi_normalize_integers => {
144 return target_modifier_consistency_check::sanitizer_cfi_normalize_integers(
145 sess, self, other,
146 );
147 }
148 _ => {}
149 },
150 _ => {}
151 };
152 match other {
153 Some(other) => self.extend().tech_value == other.extend().tech_value,
154 None => false,
155 }
156 }
157}
158
159fn tmod_push_impl(
160 opt: OptionsTargetModifiers,
161 tmod_vals: &BTreeMap<OptionsTargetModifiers, String>,
162 tmods: &mut Vec<TargetModifier>,
163) {
164 if let Some(v) = tmod_vals.get(&opt) {
165 tmods.push(TargetModifier { opt, value_name: v.clone() })
166 }
167}
168
169macro_rules! tmod_push {
170 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr) => {
171 if *$opt_expr != $init {
172 tmod_push_impl(
173 OptionsTargetModifiers::$struct_name($tmod_enum_name::$opt_name),
174 $tmod_vals,
175 $mods,
176 );
177 }
178 };
179}
180
181macro_rules! gather_tmods {
182 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
183 [SUBSTRUCT], [TARGET_MODIFIER]) => {
184 compile_error!("SUBSTRUCT can't be target modifier");
185 };
186 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
187 [UNTRACKED], [TARGET_MODIFIER]) => {
188 tmod_push!($struct_name, $tmod_enum_name, $opt_name, $opt_expr, $init, $mods, $tmod_vals)
189 };
190 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
191 [TRACKED], [TARGET_MODIFIER]) => {
192 tmod_push!($struct_name, $tmod_enum_name, $opt_name, $opt_expr, $init, $mods, $tmod_vals)
193 };
194 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
195 [TRACKED_NO_CRATE_HASH], [TARGET_MODIFIER]) => {
196 tmod_push!($struct_name, $tmod_enum_name, $opt_name, $opt_expr, $init, $mods, $tmod_vals)
197 };
198 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
199 [SUBSTRUCT], []) => {
200 $opt_expr.gather_target_modifiers($mods, $tmod_vals);
201 };
202 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
203 [UNTRACKED], []) => {{}};
204 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
205 [TRACKED], []) => {{}};
206 ($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
207 [TRACKED_NO_CRATE_HASH], []) => {{}};
208}
209
210macro_rules! gather_tmods_top_level {
211 ($_opt_name:ident, $opt_expr:expr, $mods:expr, $tmod_vals:expr, [SUBSTRUCT $substruct_enum:ident]) => {
212 $opt_expr.gather_target_modifiers($mods, $tmod_vals);
213 };
214 ($opt_name:ident, $opt_expr:expr, $mods:expr, $tmod_vals:expr, [$non_substruct:ident TARGET_MODIFIER]) => {
215 compile_error!("Top level option can't be target modifier");
216 };
217 ($opt_name:ident, $opt_expr:expr, $mods:expr, $tmod_vals:expr, [$non_substruct:ident]) => {};
218}
219
220macro_rules! top_level_tmod_enum {
241 ($( {$($optinfo:tt)*} ),* $(,)*) => {
242 top_level_tmod_enum! { @parse {}, (user_value){}; $($($optinfo)*|)* }
243 };
244 (
246 @parse
247 {$($variant:tt($substruct_enum:tt))*},
248 ($user_value:ident){$($pout:tt)*};
249 ) => {
250 #[allow(non_camel_case_types)]
251 #[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Copy, Clone, Encodable, BlobDecodable)]
252 pub enum OptionsTargetModifiers {
253 $($variant($substruct_enum)),*
254 }
255 impl OptionsTargetModifiers {
256 #[allow(unused_variables)]
257 pub fn reparse(&self, $user_value: &str) -> ExtendedTargetModifierInfo {
258 #[allow(unreachable_patterns)]
259 match self {
260 $($pout)*
261 _ => panic!("unknown target modifier option: {:?}", *self)
262 }
263 }
264 pub fn is_target_modifier(flag_name: &str) -> bool {
265 $($substruct_enum::is_target_modifier(flag_name))||*
266 }
267 }
268 };
269 (
271 @parse {$($eout:tt)*}, ($puser_value:ident){$($pout:tt)*};
272 [SUBSTRUCT $substruct_enum:ident $variant:ident] |
273 $($tail:tt)*
274 ) => {
275 top_level_tmod_enum! {
276 @parse
277 {
278 $($eout)*
279 $variant($substruct_enum)
280 },
281 ($puser_value){
282 $($pout)*
283 Self::$variant(v) => v.reparse($puser_value),
284 };
285 $($tail)*
286 }
287 };
288 (
290 @parse {$($eout:tt)*}, ($puser_value:ident){$($pout:tt)*};
291 [$non_substruct:ident] |
292 $($tail:tt)*
293 ) => {
294 top_level_tmod_enum! {
295 @parse
296 {
297 $($eout)*
298 },
299 ($puser_value){
300 $($pout)*
301 };
302 $($tail)*
303 }
304 };
305}
306
307macro_rules! top_level_options {
308 ( $( #[$top_level_attr:meta] )* pub struct Options { $(
309 $( #[$attr:meta] )*
310 $opt:ident : $t:ty [$dep_tracking_marker:ident $( $tmod:ident $variant:ident )?],
311 )* } ) => (
312 top_level_tmod_enum!( {$([$dep_tracking_marker $($tmod $variant),*])|*} );
313
314 #[derive(Clone)]
315 $( #[$top_level_attr] )*
316 pub struct Options {
317 $(
318 $( #[$attr] )*
319 pub $opt: $t
320 ),*,
321 pub target_modifiers: BTreeMap<OptionsTargetModifiers, String>,
322 }
323
324 impl Options {
325 pub fn dep_tracking_hash(&self, for_crate_hash: bool) -> Hash64 {
326 let mut sub_hashes = BTreeMap::new();
327 $({
328 hash_opt!($opt,
329 &self.$opt,
330 &mut sub_hashes,
331 for_crate_hash,
332 [$dep_tracking_marker]);
333 })*
334 let mut hasher = StableHasher::new();
335 dep_tracking::stable_hash(sub_hashes,
336 &mut hasher,
337 self.error_format,
338 for_crate_hash);
339 $({
340 hash_substruct!($opt,
341 &self.$opt,
342 self.error_format,
343 for_crate_hash,
344 &mut hasher,
345 [$dep_tracking_marker]);
346 })*
347 hasher.finish()
348 }
349
350 pub fn gather_target_modifiers(&self) -> Vec<TargetModifier> {
351 let mut mods = Vec::<TargetModifier>::new();
352 $({
353 gather_tmods_top_level!($opt,
354 &self.$opt, &mut mods, &self.target_modifiers,
355 [$dep_tracking_marker $($tmod),*]);
356 })*
357 mods.sort_by(|a, b| a.opt.cmp(&b.opt));
358 mods
359 }
360 }
361 );
362}
363
364top_level_options!(
365 #[rustc_lint_opt_ty]
390 pub struct Options {
391 #[rustc_lint_opt_deny_field_access("use `TyCtxt::crate_types` instead of this field")]
394 crate_types: Vec<CrateType> [TRACKED],
395 optimize: OptLevel [TRACKED],
396 debug_assertions: bool [TRACKED],
399 debuginfo: DebugInfo [TRACKED],
400 debuginfo_compression: DebugInfoCompression [TRACKED],
401 lint_opts: Vec<(String, lint::Level)> [TRACKED_NO_CRATE_HASH],
402 lint_cap: Option<lint::Level> [TRACKED_NO_CRATE_HASH],
403 describe_lints: bool [UNTRACKED],
404 output_types: OutputTypes [TRACKED],
405 search_paths: Vec<SearchPath> [UNTRACKED],
406 libs: Vec<NativeLib> [TRACKED],
407 sysroot: Sysroot [UNTRACKED],
408
409 target_triple: TargetTuple [TRACKED],
410
411 logical_env: FxIndexMap<String, String> [TRACKED],
413
414 test: bool [TRACKED],
415 error_format: ErrorOutputType [UNTRACKED],
416 diagnostic_width: Option<usize> [UNTRACKED],
417
418 incremental: Option<PathBuf> [UNTRACKED],
421 assert_incr_state: Option<IncrementalStateAssertion> [UNTRACKED],
422 #[rustc_lint_opt_deny_field_access("should only be used via `Config::hash_untracked_state`")]
425 untracked_state_hash: Hash64 [TRACKED_NO_CRATE_HASH],
426
427 unstable_opts: UnstableOptions [SUBSTRUCT UnstableOptionsTargetModifiers UnstableOptions],
428 prints: Vec<PrintRequest> [UNTRACKED],
429 cg: CodegenOptions [SUBSTRUCT CodegenOptionsTargetModifiers CodegenOptions],
430 externs: Externs [UNTRACKED],
431 crate_name: Option<String> [TRACKED],
432 unstable_features: UnstableFeatures [TRACKED],
434
435 actually_rustdoc: bool [TRACKED],
439 resolve_doc_links: ResolveDocLinks [TRACKED],
441
442 trimmed_def_paths: bool [TRACKED],
444
445 #[rustc_lint_opt_deny_field_access("use `Session::codegen_units` instead of this field")]
451 cli_forced_codegen_units: Option<usize> [UNTRACKED],
452 #[rustc_lint_opt_deny_field_access("use `Session::lto` instead of this field")]
453 cli_forced_local_thinlto_off: bool [UNTRACKED],
454
455 remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH],
457
458 real_rust_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH],
466
467 real_rustc_dev_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH],
475
476 edition: Edition [TRACKED],
477
478 json_artifact_notifications: bool [TRACKED],
481
482 json_timings: bool [UNTRACKED],
485
486 json_unused_externs: JsonUnusedExterns [UNTRACKED],
488
489 json_future_incompat: bool [TRACKED],
491
492 pretty: Option<PpMode> [UNTRACKED],
493
494 #[rustc_lint_opt_deny_field_access("use `SourceMap::working_dir` instead of this field")]
496 working_dir: RealFileName [TRACKED],
497
498 color: ColorConfig [UNTRACKED],
499
500 verbose: bool [TRACKED_NO_CRATE_HASH],
501 }
502);
503
504macro_rules! tmod_enum_opt {
505 ($struct_name:ident, $tmod_enum_name:ident, $opt:ident, $v:ident) => {
506 Some(OptionsTargetModifiers::$struct_name($tmod_enum_name::$opt))
507 };
508 ($struct_name:ident, $tmod_enum_name:ident, $opt:ident, ) => {
509 None
510 };
511}
512
513macro_rules! tmod_enum {
514 ($tmod_enum_name:ident, $prefix:expr, $( {$($optinfo:tt)*} ),* $(,)*) => {
515 tmod_enum! { $tmod_enum_name, $prefix, @parse {}, (user_value){}; $($($optinfo)*|)* }
516 };
517 (
519 $tmod_enum_name:ident, $prefix:expr,
520 @parse
521 {$($eout:tt)*},
522 ($user_value:ident){$($pout:tt)*};
523 ) => {
524 #[allow(non_camel_case_types)]
525 #[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Copy, Clone, Encodable, BlobDecodable)]
526 pub enum $tmod_enum_name {
527 $($eout),*
528 }
529 impl $tmod_enum_name {
530 #[allow(unused_variables)]
531 pub fn reparse(&self, $user_value: &str) -> ExtendedTargetModifierInfo {
532 #[allow(unreachable_patterns)]
533 match self {
534 $($pout)*
535 _ => panic!("unknown target modifier option: {:?}", *self)
536 }
537 }
538 pub fn is_target_modifier(flag_name: &str) -> bool {
539 match flag_name.replace('-', "_").as_str() {
540 $(stringify!($eout) => true,)*
541 _ => false,
542 }
543 }
544 }
545 };
546 (
548 $tmod_enum_name:ident, $prefix:expr,
549 @parse {$($eout:tt)*}, ($puser_value:ident){$($pout:tt)*};
550 $opt:ident, $parse:ident, $t:ty, [TARGET_MODIFIER] |
551 $($tail:tt)*
552 ) => {
553 tmod_enum! {
554 $tmod_enum_name, $prefix,
555 @parse
556 {
557 $($eout)*
558 $opt
559 },
560 ($puser_value){
561 $($pout)*
562 Self::$opt => {
563 let mut parsed : $t = Default::default();
564 let val = if $puser_value.is_empty() { None } else { Some($puser_value) };
565 parse::$parse(&mut parsed, val);
566 ExtendedTargetModifierInfo {
567 prefix: $prefix.to_string(),
568 name: stringify!($opt).to_string().replace('_', "-"),
569 tech_value: format!("{:?}", parsed),
570 }
571 },
572 };
573 $($tail)*
574 }
575 };
576 (
578 $tmod_enum_name:ident, $prefix:expr,
579 @parse {$($eout:tt)*}, ($puser_value:ident){$($pout:tt)*};
580 $opt:ident, $parse:ident, $t:ty, [] |
581 $($tail:tt)*
582 ) => {
583 tmod_enum! {
584 $tmod_enum_name, $prefix,
585 @parse
586 {
587 $($eout)*
588 },
589 ($puser_value){
590 $($pout)*
591 };
592 $($tail)*
593 }
594 };
595}
596
597macro_rules! options {
606 ($struct_name:ident, $tmod_enum_name:ident, $stat:ident, $optmod:ident, $prefix:expr, $outputname:expr,
607 $($( #[$attr:meta] )* $opt:ident : $t:ty = (
608 $init:expr,
609 $parse:ident,
610 [$dep_tracking_marker:ident $( $tmod:ident )?],
611 $desc:expr
612 $(, deprecated_do_nothing: $dnn:literal )?)
613 ),* ,) =>
614(
615 #[derive(Clone)]
616 #[rustc_lint_opt_ty]
617 pub struct $struct_name { $( $( #[$attr] )* pub $opt: $t),* }
618
619 tmod_enum!( $tmod_enum_name, $prefix, {$($opt, $parse, $t, [$($tmod),*])|*} );
620
621 impl Default for $struct_name {
622 fn default() -> $struct_name {
623 $struct_name { $($opt: $init),* }
624 }
625 }
626
627 impl $struct_name {
628 pub fn build(
629 early_dcx: &EarlyDiagCtxt,
630 matches: &getopts::Matches,
631 target_modifiers: &mut BTreeMap<OptionsTargetModifiers, String>,
632 ) -> $struct_name {
633 build_options(early_dcx, matches, target_modifiers, $stat, $prefix, $outputname)
634 }
635
636 fn dep_tracking_hash(&self, for_crate_hash: bool, error_format: ErrorOutputType) -> Hash64 {
637 let mut sub_hashes = BTreeMap::new();
638 $({
639 hash_opt!($opt,
640 &self.$opt,
641 &mut sub_hashes,
642 for_crate_hash,
643 [$dep_tracking_marker]);
644 })*
645 let mut hasher = StableHasher::new();
646 dep_tracking::stable_hash(sub_hashes,
647 &mut hasher,
648 error_format,
649 for_crate_hash
650 );
651 hasher.finish()
652 }
653
654 pub fn gather_target_modifiers(
655 &self,
656 _mods: &mut Vec<TargetModifier>,
657 _tmod_vals: &BTreeMap<OptionsTargetModifiers, String>,
658 ) {
659 $({
660 gather_tmods!($struct_name, $tmod_enum_name, $opt, &self.$opt, $init, _mods, _tmod_vals,
661 [$dep_tracking_marker], [$($tmod),*]);
662 })*
663 }
664 }
665
666 pub const $stat: OptionDescrs<$struct_name> =
667 &[ $( OptionDesc{ name: stringify!($opt), setter: $optmod::$opt,
668 type_desc: desc::$parse, desc: $desc, is_deprecated_and_do_nothing: false $( || $dnn )?,
669 tmod: tmod_enum_opt!($struct_name, $tmod_enum_name, $opt, $($tmod),*) } ),* ];
670
671 mod $optmod {
672 $(
673 pub(super) fn $opt(cg: &mut super::$struct_name, v: Option<&str>) -> bool {
674 super::parse::$parse(&mut redirect_field!(cg.$opt), v)
675 }
676 )*
677 }
678
679) }
680
681impl CodegenOptions {
682 #[allow(rustc::bad_opt_access)]
684 pub fn instrument_coverage(&self) -> InstrumentCoverage {
685 self.instrument_coverage
686 }
687}
688
689macro_rules! redirect_field {
692 ($cg:ident.link_arg) => {
693 $cg.link_args
694 };
695 ($cg:ident.pre_link_arg) => {
696 $cg.pre_link_args
697 };
698 ($cg:ident.$field:ident) => {
699 $cg.$field
700 };
701}
702
703type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
704type OptionDescrs<O> = &'static [OptionDesc<O>];
705
706pub struct OptionDesc<O> {
707 name: &'static str,
708 setter: OptionSetter<O>,
709 type_desc: &'static str,
711 desc: &'static str,
713 is_deprecated_and_do_nothing: bool,
714 tmod: Option<OptionsTargetModifiers>,
715}
716
717impl<O> OptionDesc<O> {
718 pub fn name(&self) -> &'static str {
719 self.name
720 }
721
722 pub fn desc(&self) -> &'static str {
723 self.desc
724 }
725}
726
727#[allow(rustc::untranslatable_diagnostic)] fn build_options<O: Default>(
729 early_dcx: &EarlyDiagCtxt,
730 matches: &getopts::Matches,
731 target_modifiers: &mut BTreeMap<OptionsTargetModifiers, String>,
732 descrs: OptionDescrs<O>,
733 prefix: &str,
734 outputname: &str,
735) -> O {
736 let mut op = O::default();
737 for option in matches.opt_strs(prefix) {
738 let (key, value) = match option.split_once('=') {
739 None => (option, None),
740 Some((k, v)) => (k.to_string(), Some(v)),
741 };
742
743 let option_to_lookup = key.replace('-', "_");
744 match descrs.iter().find(|opt_desc| opt_desc.name == option_to_lookup) {
745 Some(OptionDesc {
746 name: _,
747 setter,
748 type_desc,
749 desc,
750 is_deprecated_and_do_nothing,
751 tmod,
752 }) => {
753 if *is_deprecated_and_do_nothing {
754 assert!(!prefix.is_empty());
756 early_dcx.early_warn(format!("`-{prefix} {key}`: {desc}"));
757 }
758 if !setter(&mut op, value) {
759 match value {
760 None => early_dcx.early_fatal(
761 format!(
762 "{outputname} option `{key}` requires {type_desc} ({prefix} {key}=<value>)"
763 ),
764 ),
765 Some(value) => early_dcx.early_fatal(
766 format!(
767 "incorrect value `{value}` for {outputname} option `{key}` - {type_desc} was expected"
768 ),
769 ),
770 }
771 }
772 if let Some(tmod) = *tmod {
773 let v = value.map_or(String::new(), ToOwned::to_owned);
774 target_modifiers.insert(tmod, v);
775 }
776 }
777 None => early_dcx.early_fatal(format!("unknown {outputname} option: `{key}`")),
778 }
779 }
780 op
781}
782
783#[allow(non_upper_case_globals)]
784mod desc {
785 pub(crate) const parse_no_value: &str = "no value";
786 pub(crate) const parse_bool: &str =
787 "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
788 pub(crate) const parse_opt_bool: &str = parse_bool;
789 pub(crate) const parse_string: &str = "a string";
790 pub(crate) const parse_opt_string: &str = parse_string;
791 pub(crate) const parse_string_push: &str = parse_string;
792 pub(crate) const parse_opt_langid: &str = "a language identifier";
793 pub(crate) const parse_opt_pathbuf: &str = "a path";
794 pub(crate) const parse_list: &str = "a space-separated list of strings";
795 pub(crate) const parse_list_with_polarity: &str =
796 "a comma-separated list of strings, with elements beginning with + or -";
797 pub(crate) const parse_autodiff: &str = "a comma separated list of settings: `Enable`, `PrintSteps`, `PrintTA`, `PrintTAFn`, `PrintAA`, `PrintPerf`, `PrintModBefore`, `PrintModAfter`, `PrintModFinal`, `PrintPasses`, `NoPostopt`, `LooseTypes`, `Inline`, `NoTT`";
798 pub(crate) const parse_offload: &str = "a comma separated list of settings: `Enable`";
799 pub(crate) const parse_comma_list: &str = "a comma-separated list of strings";
800 pub(crate) const parse_opt_comma_list: &str = parse_comma_list;
801 pub(crate) const parse_number: &str = "a number";
802 pub(crate) const parse_opt_number: &str = parse_number;
803 pub(crate) const parse_frame_pointer: &str = "one of `true`/`yes`/`on`, `false`/`no`/`off`, or (with -Zunstable-options) `non-leaf` or `always`";
804 pub(crate) const parse_threads: &str = parse_number;
805 pub(crate) const parse_time_passes_format: &str = "`text` (default) or `json`";
806 pub(crate) const parse_passes: &str = "a space-separated list of passes, or `all`";
807 pub(crate) const parse_panic_strategy: &str = "either `unwind`, `abort`, or `immediate-abort`";
808 pub(crate) const parse_on_broken_pipe: &str = "either `kill`, `error`, or `inherit`";
809 pub(crate) const parse_patchable_function_entry: &str = "either two comma separated integers (total_nops,prefix_nops), with prefix_nops <= total_nops, or one integer (total_nops)";
810 pub(crate) const parse_opt_panic_strategy: &str = parse_panic_strategy;
811 pub(crate) const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
812 pub(crate) const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, `thread`, or 'realtime'";
813 pub(crate) const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
814 pub(crate) const parse_cfguard: &str =
815 "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
816 pub(crate) const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
817 pub(crate) const parse_debuginfo: &str = "either an integer (0, 1, 2), `none`, `line-directives-only`, `line-tables-only`, `limited`, or `full`";
818 pub(crate) const parse_debuginfo_compression: &str = "one of `none`, `zlib`, or `zstd`";
819 pub(crate) const parse_mir_strip_debuginfo: &str =
820 "one of `none`, `locals-in-tiny-functions`, or `all-locals`";
821 pub(crate) const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
822 pub(crate) const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
823 pub(crate) const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
824 pub(crate) const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
825 pub(crate) const parse_instrument_coverage: &str = parse_bool;
826 pub(crate) const parse_coverage_options: &str = "`block` | `branch` | `condition`";
827 pub(crate) const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
828 pub(crate) const parse_unpretty: &str = "`string` or `string=string`";
829 pub(crate) const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
830 pub(crate) const parse_next_solver_config: &str =
831 "either `globally` (when used without an argument), `coherence` (default) or `no`";
832 pub(crate) const parse_lto: &str =
833 "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
834 pub(crate) const parse_linker_plugin_lto: &str =
835 "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
836 pub(crate) const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`";
837 pub(crate) const parse_fmt_debug: &str = "either `full`, `shallow`, or `none`";
838 pub(crate) const parse_switch_with_opt_path: &str =
839 "an optional path to the profiling data output directory";
840 pub(crate) const parse_merge_functions: &str =
841 "one of: `disabled`, `trampolines`, or `aliases`";
842 pub(crate) const parse_symbol_mangling_version: &str =
843 "one of: `legacy`, `v0` (RFC 2603), or `hashed`";
844 pub(crate) const parse_opt_symbol_visibility: &str =
845 "one of: `hidden`, `protected`, or `interposable`";
846 pub(crate) const parse_cargo_src_file_hash: &str =
847 "one of `blake3`, `md5`, `sha1`, or `sha256`";
848 pub(crate) const parse_src_file_hash: &str = "one of `md5`, `sha1`, or `sha256`";
849 pub(crate) const parse_relocation_model: &str =
850 "one of supported relocation models (`rustc --print relocation-models`)";
851 pub(crate) const parse_code_model: &str =
852 "one of supported code models (`rustc --print code-models`)";
853 pub(crate) const parse_tls_model: &str =
854 "one of supported TLS models (`rustc --print tls-models`)";
855 pub(crate) const parse_target_feature: &str = parse_string;
856 pub(crate) const parse_terminal_url: &str =
857 "either a boolean (`yes`, `no`, `on`, `off`, etc), or `auto`";
858 pub(crate) const parse_wasi_exec_model: &str = "either `command` or `reactor`";
859 pub(crate) const parse_split_debuginfo: &str =
860 "one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
861 pub(crate) const parse_split_dwarf_kind: &str =
862 "one of supported split dwarf modes (`split` or `single`)";
863 pub(crate) const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
864 components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`";
865 pub(crate) const parse_linker_features: &str =
866 "a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld`";
867 pub(crate) const parse_polonius: &str = "either no value or `legacy` (the default), or `next`";
868 pub(crate) const parse_annotate_moves: &str =
869 "either a boolean (`yes`, `no`, `on`, `off`, etc.), or a size limit in bytes";
870 pub(crate) const parse_stack_protector: &str =
871 "one of (`none` (default), `basic`, `strong`, or `all`)";
872 pub(crate) const parse_branch_protection: &str = "a `,` separated combination of `bti`, `gcs`, `pac-ret`, (optionally with `pc`, `b-key`, `leaf` if `pac-ret` is set)";
873 pub(crate) const parse_proc_macro_execution_strategy: &str =
874 "one of supported execution strategies (`same-thread`, or `cross-thread`)";
875 pub(crate) const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`";
876 pub(crate) const parse_inlining_threshold: &str =
877 "either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
878 pub(crate) const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
879 pub(crate) const parse_function_return: &str = "`keep` or `thunk-extern`";
880 pub(crate) const parse_wasm_c_abi: &str = "`spec`";
881 pub(crate) const parse_mir_include_spans: &str =
882 "either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
883 pub(crate) const parse_align: &str = "a number that is a power of 2 between 1 and 2^29";
884}
885
886pub mod parse {
887 use std::str::FromStr;
888
889 pub(crate) use super::*;
890 pub(crate) const MAX_THREADS_CAP: usize = 256;
891
892 pub(crate) fn parse_no_value(slot: &mut bool, v: Option<&str>) -> bool {
898 match v {
899 None => {
900 *slot = true;
901 true
902 }
903 Some(_) => false,
905 }
906 }
907
908 pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
910 match v {
911 Some("y") | Some("yes") | Some("on") | Some("true") | None => {
912 *slot = true;
913 true
914 }
915 Some("n") | Some("no") | Some("off") | Some("false") => {
916 *slot = false;
917 true
918 }
919 _ => false,
920 }
921 }
922
923 pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
927 match v {
928 Some("y") | Some("yes") | Some("on") | Some("true") | None => {
929 *slot = Some(true);
930 true
931 }
932 Some("n") | Some("no") | Some("off") | Some("false") => {
933 *slot = Some(false);
934 true
935 }
936 _ => false,
937 }
938 }
939
940 pub(crate) fn parse_polonius(slot: &mut Polonius, v: Option<&str>) -> bool {
942 match v {
943 Some("legacy") | None => {
944 *slot = Polonius::Legacy;
945 true
946 }
947 Some("next") => {
948 *slot = Polonius::Next;
949 true
950 }
951 _ => false,
952 }
953 }
954
955 pub(crate) fn parse_annotate_moves(slot: &mut AnnotateMoves, v: Option<&str>) -> bool {
956 let mut bslot = false;
957 let mut nslot = 0u64;
958
959 *slot = match v {
960 None => AnnotateMoves::Enabled(None),
962 s @ Some(_) if parse_bool(&mut bslot, s) => {
964 if bslot {
965 AnnotateMoves::Enabled(None)
966 } else {
967 AnnotateMoves::Disabled
968 }
969 }
970 s @ Some(_) if parse_number(&mut nslot, s) => AnnotateMoves::Enabled(Some(nslot)),
972 _ => return false,
973 };
974
975 true
976 }
977
978 pub(crate) fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
980 match v {
981 Some(s) => {
982 *slot = s.to_string();
983 true
984 }
985 None => false,
986 }
987 }
988
989 pub(crate) fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
991 match v {
992 Some(s) => {
993 *slot = Some(s.to_string());
994 true
995 }
996 None => false,
997 }
998 }
999
1000 pub(crate) fn parse_opt_langid(slot: &mut Option<LanguageIdentifier>, v: Option<&str>) -> bool {
1002 match v {
1003 Some(s) => {
1004 *slot = rustc_errors::LanguageIdentifier::from_str(s).ok();
1005 true
1006 }
1007 None => false,
1008 }
1009 }
1010
1011 pub(crate) fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
1012 match v {
1013 Some(s) => {
1014 *slot = Some(PathBuf::from(s));
1015 true
1016 }
1017 None => false,
1018 }
1019 }
1020
1021 pub(crate) fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
1022 match v {
1023 Some(s) => {
1024 slot.push(s.to_string());
1025 true
1026 }
1027 None => false,
1028 }
1029 }
1030
1031 pub(crate) fn parse_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
1032 match v {
1033 Some(s) => {
1034 slot.extend(s.split_whitespace().map(|s| s.to_string()));
1035 true
1036 }
1037 None => false,
1038 }
1039 }
1040
1041 pub(crate) fn parse_list_with_polarity(
1042 slot: &mut Vec<(String, bool)>,
1043 v: Option<&str>,
1044 ) -> bool {
1045 match v {
1046 Some(s) => {
1047 for s in s.split(',') {
1048 let Some(pass_name) = s.strip_prefix(&['+', '-'][..]) else { return false };
1049 slot.push((pass_name.to_string(), &s[..1] == "+"));
1050 }
1051 true
1052 }
1053 None => false,
1054 }
1055 }
1056
1057 pub(crate) fn parse_fmt_debug(opt: &mut FmtDebug, v: Option<&str>) -> bool {
1058 *opt = match v {
1059 Some("full") => FmtDebug::Full,
1060 Some("shallow") => FmtDebug::Shallow,
1061 Some("none") => FmtDebug::None,
1062 _ => return false,
1063 };
1064 true
1065 }
1066
1067 pub(crate) fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
1068 if let Some(v) = v {
1069 ld.line = false;
1070 ld.file = false;
1071 ld.column = false;
1072 if v == "none" {
1073 return true;
1074 }
1075 for s in v.split(',') {
1076 match s {
1077 "file" => ld.file = true,
1078 "line" => ld.line = true,
1079 "column" => ld.column = true,
1080 _ => return false,
1081 }
1082 }
1083 true
1084 } else {
1085 false
1086 }
1087 }
1088
1089 pub(crate) fn parse_comma_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
1090 match v {
1091 Some(s) => {
1092 let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
1093 v.sort_unstable();
1094 *slot = v;
1095 true
1096 }
1097 None => false,
1098 }
1099 }
1100
1101 pub(crate) fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
1102 match v {
1103 Some(s) => {
1104 let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
1105 v.sort_unstable();
1106 *slot = Some(v);
1107 true
1108 }
1109 None => false,
1110 }
1111 }
1112
1113 pub(crate) fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
1114 let ret = match v.and_then(|s| s.parse().ok()) {
1115 Some(0) => {
1116 *slot = std::thread::available_parallelism().map_or(1, NonZero::<usize>::get);
1117 true
1118 }
1119 Some(i) => {
1120 *slot = i;
1121 true
1122 }
1123 None => false,
1124 };
1125 *slot = slot.clone().min(MAX_THREADS_CAP);
1128 ret
1129 }
1130
1131 pub(crate) fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
1133 match v.and_then(|s| s.parse().ok()) {
1134 Some(i) => {
1135 *slot = i;
1136 true
1137 }
1138 None => false,
1139 }
1140 }
1141
1142 pub(crate) fn parse_opt_number<T: Copy + FromStr>(
1144 slot: &mut Option<T>,
1145 v: Option<&str>,
1146 ) -> bool {
1147 match v {
1148 Some(s) => {
1149 *slot = s.parse().ok();
1150 slot.is_some()
1151 }
1152 None => false,
1153 }
1154 }
1155
1156 pub(crate) fn parse_frame_pointer(slot: &mut FramePointer, v: Option<&str>) -> bool {
1157 let mut yes = false;
1158 match v {
1159 _ if parse_bool(&mut yes, v) && yes => slot.ratchet(FramePointer::Always),
1160 _ if parse_bool(&mut yes, v) => slot.ratchet(FramePointer::MayOmit),
1161 Some("always") => slot.ratchet(FramePointer::Always),
1162 Some("non-leaf") => slot.ratchet(FramePointer::NonLeaf),
1163 _ => return false,
1164 };
1165 true
1166 }
1167
1168 pub(crate) fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
1169 match v {
1170 Some("all") => {
1171 *slot = Passes::All;
1172 true
1173 }
1174 v => {
1175 let mut passes = vec![];
1176 if parse_list(&mut passes, v) {
1177 slot.extend(passes);
1178 true
1179 } else {
1180 false
1181 }
1182 }
1183 }
1184 }
1185
1186 pub(crate) fn parse_opt_panic_strategy(
1187 slot: &mut Option<PanicStrategy>,
1188 v: Option<&str>,
1189 ) -> bool {
1190 match v {
1191 Some("unwind") => *slot = Some(PanicStrategy::Unwind),
1192 Some("abort") => *slot = Some(PanicStrategy::Abort),
1193 Some("immediate-abort") => *slot = Some(PanicStrategy::ImmediateAbort),
1194 _ => return false,
1195 }
1196 true
1197 }
1198
1199 pub(crate) fn parse_panic_strategy(slot: &mut PanicStrategy, v: Option<&str>) -> bool {
1200 match v {
1201 Some("unwind") => *slot = PanicStrategy::Unwind,
1202 Some("abort") => *slot = PanicStrategy::Abort,
1203 Some("immediate-abort") => *slot = PanicStrategy::ImmediateAbort,
1204 _ => return false,
1205 }
1206 true
1207 }
1208
1209 pub(crate) fn parse_on_broken_pipe(slot: &mut OnBrokenPipe, v: Option<&str>) -> bool {
1210 match v {
1211 Some("kill") => *slot = OnBrokenPipe::Kill,
1213 Some("error") => *slot = OnBrokenPipe::Error,
1214 Some("inherit") => *slot = OnBrokenPipe::Inherit,
1215 _ => return false,
1216 }
1217 true
1218 }
1219
1220 pub(crate) fn parse_patchable_function_entry(
1221 slot: &mut PatchableFunctionEntry,
1222 v: Option<&str>,
1223 ) -> bool {
1224 let mut total_nops = 0;
1225 let mut prefix_nops = 0;
1226
1227 if !parse_number(&mut total_nops, v) {
1228 let parts = v.and_then(|v| v.split_once(',')).unzip();
1229 if !parse_number(&mut total_nops, parts.0) {
1230 return false;
1231 }
1232 if !parse_number(&mut prefix_nops, parts.1) {
1233 return false;
1234 }
1235 }
1236
1237 if let Some(pfe) =
1238 PatchableFunctionEntry::from_total_and_prefix_nops(total_nops, prefix_nops)
1239 {
1240 *slot = pfe;
1241 return true;
1242 }
1243 false
1244 }
1245
1246 pub(crate) fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
1247 match v {
1248 Some(s) => match s.parse::<RelroLevel>() {
1249 Ok(level) => *slot = Some(level),
1250 _ => return false,
1251 },
1252 _ => return false,
1253 }
1254 true
1255 }
1256
1257 pub(crate) fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
1258 if let Some(v) = v {
1259 for s in v.split(',') {
1260 *slot |= match s {
1261 "address" => SanitizerSet::ADDRESS,
1262 "cfi" => SanitizerSet::CFI,
1263 "dataflow" => SanitizerSet::DATAFLOW,
1264 "kcfi" => SanitizerSet::KCFI,
1265 "kernel-address" => SanitizerSet::KERNELADDRESS,
1266 "leak" => SanitizerSet::LEAK,
1267 "memory" => SanitizerSet::MEMORY,
1268 "memtag" => SanitizerSet::MEMTAG,
1269 "shadow-call-stack" => SanitizerSet::SHADOWCALLSTACK,
1270 "thread" => SanitizerSet::THREAD,
1271 "hwaddress" => SanitizerSet::HWADDRESS,
1272 "safestack" => SanitizerSet::SAFESTACK,
1273 "realtime" => SanitizerSet::REALTIME,
1274 _ => return false,
1275 }
1276 }
1277 true
1278 } else {
1279 false
1280 }
1281 }
1282
1283 pub(crate) fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
1284 match v {
1285 Some("2") | None => {
1286 *slot = 2;
1287 true
1288 }
1289 Some("1") => {
1290 *slot = 1;
1291 true
1292 }
1293 Some("0") => {
1294 *slot = 0;
1295 true
1296 }
1297 Some(_) => false,
1298 }
1299 }
1300
1301 pub(crate) fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
1302 match v {
1303 Some("none") => *slot = Strip::None,
1304 Some("debuginfo") => *slot = Strip::Debuginfo,
1305 Some("symbols") => *slot = Strip::Symbols,
1306 _ => return false,
1307 }
1308 true
1309 }
1310
1311 pub(crate) fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
1312 if v.is_some() {
1313 let mut bool_arg = None;
1314 if parse_opt_bool(&mut bool_arg, v) {
1315 *slot = if bool_arg.unwrap() { CFGuard::Checks } else { CFGuard::Disabled };
1316 return true;
1317 }
1318 }
1319
1320 *slot = match v {
1321 None => CFGuard::Checks,
1322 Some("checks") => CFGuard::Checks,
1323 Some("nochecks") => CFGuard::NoChecks,
1324 Some(_) => return false,
1325 };
1326 true
1327 }
1328
1329 pub(crate) fn parse_cfprotection(slot: &mut CFProtection, v: Option<&str>) -> bool {
1330 if v.is_some() {
1331 let mut bool_arg = None;
1332 if parse_opt_bool(&mut bool_arg, v) {
1333 *slot = if bool_arg.unwrap() { CFProtection::Full } else { CFProtection::None };
1334 return true;
1335 }
1336 }
1337
1338 *slot = match v {
1339 None | Some("none") => CFProtection::None,
1340 Some("branch") => CFProtection::Branch,
1341 Some("return") => CFProtection::Return,
1342 Some("full") => CFProtection::Full,
1343 Some(_) => return false,
1344 };
1345 true
1346 }
1347
1348 pub(crate) fn parse_debuginfo(slot: &mut DebugInfo, v: Option<&str>) -> bool {
1349 match v {
1350 Some("0") | Some("none") => *slot = DebugInfo::None,
1351 Some("line-directives-only") => *slot = DebugInfo::LineDirectivesOnly,
1352 Some("line-tables-only") => *slot = DebugInfo::LineTablesOnly,
1353 Some("1") | Some("limited") => *slot = DebugInfo::Limited,
1354 Some("2") | Some("full") => *slot = DebugInfo::Full,
1355 _ => return false,
1356 }
1357 true
1358 }
1359
1360 pub(crate) fn parse_debuginfo_compression(
1361 slot: &mut DebugInfoCompression,
1362 v: Option<&str>,
1363 ) -> bool {
1364 match v {
1365 Some("none") => *slot = DebugInfoCompression::None,
1366 Some("zlib") => *slot = DebugInfoCompression::Zlib,
1367 Some("zstd") => *slot = DebugInfoCompression::Zstd,
1368 _ => return false,
1369 };
1370 true
1371 }
1372
1373 pub(crate) fn parse_mir_strip_debuginfo(slot: &mut MirStripDebugInfo, v: Option<&str>) -> bool {
1374 match v {
1375 Some("none") => *slot = MirStripDebugInfo::None,
1376 Some("locals-in-tiny-functions") => *slot = MirStripDebugInfo::LocalsInTinyFunctions,
1377 Some("all-locals") => *slot = MirStripDebugInfo::AllLocals,
1378 _ => return false,
1379 };
1380 true
1381 }
1382
1383 pub(crate) fn parse_linker_flavor(slot: &mut Option<LinkerFlavorCli>, v: Option<&str>) -> bool {
1384 match v.and_then(|v| LinkerFlavorCli::from_str(v).ok()) {
1385 Some(lf) => *slot = Some(lf),
1386 _ => return false,
1387 }
1388 true
1389 }
1390
1391 pub(crate) fn parse_opt_symbol_visibility(
1392 slot: &mut Option<SymbolVisibility>,
1393 v: Option<&str>,
1394 ) -> bool {
1395 if let Some(v) = v {
1396 if let Ok(vis) = SymbolVisibility::from_str(v) {
1397 *slot = Some(vis);
1398 } else {
1399 return false;
1400 }
1401 }
1402 true
1403 }
1404
1405 pub(crate) fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
1406 match v {
1407 None => false,
1408 Some(s) if s.split('=').count() <= 2 => {
1409 *slot = Some(s.to_string());
1410 true
1411 }
1412 _ => false,
1413 }
1414 }
1415
1416 pub(crate) fn parse_time_passes_format(slot: &mut TimePassesFormat, v: Option<&str>) -> bool {
1417 match v {
1418 None => true,
1419 Some("json") => {
1420 *slot = TimePassesFormat::Json;
1421 true
1422 }
1423 Some("text") => {
1424 *slot = TimePassesFormat::Text;
1425 true
1426 }
1427 Some(_) => false,
1428 }
1429 }
1430
1431 pub(crate) fn parse_dump_mono_stats(slot: &mut DumpMonoStatsFormat, v: Option<&str>) -> bool {
1432 match v {
1433 None => true,
1434 Some("json") => {
1435 *slot = DumpMonoStatsFormat::Json;
1436 true
1437 }
1438 Some("markdown") => {
1439 *slot = DumpMonoStatsFormat::Markdown;
1440 true
1441 }
1442 Some(_) => false,
1443 }
1444 }
1445
1446 pub(crate) fn parse_offload(slot: &mut Vec<Offload>, v: Option<&str>) -> bool {
1447 let Some(v) = v else {
1448 *slot = vec![];
1449 return true;
1450 };
1451 let mut v: Vec<&str> = v.split(",").collect();
1452 v.sort_unstable();
1453 for &val in v.iter() {
1454 let variant = match val {
1455 "Enable" => Offload::Enable,
1456 _ => {
1457 return false;
1459 }
1460 };
1461 slot.push(variant);
1462 }
1463
1464 true
1465 }
1466
1467 pub(crate) fn parse_autodiff(slot: &mut Vec<AutoDiff>, v: Option<&str>) -> bool {
1468 let Some(v) = v else {
1469 *slot = vec![];
1470 return true;
1471 };
1472 let mut v: Vec<&str> = v.split(",").collect();
1473 v.sort_unstable();
1474 for &val in v.iter() {
1475 let (key, arg) = match val.split_once('=') {
1477 Some((k, a)) => (k, Some(a)),
1478 None => (val, None),
1479 };
1480
1481 let variant = match key {
1482 "Enable" => AutoDiff::Enable,
1483 "PrintTA" => AutoDiff::PrintTA,
1484 "PrintTAFn" => {
1485 if let Some(fun) = arg {
1486 AutoDiff::PrintTAFn(fun.to_string())
1487 } else {
1488 return false;
1489 }
1490 }
1491 "PrintAA" => AutoDiff::PrintAA,
1492 "PrintPerf" => AutoDiff::PrintPerf,
1493 "PrintSteps" => AutoDiff::PrintSteps,
1494 "PrintModBefore" => AutoDiff::PrintModBefore,
1495 "PrintModAfter" => AutoDiff::PrintModAfter,
1496 "PrintModFinal" => AutoDiff::PrintModFinal,
1497 "NoPostopt" => AutoDiff::NoPostopt,
1498 "PrintPasses" => AutoDiff::PrintPasses,
1499 "LooseTypes" => AutoDiff::LooseTypes,
1500 "Inline" => AutoDiff::Inline,
1501 "NoTT" => AutoDiff::NoTT,
1502 _ => {
1503 return false;
1505 }
1506 };
1507 slot.push(variant);
1508 }
1509
1510 true
1511 }
1512
1513 pub(crate) fn parse_instrument_coverage(
1514 slot: &mut InstrumentCoverage,
1515 v: Option<&str>,
1516 ) -> bool {
1517 if v.is_some() {
1518 let mut bool_arg = false;
1519 if parse_bool(&mut bool_arg, v) {
1520 *slot = if bool_arg { InstrumentCoverage::Yes } else { InstrumentCoverage::No };
1521 return true;
1522 }
1523 }
1524
1525 let Some(v) = v else {
1526 *slot = InstrumentCoverage::Yes;
1527 return true;
1528 };
1529
1530 *slot = match v {
1533 "all" => InstrumentCoverage::Yes,
1534 "0" => InstrumentCoverage::No,
1535 _ => return false,
1536 };
1537 true
1538 }
1539
1540 pub(crate) fn parse_coverage_options(slot: &mut CoverageOptions, v: Option<&str>) -> bool {
1541 let Some(v) = v else { return true };
1542
1543 for option in v.split(',') {
1544 match option {
1545 "block" => slot.level = CoverageLevel::Block,
1546 "branch" => slot.level = CoverageLevel::Branch,
1547 "condition" => slot.level = CoverageLevel::Condition,
1548 "discard-all-spans-in-codegen" => slot.discard_all_spans_in_codegen = true,
1549 _ => return false,
1550 }
1551 }
1552 true
1553 }
1554
1555 pub(crate) fn parse_instrument_xray(
1556 slot: &mut Option<InstrumentXRay>,
1557 v: Option<&str>,
1558 ) -> bool {
1559 if v.is_some() {
1560 let mut bool_arg = None;
1561 if parse_opt_bool(&mut bool_arg, v) {
1562 *slot = if bool_arg.unwrap() { Some(InstrumentXRay::default()) } else { None };
1563 return true;
1564 }
1565 }
1566
1567 let options = slot.get_or_insert_default();
1568 let mut seen_always = false;
1569 let mut seen_never = false;
1570 let mut seen_ignore_loops = false;
1571 let mut seen_instruction_threshold = false;
1572 let mut seen_skip_entry = false;
1573 let mut seen_skip_exit = false;
1574 for option in v.into_iter().flat_map(|v| v.split(',')) {
1575 match option {
1576 "always" if !seen_always && !seen_never => {
1577 options.always = true;
1578 options.never = false;
1579 seen_always = true;
1580 }
1581 "never" if !seen_never && !seen_always => {
1582 options.never = true;
1583 options.always = false;
1584 seen_never = true;
1585 }
1586 "ignore-loops" if !seen_ignore_loops => {
1587 options.ignore_loops = true;
1588 seen_ignore_loops = true;
1589 }
1590 option
1591 if option.starts_with("instruction-threshold")
1592 && !seen_instruction_threshold =>
1593 {
1594 let Some(("instruction-threshold", n)) = option.split_once('=') else {
1595 return false;
1596 };
1597 match n.parse() {
1598 Ok(n) => options.instruction_threshold = Some(n),
1599 Err(_) => return false,
1600 }
1601 seen_instruction_threshold = true;
1602 }
1603 "skip-entry" if !seen_skip_entry => {
1604 options.skip_entry = true;
1605 seen_skip_entry = true;
1606 }
1607 "skip-exit" if !seen_skip_exit => {
1608 options.skip_exit = true;
1609 seen_skip_exit = true;
1610 }
1611 _ => return false,
1612 }
1613 }
1614 true
1615 }
1616
1617 pub(crate) fn parse_treat_err_as_bug(
1618 slot: &mut Option<NonZero<usize>>,
1619 v: Option<&str>,
1620 ) -> bool {
1621 match v {
1622 Some(s) => match s.parse() {
1623 Ok(val) => {
1624 *slot = Some(val);
1625 true
1626 }
1627 Err(e) => {
1628 *slot = None;
1629 e.kind() == &IntErrorKind::Zero
1630 }
1631 },
1632 None => {
1633 *slot = NonZero::new(1);
1634 true
1635 }
1636 }
1637 }
1638
1639 pub(crate) fn parse_next_solver_config(slot: &mut NextSolverConfig, v: Option<&str>) -> bool {
1640 if let Some(config) = v {
1641 *slot = match config {
1642 "no" => NextSolverConfig { coherence: false, globally: false },
1643 "coherence" => NextSolverConfig { coherence: true, globally: false },
1644 "globally" => NextSolverConfig { coherence: true, globally: true },
1645 _ => return false,
1646 };
1647 } else {
1648 *slot = NextSolverConfig { coherence: true, globally: true };
1649 }
1650
1651 true
1652 }
1653
1654 pub(crate) fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
1655 if v.is_some() {
1656 let mut bool_arg = None;
1657 if parse_opt_bool(&mut bool_arg, v) {
1658 *slot = if bool_arg.unwrap() { LtoCli::Yes } else { LtoCli::No };
1659 return true;
1660 }
1661 }
1662
1663 *slot = match v {
1664 None => LtoCli::NoParam,
1665 Some("thin") => LtoCli::Thin,
1666 Some("fat") => LtoCli::Fat,
1667 Some(_) => return false,
1668 };
1669 true
1670 }
1671
1672 pub(crate) fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
1673 if v.is_some() {
1674 let mut bool_arg = None;
1675 if parse_opt_bool(&mut bool_arg, v) {
1676 *slot = if bool_arg.unwrap() {
1677 LinkerPluginLto::LinkerPluginAuto
1678 } else {
1679 LinkerPluginLto::Disabled
1680 };
1681 return true;
1682 }
1683 }
1684
1685 *slot = match v {
1686 None => LinkerPluginLto::LinkerPluginAuto,
1687 Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
1688 };
1689 true
1690 }
1691
1692 pub(crate) fn parse_switch_with_opt_path(
1693 slot: &mut SwitchWithOptPath,
1694 v: Option<&str>,
1695 ) -> bool {
1696 *slot = match v {
1697 None => SwitchWithOptPath::Enabled(None),
1698 Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
1699 };
1700 true
1701 }
1702
1703 pub(crate) fn parse_merge_functions(
1704 slot: &mut Option<MergeFunctions>,
1705 v: Option<&str>,
1706 ) -> bool {
1707 match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
1708 Some(mergefunc) => *slot = Some(mergefunc),
1709 _ => return false,
1710 }
1711 true
1712 }
1713
1714 pub(crate) fn parse_remap_path_scope(
1715 slot: &mut RemapPathScopeComponents,
1716 v: Option<&str>,
1717 ) -> bool {
1718 if let Some(v) = v {
1719 *slot = RemapPathScopeComponents::empty();
1720 for s in v.split(',') {
1721 *slot |= match s {
1722 "macro" => RemapPathScopeComponents::MACRO,
1723 "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1724 "debuginfo" => RemapPathScopeComponents::DEBUGINFO,
1725 "coverage" => RemapPathScopeComponents::COVERAGE,
1726 "object" => RemapPathScopeComponents::OBJECT,
1727 "all" => RemapPathScopeComponents::all(),
1728 _ => return false,
1729 }
1730 }
1731 true
1732 } else {
1733 false
1734 }
1735 }
1736
1737 pub(crate) fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
1738 match v.and_then(|s| RelocModel::from_str(s).ok()) {
1739 Some(relocation_model) => *slot = Some(relocation_model),
1740 None if v == Some("default") => *slot = None,
1741 _ => return false,
1742 }
1743 true
1744 }
1745
1746 pub(crate) fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
1747 match v.and_then(|s| CodeModel::from_str(s).ok()) {
1748 Some(code_model) => *slot = Some(code_model),
1749 _ => return false,
1750 }
1751 true
1752 }
1753
1754 pub(crate) fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
1755 match v.and_then(|s| TlsModel::from_str(s).ok()) {
1756 Some(tls_model) => *slot = Some(tls_model),
1757 _ => return false,
1758 }
1759 true
1760 }
1761
1762 pub(crate) fn parse_terminal_url(slot: &mut TerminalUrl, v: Option<&str>) -> bool {
1763 *slot = match v {
1764 Some("on" | "" | "yes" | "y") | None => TerminalUrl::Yes,
1765 Some("off" | "no" | "n") => TerminalUrl::No,
1766 Some("auto") => TerminalUrl::Auto,
1767 _ => return false,
1768 };
1769 true
1770 }
1771
1772 pub(crate) fn parse_symbol_mangling_version(
1773 slot: &mut Option<SymbolManglingVersion>,
1774 v: Option<&str>,
1775 ) -> bool {
1776 *slot = match v {
1777 Some("legacy") => Some(SymbolManglingVersion::Legacy),
1778 Some("v0") => Some(SymbolManglingVersion::V0),
1779 Some("hashed") => Some(SymbolManglingVersion::Hashed),
1780 _ => return false,
1781 };
1782 true
1783 }
1784
1785 pub(crate) fn parse_src_file_hash(
1786 slot: &mut Option<SourceFileHashAlgorithm>,
1787 v: Option<&str>,
1788 ) -> bool {
1789 match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
1790 Some(hash_kind) => *slot = Some(hash_kind),
1791 _ => return false,
1792 }
1793 true
1794 }
1795
1796 pub(crate) fn parse_cargo_src_file_hash(
1797 slot: &mut Option<SourceFileHashAlgorithm>,
1798 v: Option<&str>,
1799 ) -> bool {
1800 match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
1801 Some(hash_kind) => {
1802 *slot = Some(hash_kind);
1803 }
1804 _ => return false,
1805 }
1806 true
1807 }
1808
1809 pub(crate) fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
1810 match v {
1811 Some(s) => {
1812 if !slot.is_empty() {
1813 slot.push(',');
1814 }
1815 slot.push_str(s);
1816 true
1817 }
1818 None => false,
1819 }
1820 }
1821
1822 pub(crate) fn parse_link_self_contained(slot: &mut LinkSelfContained, v: Option<&str>) -> bool {
1823 let s = v.unwrap_or("y");
1828 match s {
1829 "y" | "yes" | "on" => {
1830 slot.set_all_explicitly(true);
1831 return true;
1832 }
1833 "n" | "no" | "off" => {
1834 slot.set_all_explicitly(false);
1835 return true;
1836 }
1837 _ => {}
1838 }
1839
1840 for comp in s.split(',') {
1842 if slot.handle_cli_component(comp).is_none() {
1843 return false;
1844 }
1845 }
1846
1847 true
1848 }
1849
1850 pub(crate) fn parse_linker_features(slot: &mut LinkerFeaturesCli, v: Option<&str>) -> bool {
1852 match v {
1853 Some(s) => {
1854 for feature in s.split(',') {
1855 if slot.handle_cli_feature(feature).is_none() {
1856 return false;
1857 }
1858 }
1859
1860 true
1861 }
1862 None => false,
1863 }
1864 }
1865
1866 pub(crate) fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
1867 match v {
1868 Some("command") => *slot = Some(WasiExecModel::Command),
1869 Some("reactor") => *slot = Some(WasiExecModel::Reactor),
1870 _ => return false,
1871 }
1872 true
1873 }
1874
1875 pub(crate) fn parse_split_debuginfo(
1876 slot: &mut Option<SplitDebuginfo>,
1877 v: Option<&str>,
1878 ) -> bool {
1879 match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
1880 Some(e) => *slot = Some(e),
1881 _ => return false,
1882 }
1883 true
1884 }
1885
1886 pub(crate) fn parse_split_dwarf_kind(slot: &mut SplitDwarfKind, v: Option<&str>) -> bool {
1887 match v.and_then(|s| SplitDwarfKind::from_str(s).ok()) {
1888 Some(e) => *slot = e,
1889 _ => return false,
1890 }
1891 true
1892 }
1893
1894 pub(crate) fn parse_stack_protector(slot: &mut StackProtector, v: Option<&str>) -> bool {
1895 match v.and_then(|s| StackProtector::from_str(s).ok()) {
1896 Some(ssp) => *slot = ssp,
1897 _ => return false,
1898 }
1899 true
1900 }
1901
1902 pub(crate) fn parse_branch_protection(
1903 slot: &mut Option<BranchProtection>,
1904 v: Option<&str>,
1905 ) -> bool {
1906 match v {
1907 Some(s) => {
1908 let slot = slot.get_or_insert_default();
1909 for opt in s.split(',') {
1910 match opt {
1911 "bti" => slot.bti = true,
1912 "pac-ret" if slot.pac_ret.is_none() => {
1913 slot.pac_ret = Some(PacRet { leaf: false, pc: false, key: PAuthKey::A })
1914 }
1915 "leaf" => match slot.pac_ret.as_mut() {
1916 Some(pac) => pac.leaf = true,
1917 _ => return false,
1918 },
1919 "b-key" => match slot.pac_ret.as_mut() {
1920 Some(pac) => pac.key = PAuthKey::B,
1921 _ => return false,
1922 },
1923 "pc" => match slot.pac_ret.as_mut() {
1924 Some(pac) => pac.pc = true,
1925 _ => return false,
1926 },
1927 "gcs" => slot.gcs = true,
1928 _ => return false,
1929 };
1930 }
1931 }
1932 _ => return false,
1933 }
1934 true
1935 }
1936
1937 pub(crate) fn parse_collapse_macro_debuginfo(
1938 slot: &mut CollapseMacroDebuginfo,
1939 v: Option<&str>,
1940 ) -> bool {
1941 if v.is_some() {
1942 let mut bool_arg = None;
1943 if parse_opt_bool(&mut bool_arg, v) {
1944 *slot = if bool_arg.unwrap() {
1945 CollapseMacroDebuginfo::Yes
1946 } else {
1947 CollapseMacroDebuginfo::No
1948 };
1949 return true;
1950 }
1951 }
1952
1953 *slot = match v {
1954 Some("external") => CollapseMacroDebuginfo::External,
1955 _ => return false,
1956 };
1957 true
1958 }
1959
1960 pub(crate) fn parse_proc_macro_execution_strategy(
1961 slot: &mut ProcMacroExecutionStrategy,
1962 v: Option<&str>,
1963 ) -> bool {
1964 *slot = match v {
1965 Some("same-thread") => ProcMacroExecutionStrategy::SameThread,
1966 Some("cross-thread") => ProcMacroExecutionStrategy::CrossThread,
1967 _ => return false,
1968 };
1969 true
1970 }
1971
1972 pub(crate) fn parse_inlining_threshold(slot: &mut InliningThreshold, v: Option<&str>) -> bool {
1973 match v {
1974 Some("always" | "yes") => {
1975 *slot = InliningThreshold::Always;
1976 }
1977 Some("never") => {
1978 *slot = InliningThreshold::Never;
1979 }
1980 Some(v) => {
1981 if let Ok(threshold) = v.parse() {
1982 *slot = InliningThreshold::Sometimes(threshold);
1983 } else {
1984 return false;
1985 }
1986 }
1987 None => return false,
1988 }
1989 true
1990 }
1991
1992 pub(crate) fn parse_llvm_module_flag(
1993 slot: &mut Vec<(String, u32, String)>,
1994 v: Option<&str>,
1995 ) -> bool {
1996 let elements = v.unwrap_or_default().split(':').collect::<Vec<_>>();
1997 let [key, md_type, value, behavior] = elements.as_slice() else {
1998 return false;
1999 };
2000 if *md_type != "u32" {
2001 return false;
2004 }
2005 let Ok(value) = value.parse::<u32>() else {
2006 return false;
2007 };
2008 let behavior = behavior.to_lowercase();
2009 let all_behaviors =
2010 ["error", "warning", "require", "override", "append", "appendunique", "max", "min"];
2011 if !all_behaviors.contains(&behavior.as_str()) {
2012 return false;
2013 }
2014
2015 slot.push((key.to_string(), value, behavior));
2016 true
2017 }
2018
2019 pub(crate) fn parse_function_return(slot: &mut FunctionReturn, v: Option<&str>) -> bool {
2020 match v {
2021 Some("keep") => *slot = FunctionReturn::Keep,
2022 Some("thunk-extern") => *slot = FunctionReturn::ThunkExtern,
2023 _ => return false,
2024 }
2025 true
2026 }
2027
2028 pub(crate) fn parse_wasm_c_abi(_slot: &mut (), v: Option<&str>) -> bool {
2029 v == Some("spec")
2030 }
2031
2032 pub(crate) fn parse_mir_include_spans(slot: &mut MirIncludeSpans, v: Option<&str>) -> bool {
2033 *slot = match v {
2034 Some("on" | "yes" | "y" | "true") | None => MirIncludeSpans::On,
2035 Some("off" | "no" | "n" | "false") => MirIncludeSpans::Off,
2036 Some("nll") => MirIncludeSpans::Nll,
2037 _ => return false,
2038 };
2039
2040 true
2041 }
2042
2043 pub(crate) fn parse_align(slot: &mut Option<Align>, v: Option<&str>) -> bool {
2044 let mut bytes = 0u64;
2045 if !parse_number(&mut bytes, v) {
2046 return false;
2047 }
2048
2049 let Ok(align) = Align::from_bytes(bytes) else {
2050 return false;
2051 };
2052
2053 *slot = Some(align);
2054
2055 true
2056 }
2057}
2058
2059options! {
2060 CodegenOptions, CodegenOptionsTargetModifiers, CG_OPTIONS, cgopts, "C", "codegen",
2061
2062 #[rustc_lint_opt_deny_field_access("documented to do nothing")]
2068 ar: String = (String::new(), parse_string, [UNTRACKED],
2069 "this option is deprecated and does nothing",
2070 deprecated_do_nothing: true),
2071 #[rustc_lint_opt_deny_field_access("use `Session::code_model` instead of this field")]
2072 code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
2073 "choose the code model to use (`rustc --print code-models` for details)"),
2074 codegen_units: Option<usize> = (None, parse_opt_number, [UNTRACKED],
2075 "divide crate into N units to optimize in parallel"),
2076 collapse_macro_debuginfo: CollapseMacroDebuginfo = (CollapseMacroDebuginfo::Unspecified,
2077 parse_collapse_macro_debuginfo, [TRACKED],
2078 "set option to collapse debuginfo for macros"),
2079 control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
2080 "use Windows Control Flow Guard (default: no)"),
2081 debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
2082 "explicitly enable the `cfg(debug_assertions)` directive"),
2083 debuginfo: DebugInfo = (DebugInfo::None, parse_debuginfo, [TRACKED],
2084 "debug info emission level (0-2, none, line-directives-only, \
2085 line-tables-only, limited, or full; default: 0)"),
2086 default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
2087 "allow the linker to link its default libraries (default: no)"),
2088 dlltool: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
2089 "import library generation tool (ignored except when targeting windows-gnu)"),
2090 #[rustc_lint_opt_deny_field_access("use `Session::dwarf_version` instead of this field")]
2091 dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
2092 "version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
2093 embed_bitcode: bool = (true, parse_bool, [TRACKED],
2094 "emit bitcode in rlibs (default: yes)"),
2095 extra_filename: String = (String::new(), parse_string, [UNTRACKED],
2096 "extra data to put in each output filename"),
2097 force_frame_pointers: FramePointer = (FramePointer::MayOmit, parse_frame_pointer, [TRACKED],
2098 "force use of the frame pointers"),
2099 #[rustc_lint_opt_deny_field_access("use `Session::must_emit_unwind_tables` instead of this field")]
2100 force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
2101 "force use of unwind tables"),
2102 incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
2103 "enable incremental compilation"),
2104 #[rustc_lint_opt_deny_field_access("documented to do nothing")]
2105 inline_threshold: Option<u32> = (None, parse_opt_number, [UNTRACKED],
2106 "this option is deprecated and does nothing \
2107 (consider using `-Cllvm-args=--inline-threshold=...`)",
2108 deprecated_do_nothing: true),
2109 #[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
2110 instrument_coverage: InstrumentCoverage = (InstrumentCoverage::No, parse_instrument_coverage, [TRACKED],
2111 "instrument the generated code to support LLVM source-based code coverage reports \
2112 (note, the compiler build config must include `profiler = true`); \
2113 implies `-C symbol-mangling-version=v0`"),
2114 jump_tables: bool = (true, parse_bool, [TRACKED],
2115 "allow jump table and lookup table generation from switch case lowering (default: yes)"),
2116 link_arg: () = ((), parse_string_push, [UNTRACKED],
2117 "a single extra argument to append to the linker invocation (can be used several times)"),
2118 link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
2119 "extra arguments to append to the linker invocation (space separated)"),
2120 #[rustc_lint_opt_deny_field_access("use `Session::link_dead_code` instead of this field")]
2121 link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED],
2122 "try to generate and link dead code (default: no)"),
2123 link_self_contained: LinkSelfContained = (LinkSelfContained::default(), parse_link_self_contained, [UNTRACKED],
2124 "control whether to link Rust provided C objects/libraries or rely \
2125 on a C toolchain or linker installed in the system"),
2126 linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
2127 "system linker to link outputs with"),
2128 linker_features: LinkerFeaturesCli = (LinkerFeaturesCli::default(), parse_linker_features, [UNTRACKED],
2129 "a comma-separated list of linker features to enable (+) or disable (-): `lld`"),
2130 linker_flavor: Option<LinkerFlavorCli> = (None, parse_linker_flavor, [UNTRACKED],
2131 "linker flavor"),
2132 linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
2133 parse_linker_plugin_lto, [TRACKED],
2134 "generate build artifacts that are compatible with linker-based LTO"),
2135 llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
2136 "a list of arguments to pass to LLVM (space separated)"),
2137 #[rustc_lint_opt_deny_field_access("use `Session::lto` instead of this field")]
2138 lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
2139 "perform LLVM link-time optimizations"),
2140 metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
2141 "metadata to mangle symbol names with"),
2142 no_prepopulate_passes: bool = (false, parse_no_value, [TRACKED],
2143 "give an empty list of passes to the pass manager"),
2144 no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
2145 "disable the use of the redzone"),
2146 #[rustc_lint_opt_deny_field_access("documented to do nothing")]
2147 no_stack_check: bool = (false, parse_no_value, [UNTRACKED],
2148 "this option is deprecated and does nothing",
2149 deprecated_do_nothing: true),
2150 no_vectorize_loops: bool = (false, parse_no_value, [TRACKED],
2151 "disable loop vectorization optimization passes"),
2152 no_vectorize_slp: bool = (false, parse_no_value, [TRACKED],
2153 "disable LLVM's SLP vectorization pass"),
2154 opt_level: String = ("0".to_string(), parse_string, [TRACKED],
2155 "optimization level (0-3, s, or z; default: 0)"),
2156 #[rustc_lint_opt_deny_field_access("use `Session::overflow_checks` instead of this field")]
2157 overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
2158 "use overflow checks for integer arithmetic"),
2159 #[rustc_lint_opt_deny_field_access("use `Session::panic_strategy` instead of this field")]
2160 panic: Option<PanicStrategy> = (None, parse_opt_panic_strategy, [TRACKED],
2161 "panic strategy to compile crate with"),
2162 passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
2163 "a list of extra LLVM passes to run (space separated)"),
2164 prefer_dynamic: bool = (false, parse_bool, [TRACKED],
2165 "prefer dynamic linking to static linking (default: no)"),
2166 profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
2167 parse_switch_with_opt_path, [TRACKED],
2168 "compile the program with profiling instrumentation"),
2169 profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
2170 "use the given `.profdata` file for profile-guided optimization"),
2171 #[rustc_lint_opt_deny_field_access("use `Session::relocation_model` instead of this field")]
2172 relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
2173 "control generation of position-independent code (PIC) \
2174 (`rustc --print relocation-models` for details)"),
2175 relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
2176 "choose which RELRO level to use"),
2177 remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
2178 "output remarks for these optimization passes (space separated, or \"all\")"),
2179 rpath: bool = (false, parse_bool, [UNTRACKED],
2180 "set rpath values in libs/exes (default: no)"),
2181 save_temps: bool = (false, parse_bool, [UNTRACKED],
2182 "save all temporary output files during compilation (default: no)"),
2183 soft_float: bool = (false, parse_bool, [TRACKED],
2184 "deprecated option: use soft float ABI (*eabihf targets only) (default: no)"),
2185 #[rustc_lint_opt_deny_field_access("use `Session::split_debuginfo` instead of this field")]
2186 split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
2187 "how to handle split-debuginfo, a platform-specific option"),
2188 strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
2189 "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
2190 symbol_mangling_version: Option<SymbolManglingVersion> = (None,
2191 parse_symbol_mangling_version, [TRACKED],
2192 "which mangling version to use for symbol names ('legacy' (default), 'v0', or 'hashed')"),
2193 target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
2194 "select target processor (`rustc --print target-cpus` for details)"),
2195 target_feature: String = (String::new(), parse_target_feature, [TRACKED],
2196 "target specific attributes. (`rustc --print target-features` for details). \
2197 This feature is unsafe."),
2198 unsafe_allow_abi_mismatch: Vec<String> = (Vec::new(), parse_comma_list, [UNTRACKED],
2199 "Allow incompatible target modifiers in dependency crates (comma separated list)"),
2200 }
2206
2207options! {
2208 UnstableOptions, UnstableOptionsTargetModifiers, Z_OPTIONS, dbopts, "Z", "unstable",
2209
2210 allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
2216 "only allow the listed language features to be enabled in code (comma separated)"),
2217 always_encode_mir: bool = (false, parse_bool, [TRACKED],
2218 "encode MIR of all functions into the crate metadata (default: no)"),
2219 annotate_moves: AnnotateMoves = (AnnotateMoves::Disabled, parse_annotate_moves, [TRACKED],
2220 "emit debug info for compiler-generated move and copy operations \
2221 to make them visible in profilers. Can be a boolean or a size limit in bytes (default: disabled)"),
2222 assert_incr_state: Option<String> = (None, parse_opt_string, [UNTRACKED],
2223 "assert that the incremental cache is in given state: \
2224 either `loaded` or `not-loaded`."),
2225 assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
2226 "make cfg(version) treat the current version as incomplete (default: no)"),
2227 autodiff: Vec<crate::config::AutoDiff> = (Vec::new(), parse_autodiff, [TRACKED],
2228 "a list of autodiff flags to enable
2229 Mandatory setting:
2230 `=Enable`
2231 Optional extra settings:
2232 `=PrintTA`
2233 `=PrintAA`
2234 `=PrintPerf`
2235 `=PrintSteps`
2236 `=PrintModBefore`
2237 `=PrintModAfter`
2238 `=PrintModFinal`
2239 `=PrintPasses`,
2240 `=NoPostopt`
2241 `=LooseTypes`
2242 `=Inline`
2243 Multiple options can be combined with commas."),
2244 #[rustc_lint_opt_deny_field_access("use `Session::binary_dep_depinfo` instead of this field")]
2245 binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
2246 "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
2247 (default: no)"),
2248 box_noalias: bool = (true, parse_bool, [TRACKED],
2249 "emit noalias metadata for box (default: yes)"),
2250 branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED],
2251 "set options for branch target identification and pointer authentication on AArch64"),
2252 build_sdylib_interface: bool = (false, parse_bool, [UNTRACKED],
2253 "whether the stable interface is being built"),
2254 cf_protection: CFProtection = (CFProtection::None, parse_cfprotection, [TRACKED],
2255 "instrument control-flow architecture protection"),
2256 check_cfg_all_expected: bool = (false, parse_bool, [UNTRACKED],
2257 "show all expected values in check-cfg diagnostics (default: no)"),
2258 checksum_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_cargo_src_file_hash, [TRACKED],
2259 "hash algorithm of source files used to check freshness in cargo (`blake3` or `sha256`)"),
2260 codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
2261 "the backend to use"),
2262 codegen_source_order: bool = (false, parse_bool, [UNTRACKED],
2263 "emit mono items in the order of spans in source files (default: no)"),
2264 contract_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
2265 "emit runtime checks for contract pre- and post-conditions (default: no)"),
2266 coverage_options: CoverageOptions = (CoverageOptions::default(), parse_coverage_options, [TRACKED],
2267 "control details of coverage instrumentation"),
2268 crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
2269 "inject the given attribute in the crate"),
2270 cross_crate_inline_threshold: InliningThreshold = (InliningThreshold::Sometimes(100), parse_inlining_threshold, [TRACKED],
2271 "threshold to allow cross crate inlining of functions"),
2272 debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
2273 "emit discriminators and other data necessary for AutoFDO"),
2274 debug_info_type_line_numbers: bool = (false, parse_bool, [TRACKED],
2275 "emit type and line information for additional data types (default: no)"),
2276 debuginfo_compression: DebugInfoCompression = (DebugInfoCompression::None, parse_debuginfo_compression, [TRACKED],
2277 "compress debug info sections (none, zlib, zstd, default: none)"),
2278 deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
2279 "deduplicate identical diagnostics (default: yes)"),
2280 default_visibility: Option<SymbolVisibility> = (None, parse_opt_symbol_visibility, [TRACKED],
2281 "overrides the `default_visibility` setting of the target"),
2282 dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
2283 "in dep-info output, omit targets for tracking dependencies of the dep-info files \
2284 themselves (default: no)"),
2285 direct_access_external_data: Option<bool> = (None, parse_opt_bool, [TRACKED],
2286 "Direct or use GOT indirect to reference external data symbols"),
2287 dual_proc_macros: bool = (false, parse_bool, [TRACKED],
2288 "load proc macros for both target and host, but only link to the target (default: no)"),
2289 dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
2290 "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
2291 (default: no)"),
2292 dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
2293 "dump MIR state to file.
2294 `val` is used to select which passes and functions to dump. For example:
2295 `all` matches all passes and functions,
2296 `foo` matches all passes for functions whose name contains 'foo',
2297 `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
2298 `foo | bar` all passes for function names containing 'foo' or 'bar'."),
2299 dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
2300 "in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
2301 (default: no)"),
2302 dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
2303 "the directory the MIR is dumped into (default: `mir_dump`)"),
2304 dump_mir_exclude_alloc_bytes: bool = (false, parse_bool, [UNTRACKED],
2305 "exclude the raw bytes of allocations when dumping MIR (used in tests) (default: no)"),
2306 dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
2307 "exclude the pass number when dumping MIR (used in tests) (default: no)"),
2308 dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
2309 "in addition to `.mir` files, create graphviz `.dot` files (default: no)"),
2310 dump_mono_stats: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
2311 parse_switch_with_opt_path, [UNTRACKED],
2312 "output statistics about monomorphization collection"),
2313 dump_mono_stats_format: DumpMonoStatsFormat = (DumpMonoStatsFormat::Markdown, parse_dump_mono_stats, [UNTRACKED],
2314 "the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)"),
2315 #[rustc_lint_opt_deny_field_access("use `Session::dwarf_version` instead of this field")]
2316 dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
2317 "version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
2318 dylib_lto: bool = (false, parse_bool, [UNTRACKED],
2319 "enables LTO for dylib crate type"),
2320 eagerly_emit_delayed_bugs: bool = (false, parse_bool, [UNTRACKED],
2321 "emit delayed bugs eagerly as errors instead of stashing them and emitting \
2322 them only if an error has not been emitted"),
2323 ehcont_guard: bool = (false, parse_bool, [TRACKED],
2324 "generate Windows EHCont Guard tables"),
2325 embed_metadata: bool = (true, parse_bool, [TRACKED],
2326 "embed metadata in rlibs and dylibs (default: yes)"),
2327 embed_source: bool = (false, parse_bool, [TRACKED],
2328 "embed source text in DWARF debug sections (default: no)"),
2329 emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
2330 "emit a section containing stack size metadata (default: no)"),
2331 emit_thin_lto: bool = (true, parse_bool, [TRACKED],
2332 "emit the bc module with thin LTO info (default: yes)"),
2333 emscripten_wasm_eh: bool = (true, parse_bool, [TRACKED],
2334 "Use WebAssembly error handling for wasm32-unknown-emscripten"),
2335 enforce_type_length_limit: bool = (false, parse_bool, [TRACKED],
2336 "enforce the type length limit when monomorphizing instances in codegen"),
2337 experimental_default_bounds: bool = (false, parse_bool, [TRACKED],
2338 "enable default bounds for experimental group of auto traits"),
2339 export_executable_symbols: bool = (false, parse_bool, [TRACKED],
2340 "export symbols from executables, as if they were dynamic libraries"),
2341 external_clangrt: bool = (false, parse_bool, [UNTRACKED],
2342 "rely on user specified linker commands to find clangrt"),
2343 extra_const_ub_checks: bool = (false, parse_bool, [TRACKED],
2344 "turns on more checks to detect const UB, which can be slow (default: no)"),
2345 #[rustc_lint_opt_deny_field_access("use `Session::fewer_names` instead of this field")]
2346 fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED],
2347 "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
2348 (default: no)"),
2349 fixed_x18: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
2350 "make the x18 register reserved on AArch64 (default: no)"),
2351 flatten_format_args: bool = (true, parse_bool, [TRACKED],
2352 "flatten nested format_args!() and literals into a simplified format_args!() call \
2353 (default: yes)"),
2354 fmt_debug: FmtDebug = (FmtDebug::Full, parse_fmt_debug, [TRACKED],
2355 "how detailed `#[derive(Debug)]` should be. `full` prints types recursively, \
2356 `shallow` prints only type names, `none` prints nothing and disables `{:?}`. (default: `full`)"),
2357 force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
2358 "force all crates to be `rustc_private` unstable (default: no)"),
2359 function_return: FunctionReturn = (FunctionReturn::default(), parse_function_return, [TRACKED],
2360 "replace returns with jumps to `__x86_return_thunk` (default: `keep`)"),
2361 function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
2362 "whether each function should go in its own section"),
2363 future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
2364 "forces all lints to be future incompatible, used for internal testing (default: no)"),
2365 graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
2366 "use dark-themed colors in graphviz output (default: no)"),
2367 graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
2368 "use the given `fontname` in graphviz output; can be overridden by setting \
2369 environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
2370 has_thread_local: Option<bool> = (None, parse_opt_bool, [TRACKED],
2371 "explicitly enable the `cfg(target_thread_local)` directive"),
2372 higher_ranked_assumptions: bool = (false, parse_bool, [TRACKED],
2373 "allow deducing higher-ranked outlives assumptions from coroutines when proving auto traits"),
2374 hint_mostly_unused: bool = (false, parse_bool, [TRACKED],
2375 "hint that most of this crate will go unused, to minimize work for uncalled functions"),
2376 human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
2377 "generate human-readable, predictable names for codegen units (default: no)"),
2378 identify_regions: bool = (false, parse_bool, [UNTRACKED],
2379 "display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
2380 ignore_directory_in_diagnostics_source_blocks: Vec<String> = (Vec::new(), parse_string_push, [UNTRACKED],
2381 "do not display the source code block in diagnostics for files in the directory"),
2382 incremental_ignore_spans: bool = (false, parse_bool, [TRACKED],
2383 "ignore spans during ICH computation -- used for testing (default: no)"),
2384 incremental_info: bool = (false, parse_bool, [UNTRACKED],
2385 "print high-level information about incremental reuse (or the lack thereof) \
2386 (default: no)"),
2387 incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
2388 "verify extended properties for incr. comp. (default: no):
2389 - hashes of green query instances
2390 - hash collisions of query keys
2391 - hash collisions when creating dep-nodes"),
2392 indirect_branch_cs_prefix: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
2393 "add `cs` prefix to `call` and `jmp` to indirect thunks (default: no)"),
2394 inline_llvm: bool = (true, parse_bool, [TRACKED],
2395 "enable LLVM inlining (default: yes)"),
2396 inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
2397 "enable MIR inlining (default: no)"),
2398 inline_mir_forwarder_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
2399 "inlining threshold when the caller is a simple forwarding function (default: 30)"),
2400 inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
2401 "inlining threshold for functions with inline hint (default: 100)"),
2402 inline_mir_preserve_debug: Option<bool> = (None, parse_opt_bool, [TRACKED],
2403 "when MIR inlining, whether to preserve debug info for callee variables \
2404 (default: preserve for debuginfo != None, otherwise remove)"),
2405 inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
2406 "a default MIR inlining threshold (default: 50)"),
2407 input_stats: bool = (false, parse_bool, [UNTRACKED],
2408 "print some statistics about AST and HIR (default: no)"),
2409 instrument_mcount: bool = (false, parse_bool, [TRACKED],
2410 "insert function instrument code for mcount-based tracing (default: no)"),
2411 instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED],
2412 "insert function instrument code for XRay-based tracing (default: no)
2413 Optional extra settings:
2414 `=always`
2415 `=never`
2416 `=ignore-loops`
2417 `=instruction-threshold=N`
2418 `=skip-entry`
2419 `=skip-exit`
2420 Multiple options can be combined with commas."),
2421 layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
2422 "seed layout randomization"),
2423 link_directives: bool = (true, parse_bool, [TRACKED],
2424 "honor #[link] directives in the compiled crate (default: yes)"),
2425 link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
2426 "link native libraries in the linker invocation (default: yes)"),
2427 link_only: bool = (false, parse_bool, [TRACKED],
2428 "link the `.rlink` file generated by `-Z no-link` (default: no)"),
2429 lint_llvm_ir: bool = (false, parse_bool, [TRACKED],
2430 "lint LLVM IR (default: no)"),
2431 lint_mir: bool = (false, parse_bool, [UNTRACKED],
2432 "lint MIR before and after each transformation"),
2433 llvm_module_flag: Vec<(String, u32, String)> = (Vec::new(), parse_llvm_module_flag, [TRACKED],
2434 "a list of module flags to pass to LLVM (space separated)"),
2435 llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
2436 "a list LLVM plugins to enable (space separated)"),
2437 llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
2438 "generate JSON tracing data file from LLVM data (default: no)"),
2439 location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
2440 "what location details should be tracked when using caller_location, either \
2441 `none`, or a comma separated list of location details, for which \
2442 valid options are `file`, `line`, and `column` (default: `file,line,column`)"),
2443 ls: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
2444 "decode and print various parts of the crate metadata for a library crate \
2445 (space separated)"),
2446 macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
2447 "show macro backtraces (default: no)"),
2448 macro_stats: bool = (false, parse_bool, [UNTRACKED],
2449 "print some statistics about macro expansions (default: no)"),
2450 maximal_hir_to_mir_coverage: bool = (false, parse_bool, [TRACKED],
2451 "save as much information as possible about the correspondence between MIR and HIR \
2452 as source scopes (default: no)"),
2453 merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
2454 "control the operation of the MergeFunctions LLVM pass, taking \
2455 the same values as the target option of the same name"),
2456 meta_stats: bool = (false, parse_bool, [UNTRACKED],
2457 "gather metadata statistics (default: no)"),
2458 metrics_dir: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
2459 "the directory metrics emitted by rustc are dumped into (implicitly enables default set of metrics)"),
2460 min_function_alignment: Option<Align> = (None, parse_align, [TRACKED],
2461 "align all functions to at least this many bytes. Must be a power of 2"),
2462 mir_emit_retag: bool = (false, parse_bool, [TRACKED],
2463 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
2464 (default: no)"),
2465 mir_enable_passes: Vec<(String, bool)> = (Vec::new(), parse_list_with_polarity, [TRACKED],
2466 "use like `-Zmir-enable-passes=+DestinationPropagation,-InstSimplify`. Forces the \
2467 specified passes to be enabled, overriding all other checks. In particular, this will \
2468 enable unsound (known-buggy and hence usually disabled) passes without further warning! \
2469 Passes that are not specified are enabled or disabled by other flags as usual."),
2470 mir_include_spans: MirIncludeSpans = (MirIncludeSpans::default(), parse_mir_include_spans, [UNTRACKED],
2471 "include extra comments in mir pretty printing, like line numbers and statement indices, \
2472 details about types, etc. (boolean for all passes, 'nll' to enable in NLL MIR only, default: 'nll')"),
2473 #[rustc_lint_opt_deny_field_access("use `Session::mir_opt_level` instead of this field")]
2474 mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
2475 "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
2476 mir_preserve_ub: bool = (false, parse_bool, [TRACKED],
2477 "keep place mention statements and reads in trivial SwitchInt terminators, which are interpreted \
2478 e.g., by miri; implies -Zmir-opt-level=0 (default: no)"),
2479 mir_strip_debuginfo: MirStripDebugInfo = (MirStripDebugInfo::None, parse_mir_strip_debuginfo, [TRACKED],
2480 "Whether to remove some of the MIR debug info from methods. Default: None"),
2481 move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
2482 "the size at which the `large_assignments` lint starts to be emitted"),
2483 mutable_noalias: bool = (true, parse_bool, [TRACKED],
2484 "emit noalias metadata for mutable references (default: yes)"),
2485 namespaced_crates: bool = (false, parse_bool, [TRACKED],
2486 "allow crates to be namespaced by other crates (default: no)"),
2487 next_solver: NextSolverConfig = (NextSolverConfig::default(), parse_next_solver_config, [TRACKED],
2488 "enable and configure the next generation trait solver used by rustc"),
2489 nll_facts: bool = (false, parse_bool, [UNTRACKED],
2490 "dump facts from NLL analysis into side files (default: no)"),
2491 nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
2492 "the directory the NLL facts are dumped into (default: `nll-facts`)"),
2493 no_analysis: bool = (false, parse_no_value, [UNTRACKED],
2494 "parse and expand the source, but run no analysis"),
2495 no_codegen: bool = (false, parse_no_value, [TRACKED_NO_CRATE_HASH],
2496 "run all passes except codegen; no output"),
2497 no_generate_arange_section: bool = (false, parse_no_value, [TRACKED],
2498 "omit DWARF address ranges that give faster lookups"),
2499 no_implied_bounds_compat: bool = (false, parse_bool, [TRACKED],
2500 "disable the compatibility version of the `implied_bounds_ty` query"),
2501 no_leak_check: bool = (false, parse_no_value, [UNTRACKED],
2502 "disable the 'leak check' for subtyping; unsound, but useful for tests"),
2503 no_link: bool = (false, parse_no_value, [TRACKED],
2504 "compile without linking"),
2505 no_parallel_backend: bool = (false, parse_no_value, [UNTRACKED],
2506 "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
2507 no_profiler_runtime: bool = (false, parse_no_value, [TRACKED],
2508 "prevent automatic injection of the profiler_builtins crate"),
2509 no_steal_thir: bool = (false, parse_bool, [UNTRACKED],
2510 "don't steal the THIR when we're done with it; useful for rustc drivers (default: no)"),
2511 no_trait_vptr: bool = (false, parse_no_value, [TRACKED],
2512 "disable generation of trait vptr in vtable for upcasting"),
2513 no_unique_section_names: bool = (false, parse_bool, [TRACKED],
2514 "do not use unique names for text and data sections when -Z function-sections is used"),
2515 normalize_docs: bool = (false, parse_bool, [TRACKED],
2516 "normalize associated items in rustdoc when generating documentation"),
2517 offload: Vec<crate::config::Offload> = (Vec::new(), parse_offload, [TRACKED],
2518 "a list of offload flags to enable
2519 Mandatory setting:
2520 `=Enable`
2521 Currently the only option available"),
2522 on_broken_pipe: OnBrokenPipe = (OnBrokenPipe::Default, parse_on_broken_pipe, [TRACKED],
2523 "behavior of std::io::ErrorKind::BrokenPipe (SIGPIPE)"),
2524 osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
2525 "pass `-install_name @rpath/...` to the macOS linker (default: no)"),
2526 packed_bundled_libs: bool = (false, parse_bool, [TRACKED],
2527 "change rlib format to store native libraries as archives"),
2528 panic_abort_tests: bool = (false, parse_bool, [TRACKED],
2529 "support compiling tests with panic=abort (default: no)"),
2530 panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
2531 "panic strategy for panics in drops"),
2532 parse_crate_root_only: bool = (false, parse_bool, [UNTRACKED],
2533 "parse the crate root file only; do not parse other files, compile, assemble, or link \
2534 (default: no)"),
2535 patchable_function_entry: PatchableFunctionEntry = (PatchableFunctionEntry::default(), parse_patchable_function_entry, [TRACKED],
2536 "nop padding at function entry"),
2537 plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
2538 "whether to use the PLT when calling into shared libraries;
2539 only has effect for PIC code on systems with ELF binaries
2540 (default: PLT is disabled if full relro is enabled on x86_64)"),
2541 polonius: Polonius = (Polonius::default(), parse_polonius, [TRACKED],
2542 "enable polonius-based borrow-checker (default: no)"),
2543 pre_link_arg: () = ((), parse_string_push, [UNTRACKED],
2544 "a single extra argument to prepend the linker invocation (can be used several times)"),
2545 pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
2546 "extra arguments to prepend to the linker invocation (space separated)"),
2547 precise_enum_drop_elaboration: bool = (true, parse_bool, [TRACKED],
2548 "use a more precise version of drop elaboration for matches on enums (default: yes). \
2549 This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
2550 See #77382 and #74551."),
2551 #[rustc_lint_opt_deny_field_access("use `Session::print_codegen_stats` instead of this field")]
2552 print_codegen_stats: bool = (false, parse_bool, [UNTRACKED],
2553 "print codegen statistics (default: no)"),
2554 print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
2555 "print the LLVM optimization passes being run (default: no)"),
2556 print_mono_items: bool = (false, parse_bool, [UNTRACKED],
2557 "print the result of the monomorphization collection pass (default: no)"),
2558 print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
2559 "print layout information for each type encountered (default: no)"),
2560 proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
2561 "show backtraces for panics during proc-macro execution (default: no)"),
2562 proc_macro_execution_strategy: ProcMacroExecutionStrategy = (ProcMacroExecutionStrategy::SameThread,
2563 parse_proc_macro_execution_strategy, [UNTRACKED],
2564 "how to run proc-macro code (default: same-thread)"),
2565 profile_closures: bool = (false, parse_no_value, [UNTRACKED],
2566 "profile size of closures"),
2567 profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
2568 "use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
2569 profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
2570 "name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
2571 query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
2572 "enable queries of the dependency graph for regression testing (default: no)"),
2573 randomize_layout: bool = (false, parse_bool, [TRACKED],
2574 "randomize the layout of types (default: no)"),
2575 reg_struct_return: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
2576 "On x86-32 targets, it overrides the default ABI to return small structs in registers.
2577 It is UNSOUND to link together crates that use different values for this flag!"),
2578 regparm: Option<u32> = (None, parse_opt_number, [TRACKED TARGET_MODIFIER],
2579 "On x86-32 targets, setting this to N causes the compiler to pass N arguments \
2580 in registers EAX, EDX, and ECX instead of on the stack for\
2581 \"C\", \"cdecl\", and \"stdcall\" fn.\
2582 It is UNSOUND to link together crates that use different values for this flag!"),
2583 relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
2584 "whether ELF relocations can be relaxed"),
2585 remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
2586 "remap paths under the current working directory to this path prefix"),
2587 remap_path_scope: RemapPathScopeComponents = (RemapPathScopeComponents::all(), parse_remap_path_scope, [TRACKED],
2588 "remap path scope (default: all)"),
2589 remark_dir: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
2590 "directory into which to write optimization remarks (if not specified, they will be \
2591written to standard error output)"),
2592 retpoline: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
2593 "enables retpoline-indirect-branches and retpoline-indirect-calls target features (default: no)"),
2594 retpoline_external_thunk: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
2595 "enables retpoline-external-thunk, retpoline-indirect-branches and retpoline-indirect-calls \
2596 target features (default: no)"),
2597 #[rustc_lint_opt_deny_field_access("use `Session::sanitizers()` instead of this field")]
2598 sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED TARGET_MODIFIER],
2599 "use a sanitizer"),
2600 sanitizer_cfi_canonical_jump_tables: Option<bool> = (Some(true), parse_opt_bool, [TRACKED],
2601 "enable canonical jump tables (default: yes)"),
2602 sanitizer_cfi_generalize_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
2603 "enable generalizing pointer types (default: no)"),
2604 sanitizer_cfi_normalize_integers: Option<bool> = (None, parse_opt_bool, [TRACKED TARGET_MODIFIER],
2605 "enable normalizing integer types (default: no)"),
2606 sanitizer_dataflow_abilist: Vec<String> = (Vec::new(), parse_comma_list, [TRACKED],
2607 "additional ABI list files that control how shadow parameters are passed (comma separated)"),
2608 sanitizer_kcfi_arity: Option<bool> = (None, parse_opt_bool, [TRACKED],
2609 "enable KCFI arity indicator (default: no)"),
2610 sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
2611 "enable origins tracking in MemorySanitizer"),
2612 sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
2613 "enable recovery for selected sanitizers"),
2614 saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
2615 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
2616 the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
2617 self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
2618 parse_switch_with_opt_path, [UNTRACKED],
2619 "run the self profiler and output the raw event data"),
2620 self_profile_counter: String = ("wall-time".to_string(), parse_string, [UNTRACKED],
2621 "counter used by the self profiler (default: `wall-time`), one of:
2622 `wall-time` (monotonic clock, i.e. `std::time::Instant`)
2623 `instructions:u` (retired instructions, userspace-only)
2624 `instructions-minus-irqs:u` (subtracting hardware interrupt counts for extra accuracy)"
2625 ),
2626 self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
2628 "specify the events recorded by the self profiler;
2629 for example: `-Z self-profile-events=default,query-keys`
2630 all options: none, all, default, generic-activity, query-provider, query-cache-hit
2631 query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes"),
2632 share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
2633 "make the current crate share its generic instantiations"),
2634 shell_argfiles: bool = (false, parse_bool, [UNTRACKED],
2635 "allow argument files to be specified with POSIX \"shell-style\" argument quoting"),
2636 simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
2637 "simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
2638 to rust's source base directory. only meant for testing purposes"),
2639 small_data_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
2640 "Set the threshold for objects to be stored in a \"small data\" section"),
2641 span_debug: bool = (false, parse_bool, [UNTRACKED],
2642 "forward proc_macro::Span's `Debug` impl to `Span`"),
2643 span_free_formats: bool = (false, parse_bool, [UNTRACKED],
2645 "exclude spans when debug-printing compiler state (default: no)"),
2646 split_dwarf_inlining: bool = (false, parse_bool, [TRACKED],
2647 "provide minimal debug info in the object/executable to facilitate online \
2648 symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF"),
2649 split_dwarf_kind: SplitDwarfKind = (SplitDwarfKind::Split, parse_split_dwarf_kind, [TRACKED],
2650 "split dwarf variant (only if -Csplit-debuginfo is enabled and on relevant platform)
2651 (default: `split`)
2652
2653 `split`: sections which do not require relocation are written into a DWARF object (`.dwo`)
2654 file which is ignored by the linker
2655 `single`: sections which do not require relocation are written into object file but ignored
2656 by the linker"),
2657 split_dwarf_out_dir : Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
2658 "location for writing split DWARF objects (`.dwo`) if enabled"),
2659 split_lto_unit: Option<bool> = (None, parse_opt_bool, [TRACKED],
2660 "enable LTO unit splitting (default: no)"),
2661 src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
2662 "hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
2663 #[rustc_lint_opt_deny_field_access("use `Session::stack_protector` instead of this field")]
2664 stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED],
2665 "control stack smash protection strategy (`rustc --print stack-protector-strategies` for details)"),
2666 staticlib_allow_rdylib_deps: bool = (false, parse_bool, [TRACKED],
2667 "allow staticlibs to have rust dylib dependencies"),
2668 staticlib_prefer_dynamic: bool = (false, parse_bool, [TRACKED],
2669 "prefer dynamic linking to static linking for staticlibs (default: no)"),
2670 strict_init_checks: bool = (false, parse_bool, [TRACKED],
2671 "control if mem::uninitialized and mem::zeroed panic on more UB"),
2672 #[rustc_lint_opt_deny_field_access("use `Session::teach` instead of this field")]
2673 teach: bool = (false, parse_bool, [TRACKED],
2674 "show extended diagnostic help (default: no)"),
2675 temps_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
2676 "the directory the intermediate files are written to"),
2677 terminal_urls: TerminalUrl = (TerminalUrl::No, parse_terminal_url, [UNTRACKED],
2678 "use the OSC 8 hyperlink terminal specification to print hyperlinks in the compiler output"),
2679 #[rustc_lint_opt_deny_field_access("use `Session::lto` instead of this field")]
2680 thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
2681 "enable ThinLTO when possible"),
2682 #[rustc_lint_opt_deny_field_access("use `Session::threads` instead of this field")]
2687 threads: usize = (1, parse_threads, [UNTRACKED],
2688 "use a thread pool with N threads"),
2689 time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
2690 "measure time of each LLVM pass (default: no)"),
2691 time_passes: bool = (false, parse_bool, [UNTRACKED],
2692 "measure time of each rustc pass (default: no)"),
2693 time_passes_format: TimePassesFormat = (TimePassesFormat::Text, parse_time_passes_format, [UNTRACKED],
2694 "the format to use for -Z time-passes (`text` (default) or `json`)"),
2695 tiny_const_eval_limit: bool = (false, parse_bool, [TRACKED],
2696 "sets a tiny, non-configurable limit for const eval; useful for compiler tests"),
2697 #[rustc_lint_opt_deny_field_access("use `Session::tls_model` instead of this field")]
2698 tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
2699 "choose the TLS model to use (`rustc --print tls-models` for details)"),
2700 trace_macros: bool = (false, parse_bool, [UNTRACKED],
2701 "for every macro invocation, print its name and arguments (default: no)"),
2702 track_diagnostics: bool = (false, parse_bool, [UNTRACKED],
2703 "tracks where in rustc a diagnostic was emitted"),
2704 translate_additional_ftl: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
2708 "additional fluent translation to preferentially use (for testing translation)"),
2709 translate_directionality_markers: bool = (false, parse_bool, [TRACKED],
2710 "emit directionality isolation markers in translated diagnostics"),
2711 translate_lang: Option<LanguageIdentifier> = (None, parse_opt_langid, [TRACKED],
2712 "language identifier for diagnostic output"),
2713 translate_remapped_path_to_local_path: bool = (true, parse_bool, [TRACKED],
2714 "translate remapped paths into local paths when possible (default: yes)"),
2715 trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
2716 "generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
2717 treat_err_as_bug: Option<NonZero<usize>> = (None, parse_treat_err_as_bug, [TRACKED],
2718 "treat the `val`th error that occurs as bug (default if not specified: 0 - don't treat errors as bugs. \
2719 default if specified without a value: 1 - treat the first error as bug)"),
2720 trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
2721 "in diagnostics, use heuristics to shorten paths referring to items"),
2722 tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
2723 "select processor to schedule for (`rustc --print target-cpus` for details)"),
2724 #[rustc_lint_opt_deny_field_access("use `TyCtxt::use_typing_mode_borrowck` instead of this field")]
2725 typing_mode_borrowck: bool = (false, parse_bool, [TRACKED],
2726 "enable `TypingMode::Borrowck`, changing the way opaque types are handled during MIR borrowck"),
2727 #[rustc_lint_opt_deny_field_access("use `Session::ub_checks` instead of this field")]
2728 ub_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
2729 "emit runtime checks for Undefined Behavior (default: -Cdebug-assertions)"),
2730 ui_testing: bool = (false, parse_bool, [UNTRACKED],
2731 "emit compiler diagnostics in a form suitable for UI testing (default: no)"),
2732 uninit_const_chunk_threshold: usize = (16, parse_number, [TRACKED],
2733 "allow generating const initializers with mixed init/uninit chunks, \
2734 and set the maximum number of chunks for which this is allowed (default: 16)"),
2735 unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
2736 "take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
2737 unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
2738 "present the input source, unstable (and less-pretty) variants;
2739 `normal`, `identified`,
2740 `expanded`, `expanded,identified`,
2741 `expanded,hygiene` (with internal representations),
2742 `ast-tree` (raw AST before expansion),
2743 `ast-tree,expanded` (raw AST after expansion),
2744 `hir` (the HIR), `hir,identified`,
2745 `hir,typed` (HIR with types for each node),
2746 `hir-tree` (dump the raw HIR),
2747 `thir-tree`, `thir-flat`,
2748 `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
2749 unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
2750 "enable unsound and buggy MIR optimizations (default: no)"),
2751 #[rustc_lint_opt_deny_field_access("use `Session::unstable_options` instead of this field")]
2760 unstable_options: bool = (false, parse_no_value, [UNTRACKED],
2761 "adds unstable command line options to rustc interface (default: no)"),
2762 use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
2763 "use legacy .ctors section for initializers rather than .init_array"),
2764 use_sync_unwind: Option<bool> = (None, parse_opt_bool, [TRACKED],
2765 "Generate sync unwind tables instead of async unwind tables (default: no)"),
2766 validate_mir: bool = (false, parse_bool, [UNTRACKED],
2767 "validate MIR after each transformation"),
2768 verbose_asm: bool = (false, parse_bool, [TRACKED],
2769 "add descriptive comments from LLVM to the assembly (may change behavior) (default: no)"),
2770 #[rustc_lint_opt_deny_field_access("use `Session::verbose_internals` instead of this field")]
2771 verbose_internals: bool = (false, parse_bool, [TRACKED_NO_CRATE_HASH],
2772 "in general, enable more debug printouts (default: no)"),
2773 #[rustc_lint_opt_deny_field_access("use `Session::verify_llvm_ir` instead of this field")]
2774 verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
2775 "verify LLVM IR (default: no)"),
2776 virtual_function_elimination: bool = (false, parse_bool, [TRACKED],
2777 "enables dead virtual function elimination optimization. \
2778 Requires `-Clto[=[fat,yes]]`"),
2779 wasi_exec_model: Option<WasiExecModel> = (None, parse_wasi_exec_model, [TRACKED],
2780 "whether to build a wasi command or reactor"),
2781 wasm_c_abi: () = ((), parse_wasm_c_abi, [TRACKED],
2785 "use spec-compliant C ABI for `wasm32-unknown-unknown` (deprecated, always enabled)"),
2786 write_long_types_to_disk: bool = (true, parse_bool, [UNTRACKED],
2787 "whether long type names should be written to files instead of being printed in errors"),
2788 }