Skip to content

feat: allow custom fiber API impls on unsupported arches#13620

Merged
rvolosatovs merged 3 commits into
bytecodealliance:mainfrom
rvolosatovs:feat/custom-fiber
Jun 18, 2026
Merged

feat: allow custom fiber API impls on unsupported arches#13620
rvolosatovs merged 3 commits into
bytecodealliance:mainfrom
rvolosatovs:feat/custom-fiber

Conversation

@rvolosatovs

@rvolosatovs rvolosatovs commented Jun 12, 2026

Copy link
Copy Markdown
Member

Add support for custom embedder-supplied fiber implementations, similar to e.g. custom-virtual-memory feature and others that already exist.

I'm not sure whether custom-fiber or custom-stack-switch is more appropriate, went for the one matching the crate name.

For my concrete use case, this is sufficient to allow running Wasmtime with cranelift in interpreter mode using Pulley with async/component-model-async features enabled, compiled to wasm32-unknown-unknown with a bit of JS glue based on JSPI in the browser or node.js

@rvolosatovs rvolosatovs requested a review from a team as a code owner June 12, 2026 09:47
@rvolosatovs rvolosatovs requested review from pchickey and removed request for a team June 12, 2026 09:47
@rvolosatovs rvolosatovs marked this pull request as draft June 12, 2026 09:51
@rvolosatovs rvolosatovs force-pushed the feat/custom-fiber branch 3 times, most recently from f2c42ca to a40269c Compare June 12, 2026 10:02
@rvolosatovs rvolosatovs marked this pull request as ready for review June 12, 2026 10:04
@rvolosatovs rvolosatovs changed the title feat: allow custom fiber APIs feat: allow custom fiber API impls on unsupported arches Jun 12, 2026
Comment thread crates/fiber/src/lib.rs
Comment on lines +37 to +39
mod nostd;
use nostd as imp;
mod stackswitch;

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'm not sure if this should be gated by custom feature, but the comment in stackswitch states:

   // No support for this platform. Don't fail compilation though and
   // instead defer the error to happen at runtime when a fiber is created.
   // Should help keep compiles working and narrows the failure to only
   // situations that need fibers on unsupported platforms.

so this seems consistent

@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Jun 12, 2026

@alexcrichton alexcrichton left a comment

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.

Sounds reasonable to me, thanks!

Structurally though I'd like to plumb this a bit differently to ensure this shows up in the wasmtime-platform.h header file. That header is generated from this file and is the current source-of-truth for "wasmtime may externally rely on these things" and provides a nice place to document things as well.

Now if these C API definitions were added over there they wouldn't actually be usable in wasmtime-internal-fiber due to crate dependencies, but that's also fine to have them duplicated here. Basically, can you add these function definitions over there, document them as to their purpose, leave a provisional comment in both locations saying "hey this is duplicated over there keep them in-sync", and then regenerate the header file?

@pchickey pchickey removed their request for review June 12, 2026 17:48
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@rvolosatovs rvolosatovs added this pull request to the merge queue Jun 18, 2026
Merged via the queue into bytecodealliance:main with commit a260163 Jun 18, 2026
52 checks passed
@rvolosatovs rvolosatovs deleted the feat/custom-fiber branch June 18, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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