[lld] [WebAssembly] Default export tables with `--cooperative-threading` (PR #208263)

Alex Crichton via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 18:15:12 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;
----------------
alexcrichton wrote:

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 a `funcref` parameter ("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.

https://github.com/llvm/llvm-project/pull/208263


More information about the llvm-commits mailing list