Skip to content

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

Open
rvolosatovs wants to merge 2 commits into
bytecodealliance:mainfrom
rvolosatovs:feat/custom-fiber
Open

feat: allow custom fiber API impls on unsupported arches#13620
rvolosatovs wants to merge 2 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 2 times, most recently from b3a252b to f2c42ca Compare June 12, 2026 10:00
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@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
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
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
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