Repository navigation
Description
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 incontext.get 0 - A thread's TLS address is not stored in a
global, it's incontext.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:
- In the near future, WASIp3 is published. At this time component-model-async is considered finalized and cannot have breaking changes.
- Shortly thereafter, the
wasm32-wasip3target is added to wasi-sdk and published here. - Shortly thereafter, the
wasm32-wasip3target is added to rust-lang/rust and published there. - Embedders, toolchains, libraries, etc, would start adding support, as appropriate, for
wasm32-wasip3and support would percolate throughout the ecosystem. - Development of 🧵 continues, using
wasm32-wasip3as a target. This will culminate in patches to LLVM, wasi-libc, and Rust for example. - Eventually an LLVM release will be made with 🧵 support. My expectation is that, at this time, the
wasm32-wasip3target unconditionally uses the new ABI and has no option to go back to using the old ABI. The old ABI is still used onwasm32-wasip2-and-prior. - This LLVM release is then pulled into wasi-sdk and a version of wasi-sdk is published. Rust updates quickly thereafter with this update.
- Artifacts produced before this LLVM release for
wasm32-wasip3are just incomptatible with artifacts produced after the LLVM release. Probably some sort ofwasm-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
TartanLlama commentedon Feb 4, 2026
Yeah this all matches my expectations
dicej commentedon Feb 4, 2026
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.
alexcrichton commentedon Feb 4, 2026
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.awith thewasm32-wasipNtargets) 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 awasm32-wasip3target, but those are details I'm confident we can handle.cpetig commentedon Feb 4, 2026
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 0for 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 0from 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.getare 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 ofwasi32-unknown-unknownbeing 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.getfirst, sounds like a bad user experience for wasip3. But I really don't know whether it is possible to avoid this situation.alexcrichton commentedon Feb 5, 2026
If a Rust target of
wasm32-wasip3ships before thecontext.getchanges, 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-unknownin 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-wasip3as a target. Doing such implies WASIp3 is released (spec-wise) and wasi-libc is ready implementation-wise. If LLVM-with-context.getis mere weeks away it seems reasonable to delay, but if we're looking at 6-12 months then that's a different situation (IMO)sbc100 commentedon Feb 5, 2026
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.getfor 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?
alexcrichton commentedon Feb 6, 2026
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 definecontext.{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.tlively commentedon Feb 6, 2026
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.getwith 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.cpetig commentedon Feb 6, 2026
Thank you, Alex!
Your proposal to decouple the global vs
context.gettransition from the wasip2 to wasip3 transition is very elegant and dispels my concerns.TartanLlama commentedon Feb 21, 2026
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.alexcrichton commentedon Feb 23, 2026
@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)
TartanLlama commentedon Feb 23, 2026
@alexcrichton I mean a branch of
wasi-sdkwith 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 thecomponent-model-thread-contextfeature for WASIp3 by default. Themainbranch ofwasi-sdkwould be unaffected. Eventually, the patches would make it into an official LLVM release, at which point themainbranch ofwasi-sdkwould change its LLVM version to target the new release tag and make a proper (non "pre-release") release. Anyone using that newwasi-sdkrelease would then get the new ABI, but could opt-out of it by passing-mno-component-model-thread-contextif they really need the old one.TartanLlama commentedon Feb 23, 2026
More specifically, say the LLVM patches landed today in commit
00fcafe.wasi-sdkwould make anexperimental-threadingbranch with LLVM pinned to00fcafe. It would make a GitHub pre-release calledwasi-sdk-experimental-threading-1. Anyone using existingwasi-sdkreleases or upgrading to later non-pre-release versions is unaffected.Anyone who wants to try the experimental threading uses the
wasi-sdk-experimental-threading-1release. When targeting wasm32-wasip3, this produces executables targeting the new ABI, because that's what LLVM@00fcafewill do. We add a new CI job towasi-libcthat builds only a wasi32-wasip3 toolchain againstwasi-sdk-experimental-threading-1and runs the test suite.In the development of
wasi-libc, we develop anything that requires the new ABI behind#ifdefthat 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-threadingbranch ofwasi-sdkis closed, the LLVM version inmainis pinned to the new release, a new officialwasi-sdkrelease (say,wasi-sdk-31) is made with that version of LLVM. Users who upgrade towasi-sdk-31and are targeting WASIp3 now get the new ABI by default, with an escape hatch for those who need it.sbc100 commentedon Feb 23, 2026
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 :)
sbc100 commentedon Feb 23, 2026
(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)
TartanLlama commentedon Feb 23, 2026
Agreed! I'm suggesting we wait until the LLVM patch for the new ABI lands in trunk LLVM and target that.
alexcrichton commentedon Feb 23, 2026
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 howversion.pyworks, 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 anexperimental-threadingbranch in this repository frommain. If you can work on ensuring that a tagged release can be made with a tag name such aswasi-sdk-experimental-therading-1(seems as reasonable a name as any to me) we can land both those changes on main and theexperimental-threadingbranch. 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+mmeans it's a dirty tree b/c the build applied a patch, and otherwise the30.1gis just a mangling that is IMO pretty bad and would be best replaced withexperimental-threading-1if possible.cpetig commentedon Jun 9, 2026
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)
alexcrichton commentedon Sep 9, 2026
I believe this is all done now, so closing.