Skip to content

WASIp3, threading ABI changes, LLVM releases, and schedules #589

@alexcrichton

Description

@alexcrichton

WASIp3 is nearing publication, and with it async support in the component model. This is expected to be manifested in a new target, wasm32-wasip3, alongside existing targets. This is also expected to be manfiested into other ecosystems, such as Rust, as well. Spec-level documentation for the component model is in the explainer and marked with 🔀.

Another related component-model change coming down the pike "soon" is support for cooperative threading in the component model. This is annoted in the spec with the 🧵 emoji. The implementation of cooperative threading is not as far along as the implementation of async support + WASIp3 APIs at this current time, but it is well under way.

A major change coming with 🧵 is that the ABI of functions is going to change in two ways:

  • The in-wasm shadow stack pointer will no longer be stored in a global, it's in context.get 0
  • A thread's TLS address is not stored in a global, it's in context.get 1

These are mostly invisible changes to higher-level users but major changes from an ABI level. These changes require the component-model-async proposal as well as 🧵 and thus are expected to be exclusively scoped to the wasm32-wasip3 target. Preexisting targets, such as wasm32-wasip1, wasm32-wasip2, and wasm32-wasip1-threads are all going to be unaffected.

I'm going to set aside for now the rationale for these changes insofar as that's more of a technical discussion to have elsewhere (in theory). Instead what I'd like to focus on in this issue is the scheduling of releases for all of this. Given where the development of all this is, my personal understanding is:

  • Implementation, specification, and support for WASIp3 and component-model-async are "nearly done".
  • Implementation, specification, and support for 🧵 is underway, but still much more experimental than async support.
  • Some folks expect WASIp3+async to be released first with 🧵 layered on afterwards. Some folks expect the opposite.

My personal rough estimation is that if 🧵 were to block a wasm32-wasip3 target then it would be on the order of ~6-12 months between WASIp3+async being "done" and shipping a usable target. WASIp3 and async are usable-ish on a wasm32-wasip2 target (that's how all development has gone so far), but it's easy to get things mixed up and have wires crossed accidentally. Put another way, power users could get things done, but it's an uphill battle trying to exclusively use preexisting targets for WASIp3 + async.


Given all this, this is where I wanted to outline my personal thoughts for how to thread these needles. Specifically what I'm imaginging is:

  1. In the near future, WASIp3 is published. At this time component-model-async is considered finalized and cannot have breaking changes.
  2. Shortly thereafter, the wasm32-wasip3 target is added to wasi-sdk and published here.
  3. Shortly thereafter, the wasm32-wasip3 target is added to rust-lang/rust and published there.
  4. Embedders, toolchains, libraries, etc, would start adding support, as appropriate, for wasm32-wasip3 and support would percolate throughout the ecosystem.
  5. Development of 🧵 continues, using wasm32-wasip3 as a target. This will culminate in patches to LLVM, wasi-libc, and Rust for example.
  6. Eventually an LLVM release will be made with 🧵 support. My expectation is that, at this time, the wasm32-wasip3 target unconditionally uses the new ABI and has no option to go back to using the old ABI. The old ABI is still used on wasm32-wasip2-and-prior.
  7. This LLVM release is then pulled into wasi-sdk and a version of wasi-sdk is published. Rust updates quickly thereafter with this update.
  8. Artifacts produced before this LLVM release for wasm32-wasip3 are just incomptatible with artifacts produced after the LLVM release. Probably some sort of wasm-ld-level enforcement with some sort of ABI version

The rough assumption is that (1) and (6) are far enough apart that there's a lot of value to be had in not delaying (1). The other rough assumption is that cross-pollination of artifacts from different versions of LLVM is, as of today, a somewhat niche case which is not rampant and a stable of every project. This in theory uniquely positions this to be able to be pulled off without much disruption. Inevitably some users will cross-pollinate LLVM versions but the theory is that this will be rare enough and something that can be easily rectified if it happens.


So that's all my thoughts on this. I want to cc a number of interested parties here as well to ensure y'all are also all on board with this as well. I also don't want to pretend that any of this is set in stone, if others have other thoughts/ideas please share and we should discuss!

cc @cpetig, @dicej, @lukewagner, @TartanLlama, @tschneidereit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions