From dba28d4ac9470ca38890bb79b64ca1c7b5b8d0e7 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 1 Nov 2023 00:23:52 +0000 Subject: [PATCH] Remove build-time check for `stdsimd` feature This is blocking rust-lang/rust#117372, which replaces `stdsimd` with more fine-grained features. However the auto-detection in aHash breaks when bootstrapping Rust because it detects the `stdsimd` feature on the old toolchain which is not present on the newly build libcore. This PR removes the build-time detection of the `stdsimd` feature and instead just uses the ARM AES intrinsics directly since they are now stable, but only on AArch64. --- build.rs | 3 --- src/hash_quality_test.rs | 7 +------ src/lib.rs | 9 ++------- src/operations.rs | 14 ++------------ src/random_state.rs | 2 +- tests/bench.rs | 7 +------ 6 files changed, 7 insertions(+), 35 deletions(-) diff --git a/build.rs b/build.rs index 0c5b769..a136b36 100644 --- a/build.rs +++ b/build.rs @@ -7,9 +7,6 @@ fn main() { if let Some(true) = version_check::supports_feature("specialize") { println!("cargo:rustc-cfg=feature=\"specialize\""); } - if let Some(true) = version_check::supports_feature("stdsimd") { - println!("cargo:rustc-cfg=feature=\"stdsimd\""); - } let arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH was not set"); if arch.eq_ignore_ascii_case("x86_64") || arch.eq_ignore_ascii_case("aarch64") diff --git a/src/hash_quality_test.rs b/src/hash_quality_test.rs index 25356e4..c510d21 100644 --- a/src/hash_quality_test.rs +++ b/src/hash_quality_test.rs @@ -437,12 +437,7 @@ mod fallback_tests { ///Basic sanity tests of the cypto properties of aHash. #[cfg(any( all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), - all( - any(target_arch = "arm", target_arch = "aarch64"), - any(target_feature = "aes", target_feature = "crypto"), - not(miri), - feature = "stdsimd" - ) + all(target_arch = "aarch64", target_feature = "aes", not(miri)), ))] #[cfg(test)] mod aes_tests { diff --git a/src/lib.rs b/src/lib.rs index 978f424..92100e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,8 +95,6 @@ Note the import of [HashMapExt]. This is needed for the constructor. #![allow(clippy::pedantic, clippy::cast_lossless, clippy::unreadable_literal)] #![cfg_attr(all(not(test), not(feature = "std")), no_std)] #![cfg_attr(feature = "specialize", feature(min_specialization))] -#![cfg_attr(feature = "specialize", feature(build_hasher_simple_hash_one))] -#![cfg_attr(feature = "stdsimd", feature(stdsimd))] #[macro_use] mod convert; @@ -106,11 +104,8 @@ mod fallback_hash; cfg_if::cfg_if! { if #[cfg(any( all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), - all(any(target_arch = "arm", target_arch = "aarch64"), - any(target_feature = "aes", target_feature = "crypto"), - not(miri), - feature = "stdsimd") - ))] { + all(target_arch = "aarch64", target_feature = "aes", not(miri)), + ))] { mod aes_hash; pub use crate::aes_hash::AHasher; } else { diff --git a/src/operations.rs b/src/operations.rs index 23d4e22..5cb368f 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -110,12 +110,7 @@ pub(crate) fn aesenc(value: u128, xor: u128) -> u128 { } } -#[cfg(all( - any(target_arch = "arm", target_arch = "aarch64"), - any(target_feature = "aes", target_feature = "crypto"), - not(miri), - feature = "stdsimd" -))] +#[cfg(all(target_arch = "aarch64", target_feature = "aes", not(miri)))] #[allow(unused)] #[inline(always)] pub(crate) fn aesenc(value: u128, xor: u128) -> u128 { @@ -142,12 +137,7 @@ pub(crate) fn aesdec(value: u128, xor: u128) -> u128 { } } -#[cfg(all( - any(target_arch = "arm", target_arch = "aarch64"), - any(target_feature = "aes", target_feature = "crypto"), - not(miri), - feature = "stdsimd" -))] +#[cfg(all(target_arch = "aarch64", target_feature = "aes", not(miri)))] #[allow(unused)] #[inline(always)] pub(crate) fn aesdec(value: u128, xor: u128) -> u128 { diff --git a/src/random_state.rs b/src/random_state.rs index 54b754d..bc29af8 100644 --- a/src/random_state.rs +++ b/src/random_state.rs @@ -2,7 +2,7 @@ use core::hash::Hash; cfg_if::cfg_if! { if #[cfg(any( all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)), - all(any(target_arch = "arm", target_arch = "aarch64"), any(target_feature = "aes", target_feature = "crypto"), not(miri), feature = "stdsimd") + all(target_arch = "aarch64", target_feature = "aes", not(miri)), ))] { use crate::aes_hash::*; } else { diff --git a/tests/bench.rs b/tests/bench.rs index 5bc0fc9..f1a1414 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -14,12 +14,7 @@ const AHASH_IMPL: &str = if cfg!(any( target_feature = "aes", not(miri), ), - all( - any(target_arch = "arm", target_arch = "aarch64"), - any(target_feature = "aes", target_feature = "crypto"), - not(miri), - feature = "stdsimd", - ), + all(target_arch = "aarch64", target_feature = "aes", not(miri)), )) { "aeshash" } else {