-
Notifications
You must be signed in to change notification settings - Fork 228
WASIP3 threading support #715
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?
Conversation
Almost all functions are stubbed out to return errors. This is all done in preparation for eventually filling out these functions, but the goal of this commit is to lay down the scaffolding of the target rather than actually implement anything. CI jobs are added to build and test this target. Most tests are expected to fail, but all tests are still run as usual. Once tests are passing they'll be updated in `CMakeLists.txt` to flag the test as expected to pass instead of expected to fail. This is a very large PR line-wise, but all the major changes with large chunks of code are generated code and are expected to be easy to review. The actual changes here in the source are primarily: * Adding `#elif defined(__wasip3__)` cases * Sometimes using the WASIp2 definitions of functions for WASIp3 * Shuffling naming in the network utilities to support both WASIp2 and WASIp3 which have the same types, just renamed. * Generated bindings for WASIp3 are now vendored like WASIp2 bindings. * Wasmtime is updated for testing to be able to run generated WASIp3 binaries.
This commit is an improvement to the WASIp2 target which changes how the interface `wasi:cli/run` is defined and exported. Previously the `wasm32-wasip2` target would define a `_start` wasm export which required the use of the WASIp1-to-WASIp2 adapter to hook it up to `wasi:cli/run`. This meant that despite libc not actually using any WASIp2 APIs the adapter was still used. The purpose of this commit is to change this. The changes made here are: * The linker-level `_start` symbol now has a wasm-level export name of `wasi:cli/[email protected]#run`. This means that `_start` isn't a wasm-level export any more, meaning there's nothing for the adapter to import. * The signature of the C-level `_start` function is now different based on WASI version (returns an `int` in WASIp2, nothing on WASIp1) * The `crt1-command.o` object file now contains type information for `wasi:cli/run` (which previously wasn't present anywhere in wasi-libc). This means that when this object is linked in `wit-component` will know what to do after linking. The end result is that binaries are now produced entirely without the WASIp1-to-WASIp2 adapter and linking with `-Wl,--wasi-adapter=none`, for example, produces a working binary. Another minor change made in this commit is that the `crt1-*.c` files are now included in `clang-format` like all other source files. Build-wise this requires the usage of `wasm-tools` at build-time to embed type information in the clang-produced object file for `crt1-command.o`.
|
I think your assembly code to set the initial context from the globals got lost when the new run implementation was integrated. At least for me the initial context 0 (stack pointer) is zero and results in traps. |
|
@cpetig that code is planned to be called by wasm-tools, so that all exports are handled the same way: bytecodealliance/wasm-tools#2417 |
|
To try it out, you'd need to build wasm-component-ld against my wasm-tools branch, and use that as the linker for the executable you're building |
Adds
pthreadsupport for wasip3 based on the component model's cooperative threading builtins.Currently a draft for progress tracking.