-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
async/stream/future support for wasmtime-wit-bindgen #10044
async/stream/future support for wasmtime-wit-bindgen #10044
Conversation
In case it helps: Since
That's the same workaround used in Another |
Thanks for the links, @rvolosatovs. The compiler error I'm seeing doesn't match the ones in those issues, so I suspect it's something different. Here's a (somewhat) minimal example of what I'm seeing: |
crates/wasmtime/Cargo.toml
Outdated
@@ -62,6 +62,7 @@ semver = { workspace = true, optional = true } | |||
smallvec = { workspace = true, optional = true } | |||
hashbrown = { workspace = true, features = ["default-hasher"] } | |||
bitflags = { workspace = true } | |||
futures = { workspace = true, features = ["alloc"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be made an optional dependency activated by component-model-async
?
I've split this out of bytecodealliance#9582 to make review easier. This patch adds async/stream/future/error-context support to the host binding generator, along with placeholder type and function definitions in the `wasmtime` crate which the generated bindings can refer to. See https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#componentbindgen-updates for the design and rationale. Note that I've added temporary `[patch.crates-io]` overrides in Cargo.toml until bytecodealliance/wit-bindgen#1130 and bytecodealliance/wasm-tools#1978 have been released. Also note that we emit a `T: 'static` bound for `AsContextMut<Data = T>` when generating bindings with `concurrent_imports: true`. This is only because `rustc` insists that the closure we're passing to `LinkerInstance::func_wrap_concurrent` captures the lifetime of `T` despite my best efforts to convince it otherwise. Alex and I suspect this is a limitation in the compiler, and I asked about it on the rust-lang Zulip, but we haven't been able to determine a workaround so far. Signed-off-by: Joel Dice <[email protected]> remove obsolete TODO comment Signed-off-by: Joel Dice <[email protected]> make `futures` dep optional Signed-off-by: Joel Dice <[email protected]> update `wasm-tools` and `wit-bindgen` Signed-off-by: Joel Dice <[email protected]>
24365da
to
f04b932
Compare
Signed-off-by: Joel Dice <[email protected]>
I've split this out of #9582 to make review easier.
This patch adds async/stream/future/error-context support to the host binding generator, along with placeholder type and function definitions in the
wasmtime
crate which the generated bindings can refer to. See https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#componentbindgen-updates for the design and rationale.Note that I've added temporary
[patch.crates-io]
overrides in Cargo.toml until bytecodealliance/wit-bindgen#1130 and bytecodealliance/wasm-tools#1978 have been released.Also note that we emit a
T: 'static
bound forAsContextMut<Data = T>
when generating bindings withconcurrent_imports: true
. This is only becauserustc
insists that the closure we're passing toLinkerInstance::func_wrap_concurrent
captures the lifetime ofT
despite my best efforts to convince it otherwise. Alex and I suspect this is a limitation in the compiler, and I asked about it on the rust-lang Zulip, but we haven't been able to determine a workaround so far.