Skip to content

Commit 500faf2

Browse files
authored
Merge pull request rust-lang#1127 from bjorn3/newbe
Support building with the new Cranelift backends
2 parents 9bf5cb4 + da4aa92 commit 500faf2

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [ubuntu-latest, macos-latest]
15+
env:
16+
- BACKEND: ""
17+
- BACKEND: --features newbe
1518

1619
steps:
1720
- uses: actions/checkout@v2
@@ -51,7 +54,7 @@ jobs:
5154
export COMPILE_RUNS=2
5255
export RUN_RUNS=2
5356
54-
./test.sh
57+
./test.sh $BACKEND
5558
5659
- name: Package prebuilt cg_clif
5760
run: tar cvfJ cg_clif.tar.xz build

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)