From 71aaf2d3f828281651daa77f6a39f9d0cf31a27f Mon Sep 17 00:00:00 2001
From: Syrus
Date: Thu, 11 Apr 2019 11:40:23 -0700
Subject: [PATCH 1/8] Updated cargo
---
Cargo.lock | 1 +
1 file changed, 1 insertion(+)
diff --git a/Cargo.lock b/Cargo.lock
index 5f111b7b8f5..1e81b086e0b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2274,6 +2274,7 @@ dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.2.1",
"wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
From e986553d8be8cd3be94d05ff78120bd80a6a49d1 Mon Sep 17 00:00:00 2001
From: Syrus
Date: Thu, 11 Apr 2019 11:44:07 -0700
Subject: [PATCH 2/8] Improved CircleCI config, use rust nightly for release
---
.circleci/config.yml | 53 ++++++++++++++++++++++++++++----------------
Makefile | 7 +++---
2 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 3490bf6b539..37a5b52c18b 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -21,7 +21,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v6-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-lint-{{ arch }}
- <<: *run_install_dependencies
- run:
name: Install lint deps
@@ -40,7 +41,7 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- key: v6-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v7-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
test:
docker:
@@ -50,14 +51,17 @@ jobs:
- checkout
- restore_cache:
keys:
- - v6-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-test-cargo-cache-linux-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-test-cargo-cache-linux-stable-{{ arch }}
- <<: *run_install_dependencies
- run:
name: Tests
command: make test
- run:
name: Emscripten Tests
- command: make test-emscripten
+ command: |
+ make test-emscripten-clif
+ make test-emscripten-llvm
- run:
name: Integration Tests
command: make integration-tests
@@ -67,7 +71,7 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- key: v6-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v7-test-cargo-cache-linux-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
test-macos:
macos:
@@ -76,7 +80,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v6-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-darwin-stable-{{ arch }}
- run:
name: Install crate dependencies
command: |
@@ -112,7 +117,8 @@ jobs:
# We increase the ulimit for fixing cargo unclosed files in mac
ulimit -n 8000
sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680
- make test-emscripten
+ make test-emscripten-clif
+ make test-emscripten-llvm
- run:
name: Integration Tests
command: |
@@ -129,7 +135,7 @@ jobs:
- target/release/.fingerprint
- target/release/build
- target/release/deps
- key: v6-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v7-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
test-and-build:
docker:
@@ -138,13 +144,16 @@ jobs:
- checkout
- restore_cache:
keys:
- - v6-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-linux-nightly-{{ arch }}
- run:
name: Install dependencies
command: |
sudo apt-get install -y cmake
curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
+ # Use rust nightly (for dynasm, for now)
+ - run: rustup default nightly-2019-04-11
- run:
name: Tests
command: |
@@ -154,7 +163,8 @@ jobs:
name: Emscripten Tests
command: |
export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/"
- make test-emscripten
+ make test-emscripten-clif
+ make test-emscripten-llvm
- run:
name: Release Build
command: |
@@ -183,7 +193,7 @@ jobs:
- target/release/.fingerprint
- target/release/build
- target/release/deps
- key: v6-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
test-and-build-macos:
macos:
@@ -192,7 +202,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v6-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-darwin-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-darwin-nightly-{{ arch }}
- run:
name: Install crate dependencies
command: |
@@ -209,6 +220,8 @@ jobs:
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
cargo --version
+ # Use rust nightly (for dynasm, for now)
+ - run: rustup default nightly-2019-04-11
- run:
name: Tests
command: |
@@ -228,7 +241,8 @@ jobs:
# We increase the ulimit for fixing cargo unclosed files in mac
ulimit -n 8000
sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680
- make test-emscripten
+ make test-emscripten-clif
+ make test-emscripten-dynasm
- run:
name: Release Build
command: |
@@ -253,7 +267,7 @@ jobs:
- target/release/.fingerprint
- target/release/build
- target/release/deps
- key: v6-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v7-cargo-cache-darwin-nightly-{ arch }}-{{ checksum "Cargo.lock" }}
test-rust-nightly:
docker:
@@ -262,27 +276,28 @@ jobs:
- checkout
- restore_cache:
keys:
- - v6-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
+ - v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v7-cargo-cache-linux-nightly-{{ arch }}
- run:
name: Install dependencies
command: |
sudo apt-get install -y cmake
curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
- - run: rustup default nightly-2019-02-27
+ - run: rustup default nightly-2019-04-11
- run: |
export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/"
make test
- make test-nightly
+ make test-dynasm
make test-emscripten-clif
- make test-emscripten-nightly
+ make test-emscripten-dynasm
- save_cache:
paths:
- /usr/local/cargo/registry
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- key: v6-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
+ key: v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
publish-github-release:
docker:
diff --git a/Makefile b/Makefile
index 383d4ccf4ab..947032873ce 100644
--- a/Makefile
+++ b/Makefile
@@ -41,17 +41,16 @@ test:
cargo build -p wasmer-runtime-c-api
cargo test -p wasmer-runtime-c-api -- --nocapture
-test-nightly:
+test-dynasm:
cargo test --manifest-path lib/spectests/Cargo.toml --features dynasm
-test-emscripten:
- cargo test --manifest-path lib/emscripten/Cargo.toml --features clif -- --test-threads=1 $(runargs)
+test-emscripten-llvm:
cargo test --manifest-path lib/emscripten/Cargo.toml --features llvm -- --test-threads=1 $(runargs)
test-emscripten-clif:
cargo test --manifest-path lib/emscripten/Cargo.toml --features clif -- --test-threads=1 $(runargs)
-test-emscripten-nightly:
+test-emscripten-dynasm:
cargo test --manifest-path lib/emscripten/Cargo.toml --features dynasm -- --test-threads=1 $(runargs)
dynasm-debug-release:
From 1f06e90729c7103beed7d247c4410bd0a3167d60 Mon Sep 17 00:00:00 2001
From: Syrus
Date: Thu, 11 Apr 2019 11:51:28 -0700
Subject: [PATCH 3/8] Use better key for caching
---
.circleci/config.yml | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 37a5b52c18b..c588234dc03 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -21,8 +21,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v7-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
- - v7-lint-{{ arch }}
+ - v8-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v8-lint-{{ arch }}
- <<: *run_install_dependencies
- run:
name: Install lint deps
@@ -41,7 +41,7 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- key: v7-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v8-lint-{{ arch }}-{{ checksum "Cargo.lock" }}
test:
docker:
@@ -51,8 +51,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v7-test-cargo-cache-linux-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
- - v7-test-cargo-cache-linux-stable-{{ arch }}
+ - v8-test-cargo-cache-linux-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v8-test-cargo-cache-linux-stable-{{ arch }}
- <<: *run_install_dependencies
- run:
name: Tests
@@ -71,7 +71,7 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- key: v7-test-cargo-cache-linux-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v8-test-cargo-cache-linux-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
test-macos:
macos:
@@ -80,8 +80,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v7-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
- - v7-cargo-cache-darwin-stable-{{ arch }}
+ - v8-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v8-cargo-cache-darwin-stable-{{ arch }}
- run:
name: Install crate dependencies
command: |
@@ -135,7 +135,7 @@ jobs:
- target/release/.fingerprint
- target/release/build
- target/release/deps
- key: v7-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v8-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }}
test-and-build:
docker:
@@ -144,8 +144,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
- - v7-cargo-cache-linux-nightly-{{ arch }}
+ - v8-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v8-cargo-cache-linux-nightly-{{ arch }}
- run:
name: Install dependencies
command: |
@@ -193,7 +193,7 @@ jobs:
- target/release/.fingerprint
- target/release/build
- target/release/deps
- key: v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v8-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
test-and-build-macos:
macos:
@@ -202,8 +202,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v7-cargo-cache-darwin-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
- - v7-cargo-cache-darwin-nightly-{{ arch }}
+ - v8-cargo-cache-darwin-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v8-cargo-cache-darwin-nightly-{{ arch }}
- run:
name: Install crate dependencies
command: |
@@ -267,7 +267,7 @@ jobs:
- target/release/.fingerprint
- target/release/build
- target/release/deps
- key: v7-cargo-cache-darwin-nightly-{ arch }}-{{ checksum "Cargo.lock" }}
+ key: v8-cargo-cache-darwin-nightly-{ arch }}-{{ checksum "Cargo.lock" }}
test-rust-nightly:
docker:
@@ -276,8 +276,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
- - v7-cargo-cache-linux-nightly-{{ arch }}
+ - v8-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
+ - v8-cargo-cache-linux-nightly-{{ arch }}
- run:
name: Install dependencies
command: |
@@ -297,7 +297,7 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- key: v7-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
+ key: v8-cargo-cache-linux-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
publish-github-release:
docker:
From d67bfdb2c526edab7c785f74c14dcdbf2d4b9db6 Mon Sep 17 00:00:00 2001
From: Syrus
Date: Thu, 11 Apr 2019 12:44:03 -0700
Subject: [PATCH 4/8] Renamed dynasm backend to singlepass
---
.circleci/config.yml | 10 ++---
Cargo.lock | 40 +++++++++----------
Cargo.toml | 6 +--
Makefile | 22 +++++-----
lib/README.md | 2 +-
lib/emscripten/Cargo.toml | 4 +-
lib/emscripten/src/utils.rs | 6 +--
lib/emscripten/tests/emtests/_common.rs | 6 +--
lib/runtime-core/src/backend.rs | 2 +-
lib/runtime/Cargo.toml | 4 +-
lib/runtime/src/lib.rs | 6 +--
.../Cargo.toml | 4 +-
.../README.md | 12 +++---
.../src/codegen.rs | 0
.../src/codegen_x64.rs | 0
.../src/emitter_x64.rs | 0
.../src/lib.rs | 6 +--
.../src/machine.rs | 0
.../src/parse.rs | 0
.../src/protect_unix.rs | 0
lib/spectests/Cargo.toml | 4 +-
lib/spectests/build/spectests.rs | 6 +--
lib/spectests/examples/simple/main.rs | 6 +--
src/bin/wasmer.rs | 30 ++++++++++++--
24 files changed, 100 insertions(+), 76 deletions(-)
rename lib/{dynasm-backend => singlepass-backend}/Cargo.toml (81%)
rename lib/{dynasm-backend => singlepass-backend}/README.md (68%)
rename lib/{dynasm-backend => singlepass-backend}/src/codegen.rs (100%)
rename lib/{dynasm-backend => singlepass-backend}/src/codegen_x64.rs (100%)
rename lib/{dynasm-backend => singlepass-backend}/src/emitter_x64.rs (100%)
rename lib/{dynasm-backend => singlepass-backend}/src/lib.rs (90%)
rename lib/{dynasm-backend => singlepass-backend}/src/machine.rs (100%)
rename lib/{dynasm-backend => singlepass-backend}/src/parse.rs (100%)
rename lib/{dynasm-backend => singlepass-backend}/src/protect_unix.rs (100%)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index c588234dc03..67309e90320 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -152,7 +152,7 @@ jobs:
sudo apt-get install -y cmake
curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
- # Use rust nightly (for dynasm, for now)
+ # Use rust nightly (for singlepass, for now)
- run: rustup default nightly-2019-04-11
- run:
name: Tests
@@ -220,7 +220,7 @@ jobs:
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
cargo --version
- # Use rust nightly (for dynasm, for now)
+ # Use rust nightly (for singlepass, for now)
- run: rustup default nightly-2019-04-11
- run:
name: Tests
@@ -242,7 +242,7 @@ jobs:
ulimit -n 8000
sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680
make test-emscripten-clif
- make test-emscripten-dynasm
+ make test-emscripten-singlepass
- run:
name: Release Build
command: |
@@ -288,9 +288,9 @@ jobs:
- run: |
export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/"
make test
- make test-dynasm
+ make test-singlepass
make test-emscripten-clif
- make test-emscripten-dynasm
+ make test-emscripten-singlepass
- save_cache:
paths:
- /usr/local/cargo/registry
diff --git a/Cargo.lock b/Cargo.lock
index 1e81b086e0b..e42dd7265b7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2230,12 +2230,12 @@ dependencies = [
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
- "wasmer-dynasm-backend 0.1.0",
"wasmer-emscripten 0.2.1",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime 0.2.1",
"wasmer-runtime-abi 0.2.1",
"wasmer-runtime-core 0.2.1",
+ "wasmer-singlepass-backend 0.1.0",
"wasmer-wasi 0.2.1",
]
@@ -2263,22 +2263,6 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
-[[package]]
-name = "wasmer-dynasm-backend"
-version = "0.1.0"
-dependencies = [
- "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "wasmer-runtime-core 0.2.1",
- "wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "wasmer-emscripten"
version = "0.2.1"
@@ -2291,9 +2275,9 @@ dependencies = [
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
- "wasmer-dynasm-backend 0.1.0",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime-core 0.2.1",
+ "wasmer-singlepass-backend 0.1.0",
]
[[package]]
@@ -2327,9 +2311,9 @@ dependencies = [
"tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
- "wasmer-dynasm-backend 0.1.0",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime-core 0.2.1",
+ "wasmer-singlepass-backend 0.1.0",
]
[[package]]
@@ -2381,15 +2365,31 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "wasmer-singlepass-backend"
+version = "0.1.0"
+dependencies = [
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "wasmer-runtime-core 0.2.1",
+ "wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "wasmer-spectests"
version = "0.2.0"
dependencies = [
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
- "wasmer-dynasm-backend 0.1.0",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime-core 0.2.1",
+ "wasmer-singlepass-backend 0.1.0",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 244581f8d97..5624b659a78 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,7 @@ structopt = "0.2.11"
wabt = "0.7.2"
hashbrown = "0.1.8"
wasmer-clif-backend = { path = "lib/clif-backend" }
-wasmer-dynasm-backend = { path = "lib/dynasm-backend", optional = true }
+wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true }
wasmer-runtime = { path = "lib/runtime" }
wasmer-runtime-abi = { path = "lib/runtime-abi", optional = true }
wasmer-runtime-core = { path = "lib/runtime-core" }
@@ -33,7 +33,7 @@ wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
wasmer-wasi = { path = "lib/wasi", optional = true }
[workspace]
-members = ["lib/clif-backend", "lib/dynasm-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"]
+members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"]
[build-dependencies]
wabt = "0.7.2"
@@ -45,6 +45,6 @@ debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
llvm = ["wasmer-llvm-backend", "wasmer-runtime/llvm"]
-dynasm = ["wasmer-dynasm-backend", "wasmer-runtime/dynasm"]
+singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/singlepass"]
wasi = ["wasmer-wasi"]
vfs = ["wasmer-runtime-abi"]
diff --git a/Makefile b/Makefile
index 947032873ce..2b87dd7e7de 100644
--- a/Makefile
+++ b/Makefile
@@ -34,15 +34,15 @@ precommit: lint test
test:
# We use one thread so the emscripten stdouts doesn't collide
- cargo test --all --exclude wasmer-runtime-c-api --exclude wasmer-emscripten --exclude wasmer-spectests --exclude wasmer-dynasm-backend -- $(runargs)
+ cargo test --all --exclude wasmer-runtime-c-api --exclude wasmer-emscripten --exclude wasmer-spectests --exclude wasmer-singlepass-backend -- $(runargs)
# cargo test --all --exclude wasmer-emscripten -- --test-threads=1 $(runargs)
cargo test --manifest-path lib/spectests/Cargo.toml --features clif
cargo test --manifest-path lib/spectests/Cargo.toml --features llvm
cargo build -p wasmer-runtime-c-api
cargo test -p wasmer-runtime-c-api -- --nocapture
-test-dynasm:
- cargo test --manifest-path lib/spectests/Cargo.toml --features dynasm
+test-singlepass:
+ cargo test --manifest-path lib/spectests/Cargo.toml --features singlepass
test-emscripten-llvm:
cargo test --manifest-path lib/emscripten/Cargo.toml --features llvm -- --test-threads=1 $(runargs)
@@ -50,17 +50,17 @@ test-emscripten-llvm:
test-emscripten-clif:
cargo test --manifest-path lib/emscripten/Cargo.toml --features clif -- --test-threads=1 $(runargs)
-test-emscripten-dynasm:
- cargo test --manifest-path lib/emscripten/Cargo.toml --features dynasm -- --test-threads=1 $(runargs)
+test-emscripten-singlepass:
+ cargo test --manifest-path lib/emscripten/Cargo.toml --features singlepass -- --test-threads=1 $(runargs)
-dynasm-debug-release:
- cargo +nightly build --features "dynasm debug" --release
+singlepass-debug-release:
+ cargo +nightly build --features "singlepass debug" --release
-dynasm-release:
- cargo +nightly build --features "dynasm" --release
+singlepass-release:
+ cargo +nightly build --features "singlepass" --release
-dynasm-build:
- cargo +nightly build --features "dynasm debug"
+singlepass-build:
+ cargo +nightly build --features "singlepass debug"
release:
# If you are in OS-X, you will need mingw-w64 for cross compiling to windows
diff --git a/lib/README.md b/lib/README.md
index b8a99dd6d68..83a3355886c 100644
--- a/lib/README.md
+++ b/lib/README.md
@@ -34,6 +34,6 @@ to tune the codegen properties (compile speed, performance, etc) to best fit the
Currently, we support multiple backends for compiling WebAssembly to machine code:
-- [dynasm-backend](./dynasm-backend/): Dynasm backend - super fast compilation, slower runtime speed
+- [singlepass-backend](./singlepass-backend/): Single pass backend - super fast compilation, slower runtime speed
- [clif-backend](./clif-backend/): Cranelift backend - slower compilation, normal runtime speed
- [llvm-backend](./llvm-backend/): LLVM backend - slow compilation, native runtime speed
diff --git a/lib/emscripten/Cargo.toml b/lib/emscripten/Cargo.toml
index 5c59db3506d..8b19340b0a7 100644
--- a/lib/emscripten/Cargo.toml
+++ b/lib/emscripten/Cargo.toml
@@ -15,7 +15,7 @@ libc = "0.2.49"
byteorder = "1"
time = "0.1.41"
wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" }
-wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0", optional = true }
+wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.1.0", optional = true }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true }
[target.'cfg(windows)'.dependencies]
@@ -30,5 +30,5 @@ glob = "0.2.11"
[features]
clif = []
llvm = ["wasmer-llvm-backend"]
-dynasm = ["wasmer-dynasm-backend"]
+singlepass = ["wasmer-singlepass-backend"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
diff --git a/lib/emscripten/src/utils.rs b/lib/emscripten/src/utils.rs
index 725f0ba9408..e1cf13ef516 100644
--- a/lib/emscripten/src/utils.rs
+++ b/lib/emscripten/src/utils.rs
@@ -186,13 +186,13 @@ mod tests {
LLVMCompiler::new()
}
- #[cfg(feature = "dynasm")]
+ #[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
- use wasmer_dynasm_backend::SinglePassCompiler;
+ use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
- #[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
+ #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
diff --git a/lib/emscripten/tests/emtests/_common.rs b/lib/emscripten/tests/emtests/_common.rs
index ca5f6028265..18664e4eac7 100644
--- a/lib/emscripten/tests/emtests/_common.rs
+++ b/lib/emscripten/tests/emtests/_common.rs
@@ -20,13 +20,13 @@ macro_rules! assert_emscripten_output {
LLVMCompiler::new()
}
- #[cfg(feature = "dynasm")]
+ #[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
- use wasmer_dynasm_backend::SinglePassCompiler;
+ use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
- #[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
+ #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs
index 1e528651d92..1044a7ee56a 100644
--- a/lib/runtime-core/src/backend.rs
+++ b/lib/runtime-core/src/backend.rs
@@ -25,7 +25,7 @@ pub use crate::sig_registry::SigRegistry;
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
pub enum Backend {
Cranelift,
- Dynasm,
+ Singlepass,
LLVM,
}
diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml
index c137922f063..f34798bf550 100644
--- a/lib/runtime/Cargo.toml
+++ b/lib/runtime/Cargo.toml
@@ -9,7 +9,7 @@ edition = "2018"
readme = "README.md"
[dependencies]
-wasmer-dynasm-backend = { path = "../dynasm-backend", optional = true }
+wasmer-singlepass-backend = { path = "../singlepass-backend", optional = true }
lazy_static = "1.2.0"
memmap = "0.7.0"
@@ -37,7 +37,7 @@ default-compiler = ["wasmer-clif-backend"]
cache = ["default-compiler"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
llvm = ["wasmer-llvm-backend"]
-dynasm = ["wasmer-dynasm-backend"]
+singlepass = ["wasmer-singlepass-backend"]
[[bench]]
name = "nginx"
diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs
index a45faddc1c7..f9a9ce81924 100644
--- a/lib/runtime/src/lib.rs
+++ b/lib/runtime/src/lib.rs
@@ -171,10 +171,10 @@ pub fn default_compiler() -> &'static dyn Compiler {
#[cfg(feature = "llvm")]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
- #[cfg(feature = "dynasm")]
- use wasmer_dynasm_backend::SinglePassCompiler as DefaultCompiler;
+ #[cfg(feature = "singlepass")]
+ use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
- #[cfg(not(any(feature = "llvm", feature = "dynasm")))]
+ #[cfg(not(any(feature = "llvm", feature = "singlepass")))]
use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler;
lazy_static! {
diff --git a/lib/dynasm-backend/Cargo.toml b/lib/singlepass-backend/Cargo.toml
similarity index 81%
rename from lib/dynasm-backend/Cargo.toml
rename to lib/singlepass-backend/Cargo.toml
index 3f6ef866720..977a3eac6b0 100644
--- a/lib/dynasm-backend/Cargo.toml
+++ b/lib/singlepass-backend/Cargo.toml
@@ -1,8 +1,8 @@
[package]
-name = "wasmer-dynasm-backend"
+name = "wasmer-singlepass-backend"
version = "0.1.0"
repository = "https://github.com/wasmerio/wasmer"
-description = "Wasmer runtime Dynasm compiler backend"
+description = "Wasmer runtime single pass compiler backend"
license = "MIT"
authors = ["The Wasmer Engineering Team "]
edition = "2018"
diff --git a/lib/dynasm-backend/README.md b/lib/singlepass-backend/README.md
similarity index 68%
rename from lib/dynasm-backend/README.md
rename to lib/singlepass-backend/README.md
index a525cbfac99..3d8c63615f5 100644
--- a/lib/dynasm-backend/README.md
+++ b/lib/singlepass-backend/README.md
@@ -14,18 +14,18 @@
-
-
+
+
-
-
+
+
-# Wasmer dynasm backend
+# Wasmer singlepass backend
Wasmer is a standalone JIT WebAssembly runtime, aiming to be fully
compatible with Emscripten, Rust and Go. [Learn
more](https://github.com/wasmerio/wasmer).
-This crate represents the dynasm backend.
+This crate represents the singlepass backend.
diff --git a/lib/dynasm-backend/src/codegen.rs b/lib/singlepass-backend/src/codegen.rs
similarity index 100%
rename from lib/dynasm-backend/src/codegen.rs
rename to lib/singlepass-backend/src/codegen.rs
diff --git a/lib/dynasm-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs
similarity index 100%
rename from lib/dynasm-backend/src/codegen_x64.rs
rename to lib/singlepass-backend/src/codegen_x64.rs
diff --git a/lib/dynasm-backend/src/emitter_x64.rs b/lib/singlepass-backend/src/emitter_x64.rs
similarity index 100%
rename from lib/dynasm-backend/src/emitter_x64.rs
rename to lib/singlepass-backend/src/emitter_x64.rs
diff --git a/lib/dynasm-backend/src/lib.rs b/lib/singlepass-backend/src/lib.rs
similarity index 90%
rename from lib/dynasm-backend/src/lib.rs
rename to lib/singlepass-backend/src/lib.rs
index 0092b730268..cdb275cd3c0 100644
--- a/lib/dynasm-backend/src/lib.rs
+++ b/lib/singlepass-backend/src/lib.rs
@@ -41,7 +41,7 @@ impl CacheGen for Placeholder {
_module: &ModuleInner,
) -> Result<(Box, Box<[u8]>, Memory), CacheError> {
Err(CacheError::Unknown(
- "the dynasm backend doesn't support caching yet".to_string(),
+ "the singlepass backend doesn't support caching yet".to_string(),
))
}
}
@@ -61,7 +61,7 @@ impl Compiler for SinglePassCompiler {
_: Token,
) -> CompileResult {
let mut mcg = codegen_x64::X64ModuleCodeGenerator::new();
- let info = parse::read_module(wasm, Backend::Dynasm, &mut mcg, &compiler_config)?;
+ let info = parse::read_module(wasm, Backend::Singlepass, &mut mcg, &compiler_config)?;
let (ec, resolver) = mcg.finalize(&info)?;
Ok(ModuleInner {
cache_gen: Box::new(Placeholder),
@@ -73,7 +73,7 @@ impl Compiler for SinglePassCompiler {
unsafe fn from_cache(&self, _artifact: Artifact, _: Token) -> Result {
Err(CacheError::Unknown(
- "the dynasm backend doesn't support caching yet".to_string(),
+ "the singlepass backend doesn't support caching yet".to_string(),
))
}
}
diff --git a/lib/dynasm-backend/src/machine.rs b/lib/singlepass-backend/src/machine.rs
similarity index 100%
rename from lib/dynasm-backend/src/machine.rs
rename to lib/singlepass-backend/src/machine.rs
diff --git a/lib/dynasm-backend/src/parse.rs b/lib/singlepass-backend/src/parse.rs
similarity index 100%
rename from lib/dynasm-backend/src/parse.rs
rename to lib/singlepass-backend/src/parse.rs
diff --git a/lib/dynasm-backend/src/protect_unix.rs b/lib/singlepass-backend/src/protect_unix.rs
similarity index 100%
rename from lib/dynasm-backend/src/protect_unix.rs
rename to lib/singlepass-backend/src/protect_unix.rs
diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml
index 8dd8f83f492..d19fdab6d47 100644
--- a/lib/spectests/Cargo.toml
+++ b/lib/spectests/Cargo.toml
@@ -12,7 +12,7 @@ build = "build/mod.rs"
wasmer-runtime-core = { path = "../runtime-core", version = "0.2.0" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true }
-wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0", optional = true }
+wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.1.0", optional = true }
[build-dependencies]
wabt = "0.7.2"
@@ -25,4 +25,4 @@ default = ["fast-tests"]
fast-tests = []
clif = []
llvm = ["wasmer-llvm-backend"]
-dynasm = ["wasmer-dynasm-backend"]
\ No newline at end of file
+singlepass = ["wasmer-singlepass-backend"]
diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs
index a13faefd18a..10fb4567851 100644
--- a/lib/spectests/build/spectests.rs
+++ b/lib/spectests/build/spectests.rs
@@ -107,13 +107,13 @@ fn get_compiler() -> impl Compiler {
LLVMCompiler::new()
}
-#[cfg(feature = "dynasm")]
+#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
- use wasmer_dynasm_backend::SinglePassCompiler;
+ use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
-#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
+#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
diff --git a/lib/spectests/examples/simple/main.rs b/lib/spectests/examples/simple/main.rs
index c61cdb18fc7..357adb5f70d 100644
--- a/lib/spectests/examples/simple/main.rs
+++ b/lib/spectests/examples/simple/main.rs
@@ -22,13 +22,13 @@ fn get_compiler() -> impl Compiler {
LLVMCompiler::new()
}
-#[cfg(feature = "dynasm")]
+#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
- use wasmer_dynasm_backend::SinglePassCompiler;
+ use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
-#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
+#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs
index 34550355805..b6211a8011c 100644
--- a/src/bin/wasmer.rs
+++ b/src/bin/wasmer.rs
@@ -6,6 +6,7 @@ use std::io;
use std::io::Read;
use std::path::PathBuf;
use std::process::exit;
+use std::str::FromStr;
use hashbrown::HashMap;
use structopt::StructOpt;
@@ -62,13 +63,36 @@ struct Run {
#[structopt(parse(from_os_str))]
path: PathBuf,
- /// Application arguments
- #[structopt(name = "--", raw(multiple = "true"))]
- args: Vec,
+ // Disable the cache
+ #[structopt(long = "backend", default_value="cranelift")]
+ backend: Backend,
/// Emscripten symbol map
#[structopt(long = "em-symbol-map", parse(from_os_str))]
em_symbol_map: Option,
+
+ /// Application arguments
+ #[structopt(name = "--", raw(multiple = "true"))]
+ args: Vec,
+}
+
+#[derive(Debug)]
+enum Backend {
+ Cranelift,
+ Singlepass,
+ LLVM,
+}
+
+impl FromStr for Backend {
+ type Err = String;
+ fn from_str(s: &str) -> Result {
+ match s {
+ "singlepass" => Ok(Backend::Singlepass),
+ "cranelift" => Ok(Backend::Cranelift),
+ "llvm" => Ok(Backend::LLVM),
+ _ => Err(format!("The backend {} doesn't exist", s))
+ }
+ }
}
#[derive(Debug, StructOpt)]
From b724dd0a9b128869e9ba46c0baada037fb49758c Mon Sep 17 00:00:00 2001
From: Syrus
Date: Thu, 11 Apr 2019 13:17:19 -0700
Subject: [PATCH 5/8] Fix format
---
src/bin/wasmer.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs
index b6211a8011c..9f425457df6 100644
--- a/src/bin/wasmer.rs
+++ b/src/bin/wasmer.rs
@@ -64,7 +64,7 @@ struct Run {
path: PathBuf,
// Disable the cache
- #[structopt(long = "backend", default_value="cranelift")]
+ #[structopt(long = "backend", default_value = "cranelift")]
backend: Backend,
/// Emscripten symbol map
@@ -90,7 +90,7 @@ impl FromStr for Backend {
"singlepass" => Ok(Backend::Singlepass),
"cranelift" => Ok(Backend::Cranelift),
"llvm" => Ok(Backend::LLVM),
- _ => Err(format!("The backend {} doesn't exist", s))
+ _ => Err(format!("The backend {} doesn't exist", s)),
}
}
}
From 4740b2467f9d7fce6bab7d5516c574efd181055c Mon Sep 17 00:00:00 2001
From: Lachlan Sneff
Date: Thu, 11 Apr 2019 14:34:54 -0700
Subject: [PATCH 6/8] Add backend selection to cli
---
Cargo.toml | 2 +-
lib/runtime/src/lib.rs | 10 ++++++++++
src/bin/wasmer.rs | 40 ++++++++++++++++++++++++++++++++++------
src/webassembly.rs | 19 ++++++++++---------
4 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 5624b659a78..19c679be346 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,7 +40,7 @@ wabt = "0.7.2"
glob = "0.2.11"
[features]
-default = ["fast-tests", "wasi"]
+default = ["fast-tests", "wasi", "singlepass"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs
index f9a9ce81924..1836bb206be 100644
--- a/lib/runtime/src/lib.rs
+++ b/lib/runtime/src/lib.rs
@@ -141,6 +141,16 @@ pub fn compile_with_config(
wasmer_runtime_core::compile_with_config(&wasm[..], default_compiler(), compiler_config)
}
+/// The same as `compile_with_config` but takes a `Compiler` for the purpose of
+/// changing the backend.
+pub fn compile_with_config_with(
+ wasm: &[u8],
+ compiler_config: CompilerConfig,
+ compiler: &dyn Compiler,
+) -> error::CompileResult {
+ wasmer_runtime_core::compile_with_config(&wasm[..], compiler, compiler_config)
+}
+
/// Compile and instantiate WebAssembly code without
/// creating a [`Module`].
///
diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs
index 9f425457df6..0c09b8a9551 100644
--- a/src/bin/wasmer.rs
+++ b/src/bin/wasmer.rs
@@ -13,8 +13,13 @@ use structopt::StructOpt;
use wasmer::webassembly::InstanceABI;
use wasmer::*;
+use wasmer_clif_backend::CraneliftCompiler;
use wasmer_runtime::cache::{Cache as BaseCache, FileSystemCache, WasmHash, WASMER_VERSION_HASH};
-use wasmer_runtime_core::{self, backend::CompilerConfig};
+use wasmer_runtime_core::{
+ self,
+ backend::{Compiler, CompilerConfig},
+};
+use wasmer_singlepass_backend::SinglePassCompiler;
#[cfg(feature = "wasi")]
use wasmer_wasi;
@@ -64,7 +69,11 @@ struct Run {
path: PathBuf,
// Disable the cache
- #[structopt(long = "backend", default_value = "cranelift")]
+ #[structopt(
+ long = "backend",
+ default_value = "cranelift",
+ raw(possible_values = "Backend::variants()", case_insensitive = "true")
+ )]
backend: Backend,
/// Emscripten symbol map
@@ -76,6 +85,7 @@ struct Run {
args: Vec,
}
+#[allow(dead_code)]
#[derive(Debug)]
enum Backend {
Cranelift,
@@ -83,13 +93,23 @@ enum Backend {
LLVM,
}
+impl Backend {
+ pub fn variants() -> &'static [&'static str] {
+ &["singlepass", "cranelift", "llvm"]
+ }
+}
+
impl FromStr for Backend {
type Err = String;
fn from_str(s: &str) -> Result {
- match s {
+ match s.to_lowercase().as_str() {
"singlepass" => Ok(Backend::Singlepass),
"cranelift" => Ok(Backend::Cranelift),
- "llvm" => Ok(Backend::LLVM),
+ // "llvm" => Ok(Backend::LLVM),
+ "llvm" => Err(
+ "The LLVM backend option is not enabled by default due to binary size constraints"
+ .to_string(),
+ ),
_ => Err(format!("The backend {} doesn't exist", s)),
}
}
@@ -201,6 +221,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
.map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?;
}
+ let compiler: Box = match options.backend {
+ Backend::Singlepass => Box::new(SinglePassCompiler::new()),
+ Backend::Cranelift => Box::new(CraneliftCompiler::new()),
+ Backend::LLVM => unimplemented!(),
+ };
+
let module = if !disable_cache {
// If we have cache enabled
@@ -226,11 +252,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
module
}
Err(_) => {
- let module = webassembly::compile_with_config(
+ let module = webassembly::compile_with_config_with(
&wasm_binary[..],
CompilerConfig {
symbol_map: em_symbol_map,
},
+ &*compiler,
)
.map_err(|e| format!("Can't compile module: {:?}", e))?;
// We try to save the module into a cache file
@@ -241,11 +268,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
};
module
} else {
- webassembly::compile_with_config(
+ webassembly::compile_with_config_with(
&wasm_binary[..],
CompilerConfig {
symbol_map: em_symbol_map,
},
+ &*compiler,
)
.map_err(|e| format!("Can't compile module: {:?}", e))?
};
diff --git a/src/webassembly.rs b/src/webassembly.rs
index 01367795aed..fc32b3299a0 100644
--- a/src/webassembly.rs
+++ b/src/webassembly.rs
@@ -1,4 +1,5 @@
use std::panic;
+pub use wasmer_runtime::compile_with_config_with;
use wasmer_runtime::{
self as runtime,
error::{CallResult, Result},
@@ -78,15 +79,15 @@ pub fn compile(buffer_source: &[u8]) -> Result {
Ok(module)
}
-/// The same as `compile` but takes a `CompilerConfig` for the purpose of
-/// changing the compiler's behavior
-pub fn compile_with_config(
- buffer_source: &[u8],
- compiler_config: CompilerConfig,
-) -> Result {
- let module = runtime::compile_with_config(buffer_source, compiler_config)?;
- Ok(module)
-}
+// /// The same as `compile` but takes a `CompilerConfig` for the purpose of
+// /// changing the compiler's behavior
+// pub fn compile_with_config_with(
+// buffer_source: &[u8],
+// compiler_config: CompilerConfig,
+// ) -> Result {
+// let module = runtime::compile_with_config(buffer_source, compiler_config)?;
+// Ok(module)
+// }
/// Performs common instance operations needed when an instance is first run
/// including data setup, handling arguments and calling a main function
From 81807712d8157b970a8055108ae13adbfd5570e9 Mon Sep 17 00:00:00 2001
From: Lachlan Sneff
Date: Thu, 11 Apr 2019 14:44:43 -0700
Subject: [PATCH 7/8] Enable llvm backend
---
Cargo.toml | 6 +++---
src/bin/wasmer.rs | 13 +++++++------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 19c679be346..a82a52ef1d9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,11 +40,11 @@ wabt = "0.7.2"
glob = "0.2.11"
[features]
-default = ["fast-tests", "wasi", "singlepass"]
+default = ["fast-tests", "wasi", "singlepass", "llvm"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
-llvm = ["wasmer-llvm-backend", "wasmer-runtime/llvm"]
-singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/singlepass"]
+llvm = ["wasmer-llvm-backend"]
+singlepass = ["wasmer-singlepass-backend"]
wasi = ["wasmer-wasi"]
vfs = ["wasmer-runtime-abi"]
diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs
index 0c09b8a9551..d8ac1cbd780 100644
--- a/src/bin/wasmer.rs
+++ b/src/bin/wasmer.rs
@@ -14,6 +14,7 @@ use structopt::StructOpt;
use wasmer::webassembly::InstanceABI;
use wasmer::*;
use wasmer_clif_backend::CraneliftCompiler;
+use wasmer_llvm_backend::LLVMCompiler;
use wasmer_runtime::cache::{Cache as BaseCache, FileSystemCache, WasmHash, WASMER_VERSION_HASH};
use wasmer_runtime_core::{
self,
@@ -105,11 +106,11 @@ impl FromStr for Backend {
match s.to_lowercase().as_str() {
"singlepass" => Ok(Backend::Singlepass),
"cranelift" => Ok(Backend::Cranelift),
- // "llvm" => Ok(Backend::LLVM),
- "llvm" => Err(
- "The LLVM backend option is not enabled by default due to binary size constraints"
- .to_string(),
- ),
+ "llvm" => Ok(Backend::LLVM),
+ // "llvm" => Err(
+ // "The LLVM backend option is not enabled by default due to binary size constraints"
+ // .to_string(),
+ // ),
_ => Err(format!("The backend {} doesn't exist", s)),
}
}
@@ -224,7 +225,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
let compiler: Box = match options.backend {
Backend::Singlepass => Box::new(SinglePassCompiler::new()),
Backend::Cranelift => Box::new(CraneliftCompiler::new()),
- Backend::LLVM => unimplemented!(),
+ Backend::LLVM => Box::new(LLVMCompiler::new()),
};
let module = if !disable_cache {
From a100b2a72e31876e4b0d83dc5918d6d992d9773e Mon Sep 17 00:00:00 2001
From: Lachlan Sneff
Date: Thu, 11 Apr 2019 15:31:02 -0700
Subject: [PATCH 8/8] feature cfg away singlepass and llvm backends in cli
---
Cargo.lock | 1 +
Cargo.toml | 7 ++++---
src/bin/wasmer.rs | 8 ++++++++
src/webassembly.rs | 1 -
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index fec3babbb58..bcd7f4790d8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2227,6 +2227,7 @@ dependencies = [
"errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
diff --git a/Cargo.toml b/Cargo.toml
index a82a52ef1d9..de45b1ab72a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,13 +38,14 @@ members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/run
[build-dependencies]
wabt = "0.7.2"
glob = "0.2.11"
+rustc_version = "0.2.3"
[features]
-default = ["fast-tests", "wasi", "singlepass", "llvm"]
+default = ["fast-tests", "wasi"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
-llvm = ["wasmer-llvm-backend"]
-singlepass = ["wasmer-singlepass-backend"]
+"backend:llvm" = ["wasmer-llvm-backend"]
+"backend:singlepass" = ["wasmer-singlepass-backend"]
wasi = ["wasmer-wasi"]
vfs = ["wasmer-runtime-abi"]
diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs
index d8ac1cbd780..cc97810a98f 100644
--- a/src/bin/wasmer.rs
+++ b/src/bin/wasmer.rs
@@ -14,12 +14,14 @@ use structopt::StructOpt;
use wasmer::webassembly::InstanceABI;
use wasmer::*;
use wasmer_clif_backend::CraneliftCompiler;
+#[cfg(feature = "backend:llvm")]
use wasmer_llvm_backend::LLVMCompiler;
use wasmer_runtime::cache::{Cache as BaseCache, FileSystemCache, WasmHash, WASMER_VERSION_HASH};
use wasmer_runtime_core::{
self,
backend::{Compiler, CompilerConfig},
};
+#[cfg(feature = "backend:singlepass")]
use wasmer_singlepass_backend::SinglePassCompiler;
#[cfg(feature = "wasi")]
use wasmer_wasi;
@@ -223,9 +225,15 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
}
let compiler: Box = match options.backend {
+ #[cfg(feature = "backend:singlepass")]
Backend::Singlepass => Box::new(SinglePassCompiler::new()),
+ #[cfg(not(feature = "backend:singlepass"))]
+ Backend::Singlepass => return Err("The singlepass backend is not enabled".to_string()),
Backend::Cranelift => Box::new(CraneliftCompiler::new()),
+ #[cfg(feature = "backend:llvm")]
Backend::LLVM => Box::new(LLVMCompiler::new()),
+ #[cfg(not(feature = "backend:llvm"))]
+ Backend::LLVM => return Err("the llvm backend is not enabled".to_string()),
};
let module = if !disable_cache {
diff --git a/src/webassembly.rs b/src/webassembly.rs
index fc32b3299a0..354136ead7e 100644
--- a/src/webassembly.rs
+++ b/src/webassembly.rs
@@ -5,7 +5,6 @@ use wasmer_runtime::{
error::{CallResult, Result},
ImportObject, Instance, Module,
};
-use wasmer_runtime_core::backend::CompilerConfig;
use wasmer_runtime_core::types::Value;
use wasmer_emscripten::run_emscripten_instance;