Repository navigation
[WebAssembly] Default export tables with --cooperative-threading
#208263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sbc100
merged 1 commit into
llvm:main
from
alexcrichton:wasm-ld-wasip3-export-table-default
Aug 6, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make more sense to do this in the clang driver? Or in the wask-sdk clang driver config file?
Also, couldn't you imagine a scheme which did not involve exporting the table but instead exporting a
spawn_fibrefunction that take a table index itself? i.e. is it really true that the embedder always need to read from the table or can just use function pointers in some cases?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about putting in the driver, yeah, but I feel that here in wasm-ld is the best place. One consequence of a driver is that
--export-tableas a flag is incompatible with-shared,--import-table, and--relocatable. For all of these flags the driver would have to figure out what's going on and whether--export-tableotherwise needs to be passed. Given that I don't think the*.cfgfile will work, and while the driver in theory could work it'd also be something I'd have to replicate in rustc, too. Given all that it's how I figured that here inwasm-ldwas probably the best place to put this since it's got the most context.For a different scheme, that's theoretically possible, yeah, but the current definition of the threading intrinsics is that the new-thread intrinsic takes a table + index and spawns the thread based on that. This is intended to be somewhat future-compatible with a world where an intrinsic takes a
funcrefdirectly, but that's not possible to call from C right now hence the interim table+index intrinsic.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yes I the driver would need more smarts in that case to avoid adding
--export-tablewhen it shouldn't.I'm not convinced the linker should be charge or implementing the specifics of the wasi scheme like this, but maybe its the only good option in this case.
On the other hand is it too late to reconsider how fibers are launched in the pre-funcref world. Wouldn't calling
start_fibre_indirectbe better some ways (since it would avoid exposing the entire table to host)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coop threading hasn't shipped yet so it's still possible to change details like this, but personally I'd say that this is the next-best design before a true
funcref-like design. I'd prefer, for example, to call an imported function with afuncrefparameter ("go run this in a thread") as the desired end state which would also keep the table entirely encapsulated.If you'd like though I can file an issue on WebAssembly/component-model and cc you on that for discussion, too.