Skip to content

Make component-model-async feature no_std-compatible #13533

Merged
alexcrichton merged 4 commits into
bytecodealliance:mainfrom
alexcrichton:async-nostd
Jun 2, 2026
Merged

Make component-model-async feature no_std-compatible #13533
alexcrichton merged 4 commits into
bytecodealliance:mainfrom
alexcrichton:async-nostd

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

@alexcrichton alexcrichton commented Jun 2, 2026

This commit goes through the remaining bits of Wasmtime's
component-model-async feature and gets everything compiling with
no_std targets. The notable changes here are:

  • Two Mutexes were replaced with a new custom TryMutex type. Usage
    panics on contention because contention should not be possible in the
    current architecture.

  • TLS has been extended in the custom API to take an index of which
    TLS slot to access. Notably Wasmtime now requires two TLS slots
    instead of one.

Note: this is currently rebased on #13532

@alexcrichton alexcrichton requested review from a team as code owners June 2, 2026 02:27
@alexcrichton alexcrichton requested review from fitzgen and pchickey and removed request for a team June 2, 2026 02:27
@github-actions github-actions Bot added wasi Issues pertaining to WASI wasmtime:api Related to the API of the `wasmtime` crate itself labels Jun 2, 2026
This commit goes through the remaining bits of Wasmtime's
`component-model-async` feature and gets everything compiling with
`no_std` targets. The notable changes here are:

* Two `Mutex`es were replaced with a new custom `TryMutex` type. Usage
  panics on contention because contention should not be possible in the
  current architecture.

* TLS has been extended in the `custom` API to take an index of which
  TLS slot to access. Notably Wasmtime now requires two TLS slots
  instead of one.

prtest:full
///
/// The returned `TryMutexGuard` is an RAII guard to unlock this lock when
/// dropped.
pub fn try_lock(&self) -> Option<TryMutexGuard<'_, T>> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should return a Result<TryMutexGuard> and bail_bug! on contention?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked this idea, then realized I should also be adding at least a simple smoke test for this type, then realized that bail_bug! would make this more difficult to test. Given that I think this'll stay as-is as I think it might still be a useful primitive elsewhere for "just make this thing Sync and/or `"just make this thing mutable" in cases where contention may or may not be fatal.

@alexcrichton alexcrichton enabled auto-merge June 2, 2026 21:01
@alexcrichton alexcrichton added this pull request to the merge queue Jun 2, 2026
Merged via the queue into bytecodealliance:main with commit 0402a1c Jun 2, 2026
193 checks passed
@alexcrichton alexcrichton deleted the async-nostd branch June 2, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants