Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -422,8 +422,15 @@ File = check(Archive::create(MB), "failed to parse archive"); // Read the symbol table to construct Lazy objects. - for (const Archive::Symbol &Sym : File->symbols()) + bool IsEmpty = true; + for (const Archive::Symbol &Sym : File->symbols()) { Symtab::X->addLazyArchive(this, Sym); + IsEmpty = false; + } + + if (IsEmpty) + warning(getName() + " has no symbol. If you are doing an LTO build LTO, " + "make sure you are using llvm-ar instead of ar."); } // Returns a buffer pointing to a member file containing a given symbol. Index: test/ELF/empty-archive.s =================================================================== --- test/ELF/empty-archive.s +++ test/ELF/empty-archive.s @@ -1,3 +1,5 @@ // RUN: llvm-ar rc %t.a // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld -shared %t.o %t.a -o t +// RUN: ld.lld -shared %t.o %t.a -o t 2>&1 | FileCheck %s + +// CHECK: has no symbol. If you are doing an LTO build LTO, make sure you are using llvm-ar instead of ar.