@@ -180,7 +180,10 @@ fn detect_features() -> u32 {
180
180
features
181
181
}
182
182
183
- #[ cfg( all( target_os = "ios" , target_arch = "aarch64" ) ) ]
183
+ #[ cfg( all(
184
+ target_arch = "aarch64" ,
185
+ any( target_os = "ios" , target_os = "macos" , target_os = "tvos" )
186
+ ) ) ]
184
187
fn detect_features ( ) -> u32 {
185
188
let mut features = ARMCAP_STATIC ;
186
189
@@ -219,7 +222,7 @@ fn detect_features() -> u32 {
219
222
target_os = "fuchsia" ,
220
223
all( target_os = "linux" , not( target_env = "uclibc" ) ) ,
221
224
target_os = "windows" ,
222
- target_os = "ios"
225
+ any ( target_os = "ios" , target_os = "macos" , target_os = "tvos" ) ,
223
226
) )
224
227
) ) ]
225
228
fn detect_features ( ) -> u32 {
@@ -242,7 +245,9 @@ macro_rules! features {
242
245
} ;
243
246
) +
244
247
245
- const ARMCAP_STATIC : u32 = 0
248
+ // See const assertions below.
249
+ const ARMCAP_STATIC : u32 = ARMCAP_STATIC_DETECTED & ARMCAP_STATIC_FILTER ;
250
+ const ARMCAP_STATIC_DETECTED : u32 = 0
246
251
$(
247
252
| (
248
253
if cfg!( all( any( target_arch = "aarch64" , target_arch = "arm" ) ,
@@ -251,8 +256,13 @@ macro_rules! features {
251
256
} else {
252
257
0
253
258
}
254
- )
259
+ )
255
260
) +;
261
+ const ARMCAP_STATIC_FILTER : u32 = if cfg!( all( target_arch = "aarch64" , target_os = "macos" ) ) {
262
+ AARCH64_APPLE_FEATURES
263
+ } else {
264
+ !0
265
+ } ;
256
266
257
267
#[ cfg( all( test, any( target_arch = "arm" , target_arch = "aarch64" ) ) ) ]
258
268
const ALL_FEATURES : [ Feature ; 5 ] = [
@@ -389,20 +399,25 @@ prefixed_extern! {
389
399
// target_feature="neon"
390
400
// target_feature="sha2"
391
401
// target_feature="sha3"
402
+ //
403
+ // XXX/TODO(coverage)/TODO(size): aarch64-apple-darwin is statically guaranteed to have "sha3" but
404
+ // other aarch64-apple-* targets require dynamic detection. Since we don't have test coverage for
405
+ // the other targets yet, we wouldn't have a way of testing the dynamic detection if we statically
406
+ // enabled `SHA512` for -darwin. So instead, temporarily, we statically ignore the static
407
+ // availability of the feature on -darwin so that it runs the dynamic detection.
392
408
// ```
393
409
#[ allow( clippy:: assertions_on_constants) ]
394
410
const _AARCH64_HAS_NEON: ( ) =
395
411
assert ! ( ( ( ARMCAP_STATIC & NEON . mask) == NEON . mask) || !cfg!( target_arch = "aarch64" ) ) ;
396
- #[ allow( clippy:: assertions_on_constants) ]
397
- const _AARCH64_APPLE_FEATURES: u32 = NEON . mask | AES . mask | SHA256 . mask | PMULL . mask ;
412
+ const AARCH64_APPLE_FEATURES : u32 = NEON . mask | AES . mask | SHA256 . mask | PMULL . mask ;
398
413
#[ allow( clippy:: assertions_on_constants) ]
399
414
const _AARCH64_APPLE_TARGETS_EXPECTED_FEATURES: ( ) = assert ! (
400
415
( ( ARMCAP_STATIC & _AARCH64_APPLE_FEATURES) == _AARCH64_APPLE_FEATURES)
401
416
|| !cfg!( all( target_arch = "aarch64" , target_vendor = "apple" ) )
402
417
) ;
403
418
#[ allow( clippy:: assertions_on_constants) ]
404
419
const _AARCH64_APPLE_DARWIN_TARGETS_EXPECTED_FEATURES: ( ) = assert ! (
405
- ( ( ARMCAP_STATIC & SHA512 . mask ) == SHA512 . mask )
420
+ ( ARMCAP_STATIC == AARCH64_APPLE_FEATURES )
406
421
|| !cfg!( all( target_arch = "aarch64" , target_os = "macos" ) )
407
422
) ;
408
423
0 commit comments