Replies: 3 comments
-
That's a use case we didn't foresee when checking WASI imports, but I believe it should be easy to add support to it. Could you attach the generated wasm so we can take a look at the expected name of the import? |
Beta Was this translation helpful? Give feedback.
-
I compiled an "hello world" module with the following [target.wasm32-wasi]
rustflags = [
"-C", "link-args=--import-memory",
] The result of
|
Beta Was this translation helpful? Give feedback.
-
I met with the same case when I imported memory into wasm32-wasi module which was compiled by clang/llvm (v13.0.0). I made a workaround solution by manually inserting an export memory instruction into the wasm code. With the wasm2wat and wat2wasm command tools provided by wabt, I did it like this flow: my_code.wasm ---wasm2wat---> my_code.wat ---manually insert: (export "memory" (memory 0))---> my_modified_code.wat ---wat2wasm---> my_code.wasm It works for me. |
Beta Was this translation helpful? Give feedback.
-
Summary
It seems like it's impossible to run a WASI module that expects the memory to be imported. Is that by design and a limitation of WASI itself or an issue with WASI support in wasmer?
Additional details
I created a wasm32-wasi module in rust by passing the
--import-memory
argument to lld. The resulting wasm-wasi module includes an import from env.memory and it doesn't include a memory export (there is no way to do both in llvm).I then tried to run the module with wasmer (rust) but it fails because it fails to find a memory export. The main issue I think is that it expects memory to be exported due to the annotation in
wasmer/lib/wasi/src/lib.rs
Lines 59 to 60 in 519a403
Without wasi, wasmer works with modules that import memory by giving an import object with env memory. However, with wasi even if you chain your own import object that has a memory import to the wasienv import object it doesn't work. Probably because the code linked above is hard coded only for modules that export memory.
Beta Was this translation helpful? Give feedback.
All reactions