From 6aa80c5ae0f0fc04a48cf580e9aaa5a67f8c6f79 Mon Sep 17 00:00:00 2001 From: ph0llux Date: Sat, 27 Jul 2024 14:33:38 +0200 Subject: [PATCH] Remove autodetection of aes ni, due runtime autodetection by used aes crate. --- .cargo/config.toml | 14 --- ...{Build_and_test.yml => build_and_test.yml} | 0 Cargo.toml | 4 +- build.rs | 102 ------------------ 4 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 .cargo/config.toml rename .github/workflows/{Build_and_test.yml => build_and_test.yml} (100%) delete mode 100644 build.rs diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index f1486fe..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,14 +0,0 @@ -[build] -rustflags = [] -[target.'cfg(has_aes)'] -rustflags = ["-Ctarget-feature=+aes"] -[target.'cfg(has_sse2)'] -rustflags = ["-Ctarget-feature=+sse2"] -[target.'cfg(has_ssse3)'] -rustflags = ["-Ctarget-feature=+ssse3"] -[target.'cfg(has_sse4_1)'] -rustflags = ["-Ctarget-feature=+sse4.1"] -[target.'cfg(has_neon)'] -rustflags = ["-Ctarget-feature=+neon"] -[target.'cfg(has_sha2)'] -rustflags = ["-Ctarget-feature=+sha2"] \ No newline at end of file diff --git a/.github/workflows/Build_and_test.yml b/.github/workflows/build_and_test.yml similarity index 100% rename from .github/workflows/Build_and_test.yml rename to .github/workflows/build_and_test.yml diff --git a/Cargo.toml b/Cargo.toml index a963a45..c2ca6da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,9 +61,7 @@ xattr = "1" posix-acl = "1.1.0" [features] -default = ["autodetect-cpu-instructions"] -autodetect-cpu-instructions = [] # uses the CPU flags for AES, SSE2, SSE4.1, SSSE3, etc., if the appropriate CPU which builds the binary supports them -force-cpu-instructions = [] # forces the use of the CPU flags for AES, SSE2, SSE4.1, SSSE3, etc., even if the CPU which builds the binary does not support them +default = [] serde = ["dep:serde", "dep:hex", "ordered-float/serde"] log = ["dep:log", "dep:hex"] diff --git a/build.rs b/build.rs deleted file mode 100644 index 4ba1b3e..0000000 --- a/build.rs +++ /dev/null @@ -1,102 +0,0 @@ -fn main() { - #[cfg(feature = "autodetect-cpu-instructions")] - check_cpu_instructions(); - #[cfg(feature = "force-cpu-instructions")] - set_all_instructions(); -} - -#[cfg(feature = "autodetect-cpu-instructions")] -fn check_cpu_instructions() { - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - check_x86_64_instructions(); - #[cfg(target_arch = "aarch64")] - check_aarch64_instructions(); -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[cfg(feature = "autodetect-cpu-instructions")] -fn check_x86_64_instructions() { - if is_x86_feature_detected!("aes") { - set_aes(); - } - if is_x86_feature_detected!("sse2") { - set_sse2(); - } - if is_x86_feature_detected!("ssse3") { - set_ssse3(); - } - if is_x86_feature_detected!("sse4.1") { - set_sse4_1(); - } -} - -#[cfg(target_arch = "aaarch64")] -#[cfg(feature = "autodetect-cpu-instructions")] -fn check_aarch64_instructions() { - if is_aarch64_feature_detected!("aes") { - set_aes(); - } - if is_aarch64_feature_detected!("sha2") { - set_sha2(); - } - if is_aarch64_feature_detected!("neon") { - set_neon(); - } -} - - -#[cfg(feature = "force-cpu-instructions")] -fn set_all_instructions() { - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - force_set_x86_64_instructions(); - #[cfg(target_arch = "aarch64")] - force_set_aarch64_instructions(); -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[cfg(feature = "force-cpu-instructions")] -fn force_set_x86_64_instructions() { - set_aes(); - set_sse2(); - set_ssse3(); - set_sse4_1(); -} - -#[cfg(target_arch = "aarch64")] -#[cfg(feature = "force-cpu-instructions")] -fn force_set_aarch64_instructions() { - set_aes(); - set_sha2(); - set_neon(); -} - - -#[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))] -fn set_aes() { - println!("cargo:rustc-cfg=has_aes"); -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -fn set_sse2() { - println!("cargo:rustc-cfg=has_sse2"); -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -fn set_ssse3() { - println!("cargo:rustc-cfg=has_ssse3"); -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -fn set_sse4_1() { - println!("cargo:rustc-cfg=has_sse4_1"); -} - -#[cfg(target_arch = "aarch64")] -fn set_sha2() { - println!("cargo:rustc-cfg=has_sha2"); -} - -#[cfg(target_arch = "aarch64")] -fn set_neon() { - println!("cargo:rustc-cfg=has_neon"); -} \ No newline at end of file