Skip to content

Commit

Permalink
multiple fixes (#86)
Browse files Browse the repository at this point in the history
* chore(deps): update to latest stable release of Rust

Update to Rust 1.79.0. Also, make sure all the required targets are
installed.

Signed-off-by: Flavio Castelli <[email protected]>

* automation: uniform handling of Rust installation

Prior to this commit, the GH actions installed the rust toolchain using
the now archived `actions-rs/toolchain`.

On top of that, the actions were installing latest `stable` release of
Rust, overriding what was specified inside of our `rust-toolchain.toml`
file. That lead to different behaviour locally and inside of the
runners.
For example, that caused the automated release of `wasmtime-provider`
1.19.0 to fail because of different clippy rules between the local
development and the runners.

GitHub runners have `rustup` installed by default. That, together with
our `rust-toolchain.toml` file is enough to get the right version of
Rust automatically installed.

Signed-off-by: Flavio Castelli <[email protected]>

* deps: update Rust's WASI target

The old `wasm32-wasi` target has been deprecated and is going to be
completely replaced by `wasm32-wasip1`.

See [this blog post](https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html).

This commit ensures we use the right WASI target.

As a final note, the `.wasm` file part of the commit is the same program
rebuilt with the new target.

Signed-off-by: Flavio Castelli <[email protected]>

* fixes: address linter warnings

Address all the linter warnings raised by latest version of clippy

Signed-off-by: Flavio Castelli <[email protected]>

---------

Signed-off-by: Flavio Castelli <[email protected]>
  • Loading branch information
flavio authored Jul 11, 2024
1 parent 45d1c86 commit 4bfab87
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 36 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
target: wasm32-wasi
- name: lint
run: make check

workspace-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
target: wasm32-wasi
- name: lint
run: make test

wasmtime-provider:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
target: wasm32-wasi
- name: test
run: |
cd crates/wasmtime-provider
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ jobs:

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
toolchain: stable
override: true

- name: publish ${{ matrix.crate }} to crates.io
if: startsWith(github.ref, format('refs/tags/{0}-v', matrix.crate))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ wasm: $(WAPC_GUEST_WASM) $(TEST_WASI_WASM) $(TEST_WASM_WASM) $(TEST_WAPC_TIMEOUT

.PHONY: check
check:
cargo +nightly fmt --check
cargo fmt --check
cargo clippy --all --all-features --tests -- -D warnings

.PHONY: tidy
Expand Down
2 changes: 1 addition & 1 deletion crates/wapc-guest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ fn ping(msg: &[u8]) -> wapc::CallResult {

## Building

This crate is meant for projects targeting `wasm32-unknown-unknown` or `wasm32-wasi`.
This crate is meant for projects targeting `wasm32-unknown-unknown` or `wasm32-wasip1`.
2 changes: 1 addition & 1 deletion crates/wapc-pool/src/hostpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl HostPool {
let pool = self
.pool
.take()
.ok_or_else(|| wapc::errors::Error::from(crate::errors::Error::NoPool))?;
.ok_or_else(|| wapc::errors::Error::from(Error::NoPool))?;

pool.shutdown_join();
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/wapc/src/wapchost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{errors, HostCallback, Invocation};

static GLOBAL_MODULE_COUNT: AtomicU64 = AtomicU64::new(1);

type Result<T> = std::result::Result<T, crate::errors::Error>;
type Result<T> = std::result::Result<T, errors::Error>;

/// A WebAssembly host runtime for waPC-compliant modules
///
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm3-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl WebAssemblyEngineProvider for Wasm3EngineProvider {
}

// Invoke all the starters in order (if they exist)
for starter in wapc::wapc_functions::REQUIRED_STARTS.iter() {
for starter in wapc_functions::REQUIRED_STARTS.iter() {
let func = module.find_function::<(), ()>(starter);
if let Ok(func) = func {
if let Err(e) = func.call() {
Expand Down
10 changes: 5 additions & 5 deletions crates/wasmtime-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ impl WapcStore {
#[cfg(feature = "wasi")]
fn new(wasi_params: &WasiParams, host: Option<Arc<ModuleState>>) -> Result<WapcStore> {
let preopened_dirs = wasi::compute_preopen_dirs(&wasi_params.preopened_dirs, &wasi_params.map_dirs)
.map_err(|e| errors::Error::WasiInitCtxError(format!("Cannot compute preopened dirs: {:?}", e)))?;
.map_err(|e| Error::WasiInitCtxError(format!("Cannot compute preopened dirs: {:?}", e)))?;
let wasi_ctx = wasi::init_ctx(&preopened_dirs, &wasi_params.argv, &wasi_params.env_vars)
.map_err(|e| errors::Error::WasiInitCtxError(e.to_string()))?;
.map_err(|e| Error::WasiInitCtxError(e.to_string()))?;

Ok(WapcStore { wasi_ctx, host })
}
Expand Down Expand Up @@ -370,7 +370,7 @@ impl WebAssemblyEngineProvider for WasmtimeEngineProvider {
let mut guest_error = err.to_string();
if let Some(trap) = err.downcast_ref::<wasmtime::Trap>() {
if matches!(trap, wasmtime::Trap::Interrupt) {
guest_error = "guest code interrupted, execution deadline exceeded".to_owned();
"guest code interrupted, execution deadline exceeded".clone_into(&mut guest_error);
}
}
engine_inner.host.set_guest_error(guest_error);
Expand Down Expand Up @@ -404,7 +404,7 @@ impl WebAssemblyEngineProvider for WasmtimeEngineProvider {

impl WasmtimeEngineProvider {
fn initialize(&mut self) -> Result<()> {
for starter in wapc::wapc_functions::REQUIRED_STARTS.iter() {
for starter in wapc_functions::REQUIRED_STARTS.iter() {
if let Some(deadlines) = &self.epoch_deadlines {
// the deadline counter must be set before invoking the wasm function
self.store.set_epoch_deadline(deadlines.wapc_init);
Expand Down Expand Up @@ -445,5 +445,5 @@ fn guest_call_fn(store: impl AsContextMut, instance: &Arc<RwLock<Instance>>) ->
instance
.read()
.get_typed_func::<(i32, i32), i32>(store, wapc_functions::GUEST_CALL)
.map_err(|_| errors::Error::GuestCallNotFound)
.map_err(|_| Error::GuestCallNotFound)
}
8 changes: 3 additions & 5 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[toolchain]
channel = "1.77"
channel = "1.79"
components = ["rustfmt", "clippy"]
targets = ["wasm32-wasi"]

# Note: rebuilding the wasm requires targets
# wasm32-unknown-unknown and wasm32-wasi
# Note: rebuilding the wasm requires these targets
targets = ["wasm32-wasip1", "wasm32-unknown-unknown"]
2 changes: 1 addition & 1 deletion wasm/crates/wapc-guest-timeout/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: build clean

NAME=wapc_guest_timeout
TARGET=wasm32-wasi
TARGET=wasm32-wasip1

build: build/$(NAME).wasm

Expand Down
Binary file modified wasm/crates/wapc-guest-timeout/build/wapc_guest_timeout.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion wasm/crates/wasi-basic/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: build clean

NAME=wasi_basic
TARGET=wasm32-wasi
TARGET=wasm32-wasip1

build: build/$(NAME).wasm

Expand Down

0 comments on commit 4bfab87

Please sign in to comment.