Skip to content

Commit eda0ae2

Browse files
committed
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
1 parent d93f465 commit eda0ae2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

build.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn write_tables() {
155155
feature = "simd-accel",
156156
any(target_arch = "x86_64", target_arch = "aarch64"),
157157
not(target_env = "msvc"),
158-
not(any(target_os = "android", target_os = "ios"))
158+
not(any(target_os = "ios"))
159159
))]
160160
fn compile_simd_c() {
161161
let mut build = cc::Build::new();
@@ -169,8 +169,11 @@ fn compile_simd_c() {
169169
Err(_error) => {
170170
// On x86-64 enabling Haswell architecture unlocks useful instructions and improves performance
171171
// dramatically while allowing it to run ony modern CPU.
172-
#[cfg(target_arch = "x86_64")]
173-
build.flag(&"-march=haswell");
172+
match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str(){
173+
"x86_64" => drop(build.flag(&"-march=haswell")),
174+
"aarch64" => drop(build.flag(&"-march=armv8-a")),
175+
_ => ()
176+
}
174177
}
175178
}
176179

@@ -184,7 +187,7 @@ fn compile_simd_c() {
184187
feature = "simd-accel",
185188
any(target_arch = "x86_64", target_arch = "aarch64"),
186189
not(target_env = "msvc"),
187-
not(any(target_os = "android", target_os = "ios"))
190+
not(any(target_os = "ios"))
188191
)))]
189192
fn compile_simd_c() {}
190193

0 commit comments

Comments
 (0)