wasmi icon indicating copy to clipboard operation
wasmi copied to clipboard

Implement support for running `wasm32-wasi` compiled Wasm binaries

Open Robbepop opened this issue 3 years ago • 6 comments

The WebAssembly System Interface (WASI) is an important part at enabling support for a wide variety of WebAssembly targets. With wasmi_v1 and its Linker definition it should be very straight forward to implement WASI support for the wasmi interpreter.

Ideally the entire WASI implementation resides in a new sub-crate of the wasmi workspace, called wasi. This sub-crate implements the WASI interface and provides extension methods for the wasmi_v1::Linker to add WASI support.

As a follow-up feature we could provide an executable for wasmi_v1 that runs input .wasm or .wat files using WASI support out of the box as it is done in Wasmtime.

As an overview of what needs to be implemented you can inspect: https://doc.rust-lang.org/std/os/wasi/index.html The Wasmtime implementation of WASI is also a place to look out for inspiration. Technically we could also use it as a common ground for our WASI support.

Robbepop avatar Feb 12 '22 14:02 Robbepop

Would certainly love to work on this @Robbepop

OLUWAMUYIWA avatar Sep 18 '22 17:09 OLUWAMUYIWA

Would certainly love to work on this @Robbepop

I would certainly appreciate help with this issue! Please feel free to let me know what you need to know and how I can help you with work on this. :)

As a follow-up feature we could provide an executable for wasmi_v1 that runs input .wasm or .wat files using WASI support out of the box as it is done in Wasmtime.

The situation here has significantly improved since creation of the issue since we now have wasmi_cli which is a CLI tool to invoke .wasm and .wat files using wasmi. Therefore as a follow-up we really would love for this CLI tool to have WASI support out of the box. Link to wasmi_cli: https://github.com/paritytech/wasmi/tree/master/cli

Robbepop avatar Sep 18 '22 17:09 Robbepop

Thanks! I will implement it in drafts. If I need help, I'll let you know.

OLUWAMUYIWA avatar Sep 20 '22 02:09 OLUWAMUYIWA

In case you were not already aware of the Wasmtime wasi-common crate: https://crates.io/crates/wasi-common/1.0.0

I think it might suite as a good foundation for WASI support in wasmi.

Robbepop avatar Sep 22 '22 05:09 Robbepop

Yes I found it while looking around. I'm making use of it. Thanks!

OLUWAMUYIWA avatar Sep 22 '22 13:09 OLUWAMUYIWA

@OLUWAMUYIWA how is it going with the wasmi WASI implementation so far? Do you need any help or can we somehow support you?

Robbepop avatar Oct 17 '22 13:10 Robbepop

Hi Rob. Apologies. I got stuck at some point. Rather than getting unstuck, I paused and got busier. Still interested. Will pick it up again tomorrow, and ask you some questions. Is there a discord?

OLUWAMUYIWA avatar Oct 18 '22 13:10 OLUWAMUYIWA

Thank you for the response @OLUWAMUYIWA . Looking forward to answer all your questions. :) I was just curious which is why I asked. The folks at CNCF would really love to have WASI support for wasmi though. ^.^

Robbepop avatar Oct 18 '22 13:10 Robbepop

@OLUWAMUYIWA I just sent you an e-Mail with my Discord handle. :) (Did not want to post that publicly here.)

Robbepop avatar Oct 26 '22 07:10 Robbepop