From 7193282de503211dd924fa62c8a32bd193c38163 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 8 Jun 2021 12:01:19 +0200 Subject: [PATCH 01/10] test(c-api) Clean up the `tests/Makefile`. 1. Use single tabs rather than three, it fits in a small terminal window, 2. `CAPI_WASMER_TESTS` has been removed in https://github.com/wasmerio/wasmer/pull/2375, but partially. This patch finishes the work. 3. The `test-%: %.o` rule is a remainder of some older code, it's no longer needed. --- lib/c-api/tests/Makefile | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/c-api/tests/Makefile b/lib/c-api/tests/Makefile index 0ce117412b3..ca17c83bd57 100644 --- a/lib/c-api/tests/Makefile +++ b/lib/c-api/tests/Makefile @@ -19,27 +19,19 @@ $(info * LDFLAGS: $(LDFLAGS)) $(info * LDLIBS: $(LDLIBS)) CAPI_BASE_TESTS = \ - wasm-c-api/example/callback wasm-c-api/example/global wasm-c-api/example/hello \ - wasm-c-api/example/memory wasm-c-api/example/reflect wasm-c-api/example/serialize \ - wasm-c-api/example/start wasm-c-api/example/trap wasm-c-api/example/multi + wasm-c-api/example/callback wasm-c-api/example/global wasm-c-api/example/hello \ + wasm-c-api/example/memory wasm-c-api/example/reflect wasm-c-api/example/serialize \ + wasm-c-api/example/start wasm-c-api/example/trap wasm-c-api/example/multi CAPI_BASE_TESTS_NOT_WORKING = \ - wasm-c-api/example/finalize wasm-c-api/example/hostref wasm-c-api/example/threads \ + wasm-c-api/example/finalize wasm-c-api/example/hostref wasm-c-api/example/threads \ wasm-c-api/example/table -ALL = $(CAPI_BASE_TESTS) $(CAPI_WASMER_TESTS) - -test-%: %.o +ALL = $(CAPI_BASE_TESTS) .PHONY: all all: $(ALL) -.PHONY: test-capi-wasmer -.SILENT: test-capi-wasmer -test-capi-wasmer: $(CAPI_WASMER_TESTS) - set -o errexit; \ - $(foreach example,$?,echo Running \"$(example)\" example; cd $(shell dirname $(realpath $(example))) && ./$(shell basename $(example)); echo;) - .PHONY: test-capi-base .SILENT: test-capi-base test-capi-base: $(CAPI_BASE_TESTS) @@ -48,7 +40,7 @@ test-capi-base: $(CAPI_BASE_TESTS) .PHONY: test-capi-base .SILENT: test-capi-base -test-capi: test-capi-base test-capi-wasmer +test-capi: test-capi-base test: test-capi From 2eba776decadb759dafc8b9501e831d8deada6b4 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 13 Jul 2021 12:18:19 +0200 Subject: [PATCH 02/10] feat: Add the `stale` bot. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch configures (and thus finishes the installation) of the β€œstale” bot, learn more at https://probot.github.io/apps/stale/. --- .github/stale.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000000..49521c7acb6 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 90 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 15 +# Issues with these labels will never be considered stale +exemptLabels: + - "🐞 bug" +# Label to use when marking an issue as stale +staleLabel: "🚫 won't fix" +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: > + Feel free to reopen the issue if it has been closed by mistake. From 758650cbb477274c00943d2efddc7b1b20b27fde Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 14 Jul 2021 10:24:47 +0200 Subject: [PATCH 03/10] Update .github/stale.yml Co-authored-by: Syrus Akbary --- .github/stale.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/stale.yml b/.github/stale.yml index 49521c7acb6..9f0c1eb4c43 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,7 +1,7 @@ # Number of days of inactivity before an issue becomes stale -daysUntilStale: 90 +daysUntilStale: 365 # Number of days of inactivity before a stale issue is closed -daysUntilClose: 15 +daysUntilClose: 30 # Issues with these labels will never be considered stale exemptLabels: - "🐞 bug" From 2e2beff7b6cb491a700cc0ebf638f4b00450a9ef Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 14 Jul 2021 10:26:05 +0200 Subject: [PATCH 04/10] Update .github/stale.yml --- .github/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/stale.yml b/.github/stale.yml index 9f0c1eb4c43..f992c78e168 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -6,7 +6,7 @@ daysUntilClose: 30 exemptLabels: - "🐞 bug" # Label to use when marking an issue as stale -staleLabel: "🚫 won't fix" +staleLabel: "🏚 stale" # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had From 6fd500433414059e2221420c8b5f963a4e0a4263 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 16 Jul 2021 15:12:40 +0200 Subject: [PATCH 05/10] fix(api) Fix typo in the `Cargo.toml` description --- lib/api/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index 95926231340..4868f5ccd6d 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wasmer" version = "2.0.0" -description = "High-performant WebAssembly runtime" +description = "High-performance WebAssembly runtime" categories = ["wasm"] keywords = ["wasm", "webassembly", "runtime", "vm"] authors = ["Wasmer Engineering Team "] From e9166434b216f45db92b654dddc76ad344780810 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 16 Jul 2021 16:47:33 -0700 Subject: [PATCH 06/10] Trying to fix sed command on Linux to fix documentation break --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4a3d3acd20b..70fdf32342e 100644 --- a/Makefile +++ b/Makefile @@ -395,9 +395,9 @@ build-docs-capi: capi-setup # `wasmer-c-api` lib's name is `wasmer`. To avoid a conflict # when generating the documentation, we rename it to its # crate's name. Then we restore the lib's name. - sed -i '' -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml + sed -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml RUSTFLAGS="${RUSTFLAGS}" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,universal,staticlib,dylib,cranelift,wasi - sed -i '' -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml + sed -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml build-capi: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ From 3ecbdb515055dfcb9364487dbc621b0ccffb8382 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 17 Jul 2021 14:53:36 -0700 Subject: [PATCH 07/10] Error on wasmer validate if the provided file is not wasm. Fix #2477 --- lib/cli/src/commands/validate.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cli/src/commands/validate.rs b/lib/cli/src/commands/validate.rs index 56b978416e7..fb9554d684e 100644 --- a/lib/cli/src/commands/validate.rs +++ b/lib/cli/src/commands/validate.rs @@ -1,5 +1,5 @@ use crate::store::StoreOptions; -use anyhow::{Context, Result}; +use anyhow::{bail, Context, Result}; use std::path::PathBuf; use structopt::StructOpt; use wasmer::*; @@ -24,6 +24,9 @@ impl Validate { fn inner_execute(&self) -> Result<()> { let (store, _engine_type, _compiler_type) = self.store.get_store()?; let module_contents = std::fs::read(&self.path)?; + if !is_wasm(&module_contents) { + bail!("`wasmer validate` only validates WebAssembly files"); + } Module::validate(&store, &module_contents)?; eprintln!("Validation passed for `{}`.", self.path.display()); Ok(()) From 4255387f4924069dbaed03e9566c268d6e34bb77 Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Sat, 17 Jul 2021 16:45:31 -0400 Subject: [PATCH 08/10] =?UTF-8?q?Rename=20wasm=5Finstance=5Fnew()=E2=80=99?= =?UTF-8?q?s=20=E2=80=9Ctraps=E2=80=9D=20argument=20to=20=E2=80=9Ctrap?= =?UTF-8?q?=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #2472 --- CHANGELOG.md | 2 ++ lib/c-api/examples/features.c | 6 +++--- lib/c-api/src/wasm_c_api/externals/mod.rs | 4 ++-- lib/c-api/src/wasm_c_api/instance.rs | 18 +++++++++--------- lib/c-api/src/wasm_c_api/mod.rs | 4 ++-- .../unstable/middlewares/metering.rs | 14 +++++++------- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c55fae80ef..f6272b50be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C ## **[Unreleased]** ### Changed +- [#2478](https://github.com/wasmerio/wasmer/pull/2478) Rename `traps` input to `wasm_instance_new()` to `trap`. + - [#2427](https://github.com/wasmerio/wasmer/pull/2427) Update `loupe` to 0.1.3. ### Fixed diff --git a/lib/c-api/examples/features.c b/lib/c-api/examples/features.c index b9f01258b5e..c42215d1eb1 100644 --- a/lib/c-api/examples/features.c +++ b/lib/c-api/examples/features.c @@ -40,8 +40,8 @@ int main(int argc, const char* argv[]) { printf("Instantiating module...\n"); wasm_extern_vec_t imports = WASM_EMPTY_VEC; - wasm_trap_t* traps = NULL; - wasm_instance_t* instance = wasm_instance_new(store, module, &imports,&traps); + wasm_trap_t* trap = NULL; + wasm_instance_t* instance = wasm_instance_new(store, module, &imports,&trap); if (!instance) { printf("> Error instantiating module!\n"); @@ -67,7 +67,7 @@ int main(int argc, const char* argv[]) { wasm_val_vec_t arguments_as_array = WASM_ARRAY_VEC(arguments); wasm_val_vec_t results_as_array = WASM_ARRAY_VEC(results); - wasm_trap_t* trap = wasm_func_call(swap, &arguments_as_array, &results_as_array); + trap = wasm_func_call(swap, &arguments_as_array, &results_as_array); if (trap != NULL) { printf("> Failed to call `swap`.\n"); diff --git a/lib/c-api/src/wasm_c_api/externals/mod.rs b/lib/c-api/src/wasm_c_api/externals/mod.rs index ca1cb279762..0a701db1c78 100644 --- a/lib/c-api/src/wasm_c_api/externals/mod.rs +++ b/lib/c-api/src/wasm_c_api/externals/mod.rs @@ -275,9 +275,9 @@ mod tests { assert(module); wasm_extern_vec_t imports = WASM_EMPTY_VEC; - wasm_trap_t* traps = NULL; + wasm_trap_t* trap = NULL; - wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps); + wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap); assert(instance); wasm_extern_vec_t exports; diff --git a/lib/c-api/src/wasm_c_api/instance.rs b/lib/c-api/src/wasm_c_api/instance.rs index 0774c6ae43a..67b11d3e7a6 100644 --- a/lib/c-api/src/wasm_c_api/instance.rs +++ b/lib/c-api/src/wasm_c_api/instance.rs @@ -25,7 +25,7 @@ pub struct wasm_instance_t { /// 2. Runtime errors that happen when running the module `start` /// function. /// -/// Failures are stored in the `traps` argument; the program doesn't +/// The failure is stored in the `trap` argument; the program doesn't /// panic. /// /// # Notes @@ -41,7 +41,7 @@ pub unsafe extern "C" fn wasm_instance_new( _store: Option<&wasm_store_t>, module: Option<&wasm_module_t>, imports: Option<&wasm_extern_vec_t>, - traps: *mut *mut wasm_trap_t, + trap: *mut *mut wasm_trap_t, ) -> Option> { let module = module?; let imports = imports?; @@ -67,8 +67,8 @@ pub unsafe extern "C" fn wasm_instance_new( } Err(InstantiationError::Start(runtime_error)) => { - let trap: Box = Box::new(runtime_error.into()); - *traps = Box::into_raw(trap); + let this_trap: Box = Box::new(runtime_error.into()); + *trap = Box::into_raw(this_trap); return None; } @@ -124,9 +124,9 @@ pub unsafe extern "C" fn wasm_instance_delete(_instance: Option Date: Mon, 19 Jul 2021 11:37:00 +0200 Subject: [PATCH 09/10] doc(c-api) Fix CHAGNELOG. --- CHANGELOG.md | 2 -- lib/c-api/CHANGELOG.md | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6272b50be4..5c55fae80ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,6 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C ## **[Unreleased]** ### Changed -- [#2478](https://github.com/wasmerio/wasmer/pull/2478) Rename `traps` input to `wasm_instance_new()` to `trap`. - - [#2427](https://github.com/wasmerio/wasmer/pull/2427) Update `loupe` to 0.1.3. ### Fixed diff --git a/lib/c-api/CHANGELOG.md b/lib/c-api/CHANGELOG.md index 140e63793b7..e8a5bc5e429 100644 --- a/lib/c-api/CHANGELOG.md +++ b/lib/c-api/CHANGELOG.md @@ -11,6 +11,9 @@ Looking for changes to the Wasmer CLI and the Rust API? See our [Primary Changel ### Added - [#2449](https://github.com/wasmerio/wasmer/pull/2449) Configure `soname`, `install_name`, `out-implib`, etc. +### Changed +- [#2478](https://github.com/wasmerio/wasmer/pull/2478) Rename `traps` input to `wasm_instance_new()` to `trap`. + ### Fixed - [#2444](https://github.com/wasmerio/wasmer/pull/2444) Trap's messages are always null terminated. From e474531d0b735140838b8538465402110935f4d2 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 19 Jul 2021 12:04:40 +0200 Subject: [PATCH 10/10] doc(makefile) Make `sed -i` cross-platform to fix `wasmer-c-api`'s doc. When generating the documentation for `wasmer-c-api`, we need to modify its `Cargo.toml` file. For that, we use `sed`. But we must use the `-i` argument (for `in-place` modifications). Unfortunately, it's different between macOS and Linux. This patch makes it cross-platform so that it runs on macOS and on Linux (incl. the CI). --- Makefile | 71 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 70fdf32342e..b21caf3adf5 100644 --- a/Makefile +++ b/Makefile @@ -329,9 +329,25 @@ $(info --------------) $(info ) $(info ) -############ -# Building # -############ +##### +# +# Configure `sed -i` for a cross-platform usage. +# +##### + +SEDI ?= + +ifeq ($(IS_DARWIN), 1) + SEDI := "-i ''" +else ifeq ($(IS_LINUX), 1) + SEDI := "-i" +endif + +##### +# +# Building. +# +##### # Not really "all", just the default target that builds enough so make # install will go through. @@ -363,13 +379,11 @@ build-wasmer-headless-minimal: RUSTFLAGS="${RUSTFLAGS}" xargo build --target $(HOST_TARGET) --release --manifest-path=lib/cli/Cargo.toml --no-default-features --features headless-minimal --bin wasmer-headless ifeq ($(IS_DARWIN), 1) strip -u target/$(HOST_TARGET)/release/wasmer-headless -else -ifeq ($(IS_WINDOWS), 1) +else ifeq ($(IS_WINDOWS), 1) strip --strip-unneeded target/$(HOST_TARGET)/release/wasmer-headless.exe else strip --strip-unneeded target/$(HOST_TARGET)/release/wasmer-headless endif -endif WAPM_VERSION = v0.5.1 get-wapm: @@ -395,9 +409,9 @@ build-docs-capi: capi-setup # `wasmer-c-api` lib's name is `wasmer`. To avoid a conflict # when generating the documentation, we rename it to its # crate's name. Then we restore the lib's name. - sed -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml + sed "$(SEDI)" -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml RUSTFLAGS="${RUSTFLAGS}" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,universal,staticlib,dylib,cranelift,wasi - sed -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml + sed "$(SEDI)" -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml build-capi: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ @@ -469,10 +483,11 @@ build-capi-headless-all: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ --no-default-features --features universal,dylib,staticlib,wasi - -########### -# Testing # -########### +##### +# +# Testing. +# +##### test: test-compilers test-packages test-examples @@ -485,9 +500,11 @@ test-packages: cargo test --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std cargo test --manifest-path lib/cli/Cargo.toml $(compiler_features) --release -######################## -# Testing (Compatible) # -######################## +##### +# +# Testing compilers. +# +##### test-compilers-compat: $(foreach compiler,$(compilers),test-$(compiler)) @@ -538,9 +555,11 @@ test-examples: test-integration: cargo test -p wasmer-integration-tests-cli -############# -# Packaging # -############# +##### +# +# Packaging. +# +##### package-wapm: mkdir -p "package/bin" @@ -626,9 +645,11 @@ endif tar -C package -zcvf wasmer.tar.gz bin lib include LICENSE ATTRIBUTIONS mv wasmer.tar.gz dist/ -######################## -# (Distro-) Installing # -######################## +##### +# +# Installating (for Distros). +# +##### DESTDIR ?= /usr/local @@ -669,9 +690,11 @@ install-pkgconfig: install-wasmer-headless-minimal: install -Dm755 target/release/wasmer-headless $(DESTDIR)/bin/wasmer-headless -################# -# Miscellaneous # -################# +##### +# +# Miscellaneous. +# +##### # Updates the spectests from the repo update-testsuite: