Stream: wasi

Topic: wasi components?


view this post on Zulip Ramon Klass (Jan 23 2023 at 14:38):

I'm trying to make a component that needs wasi, I can compile the code to --target=wasm32-wasi and convert it with wasm-tools component new target/wasm32-wasi/debug/project.wasm -o test.wasm --adapt wasi_snapshot_preview1.wasm.
when trying to load it with Component::from_file I get an error depending on if I try to use project.wasm or project.wasi.wasm, either "import testwasi not defined" or the feature disabled one, I think I need a version of wasmtime_wasi::add_to_linker(&mut linker, |s| s) for the Component linker, but I'm not sure and stuck

view this post on Zulip Pat Hickey (Jan 23 2023 at 18:59):

if its asking for testwasi that is an interface that exists solely for testing inside the wit-component project, and shouldn't be used elsewhere

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:03):

the current work in progress on wasi preview 2, using components, is at https://github.com/bytecodealliance/preview2-prototyping/ . it has limited functionality and is under active development

Polyfill adapter for preview1-using wasm modules to call preview2 functions. - GitHub - bytecodealliance/preview2-prototyping: Polyfill adapter for preview1-using wasm modules to call preview2 func...

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:04):

so please if you use that expect it to be changing underneath you pretty frequently

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:04):

also, there are known bugs with using the preview 2 prototype adapter with the current rustc, the rust guest may stomp on memory the adapter is using, that fix will land in nightly in a little bit

view this post on Zulip Ramon Klass (Jan 23 2023 at 19:05):

maybe I compiled my wasi_snapshot_preview1.wasm wrongly?
I ran RUSTFLAGS="-Clink-args=--import-memory -Clink-args=-zstack-size=0" cargo build --release --target=wasm32-unknown-unknown in wit-bindgen/crates/wasi_snapshot_preview1

view this post on Zulip Ramon Klass (Jan 23 2023 at 19:07):

thanks a lot I will look into that and yes I don't expect it to work out of the box in such an early state, but I would love to learn about and follow along with the active development so I know when it feels ready to use for mor than experiments :)

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:09):

yeah, that crate inside wit-bindgen is the one thats just for testing purposes

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:09):

we probably should have named the directory testwasi or something

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:11):

you can grep for the implementation of testwasi inside that repo, but basically it just gives us the ability to print-debug

view this post on Zulip Pat Hickey (Jan 23 2023 at 19:11):

its a smoke test to show that adapters work at all


Last updated: Nov 22 2024 at 17:03 UTC