-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I am storing non-Send data inside a Store<T> in a single-threaded synchronous environment.
Also I am using the wasmtime::component::bindgen! macro to generate bindings for my WIT definition.
Updating the wasmtime dependency from 28.0.0 to 32.0.0 introduces a compilation error because a new Send bound on the store data exists for calling guest-exported functions.
I tried setting require_store_data_send: false and async: false according to the bindgen! documentation, however these seem to only have an impact on the trait bound of the generated add_to_linker_imports_get_host function.
Here is a minimal example for better understanding:
bindgen!({
inline: "
package my:inline;
world my-world {
export foo: func();
}
",
async: false,
require_store_data_send: false,
});expands to
impl MyWorld {
...
pub fn call_foo<S: wasmtime::AsContextMut>(
&self,
mut store: S,
) -> wasmtime::Result<()>
where
<S as wasmtime::AsContext>::Data: Send,
{ ... }
}Here there is a <S as wasmtime::AsContext>::Data: Send trait bound, which essentially forbids the use of non-Send store data when calling guest-exposed functions.
This restriction did not exist in v28.0.0 and I do not see a reason why it would be required now.
The change was introduced in this commit in crates/wit-bindgen/src/lib.rs line 3290 (this is the direct link, however the link does not load correctly for me atleast).
My question is: Is this indeed a bug or is there is any other option I've overlooked that allows me to use non-Send store data?