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