Skip to content

Commit

Permalink
1. Fix cross build bug for aarch64 with simd-accel
Browse files Browse the repository at this point in the history
2. Set -march=armv8-a as default value for aarch64
3. Enable aarch64 + simd-accel for Android build
  • Loading branch information
kings-way committed May 22, 2022
1 parent d93f465 commit b3e09b5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"); },
_ => ()
}
}
}

Expand All @@ -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() {}

Expand Down

0 comments on commit b3e09b5

Please sign in to comment.