Skip to content

Conversation

@TartanLlama
Copy link
Contributor

@TartanLlama TartanLlama commented Jan 8, 2026

Adds the co-op threading builtins for the component model to the C generator. This is needed for work on wasip3 in wasi-libc.

Some design decisions we may want to go a different way on:

  • Introduces two breaking changes:
    • context_get/set now take an additional parameter indicating which context slot to operate on. We could maintain the old versions, but I think this will be an easy fix for anyone who is using them.
    • <world>_yield has been renamed <world>_thread_yield for parity with the other builtins. I think this is a similarly easy fix for users.
  • Does not put the new builtins behind a flag: if any async functions are required, the new builtins are also included. The knock-on effect is that users of async with wasmtime would need to additionally specify -W component-model-threading -W component-model-async-stackful, or they would see instantiation errors indicating to add those flags. I'm happy to split them out if we think that's the best approach.
  • Added a new --generate-async-helpers flag to force generation of the async helpers in situations where you don't have any futures or functions marked async, but you still want the threading builtins.

Rust support can be done in a follow-up PR; I'm not familiar with the design of the Rust guest generator, so focused on this part that is needed for wasi-libc.

@alexcrichton alexcrichton added this pull request to the merge queue Jan 9, 2026
Merged via the queue into bytecodealliance:main with commit 56d49b4 Jan 9, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants