From 4b9df1f7776314f8f234c13bef9cd4b62dbc3bcb Mon Sep 17 00:00:00 2001 From: Syrus Date: Thu, 24 Jan 2019 14:50:29 -0800 Subject: [PATCH 1/7] Added Rust embedded description --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0a1c3ae8a..a9c6cfe66 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Install Wasmer with: curl https://get.wasmer.io -sSfL | sh ``` +_**NEW ✨**: Now you can also embed Wasmer in your Rust application, check our [example repo](https://github.com/wasmerio/wasmer-rust-example) to see how to do it!_ + ### Usage `wasmer` can execute both the standard binary format (`.wasm`) and the text @@ -54,15 +56,16 @@ curl https://sh.rustup.rs -sSf | sh ### Other dependencies Please select your operating system: -* [macOS](#macos) -* [Debian-based Linuxes](#debian-based-linuxes) -* [Microsoft Windows](#windows-msvc) + +- [macOS](#macos) +- [Debian-based Linuxes](#debian-based-linuxes) +- [Microsoft Windows](#windows-msvc) #### macOS If you have [homebrew](https://brew.sh/) installed: -``` sh +```sh brew install cmake ``` @@ -74,21 +77,20 @@ sudo port install cmake #### Debian-based Linuxes -``` sh +```sh sudo apt install cmake ``` #### Windows (MSVC) -Right now Windows support is *highly experimental*. +Right now Windows support is _highly experimental_. We are working on this so Wasmer can soon be released for Windows. 1. Install Python for Windows (https://www.python.org/downloads/release/python-2714/). The Windows x86-64 MSI installer is fine. -You should change the installation to install the "Add python.exe to Path" feature. + You should change the installation to install the "Add python.exe to Path" feature. 2. Install Git for Windows (https://git-scm.com/download/win). DO allow it to add git.exe to the PATH (default -settings for the installer are fine). - + settings for the installer are fine). ## Building From 4185a10e486d7631a0ff79b082d5452c7ff3a52d Mon Sep 17 00:00:00 2001 From: Syrus Date: Thu, 24 Jan 2019 15:50:06 -0800 Subject: [PATCH 2/7] Improved linguist to skip WebAssembly/C files --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..b7c3d068b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +lib/emscripten/emtests/* linguist-vendored +lib/runtime-core/spectests/* linguist-vendored From 87f3af5a9917c9ab88c3c3f50caa35677f299eca Mon Sep 17 00:00:00 2001 From: Dave Loyall Date: Fri, 25 Jan 2019 10:35:18 -0600 Subject: [PATCH 3/7] s/on the works/in the works/ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9c6cfe66..51d7ccae5 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ Below are some of the goals (written with order) of this project: - [x] It should be 100% compatible with the [WebAssembly Spectest](https://github.com/wasmerio/wasmer/tree/master/spectests) - [x] It should be fast _(partially achieved)_ -- [ ] Support Emscripten calls _(on the works)_ +- [ ] Support Emscripten calls _(in the works)_ - [ ] Support Rust ABI calls - [ ] Support GO ABI calls From 65872a1be4bba3dd8565dc876f58f63ebcf6f086 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Wed, 23 Jan 2019 00:31:58 -0600 Subject: [PATCH 4/7] Cherry-picked fix --- lib/clif-backend/src/module.rs | 5 +++-- lib/clif-backend/src/resolver.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/clif-backend/src/module.rs b/lib/clif-backend/src/module.rs index b50517f6e..596763db0 100644 --- a/lib/clif-backend/src/module.rs +++ b/lib/clif-backend/src/module.rs @@ -92,8 +92,9 @@ impl Module { func_assoc.iter_mut().for_each(|(_, sig_index)| { *sig_index = sig_registry.lookup_deduplicated_sigindex(*sig_index); }); - - let (func_resolver_builder, handler_data) = FuncResolverBuilder::new(isa, functions)?; + let imported_functions_len = self.module.imported_functions.len(); + let (func_resolver_builder, handler_data) = + FuncResolverBuilder::new(isa, functions, imported_functions_len)?; self.module.func_resolver = Box::new(func_resolver_builder.finalize()?); let trampolines = Trampolines::new(isa, &self.module); diff --git a/lib/clif-backend/src/resolver.rs b/lib/clif-backend/src/resolver.rs index 25b85b113..85663fc30 100644 --- a/lib/clif-backend/src/resolver.rs +++ b/lib/clif-backend/src/resolver.rs @@ -14,7 +14,7 @@ use wasmer_runtime_core::{ sys::{Memory, Protect}, }, error::{CompileError, CompileResult}, - structures::Map, + structures::{Map, TypedIndex}, types::LocalFuncIndex, vm, vmcalls, }; @@ -23,12 +23,14 @@ use wasmer_runtime_core::{ pub struct FuncResolverBuilder { resolver: FuncResolver, relocations: Map>, + import_len: usize, } impl FuncResolverBuilder { pub fn new( isa: &isa::TargetIsa, function_bodies: Map, + import_len: usize, ) -> CompileResult<(Self, HandlerData)> { let mut compiled_functions: Vec> = Vec::with_capacity(function_bodies.len()); let mut relocations = Map::with_capacity(function_bodies.len()); @@ -100,6 +102,7 @@ impl FuncResolverBuilder { Self { resolver: FuncResolver { map, memory }, relocations, + import_len, }, handler_data, )) @@ -113,6 +116,10 @@ impl FuncResolverBuilder { // This will always be an internal function // because imported functions are not // called in this way. + // Adjust from wasm-wide function index to index of locally-defined functions only. + let local_func_index = + LocalFuncIndex::new(local_func_index.index() - self.import_len); + self.resolver.lookup(local_func_index).unwrap().as_ptr() as isize } RelocationType::LibCall(libcall) => match libcall { From 29a3af11fc49d3c6d324e86b70fc48e32e268610 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 25 Jan 2019 10:34:43 -0800 Subject: [PATCH 5/7] Updated lib crate versions --- Cargo.lock | 14 +++++++------- lib/clif-backend/Cargo.toml | 4 ++-- lib/runtime-core/Cargo.toml | 2 +- lib/runtime/Cargo.toml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b02c01753..827078100 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -489,15 +489,15 @@ dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-clif-backend 0.1.1", + "wasmer-clif-backend 0.1.2", "wasmer-emscripten 0.1.0", - "wasmer-runtime 0.1.3", + "wasmer-runtime 0.1.4", "wasmer-runtime-core 0.1.2", ] [[package]] name = "wasmer-clif-backend" -version = "0.1.1" +version = "0.1.2" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -521,15 +521,15 @@ dependencies = [ "libc 0.2.44 (git+https://github.com/rust-lang/libc)", "time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-clif-backend 0.1.1", + "wasmer-clif-backend 0.1.2", "wasmer-runtime-core 0.1.2", ] [[package]] name = "wasmer-runtime" -version = "0.1.3" +version = "0.1.4" dependencies = [ - "wasmer-clif-backend 0.1.1", + "wasmer-clif-backend 0.1.2", "wasmer-runtime-core 0.1.2", ] @@ -543,7 +543,7 @@ dependencies = [ "nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-clif-backend 0.1.1", + "wasmer-clif-backend 0.1.2", "wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/lib/clif-backend/Cargo.toml b/lib/clif-backend/Cargo.toml index 28fb0fbd2..44855f1df 100644 --- a/lib/clif-backend/Cargo.toml +++ b/lib/clif-backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-clif-backend" -version = "0.1.1" +version = "0.1.2" description = "Wasmer runtime Cranelift compiler backend" license = "MIT" authors = ["The Wasmer Engineering Team "] @@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer" edition = "2018" [dependencies] -wasmer-runtime-core = { path = "../runtime-core", version = "0.1.1" } +wasmer-runtime-core = { path = "../runtime-core", version = "0.1.2" } cranelift-native = "0.26.0" cranelift-codegen = "0.26.0" cranelift-entity = "0.26.0" diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index b1551c149..861fb14d7 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -24,7 +24,7 @@ errno = "0.2.4" wabt = "0.7.2" [dev-dependencies] -wasmer-clif-backend = { path = "../clif-backend", version = "0.1.1" } +wasmer-clif-backend = { path = "../clif-backend", version = "0.1.2" } wabt = "0.7.2" field-offset = "0.1.1" diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 4642f9d84..f1aee273c 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-runtime" -version = "0.1.3" +version = "0.1.4" description = "Wasmer runtime library" license = "MIT" authors = ["The Wasmer Engineering Team "] @@ -10,7 +10,7 @@ readme = "README.md" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.1.2" } -wasmer-clif-backend = { path = "../clif-backend", version = "0.1.1", optional = true } +wasmer-clif-backend = { path = "../clif-backend", version = "0.1.2", optional = true } [features] default = ["wasmer-clif-backend"] From 33efbe017f55d3e178328b339ef751b51f5ee0c9 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Fri, 25 Jan 2019 23:42:14 -0800 Subject: [PATCH 6/7] Fix spectests link in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51d7ccae5..64f2fc530 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ cargo install --path . ## Testing -Thanks to [spectests](https://github.com/wasmerio/wasmer/tree/master/spectests) we can assure 100% compatibility with the WebAssembly spec test suite. +Thanks to [spectests](https://github.com/wasmerio/wasmer/tree/master/lib/runtime-core/spectests) we can assure 100% compatibility with the WebAssembly spec test suite. Tests can be run with: From d71ee5ad131854dbe793bac2b81a0d967bf0e675 Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Sat, 26 Jan 2019 08:47:09 +0100 Subject: [PATCH 7/7] Import u64 correctly --- lib/runtime-core/src/macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime-core/src/macros.rs b/lib/runtime-core/src/macros.rs index 9da01c254..80be85478 100644 --- a/lib/runtime-core/src/macros.rs +++ b/lib/runtime-core/src/macros.rs @@ -38,7 +38,7 @@ macro_rules! __export_func_convert_type { Type::I64 }; (u64) => { - Type::I32 + Type::I64 }; (f32) => { Type::F32