diff options
| author | rsdy <[email protected]> | 2021-10-09 19:46:07 +0100 |
|---|---|---|
| committer | rsdy <[email protected]> | 2021-10-11 20:45:01 +0100 |
| commit | 6b9cbe5e23443eb05d5cbdf645cb54b3706ea0c6 (patch) | |
| tree | e47e1a9e8403b74770f66100569a60b10e8c319c | |
| parent | c5941a2731516c365ec30db0b0723c4edbb3f9c7 (diff) | |
Match the C binding's target arch detection with the root crate's
| -rw-r--r-- | c/blake3_c_rust_bindings/build.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/c/blake3_c_rust_bindings/build.rs b/c/blake3_c_rust_bindings/build.rs index d5dc47a..98f8396 100644 --- a/c/blake3_c_rust_bindings/build.rs +++ b/c/blake3_c_rust_bindings/build.rs @@ -22,6 +22,10 @@ fn is_armv7() -> bool { target_components()[0] == "armv7" } +fn is_aarch64() -> bool { + target_components()[0] == "aarch64" +} + // Windows targets may be using the MSVC toolchain or the GNU toolchain. The // right compiler flags to use depend on the toolchain. (And we don't want to // use flag_if_supported, because we don't want features to be silently @@ -148,10 +152,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { avx512_build.compile("blake3_avx512"); } - // We only build NEON code here if 1) it's requested and 2) the root crate - // is not already building it. The only time this will really happen is if - // you build this crate by hand with the "neon" feature for some reason. - if defined("CARGO_FEATURE_NEON") { + // We only build NEON code here if + // 1) it's requested + // and 2) the root crate is not already building it. + // The only time this will really happen is if you build this + // crate by hand with the "neon" feature for some reason. + // + // In addition, 3) if the target is aarch64, NEON is on by default. + if defined("CARGO_FEATURE_NEON") || is_aarch64() { let mut neon_build = new_build(); neon_build.file(c_dir_path("blake3_neon.c")); // ARMv7 platforms that support NEON generally need the following |
