Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple fixes #86

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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