[lld] [lld][WebAssembly] Fix stub library deps causing LTO archive members to be required post-LTO (PR #101894)

Alon Zakai via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 14:52:20 PDT 2024


================
@@ -949,6 +949,17 @@ static void processStubLibrariesPreLTO() {
           auto* needed = symtab->find(dep);
           if (needed ) {
             needed->isUsedInRegularObj = true;
+            // Like with handleLibcall we have extract any LTO archive members
+            // that might need to be exported due to stub library symbol being
+            // used.  Without this the LTO object could be extracted during
+            // processStubLibraries, which is too late since LTO has already
+            // beeing performed at that point.
+            if (needed->isLazy() && isa<BitcodeFile>(needed->getFile())) {
+              if (!config->whyExtract.empty())
+                ctx.whyExtractRecords.emplace_back(toString(stub_file),
+                                                   needed->getFile(), *needed);
+              cast<LazySymbol>(needed)->extract();
+            }
----------------
kripken wrote:

Perhaps this code could be shared with `handleLibcall`?

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


More information about the llvm-commits mailing list