[lld] [WebAssembly] Don't use passive segments for bss in coop threads (PR #208284)

Alex Crichton via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 09:06:01 PDT 2026


================
@@ -1058,14 +1058,13 @@ OutputSegment *Writer::createOutputSegment(StringRef name) {
   OutputSegment *s = make<OutputSegment>(name);
   // In the shared memory case, all data segments must be passive since they
   // will be initialized once by the main thread and then shared with other
-  // threads. In the cooperative threading case, TLS segments must be passive
-  // so they can be re-initialized per-thread via memory.init, and .bss
-  // segments are passive to avoid serializing their zero bytes into the binary;
-  // they are still present as passive segment entries and zero-filled via
-  // memory.fill in __wasm_init_memory.
+  // threads. In the cooperative threading case, TLS segments need to exist to
+  // be able to run TLS initialization on spawned threads, so that's managed
+  // here by flagging TLS as passive as well. This triggers initialization in
+  // the `start` function for the "primordial" thread of sorts, and new
+  // threads/tasks can initialize their own with `__wasm_init_tls`.
----------------
alexcrichton wrote:

Sure yeah, I went ahead and just dropped the sentence

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


More information about the llvm-commits mailing list