Skip to content

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

Closed

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

Activity

  1. TartanLlama commented on Feb 4, 2026

    @TartanLlama

    Yeah this all matches my expectations

  2. dicej commented on Feb 4, 2026

    @dicej
    Collaborator

    Thanks for writing this up, Alex.

    There are no ABI compatibility guarantees across major WASI-SDK releases anyway, so prominent users of dynamic linking (such as the Python ecosystem) should be prepared for this kind of thing already.

  3. alexcrichton commented on Feb 4, 2026

    @alexcrichton
    CollaboratorAuthor

    That's true yeah that there's no guaranteed ABI stability, but so far wasi-sdk has practically been quite ABI-stable so I could imagine mixing artifacts across versions still comes up, if only by accident. An example of this is wasm-ld in rust-lang/rust. The version that rust-lang/rust ships is using whatever LLVM version rustc is using, but this is not tied to the exact same version that wasi-sdk used in CI (and used to ship libc.a with thewasm32-wasipN targets) is built with. Minor discrepancies like that still come up and are generally expected to work. That's where for rust-lang/rust we'll need to carefully coordinate the update there w.r.t. and LLVM release and a wasm32-wasip3 target, but those are details I'm confident we can handle.

  4. cpetig commented on Feb 4, 2026

    @cpetig

    Thanks for writing this down in this detail, Alex!

    As a bleeding edge user of the LLVM patches which enable 🧵 support I was hoping that (1) and (6) would be some days away from each other. Thus, I asked for avoiding a wasip3 release which doesn't already use the new context.get 0 for stack pointer. For wasi-sdk this should be possible as including a development version of LLVM containing the change would be possible, though somewhat more risky than only using upstream releases.

    But I can understand that for the Rust project relying on patched pre-releases of LLVM is not an option. And making an exception for a single tier3 target sounds outrageous. Delaying the LLVM 22 transition in wasi-sdk for the other targets to wait for p3 readiness feels also wrong.

    In an ideal world any compiler targeting wasip3 and referencing the no-longer-pre-release-dated WASI interfaces would already use context.get 0 from the get go. This way, there might be evolving thread primitives in the libraries, but at least the object files would be compatible across any wasip3 toolchain.

    My feeling is that the LLVM changes for context.get are unchanging in the upcoming months and only the libraries would evolve. So there might be a chance of including these at an early stage when the full 🧵 support is not yet finalized. (Given the history of wasi32-unknown-unknown being incompatible between Rust and C for years, I really believe any quick decisions would be a mistake. Even if it would work out my way here.)

    Having a Rust release which is binary incompatible to a C SDK release, because one side transitioned to context.get first, sounds like a bad user experience for wasip3. But I really don't know whether it is possible to avoid this situation.

  5. alexcrichton commented on Feb 5, 2026

    @alexcrichton
    CollaboratorAuthor

    If a Rust target of wasm32-wasip3 ships before the context.get changes, then it's definitely guaranteed that there'll be a period of time where the latest wasi-sdk and the latest Rust stable differ. This is just due to the nature of Rust's release trains and how Rust needs to bundle wasi-sdk artifacts, so wasi-sdk needs to be released first.

    I'm bullish on being able to pull this off myself. A key part of the problem with wasm32-unknown-unknown in Rust was that an existing user (wasm-bindgen) heavily relied on the "broken" ABI and didn't have a transition to the "correct" ABI. That ingredient is missing here as mixing C/Rust with different versions of LLVM will be broken and difficult to rely on the broken-ness.

    I'll definitely acknowledge though that what exactly happens here will be highly dependent on the precise timelines. If we don't release WASIp3 til October then that changes a lot of this. If wasi-libc's WASIp3 port isn't ready to October that also changes things. Given that we can also reconvene here right before "pulling the trigger" of sorts and publishing a wasi-sdk with wasm32-wasip3 as a target. Doing such implies WASIp3 is released (spec-wise) and wasi-libc is ready implementation-wise. If LLVM-with-context.get is mere weeks away it seems reasonable to delay, but if we're looking at 6-12 months then that's a different situation (IMO)

  6. sbc100 commented on Feb 5, 2026

    @sbc100
    Member

    So is the plan to have a separate LLVM mode for "context.get" vs "global.get"? Is there a patch for this already? I think it might be good idea to align with shared everything threads if this is the plan since shared everything threads also need to move away from using global.get for SP & TLS base. (CC @tlively )

    I guess its also a fairly easy transform to convert a binary from one standard to the other using something like a binaryen pass?

  7. alexcrichton commented on Feb 6, 2026

    @alexcrichton
    CollaboratorAuthor

    I believe the work-in-progress PR is at llvm/llvm-project#175800. My impression is that this strategy loosely corresponds with the predicted direction of shared-everything-threads where there'll be something dedicated to the stack pointer which isn't global.{get,set}. If new wasm opcodes come around we'd likely define context.{get,set} in the component model to be exactly those opcodes and otherwise if it's "host magic" then things are already set up to take advantage of that.

    And yeah it should be relatively simple to binary translate between various options. We already plan on doing so for the web embedding of components where global.{get,set} is likely to be sufficient and the JS host can manage as appropriate.

  8. tlively commented on Feb 6, 2026

    @tlively
    Member

    There is no consensus on how stack pointers will ultimately work with shared-everything threads and there is no path to achieving consensus until prototype implementations have made significantly more progress. The expected timescale for that is significantly longer than anything else mentioned in this thread.

    But my understanding is that the component model folks have designed context.get with this uncertainty in mind and are comfortable moving forward ahead of shared-everything threads. I just want to make sure everyone is on the same page about how uncertain this is.

  9. cpetig commented on Feb 6, 2026

    @cpetig

    Thank you, Alex!

    Your proposal to decouple the global vs context.get transition from the wasip2 to wasip3 transition is very elegant and dispels my concerns.

  10. TartanLlama commented on Feb 21, 2026

    @TartanLlama

    When that LLVM patch lands, what do we think about having some experimental threading channel release of wasi-sdk? This could enable users to try out the support without having to build one manually, and it could help enable wasi-libc development, where we can guard parts that require the new ABI behind #ifdef __wasm_component_model_thread_context__. This way, we can test both ABIs side by side in CI, enabling easier merging of pthreads changes without affecting the non-experimental channel. Then when an LLVM release drops with the new ABI, the only thing that would change is the default ABI, wasi-libc would already be good to go.

  11. alexcrichton commented on Feb 23, 2026

    @alexcrichton
    CollaboratorAuthor

    @TartanLlama do you mean two builds of the same wasi-sdk source? Or two builds of two different sources? If the former, is the idea that one source's lack of flags would produce one output while another source's passing-of-flags would produce a different output? (e.g. different defaults in LLVM itself)

  12. TartanLlama commented on Feb 23, 2026

    @TartanLlama

    @alexcrichton I mean a branch of wasi-sdk with the LLVM submodule pinned to some version that contains the threading patches, and a GitHub release marked as "pre-release". The LLVM version in the experimental branch would compile with the component-model-thread-context feature for WASIp3 by default. The main branch of wasi-sdk would be unaffected. Eventually, the patches would make it into an official LLVM release, at which point the main branch of wasi-sdk would change its LLVM version to target the new release tag and make a proper (non "pre-release") release. Anyone using that new wasi-sdk release would then get the new ABI, but could opt-out of it by passing -mno-component-model-thread-context if they really need the old one.

  13. TartanLlama commented on Feb 23, 2026

    @TartanLlama

    More specifically, say the LLVM patches landed today in commit 00fcafe. wasi-sdk would make an experimental-threading branch with LLVM pinned to 00fcafe. It would make a GitHub pre-release called wasi-sdk-experimental-threading-1. Anyone using existing wasi-sdk releases or upgrading to later non-pre-release versions is unaffected.

    Anyone who wants to try the experimental threading uses the wasi-sdk-experimental-threading-1 release. When targeting wasm32-wasip3, this produces executables targeting the new ABI, because that's what LLVM@00fcafe will do. We add a new CI job to wasi-libc that builds only a wasi32-wasip3 toolchain against wasi-sdk-experimental-threading-1 and runs the test suite.

    In the development of wasi-libc, we develop anything that requires the new ABI behind #ifdef that will only pass with LLVM@00fcafe. WASIp3 development that does not rely on the new ABI can continue as before. We can merge the pthreads implementation in piece-by-piece, tested against the experimental toolchain.

    When an official LLVM release is made that includes support for the new ABI, the experimental-threading branch of wasi-sdk is closed, the LLVM version in main is pinned to the new release, a new official wasi-sdk release (say, wasi-sdk-31) is made with that version of LLVM. Users who upgrade to wasi-sdk-31 and are targeting WASIp3 now get the new ABI by default, with an escape hatch for those who need it.

  14. sbc100 commented on Feb 23, 2026

    @sbc100
    Member

    While I think its reasonable to have some kind of bleeding edge branch/build that tracks LLVM tip-of-tree, I think it would be great in wasm-sdk could avoid forking llvm (i.e. we should avoid tracking changes that have not yet landed on the LLVM side).

    I'm not sure if that is what you are suggesting but I thought I would warn against it anyway :)

  15. sbc100 commented on Feb 23, 2026

    @sbc100
    Member

    (Obviously its trivial for a fork of wasi-sdk to track a fork a llvm, but we should avoid it upstream if we can IMHO)

  16. TartanLlama commented on Feb 23, 2026

    @TartanLlama

    While I think its reasonable to have some kind of bleeding edge branch/build that tracks LLVM tip-of-tree, I think it would be great in wasm-sdk could avoid forking llvm

    Agreed! I'm suggesting we wait until the LLVM patch for the new ABI lands in trunk LLVM and target that.

  17. alexcrichton commented on Feb 23, 2026

    @alexcrichton
    CollaboratorAuthor

    Ok yeah that sounds reasonable to me. There was a similar request for C++ exceptions, where once there's infrastructure here for wasi-sdk I think it'd be reasonable to do that for exceptions too perhaps.

    Currently there's no infrastructure for a tagged release like that in this repository. I think tags are required to be wasi-sdk-\d+ at the moment given how version.py works, but this is a pretty minor thing all-things-considered. How about this: @TartanLlama if you want to ping me when the LLVM PR merges I'll fork off an experimental-threading branch in this repository from main. If you can work on ensuring that a tagged release can be made with a tag name such as wasi-sdk-experimental-therading-1 (seems as reasonable a name as any to me) we can land both those changes on main and the experimental-threading branch. I can then push up a tag which should trigger the whole release and I can mark it as a pre-release in this repo.

    FWIW for the exceptions-based build I hacked around it with this to produce final artifacts with wasi-sdk-30.1g-exns+m* -- the +m means it's a dirty tree b/c the build applied a patch, and otherwise the 30.1g is just a mangling that is IMO pretty bad and would be best replaced with experimental-threading-1 if possible.

  18. cpetig commented on Jun 9, 2026

    @cpetig

    Agreed! I'm suggesting we wait until the LLVM patch for the new ABI lands in trunk LLVM and target that.

    The patch has landed 🥳 so this preview release would be possible in the near future. With the wasip3 voting tomorrow I guess that a first full p3 compiler has priority.

    (Please contact me if you feel that I can help with this)

  19. alexcrichton commented on Sep 9, 2026

    @alexcrichton
    CollaboratorAuthor

    I believe this is all done now, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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