@@ -96,21 +96,26 @@ fn build_kimchi_stubs(target_dir: Option<&str>, offline: bool) -> Result<()> {
96
96
97
97
// If optimisations are enabled and the CPU supports ADX and BMI2, we enable
98
98
// those features.
99
- let rustflags = if optimisations_enabled && cpu_supports_adx_bmi2 {
100
- Some ( "-C target-feature=+bmi2,+adx" . to_string ( ) )
101
- } else if !optimisations_enabled && cpu_supports_adx_bmi2 {
102
- // If optimisations are disabled but the CPU supports ADX and BMI2,
103
- // we explicitly disable them.
104
- Some ( "-C target-feature=-bmi2,-adx" . to_string ( ) )
105
- } else if !cpu_supports_adx_bmi2 {
106
- // If the CPU does not support ADX and BMI2, we do not set any
107
- // target features. It could be handled in the `else` branch, but we
108
- // want to be explicit. If the CPU does not support these features, but
109
- // we still add the -bmi2 and -adx flags, it will cause a build warning
110
- // we want to avoid on the user console.
111
- None
112
- } else {
113
- None
99
+ let rustflags = match ( optimisations_enabled, cpu_supports_adx_bmi2) {
100
+ ( true , true ) => {
101
+ // If optimisations are enabled and the CPU supports ADX and BMI2,
102
+ // we enable them.
103
+ Some ( "-C target-feature=+bmi2,+adx" . to_string ( ) )
104
+ }
105
+ ( false , true ) => {
106
+ // If optimisations are disabled but the CPU supports ADX and BMI2,
107
+ // we explicitly disable them.
108
+ Some ( "-C target-feature=-bmi2,-adx" . to_string ( ) )
109
+ }
110
+ ( true , false ) => {
111
+ // If the CPU does not support ADX and BMI2, we do not set any
112
+ // target features. It could be handled in the `else` branch, but we
113
+ // want to be explicit. If the CPU does not support these features, but
114
+ // we still add the -bmi2 and -adx flags, it will cause a build warning
115
+ // we want to avoid on the user console.
116
+ None
117
+ }
118
+ ( false , false ) => None ,
114
119
} ;
115
120
116
121
let target_dir = target_dir. unwrap_or ( "target/kimchi_stubs_build" ) ;
0 commit comments