Skip to content

Commit

Permalink
Remove build-time check for stdsimd feature
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Amanieu committed Nov 1, 2023
1 parent 7fbcf0f commit dba28d4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 35 deletions.
3 changes: 0 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 1 addition & 6 deletions src/hash_quality_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
14 changes: 2 additions & 12 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/random_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions tests/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit dba28d4

Please sign in to comment.