Browse Source
Enable AArch64 processor feature detection unconditionally (#4034)
std::arch::is_aarch64_feature_detected!() is now part of stable
Rust, so we can always use it.
Copyright (c) 2022, Arm Limited.
pull/4083/head
Anton Kirilov
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
42 additions and
17 deletions
-
.github/workflows/main.yml
-
cranelift/native/src/lib.rs
-
crates/fuzzing/src/generators.rs
-
crates/wasmtime/src/engine.rs
|
|
@ -62,7 +62,7 @@ jobs: |
|
|
|
submodules: true |
|
|
|
- uses: ./.github/actions/install-rust |
|
|
|
with: |
|
|
|
toolchain: nightly-2021-12-15 |
|
|
|
toolchain: nightly-2022-04-27 |
|
|
|
|
|
|
|
# Build C API documentation |
|
|
|
- run: sudo apt-get update -y && sudo apt-get install -y libclang1-9 libclang-cpp9 |
|
|
@ -178,7 +178,7 @@ jobs: |
|
|
|
# flags to rustc. |
|
|
|
- uses: ./.github/actions/install-rust |
|
|
|
with: |
|
|
|
toolchain: nightly-2021-12-15 |
|
|
|
toolchain: nightly-2022-04-27 |
|
|
|
- run: cargo install cargo-fuzz --vers "^0.11" |
|
|
|
# Install OCaml packages necessary for 'differential_spec' fuzz target. |
|
|
|
- run: sudo apt install -y ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev |
|
|
|
|
|
@ -105,8 +105,7 @@ pub fn builder_with_options(infer_native_flags: bool) -> Result<isa::Builder, &' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// `stdsimd` is necessary for std::is_aarch64_feature_detected!().
|
|
|
|
#[cfg(all(target_arch = "aarch64", feature = "stdsimd"))] |
|
|
|
#[cfg(target_arch = "aarch64")] |
|
|
|
{ |
|
|
|
use cranelift_codegen::settings::Configurable; |
|
|
|
|
|
|
@ -114,7 +113,7 @@ pub fn builder_with_options(infer_native_flags: bool) -> Result<isa::Builder, &' |
|
|
|
return Ok(isa_builder); |
|
|
|
} |
|
|
|
|
|
|
|
if std::is_aarch64_feature_detected!("lse") { |
|
|
|
if std::arch::is_aarch64_feature_detected!("lse") { |
|
|
|
isa_builder.enable("has_lse").unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -702,7 +702,7 @@ impl<'a> Arbitrary<'a> for CodegenSettings { |
|
|
|
// print a warning and return an error because this fuzz
|
|
|
|
// input must be discarded.
|
|
|
|
#[cfg(target_arch = $arch)] |
|
|
|
if enable && !std::$test!($std) { |
|
|
|
if enable && !std::arch::$test!($std) { |
|
|
|
log::warn!("want to enable clif `{}` but host doesn't support it", |
|
|
|
$clif); |
|
|
|
return Err(arbitrary::Error::EmptyChoose) |
|
|
@ -752,6 +752,11 @@ impl<'a> Arbitrary<'a> for CodegenSettings { |
|
|
|
std:"avx512vl" => clif:"has_avx512vl" ratio: 1 in 1000, |
|
|
|
std:"avx512vbmi" => clif:"has_avx512vbmi" ratio: 1 in 1000, |
|
|
|
}, |
|
|
|
"aarch64" => { |
|
|
|
test: is_aarch64_feature_detected, |
|
|
|
|
|
|
|
std: "lse" => clif: "has_lse", |
|
|
|
}, |
|
|
|
}; |
|
|
|
return Ok(CodegenSettings::Target { |
|
|
|
target: target_lexicon::Triple::host().to_string(), |
|
|
|
|
|
@ -388,9 +388,23 @@ impl Engine { |
|
|
|
)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let enabled; |
|
|
|
|
|
|
|
#[cfg(target_arch = "aarch64")] |
|
|
|
{ |
|
|
|
enabled = match flag { |
|
|
|
"has_lse" => Some(std::arch::is_aarch64_feature_detected!("lse")), |
|
|
|
// fall through to the very bottom to indicate that support is
|
|
|
|
// not enabled to test whether this feature is enabled on the
|
|
|
|
// host.
|
|
|
|
_ => None, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(target_arch = "x86_64")] |
|
|
|
{ |
|
|
|
let enabled = match flag { |
|
|
|
enabled = match flag { |
|
|
|
"has_sse3" => Some(std::is_x86_feature_detected!("sse3")), |
|
|
|
"has_ssse3" => Some(std::is_x86_feature_detected!("ssse3")), |
|
|
|
"has_sse41" => Some(std::is_x86_feature_detected!("sse4.1")), |
|
|
@ -412,18 +426,25 @@ impl Engine { |
|
|
|
// host.
|
|
|
|
_ => None, |
|
|
|
}; |
|
|
|
match enabled { |
|
|
|
Some(true) => return Ok(()), |
|
|
|
Some(false) => { |
|
|
|
return Err(format!( |
|
|
|
"compilation setting {:?} is enabled but not available on the host", |
|
|
|
flag |
|
|
|
)) |
|
|
|
} |
|
|
|
// fall through
|
|
|
|
None => {} |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(not(any(target_arch = "aarch64", target_arch = "x86_64")))] |
|
|
|
{ |
|
|
|
enabled = None; |
|
|
|
} |
|
|
|
|
|
|
|
match enabled { |
|
|
|
Some(true) => return Ok(()), |
|
|
|
Some(false) => { |
|
|
|
return Err(format!( |
|
|
|
"compilation setting {:?} is enabled, but not available on the host", |
|
|
|
flag |
|
|
|
)) |
|
|
|
} |
|
|
|
// fall through
|
|
|
|
None => {} |
|
|
|
} |
|
|
|
|
|
|
|
Err(format!( |
|
|
|
"cannot test if target-specific flag {:?} is available at runtime", |
|
|
|
flag |
|
|
|