wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Add WASM32 Platform

Open basicer opened this issue 3 months ago • 10 comments

Adds WASM32 as a new platform, allowing it provide an implementation of the wasm-c-api interpreter to applications that themselves want to be compiled to wasm.

basicer avatar Sep 20 '25 19:09 basicer

what platform is your target? eg. wasi, emscripten, ... it's might be better to name the core/shared/platform bits accordingly.

do you have any plan for the CI?

yamt avatar Sep 22 '25 01:09 yamt

I've been testing with emscripten, but targeting wasi-sdk.

basicer avatar Sep 22 '25 06:09 basicer

Sorry, but I don't fully understand the use case of this PR. Does it mean a wasm32-wasi version of wamr which is compiled by wasi-sdk or emscripten?

lum1n0us avatar Sep 22 '25 07:09 lum1n0us

The idea is that for applications that use the wasm-c-api, those applications can still run in the browser by embedding WAMR as the wasm runtime, and allowing WARM to be built for the browser.

basicer avatar Sep 22 '25 07:09 basicer

A browser use the WASM runtime via wasm-c-api to execute wasm32-wasi or wasm32-emscripten? WAMR is still a native library for the browser.

lum1n0us avatar Sep 22 '25 07:09 lum1n0us

Here is an example use case: https://github.com/ashtonmeuser/godot-wasm/pull/78 That is a plugin for the Godot game engine that allows it to load gameplay logic written in webassembly. The game engine runs on many platforms, but also in the browser. To support running in the browser, some tweaks were needed to WAMR to add WASM32 as a platform.

basicer avatar Sep 22 '25 18:09 basicer

Here is an example use case: ashtonmeuser/godot-wasm#78 That is a plugin for the Godot game engine that allows it to load gameplay logic written in webassembly. The game engine runs on many platforms, but also in the browser. To support running in the browser, some tweaks were needed to WAMR to add WASM32 as a platform.

i'm a bit confused. the project states wasmtime and wasmer support. i don't think they (or any jit-based runtimes) can run on wasm. is the combination just currently not supported?

yamt avatar Sep 24 '25 02:09 yamt

i'm a bit confused. the project states wasmtime and wasmer support. i don't think they (or any jit-based runtimes) can run on wasm. is the combination just currently not supported?

Right. Currently that plugin doesn't support the web build. I'm adding WAMR support to that project specifically because it seemed feasible to port WARM's faster interpreter to WASM.

basicer avatar Sep 24 '25 17:09 basicer

  • wasm32 is a target, but the platform name should be specific, like wasi or emscripten.

I generally use emscripten's toolchain but pass the -sPURE_WASI=1 option such that it generates executables that can be run on the command line with WASI hosts. What platform would you consider that?

  • If it's not too much trouble, please create a mini product for the platform to demonstrate how it works. We can then add the corresponding steps in CI.

The posix mini target seems to work out of the box with WASI, I'll see about getting the build script setup for that.

basicer avatar Sep 24 '25 17:09 basicer

  • wasm32 is a target, but the platform name should be specific, like wasi or emscripten.

I generally use emscripten's toolchain but pass the -sPURE_WASI=1 option such that it generates executables that can be run on the command line with WASI hosts. What platform would you consider that?

Seems like emscripten would be the correct choice for platform here. Practically, as it applies to https://github.com/ashtonmeuser/godot-wasm, emscripten is also what Godot uses to build for the web.

Although a case could be made for WAMR to have a generic unknown platform akin to Rust's wasm32-unknown-unknown target.

ashtonmeuser avatar Oct 02 '25 04:10 ashtonmeuser