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