Skip to content

Commit 173ec34

Browse files
committed
Add a feature flag to switch between oldbe and newbe
1 parent a19ef67 commit 173ec34

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ crate-type = ["dylib"]
99

1010
[dependencies]
1111
# These have to be in sync with each other
12-
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
12+
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind", "x86", "x64"] }
1313
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
1414
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
1515
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
@@ -37,6 +37,7 @@ libloading = { version = "0.6.0", optional = true }
3737
default = ["jit", "inline_asm"]
3838
jit = ["cranelift-jit", "libloading"]
3939
inline_asm = []
40+
newbe = []
4041

4142
[profile.dev]
4243
# By compiling dependencies with optimizations, performing tests gets much faster.

build.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -e
55
export CHANNEL="release"
66
build_sysroot=1
77
target_dir='build'
8+
newbe=''
89
while [[ $# != 0 ]]; do
910
case $1 in
1011
"--debug")
@@ -17,9 +18,12 @@ while [[ $# != 0 ]]; do
1718
target_dir=$2
1819
shift
1920
;;
21+
"--newbe")
22+
newbe='--features newbe'
23+
;;
2024
*)
2125
echo "Unknown flag '$1'"
22-
echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR]"
26+
echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR] [--newbe]"
2327
;;
2428
esac
2529
shift
@@ -39,9 +43,9 @@ else
3943
exit 1
4044
fi
4145
if [[ "$CHANNEL" == "release" ]]; then
42-
cargo build --release
46+
cargo build $newbe --release
4347
else
44-
cargo build
48+
cargo build $newbe
4549
fi
4650

4751
rm -rf "$target_dir"

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ fn build_isa(sess: &Session) -> Box<dyn isa::TargetIsa + 'static> {
339339

340340
let flags = settings::Flags::new(flags_builder);
341341

342-
let mut isa_builder = cranelift_codegen::isa::lookup(target_triple).unwrap();
342+
let variant = if cfg!(feature = "newbe") {
343+
cranelift_codegen::isa::BackendVariant::MachInst
344+
} else {
345+
cranelift_codegen::isa::BackendVariant::Legacy
346+
};
347+
let mut isa_builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
343348
// Don't use "haswell", as it implies `has_lzcnt`.macOS CI is still at Ivy Bridge EP, so `lzcnt`
344349
// is interpreted as `bsr`.
345350
isa_builder.enable("nehalem").unwrap();

0 commit comments

Comments
 (0)