bytecodealliance / wasm-tools

CLI and Rust libraries for low-level manipulation of WebAssembly modules
Apache License 2.0
1.27k stars 229 forks source link

`wit-parser::decoding::decode` should error when given a core module #1673

Closed rylev closed 2 weeks ago

rylev commented 1 month ago

wit-parser::decoding::decode requires a WebAssembly component (either as a normal component or as a WIT-package-encoded-as-binary). However, if you pass in a core module, everything "works" (i.e., no error is returned), but you end up with an empty resolve. I imagine the right thing to do here would be to error specifying that a component must be passed.

Let me know if this is the case, and I can submit a fix.

alexcrichton commented 1 month ago

One use case of passing a core module is that there's these *.o files that come out of wit-bindgen with world information and I wanted to support wasm-tools component wit on these files. I don't believe that's tested in this repository though and I'm not sure if it still works at all. That leads me to:

ChristofPetig commented 3 weeks ago

I have used wasm-tools component wit on core modules containing the section in the past and it worked fine. Given the wasit2 idea (core modules with WIT interfaces, see WASI issue #595) I would recommend to go for the second choice.