[lld] [lld][WebAssembly] LTO: Use PIC reloc model with dynamic imports (PR #165342)

Alon Zakai via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 28 08:57:37 PDT 2025


================
@@ -63,6 +63,12 @@ static lto::Config createConfig() {
     c.RelocModel = std::nullopt;
   else if (ctx.isPic)
     c.RelocModel = Reloc::PIC_;
+  else if (ctx.arg.unresolvedSymbols == UnresolvedPolicy::ImportDynamic)
+    // With ImportDynamic we also need to use the PIC relocation model so that
+    // external symbols are references via the GOT.
+    // TODO(sbc): This should probably be Reloc::DynamicNoPIC, but the backend
+    // doesn't currently support that.
+    c.RelocModel = Reloc::PIC_;
----------------
kripken wrote:

Do the [docs for `import-dynamic`](https://lld.llvm.org/WebAssembly.html) need to be updated?

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


More information about the llvm-commits mailing list