about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-01-18 14:48:50 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2021-01-21 19:33:29 +0100
commit173ec34e3db3bbbbe0117e2f831053a183d99a40 (patch)
treecdce0c47cb05c2900a7537bbb4d1e75c5945ce93
parenta19ef67f146df8da634cbab1e5ff5f3c2f3176d1 (diff)
downloadrust-173ec34e3db3bbbbe0117e2f831053a183d99a40.tar.gz
rust-173ec34e3db3bbbbe0117e2f831053a183d99a40.zip
Add a feature flag to switch between oldbe and newbe
-rw-r--r--Cargo.toml3
-rwxr-xr-xbuild.sh10
-rw-r--r--src/lib.rs7
3 files changed, 15 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8e1933bb14e..eb9d4e09ebc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ crate-type = ["dylib"]
 
 [dependencies]
 # These have to be in sync with each other
-cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
+cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind", "x86", "x64"] }
 cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
 cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
 cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
@@ -37,6 +37,7 @@ libloading = { version = "0.6.0", optional = true }
 default = ["jit", "inline_asm"]
 jit = ["cranelift-jit", "libloading"]
 inline_asm = []
+newbe = []
 
 [profile.dev]
 # By compiling dependencies with optimizations, performing tests gets much faster.
diff --git a/build.sh b/build.sh
index 48fb5819a19..a00c01a179c 100755
--- a/build.sh
+++ b/build.sh
@@ -5,6 +5,7 @@ set -e
 export CHANNEL="release"
 build_sysroot=1
 target_dir='build'
+newbe=''
 while [[ $# != 0 ]]; do
     case $1 in
         "--debug")
@@ -17,9 +18,12 @@ while [[ $# != 0 ]]; do
             target_dir=$2
             shift
             ;;
+        "--newbe")
+            newbe='--features newbe'
+            ;;
         *)
             echo "Unknown flag '$1'"
-            echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR]"
+            echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR] [--newbe]"
             ;;
     esac
     shift
@@ -39,9 +43,9 @@ else
    exit 1
 fi
 if [[ "$CHANNEL" == "release" ]]; then
-    cargo build --release
+    cargo build $newbe --release
 else
-    cargo build
+    cargo build $newbe
 fi
 
 rm -rf "$target_dir"
diff --git a/src/lib.rs b/src/lib.rs
index 4b6431e42b5..2152d2ebdef 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -339,7 +339,12 @@ fn build_isa(sess: &Session) -> Box<dyn isa::TargetIsa + 'static> {
 
     let flags = settings::Flags::new(flags_builder);
 
-    let mut isa_builder = cranelift_codegen::isa::lookup(target_triple).unwrap();
+    let variant = if cfg!(feature = "newbe") {
+        cranelift_codegen::isa::BackendVariant::MachInst
+    } else {
+        cranelift_codegen::isa::BackendVariant::Legacy
+    };
+    let mut isa_builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
     // Don't use "haswell", as it implies `has_lzcnt`.macOS CI is still at Ivy Bridge EP, so `lzcnt`
     // is interpreted as `bsr`.
     isa_builder.enable("nehalem").unwrap();