-
Notifications
You must be signed in to change notification settings - Fork 724
Add WASM32 Platform #4639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add WASM32 Platform #4639
Conversation
f44bb82
to
8a874ce
Compare
what platform is your target? do you have any plan for the CI? |
I've been testing with emscripten, but targeting wasi-sdk. |
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? |
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. |
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. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- wasm32 is a target, but the platform name should be specific, like wasi or emscripten.
- 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.
thread_manager_destroy(); | ||
#endif | ||
|
||
#if WASM_ENABLE_INVOKE_NATIVE != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC WASM_ENABLE_INVOKE_NATIVE
is designed to prevent the involvement of runtime built-in functions. In that case, -DWAMR_BUILD_LIBC_BUILTIN=0 -DWAMR_BUILD_LIBC_WASI=0
can achieve the same effect, along with -DWAMR_BUILD_QUICK_AOT_ENTRY=0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess it's a good opportunity to replace the heavy ifdef conditions with something easier to maintain.
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. |
I generally use emscripten's toolchain but pass the
The posix mini target seems to work out of the box with WASI, I'll see about getting the build script setup for that. |
#include "platform_common.h" | ||
|
||
#if !defined(__wasm32__) && !defined(__EMSCRIPTEN__) | ||
#include "platform_wasi_types.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you avoid using platform_wasi_types.h?
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. |
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.