Skip to content

Commit

Permalink
Update wasm-tools crates to 226 (#10235)
Browse files Browse the repository at this point in the history
* Update wasm-tools crates to 226

This commit updates the wasm-tools crates to the 226 track of versions.
The most notable change here is the removal and refactoring within
wasm-tools of support for multiple and named returns in the component
model along with the support for 33+ flags in the `flags` type. This has
been gated for some time now and it's just now being removed now that
it's been awhile an no issues have been raised.

prtest:full

* Fix some issues from CI

* Fix benchmarks

* Switch to crates.io-based crates
  • Loading branch information
alexcrichton authored Feb 19, 2025
1 parent 362b0db commit 287e8fb
Show file tree
Hide file tree
Showing 30 changed files with 250 additions and 854 deletions.
178 changes: 127 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,16 @@ wit-bindgen = { version = "0.39.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.39.0", default-features = false }

# wasm-tools family:
wasmparser = { version = "0.225.0", default-features = false, features = ['simd'] }
wat = "1.225.0"
wast = "225.0.0"
wasmprinter = "0.225.0"
wasm-encoder = "0.225.0"
wasm-smith = "0.225.0"
wasm-mutate = "0.225.0"
wit-parser = "0.225.0"
wit-component = "0.225.0"
wasm-wave = "0.225.0"
wasmparser = { version = "0.226.0", default-features = false, features = ['simd'] }
wat = "1.226.0"
wast = "226.0.0"
wasmprinter = "0.226.0"
wasm-encoder = "0.226.0"
wasm-smith = "0.226.0"
wasm-mutate = "0.226.0"
wit-parser = "0.226.0"
wit-component = "0.226.0"
wasm-wave = "0.226.0"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
Expand Down
2 changes: 1 addition & 1 deletion benches/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ mod component {
(func (export "nop")
(canon lift (core func $i "nop"))
)
(func (export "nop-params-and-results") (param "x" u32) (param "y" u64) (result "z" float32)
(func (export "nop-params-and-results") (param "x" u32) (param "y" u64) (result float32)
(canon lift (core func $i "nop-params-and-results"))
)
)
Expand Down
6 changes: 0 additions & 6 deletions crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,6 @@ wasmtime_option_group! {
pub memory64: Option<bool>,
/// Configure support for the component-model proposal.
pub component_model: Option<bool>,
/// Configure support for 33+ flags in the component model.
pub component_model_more_flags: Option<bool>,
/// Component model support for more than one return value.
pub component_model_multiple_returns: Option<bool>,
/// Component model support for async lifting/lowering.
pub component_model_async: Option<bool>,
/// Configure support for the function-references proposal.
Expand Down Expand Up @@ -991,8 +987,6 @@ impl CommonOptions {

handle_conditionally_compiled! {
("component-model", component_model, wasm_component_model)
("component-model", component_model_more_flags, wasm_component_model_more_flags)
("component-model", component_model_multiple_returns, wasm_component_model_multiple_returns)
("component-model-async", component_model_async, wasm_component_model_async)
("threads", threads, wasm_threads)
("gc", gc, wasm_gc)
Expand Down
14 changes: 0 additions & 14 deletions crates/component-macro/tests/codegen/multi-return.wit

This file was deleted.

3 changes: 0 additions & 3 deletions crates/component-macro/tests/codegen/variants.wit
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ interface variants {

is-clone-arg: func(a: is-clone);
is-clone-return: func() -> is-clone;

return-named-option: func() -> (a: option<u8>);
return-named-result: func() -> (a: result<u8, my-errno>);
}

world my-world {
Expand Down
80 changes: 0 additions & 80 deletions crates/component-macro/tests/expanded/variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,6 @@ pub mod foo {
fn result_simple(&mut self) -> Result<u32, i32>;
fn is_clone_arg(&mut self, a: IsClone) -> ();
fn is_clone_return(&mut self) -> IsClone;
fn return_named_option(&mut self) -> Option<u8>;
fn return_named_result(&mut self) -> Result<u8, MyErrno>;
}
pub trait GetHost<
T,
Expand Down Expand Up @@ -780,22 +778,6 @@ pub mod foo {
Ok((r,))
},
)?;
inst.func_wrap(
"return-named-option",
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
let host = &mut host_getter(caller.data_mut());
let r = Host::return_named_option(host);
Ok((r,))
},
)?;
inst.func_wrap(
"return-named-result",
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
let host = &mut host_getter(caller.data_mut());
let r = Host::return_named_result(host);
Ok((r,))
},
)?;
Ok(())
}
pub fn add_to_linker<T, U>(
Expand Down Expand Up @@ -916,12 +898,6 @@ pub mod foo {
fn is_clone_return(&mut self) -> IsClone {
Host::is_clone_return(*self)
}
fn return_named_option(&mut self) -> Option<u8> {
Host::return_named_option(*self)
}
fn return_named_result(&mut self) -> Result<u8, MyErrno> {
Host::return_named_result(*self)
}
}
}
}
Expand Down Expand Up @@ -1298,8 +1274,6 @@ pub mod exports {
result_simple: wasmtime::component::Func,
is_clone_arg: wasmtime::component::Func,
is_clone_return: wasmtime::component::Func,
return_named_option: wasmtime::component::Func,
return_named_result: wasmtime::component::Func,
}
#[derive(Clone)]
pub struct GuestIndices {
Expand All @@ -1323,8 +1297,6 @@ pub mod exports {
result_simple: wasmtime::component::ComponentExportIndex,
is_clone_arg: wasmtime::component::ComponentExportIndex,
is_clone_return: wasmtime::component::ComponentExportIndex,
return_named_option: wasmtime::component::ComponentExportIndex,
return_named_result: wasmtime::component::ComponentExportIndex,
}
impl GuestIndices {
/// Constructor for [`GuestIndices`] which takes a
Expand Down Expand Up @@ -1399,8 +1371,6 @@ pub mod exports {
let result_simple = lookup("result-simple")?;
let is_clone_arg = lookup("is-clone-arg")?;
let is_clone_return = lookup("is-clone-return")?;
let return_named_option = lookup("return-named-option")?;
let return_named_result = lookup("return-named-result")?;
Ok(GuestIndices {
e1_arg,
e1_result,
Expand All @@ -1422,8 +1392,6 @@ pub mod exports {
result_simple,
is_clone_arg,
is_clone_return,
return_named_option,
return_named_result,
})
}
pub fn load(
Expand Down Expand Up @@ -1574,18 +1542,6 @@ pub mod exports {
(IsClone,),
>(&mut store, &self.is_clone_return)?
.func();
let return_named_option = *_instance
.get_typed_func::<
(),
(Option<u8>,),
>(&mut store, &self.return_named_option)?
.func();
let return_named_result = *_instance
.get_typed_func::<
(),
(Result<u8, MyErrno>,),
>(&mut store, &self.return_named_result)?
.func();
Ok(Guest {
e1_arg,
e1_result,
Expand All @@ -1607,8 +1563,6 @@ pub mod exports {
result_simple,
is_clone_arg,
is_clone_return,
return_named_option,
return_named_result,
})
}
}
Expand Down Expand Up @@ -2045,40 +1999,6 @@ pub mod exports {
callee.post_return(store.as_context_mut())?;
Ok(ret0)
}
pub fn call_return_named_option<S: wasmtime::AsContextMut>(
&self,
mut store: S,
) -> wasmtime::Result<Option<u8>>
where
<S as wasmtime::AsContext>::Data: Send,
{
let callee = unsafe {
wasmtime::component::TypedFunc::<
(),
(Option<u8>,),
>::new_unchecked(self.return_named_option)
};
let (ret0,) = callee.call(store.as_context_mut(), ())?;
callee.post_return(store.as_context_mut())?;
Ok(ret0)
}
pub fn call_return_named_result<S: wasmtime::AsContextMut>(
&self,
mut store: S,
) -> wasmtime::Result<Result<u8, MyErrno>>
where
<S as wasmtime::AsContext>::Data: Send,
{
let callee = unsafe {
wasmtime::component::TypedFunc::<
(),
(Result<u8, MyErrno>,),
>::new_unchecked(self.return_named_result)
};
let (ret0,) = callee.call(store.as_context_mut(), ())?;
callee.post_return(store.as_context_mut())?;
Ok(ret0)
}
}
}
}
Expand Down
88 changes: 0 additions & 88 deletions crates/component-macro/tests/expanded/variants_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,6 @@ pub mod foo {
async fn result_simple(&mut self) -> Result<u32, i32>;
async fn is_clone_arg(&mut self, a: IsClone) -> ();
async fn is_clone_return(&mut self) -> IsClone;
async fn return_named_option(&mut self) -> Option<u8>;
async fn return_named_result(&mut self) -> Result<u8, MyErrno>;
}
pub trait GetHost<
T,
Expand Down Expand Up @@ -834,26 +832,6 @@ pub mod foo {
})
},
)?;
inst.func_wrap_async(
"return-named-option",
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
wasmtime::component::__internal::Box::new(async move {
let host = &mut host_getter(caller.data_mut());
let r = Host::return_named_option(host).await;
Ok((r,))
})
},
)?;
inst.func_wrap_async(
"return-named-result",
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
wasmtime::component::__internal::Box::new(async move {
let host = &mut host_getter(caller.data_mut());
let r = Host::return_named_result(host).await;
Ok((r,))
})
},
)?;
Ok(())
}
pub fn add_to_linker<T, U>(
Expand Down Expand Up @@ -975,12 +953,6 @@ pub mod foo {
async fn is_clone_return(&mut self) -> IsClone {
Host::is_clone_return(*self).await
}
async fn return_named_option(&mut self) -> Option<u8> {
Host::return_named_option(*self).await
}
async fn return_named_result(&mut self) -> Result<u8, MyErrno> {
Host::return_named_result(*self).await
}
}
}
}
Expand Down Expand Up @@ -1357,8 +1329,6 @@ pub mod exports {
result_simple: wasmtime::component::Func,
is_clone_arg: wasmtime::component::Func,
is_clone_return: wasmtime::component::Func,
return_named_option: wasmtime::component::Func,
return_named_result: wasmtime::component::Func,
}
#[derive(Clone)]
pub struct GuestIndices {
Expand All @@ -1382,8 +1352,6 @@ pub mod exports {
result_simple: wasmtime::component::ComponentExportIndex,
is_clone_arg: wasmtime::component::ComponentExportIndex,
is_clone_return: wasmtime::component::ComponentExportIndex,
return_named_option: wasmtime::component::ComponentExportIndex,
return_named_result: wasmtime::component::ComponentExportIndex,
}
impl GuestIndices {
/// Constructor for [`GuestIndices`] which takes a
Expand Down Expand Up @@ -1458,8 +1426,6 @@ pub mod exports {
let result_simple = lookup("result-simple")?;
let is_clone_arg = lookup("is-clone-arg")?;
let is_clone_return = lookup("is-clone-return")?;
let return_named_option = lookup("return-named-option")?;
let return_named_result = lookup("return-named-result")?;
Ok(GuestIndices {
e1_arg,
e1_result,
Expand All @@ -1481,8 +1447,6 @@ pub mod exports {
result_simple,
is_clone_arg,
is_clone_return,
return_named_option,
return_named_result,
})
}
pub fn load(
Expand Down Expand Up @@ -1633,18 +1597,6 @@ pub mod exports {
(IsClone,),
>(&mut store, &self.is_clone_return)?
.func();
let return_named_option = *_instance
.get_typed_func::<
(),
(Option<u8>,),
>(&mut store, &self.return_named_option)?
.func();
let return_named_result = *_instance
.get_typed_func::<
(),
(Result<u8, MyErrno>,),
>(&mut store, &self.return_named_result)?
.func();
Ok(Guest {
e1_arg,
e1_result,
Expand All @@ -1666,8 +1618,6 @@ pub mod exports {
result_simple,
is_clone_arg,
is_clone_return,
return_named_option,
return_named_result,
})
}
}
Expand Down Expand Up @@ -2141,44 +2091,6 @@ pub mod exports {
callee.post_return_async(store.as_context_mut()).await?;
Ok(ret0)
}
pub async fn call_return_named_option<S: wasmtime::AsContextMut>(
&self,
mut store: S,
) -> wasmtime::Result<Option<u8>>
where
<S as wasmtime::AsContext>::Data: Send,
{
let callee = unsafe {
wasmtime::component::TypedFunc::<
(),
(Option<u8>,),
>::new_unchecked(self.return_named_option)
};
let (ret0,) = callee
.call_async(store.as_context_mut(), ())
.await?;
callee.post_return_async(store.as_context_mut()).await?;
Ok(ret0)
}
pub async fn call_return_named_result<S: wasmtime::AsContextMut>(
&self,
mut store: S,
) -> wasmtime::Result<Result<u8, MyErrno>>
where
<S as wasmtime::AsContext>::Data: Send,
{
let callee = unsafe {
wasmtime::component::TypedFunc::<
(),
(Result<u8, MyErrno>,),
>::new_unchecked(self.return_named_result)
};
let (ret0,) = callee
.call_async(store.as_context_mut(), ())
.await?;
callee.post_return_async(store.as_context_mut()).await?;
Ok(ret0)
}
}
}
}
Expand Down
Loading

0 comments on commit 287e8fb

Please sign in to comment.