feat(wasi): add wasm32-wasi as a compile target#13
Open
rioam2 wants to merge 3 commits intomsvetkin:mainfrom
Open
feat(wasi): add wasm32-wasi as a compile target#13rioam2 wants to merge 3 commits intomsvetkin:mainfrom
rioam2 wants to merge 3 commits intomsvetkin:mainfrom
Conversation
73fd21b to
9f9f295
Compare
096dd02 to
a3c7db1
Compare
rioam2
commented
Jul 25, 2024
| { os: ubuntu-latest, preset: x64-linux-gcc-dynamic }, | ||
| { os: ubuntu-latest, preset: x86-linux-gcc-dynamic }, | ||
| { os: ubuntu-latest, preset: x64-linux-clang-dynamic }, | ||
| { os: ubuntu-latest, preset: x86-linux-clang-dynamic }, |
Contributor
Author
There was a problem hiding this comment.
This was removed from .github/ci.yaml in 5efee87, so I removed it here in .github/workflows/ci.yaml as well. It fails due to missing libc++abi on x86
rioam2
commented
Jul 25, 2024
| with: | ||
| name: logs-${{matrix.target.preset}} | ||
| path: | | ||
| /usr/local/share/vcpkg/**/*.log |
Contributor
Author
There was a problem hiding this comment.
Not necessary for this PR, but adds a nice way to debug issues in CI.
Can be removed and put up as a separate PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #9
This PR adds support for cross-compiling to wasm32-wasi as a CMake target. It builds on top of the
wasm32-wasitoolchain here, and more accurately, wasi-sdk.The example contained in this PR exposes a WebAssembly interface following the reactor model. In other words, it is an example module that exposes functions that can be called in reaction to events on the host.
Usage information from README:
If you wish to expose parts of your library as a WebAssembly module, you can add the
extern "C" __attribute__((export_name("<my_function_name>")))annotation to any function you wish to expose insrc/wasm/interface.cpp, and compile using thewasm32-wasi-clangpreset. This will generate a minimal WebAssembly binary exposing your exported functions atbuild/<PRESET>/src/wasm/<Debug|Release|RelWithDebInfo>/lib<PROJECT_NAME>.wasm. This binary conforms to the WASI WebAssembly standard, so it can be utilized in any WASI-supporting runtime likewasmer.ioor wasmtime.A WebAssembly version of your CLI will also be available:
Note
Exposed WebAssembly functions currently only accept parameters and return values of numerical type. This is how core WebAssembly files work, and without additional glue-code or binding generators like wit-bindgen, complex data-types cannot be sent over the runtime's ABI boundary. Complex data must be transferred via pointer and serialized bytes in exported/shared memory.
Acknowledgements:
stack_tand signal support, which has not yet been implemented in wasi-sdk. A custom port for this library is loaded from https://github.com/rioam2/vcpkg-wasm32-wasidup, which is not implemented in libc, and therefore wasi-sdk. As such, a custom port for this library is loaded from https://github.com/rioam2/vcpkg-wasm32-wasifmtandcatch2with wasm32-wasi that has not been upstreamed.