[lld] [lld-macho] Fix unchecked Error crash for thin archive missing child (PR #97169)

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 6 05:19:24 PDT 2024


================
@@ -349,7 +349,14 @@ static InputFile *addFile(StringRef path, LoadType loadType,
         Error e = Error::success();
         for (const object::Archive::Child &c : file->getArchive().children(e)) {
           Expected<MemoryBufferRef> mb = c.getMemoryBufferRef();
-          if (!mb || !hasObjCSection(*mb))
+          if (!mb) {
+            // Thin archives from repro tarballs can contain missing members
+            // if the member was not loaded later during the initial link.
----------------
nico wrote:

Should we add a `if (c.getParent()->isThin())` here to not drop valid errors?

But outside or repro files, .o files referenced from an archive being missing seems like something we probably want to diag on, hmm.

Maybe we should eagerly put all .o files referenced from thin archives into the repro file always, not just when they're referenced?


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


More information about the llvm-commits mailing list