[lld] [lld][WebAssembly] Preserve LTO stub deps for bitcode symbols (PR #173235)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 22 08:28:50 PST 2025


================
@@ -1028,7 +1028,11 @@ static void processStubLibrariesPreLTO() {
       // If the symbol is not present at all (yet), or if it is present but
       // undefined, then mark the dependent symbols as used by a regular
       // object so they will be preserved and exported by the LTO process.
-      if (!sym || sym->isUndefined()) {
+      // If the symbol is defined and in bitcode, it can be DCE'd during LTO and
+      // become undefined, so mark the dependent symbols as used by a regular
+      // object as well.
+      if (!sym || sym->isUndefined() ||
+          (sym->isDefined() && isa_and_nonnull<BitcodeFile>(sym->getFile()))) {
----------------
sbc100 wrote:

I don't think I've used `isa_and_nonnull` thus far in wasm-ld.  Is it needed here or does `isa` work ?

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


More information about the llvm-commits mailing list