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
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
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
so please if you use that expect it to be changing underneath you pretty frequently
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
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
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 :)
yeah, that crate inside wit-bindgen is the one thats just for testing purposes
we probably should have named the directory testwasi or something
you can grep for the implementation of testwasi inside that repo, but basically it just gives us the ability to print-debug
its a smoke test to show that adapters work at all
Last updated: Dec 23 2024 at 13:07 UTC