diff options
| author | Jack O'Connor <[email protected]> | 2019-12-09 21:50:05 -0500 |
|---|---|---|
| committer | Jack O'Connor <[email protected]> | 2019-12-09 21:52:24 -0500 |
| commit | 8c4cd710c3a37ca8c350a73f7aa22f62e7ca6572 (patch) | |
| tree | 0b69c9074b74ac3fe455200328d9958b83d7756d /build.rs | |
| parent | 61b34f35b43e09049b5177d7aea97fb27351a984 (diff) | |
set ARMv7 NEON compiler flags automatically
Diffstat (limited to 'build.rs')
| -rw-r--r-- | build.rs | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -11,6 +11,13 @@ fn is_windows() -> bool { target_os == "windows" } +fn is_armv7() -> bool { + let target = env::var("TARGET").unwrap(); + let target_components: Vec<&str> = target.split("-").collect(); + let target_arch = target_components[0]; + target_arch == "armv7" +} + fn new_build() -> cc::Build { let mut build = cc::Build::new(); if !is_windows() { @@ -41,8 +48,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { build.file("src/c/blake3_portable.c"); // ARMv7 platforms that support NEON generally need the following // flags. AArch64 supports NEON by default and does not support -mpfu. - // build.flag("-mfpu=neon-vfpv4"); - // build.flag("-mfloat-abi=hard"); + if is_armv7() { + build.flag("-mfpu=neon-vfpv4"); + build.flag("-mfloat-abi=hard"); + } build.compile("blake3_neon"); } |
