swiftwasm / WasmKit

WebAssembly Runtime written in Swift
https://swiftpackageindex.com/swiftwasm/WasmKit/main/documentation/wasmkit
MIT License
226 stars 8 forks source link

WASI Preview 2/component model support #105

Open bacongobbler opened 3 months ago

bacongobbler commented 3 months ago

Hey there! Really cool project.

I was curious to see if one someone from the community is interested in adding support for applications that have been compiled against WASI preview 2 and the component model.

For some background context, I'm really interested in embedding a library compiled to WebAssembly into an iOS app. My library has been compiled to WASI via Rust's wasm32-wasi-preview2 target and I'm looking to see how many different devices I can currently embed that library into.

Is there a limitation preventing this project from supporting WASI preview 2 and/or the component model? Are there alternative runtimes available with wasip2 support that you're aware of?

Thank you!

kateinoigakukun commented 3 months ago

Currently, we support generating overlay (bindgen in Rust terminology) code from WIT file for both host runtime side and guest Wasm program side, and the generated code allows lifting / lowering Canonical ABI values.

https://github.com/swiftwasm/WasmKit/tree/main/Sources/WITOverlayGenerator

However, we currently don't implement the following features at this moment, so WasmKit might not satisfy your use case right now, but I'm definitely interested in fully supporting CM in the future. It's just a human resource limitation.

An alternative solution for you I have in mind is jco, which allows lowering a component into core modules and JS glue code. I think you can use the tool with JavaScriptCore engine for now, but I've never tried it.