[lld] [WebAssembly] Default export tables with `--cooperative-threading` (PR #208263)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 17:54:51 PDT 2026
================
@@ -759,6 +759,14 @@ static void setConfigs() {
if (ctx.arg.sharedMemory)
error("--cooperative-threading is incompatible with --shared-memory");
ctx.arg.libcallThreadContext = true;
+
+ // Cooperative threading requires the table is either imported or exported
+ // or otherwise there's no way for embedders to read spawned functions from
+ // the table. If we've gotten this far and the table isn't otherwise
+ // imported (e.g in `isPic` mode) then export the table instead to ensure
+ // that it's visible to the outside world.
+ if (!ctx.arg.importTable)
+ ctx.arg.exportTable = true;
----------------
sbc100 wrote:
Hmm, yes I the driver would need more smarts in that case to avoid adding `--export-table` when it shouldn't.
I'm 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_indirect` be better some ways (since it would avoid exposing the entire table to host)?
https://github.com/llvm/llvm-project/pull/208263
More information about the llvm-commits
mailing list