Skip to content

Commit

Permalink
Cranelift: Add a cargo feature to enable support for all native ISAs (#…
Browse files Browse the repository at this point in the history
…9237)

That is, all architectures other than Pulley.

Fixes #9229
  • Loading branch information
fitzgen authored Sep 12, 2024
1 parent 4128b5b commit aee78b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ default = ["disas", "cranelift-codegen/all-arch", "cranelift-codegen/trace-log",
disas = ["capstone"]
souper-harvest = ["cranelift-codegen/souper-harvest", "rayon"]
all-arch = ["cranelift-codegen/all-arch"]
all-native-arch = ["cranelift-codegen/all-native-arch"]
8 changes: 7 additions & 1 deletion cranelift/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ host-arch = []

# Option to enable all architectures.
all-arch = [
"all-native-arch",
"pulley",
]

# Option to enable all architectures that correspond to an actual native target
# (that is, exclude Pulley).
all-native-arch = [
"x86",
"arm64",
"s390x",
"riscv64",
"pulley",
]

# For dependent crates that want to serialize some parts of cranelift
Expand Down
3 changes: 2 additions & 1 deletion cranelift/codegen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn main() {
let target_triple = env::var("TARGET").expect("The TARGET environment variable must be set");

let all_arch = env::var("CARGO_FEATURE_ALL_ARCH").is_ok();
let all_native_arch = env::var("CARGO_FEATURE_ALL_NATIVE_ARCH").is_ok();

let mut isas = meta::isa::Isa::all()
.iter()
Expand All @@ -47,7 +48,7 @@ fn main() {
.collect::<Vec<_>>();

// Don't require host isa if under 'all-arch' feature.
let host_isa = env::var("CARGO_FEATURE_HOST_ARCH").is_ok() && !all_arch;
let host_isa = env::var("CARGO_FEATURE_HOST_ARCH").is_ok() && !all_native_arch;

if isas.is_empty() || host_isa {
// Try to match native target.
Expand Down

0 comments on commit aee78b1

Please # to comment.