From b3e09b5250753351d05fde20ec40042eaeaf9ae2 Mon Sep 17 00:00:00 2001 From: King's Way Date: Sun, 22 May 2022 17:08:41 +0800 Subject: [PATCH] 1. Fix cross build bug for aarch64 with simd-accel 2. Set -march=armv8-a as default value for aarch64 3. Enable aarch64 + simd-accel for Android build --- build.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 1eac72b..5d7aa6b 100644 --- a/build.rs +++ b/build.rs @@ -155,7 +155,7 @@ fn write_tables() { feature = "simd-accel", any(target_arch = "x86_64", target_arch = "aarch64"), not(target_env = "msvc"), - not(any(target_os = "android", target_os = "ios")) + not(any(target_os = "ios")) ))] fn compile_simd_c() { let mut build = cc::Build::new(); @@ -169,8 +169,11 @@ fn compile_simd_c() { Err(_error) => { // On x86-64 enabling Haswell architecture unlocks useful instructions and improves performance // dramatically while allowing it to run ony modern CPU. - #[cfg(target_arch = "x86_64")] - build.flag(&"-march=haswell"); + match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str(){ + "x86_64" => { build.flag(&"-march=haswell"); }, + "aarch64" => { build.flag(&"-march=armv8-a"); }, + _ => () + } } } @@ -184,7 +187,7 @@ fn compile_simd_c() { feature = "simd-accel", any(target_arch = "x86_64", target_arch = "aarch64"), not(target_env = "msvc"), - not(any(target_os = "android", target_os = "ios")) + not(any(target_os = "ios")) )))] fn compile_simd_c() {}