Is there a path to get WasiCtx
working with Wasmtime component hosts generated with bindgen!()
? Currently wasmtime_wasi::add_to_linker
requires a 'normal' module linker so there doesn't seem to be an obvious way to have a host supply WASI imports to a component. I created my component with the snapshot1 adapter.
Just curious if this is possible right now, I realize this is at the edge of a lot of ongoing work :)
this is very much the bleeding edge ;) I got this far:
https://github.com/bytecodealliance/preview2-prototyping/blob/main/host/src/main.rs this is how it's supposed to work once everything is finished
but wasi_cap_std_sync::WasiCtxBuilder
can't be imported right now, so using this host crate as a lib seems to be currently just not intended
If you've got a component then the existing wasmtime-wasi
crate won't work for you since it's working at the core wasm abstraction layer which isn't compatible. This means that the quick answer to your question is "no, wasmtime_wasi::add_to_linker
will not get component support".
The full answer is a bit more nuanced. Your component imports WASI-related functionality, it's just at the component model layer of abstraction. Currently there is not a built-in crate in Wasmtime itself to implement this functionality. The preview2-prototyping repository, however, has a work-in-progress implementation that we'll eventually e upstraming into Wasmtime.
@Alex Crichton would it be possible to reexport that bulder in host/src/lib.rs so we can try out wasi reactors?
by "that" what do you mean?
https://github.com/bytecodealliance/preview2-prototyping/blob/main/host/src/main.rs#L4
wasi_cap_std_sync is not in the workspace of the repo, so only crates inside the repo can import from it. main.rs imports the WasiCtxBuilder so it can use it, but lib.rs neither imports nor reexports it so if you try to use host as a lib you won't get a WasiCtxBuilder
oh the preview2-protoyping repo is very much still in the "prototyping" state meaning it hasn't finished design for "how will this be used externally", so questions about how to use I think will get answered in time but for now you'll need to get your hands dirty I think to work with it
I should clarify that I am not myself working very closely on the implementation at this time, for specific questions I'd reach out to Pat/Dan
Thanks for the answer! The preview2 prototyping might do it for my current playing around :)
Jesse Wellenberg (Yeseh) has marked this topic as resolved.
Last updated: Nov 22 2024 at 17:03 UTC