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?
I am storing non-
Senddata inside aStore<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
wasmtimedependency from28.0.0to32.0.0introduces a compilation error because a newSendbound on the store data exists for calling guest-exported functions.I tried setting
require_store_data_send: falseandasync: falseaccording to thebindgen!documentation, however these seem to only have an impact on the trait bound of the generatedadd_to_linker_imports_get_hostfunction.Here is a minimal example for better understanding:
expands to
Here there is a
<S as wasmtime::AsContext>::Data: Sendtrait bound, which essentially forbids the use of non-Sendstore data when calling guest-exposed functions.This restriction did not exist in
v28.0.0and 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.rsline 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-
Sendstore data?