@@ -116,7 +116,7 @@ mod target_modifier_consistency_check {
116116 r : Option < & TargetModifier > ,
117117 ) -> bool {
118118 // For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier
119- if opts. unstable_opts . sanitizer . contains ( SanitizerSet :: KCFI ) {
119+ if opts. cg . sanitize . contains ( SanitizerSet :: KCFI ) {
120120 if let Some ( r) = r {
121121 return l. extend ( ) . tech_value == r. extend ( ) . tech_value ;
122122 } else {
@@ -136,18 +136,19 @@ impl TargetModifier {
136136 pub fn consistent ( & self , opts : & Options , other : Option < & TargetModifier > ) -> bool {
137137 assert ! ( other. is_none( ) || self . opt == other. unwrap( ) . opt) ;
138138 match self . opt {
139- OptionsTargetModifiers :: UnstableOptions ( unstable ) => match unstable {
140- UnstableOptionsTargetModifiers :: sanitizer => {
139+ OptionsTargetModifiers :: CodegenOptions ( stable ) => match stable {
140+ CodegenOptionsTargetModifiers :: sanitize => {
141141 return target_modifier_consistency_check:: sanitizer ( self , other) ;
142142 }
143+ } ,
144+ OptionsTargetModifiers :: UnstableOptions ( unstable) => match unstable {
143145 UnstableOptionsTargetModifiers :: sanitizer_cfi_normalize_integers => {
144146 return target_modifier_consistency_check:: sanitizer_cfi_normalize_integers (
145147 opts, self , other,
146148 ) ;
147149 }
148150 _ => { }
149151 } ,
150- _ => { }
151152 } ;
152153 match other {
153154 Some ( other) => self . extend ( ) . tech_value == other. extend ( ) . tech_value ,
@@ -1239,25 +1240,14 @@ pub mod parse {
12391240 }
12401241
12411242 pub ( crate ) fn parse_sanitizers ( slot : & mut SanitizerSet , v : Option < & str > ) -> bool {
1242- if let Some ( v) = v {
1243- for s in v. split ( ',' ) {
1244- * slot |= match s {
1245- "address" => SanitizerSet :: ADDRESS ,
1246- "cfi" => SanitizerSet :: CFI ,
1247- "dataflow" => SanitizerSet :: DATAFLOW ,
1248- "kcfi" => SanitizerSet :: KCFI ,
1249- "kernel-address" => SanitizerSet :: KERNELADDRESS ,
1250- "leak" => SanitizerSet :: LEAK ,
1251- "memory" => SanitizerSet :: MEMORY ,
1252- "memtag" => SanitizerSet :: MEMTAG ,
1253- "shadow-call-stack" => SanitizerSet :: SHADOWCALLSTACK ,
1254- "thread" => SanitizerSet :: THREAD ,
1255- "hwaddress" => SanitizerSet :: HWADDRESS ,
1256- "safestack" => SanitizerSet :: SAFESTACK ,
1257- _ => return false ,
1258- }
1243+ if let Some ( s) = v {
1244+ let sanitizer_set = SanitizerSet :: from_comma_list ( s) ;
1245+ if sanitizer_set. is_ok ( ) {
1246+ * slot |= sanitizer_set. unwrap ( ) ;
1247+ true
1248+ } else {
1249+ false
12591250 }
1260- true
12611251 } else {
12621252 false
12631253 }
@@ -2158,8 +2148,8 @@ options! {
21582148 "output remarks for these optimization passes (space separated, or \" all\" )" ) ,
21592149 rpath: bool = ( false , parse_bool, [ UNTRACKED ] ,
21602150 "set rpath values in libs/exes (default: no)" ) ,
2161- save_temps : bool = ( false , parse_bool , [ UNTRACKED ] ,
2162- "save all temporary output files during compilation (default: no) " ) ,
2151+ sanitize : SanitizerSet = ( SanitizerSet :: empty ( ) , parse_sanitizers , [ TRACKED TARGET_MODIFIER ] ,
2152+ "use one or multiple sanitizers " ) ,
21632153 soft_float: bool = ( false , parse_bool, [ TRACKED ] ,
21642154 "deprecated option: use soft float ABI (*eabihf targets only) (default: no)" ) ,
21652155 #[ rustc_lint_opt_deny_field_access( "use `Session::split_debuginfo` instead of this field" ) ]
@@ -2177,6 +2167,8 @@ options! {
21772167 This feature is unsafe.") ,
21782168 unsafe_allow_abi_mismatch: Vec <String > = ( Vec :: new( ) , parse_comma_list, [ UNTRACKED ] ,
21792169 "Allow incompatible target modifiers in dependency crates (comma separated list)" ) ,
2170+ save_temps: bool = ( false , parse_bool, [ UNTRACKED ] ,
2171+ "Allow incompatible target modifiers in dependency crates (comma separated list)" ) ,
21802172 // tidy-alphabetical-end
21812173
21822174 // If you add a new option, please update:
@@ -2575,8 +2567,6 @@ written to standard error output)"),
25752567 retpoline_external_thunk: bool = ( false , parse_bool, [ TRACKED TARGET_MODIFIER ] ,
25762568 "enables retpoline-external-thunk, retpoline-indirect-branches and retpoline-indirect-calls \
25772569 target features (default: no)") ,
2578- sanitizer: SanitizerSet = ( SanitizerSet :: empty( ) , parse_sanitizers, [ TRACKED TARGET_MODIFIER ] ,
2579- "use a sanitizer" ) ,
25802570 sanitizer_cfi_canonical_jump_tables: Option <bool > = ( Some ( true ) , parse_opt_bool, [ TRACKED ] ,
25812571 "enable canonical jump tables (default: yes)" ) ,
25822572 sanitizer_cfi_generalize_pointers: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
@@ -2594,6 +2584,8 @@ written to standard error output)"),
25942584 saturating_float_casts: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
25952585 "make float->int casts UB-free: numbers outside the integer type's range are clipped to \
25962586 the max/min integer respectively, and NaN is mapped to 0 (default: yes)") ,
2587+ sanitize: SanitizerSet = ( SanitizerSet :: empty( ) , parse_sanitizers, [ TRACKED TARGET_MODIFIER ] ,
2588+ "use one or multiple sanitizers" ) ,
25972589 self_profile: SwitchWithOptPath = ( SwitchWithOptPath :: Disabled ,
25982590 parse_switch_with_opt_path, [ UNTRACKED ] ,
25992591 "run the self profiler and output the raw event data" ) ,
0 commit comments