Skip to content

Commit

Permalink
don't default to NEON intrinsics in build.rs for big-endian targets
Browse files Browse the repository at this point in the history
  • Loading branch information
oconnor663 committed Sep 20, 2023
1 parent 8bfe93f commit 4e25f2e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ fn is_armv7() -> bool {
target_components()[0] == "armv7"
}

fn endianness() -> String {
let endianness = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap();
assert!(endianness == "little" || endianness == "big");
endianness
}

fn is_little_endian() -> bool {
endianness() == "little"
}

fn is_big_endian() -> bool {
endianness() == "big"
}

// 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
Expand Down Expand Up @@ -253,7 +267,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}

if (is_arm() && is_neon()) || (!is_no_neon() && !is_pure() && is_aarch64()) {
if is_neon() && is_big_endian() {
panic!("The NEON implementation doesn't support big-endian ARM.")
}

if (is_arm() && is_neon())
|| (!is_no_neon() && !is_pure() && is_aarch64() && is_little_endian())
{
println!("cargo:rustc-cfg=blake3_neon");
build_neon_c_intrinsics();
}
Expand Down

0 comments on commit 4e25f2e

Please sign in to comment.