Index: ELF/InputFiles.h =================================================================== --- ELF/InputFiles.h +++ ELF/InputFiles.h @@ -284,15 +284,11 @@ static bool classof(const InputFile *F) { return F->kind() == ArchiveKind; } template void parse(); - // Pulls out an object file that contains a definition for Sym and - // returns it. If the same file was instantiated before, this - // function returns a nullptr (so we don't instantiate the same file - // more than once.) + // Pulls out an object file that contains a definition for Sym. InputFile *fetch(const Archive::Symbol &Sym); private: std::unique_ptr File; - llvm::DenseSet Seen; }; class BitcodeFile : public InputFile { Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -827,9 +827,6 @@ ": could not get the member for symbol " + Sym.getName()); - if (!Seen.insert(C.getChildOffset()).second) - return nullptr; - MemoryBufferRef MB = CHECK(C.getMemoryBufferRef(), toString(this) + Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -646,8 +646,7 @@ template void SymbolTable::fetchLazy(Symbol *Sym) { if (auto *S = dyn_cast(Sym)) { - if (InputFile *File = S->fetch()) - addFile(File); + addFile(S->fetch()); return; } Index: test/ELF/archive-fetch.s =================================================================== --- test/ELF/archive-fetch.s +++ test/ELF/archive-fetch.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 + +# RUN: echo '.quad foo' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tfoo.o +# RUN: echo '.quad bar' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tbar.o + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: rm -f %t.a +# RUN: llvm-ar rcs %t.a %t.o + +# Test we can link it. +# RUN: ld.lld %t.a %tfoo.o %tbar.o -o /dev/null + +.global foo +foo: + +.global bar +bar: