Index: lld/trunk/ELF/Config.h =================================================================== --- lld/trunk/ELF/Config.h +++ lld/trunk/ELF/Config.h @@ -98,6 +98,7 @@ std::vector VersionScriptLocals; std::vector BuildIdVector; bool AllowMultipleDefinition; + bool ArchiveWithoutSymbolsSeen = false; bool AsNeeded = false; bool Bsymbolic; bool BsymbolicFunctions; Index: lld/trunk/ELF/InputFiles.cpp =================================================================== --- lld/trunk/ELF/InputFiles.cpp +++ lld/trunk/ELF/InputFiles.cpp @@ -556,8 +556,12 @@ MB.getBufferIdentifier() + ": failed to parse archive"); // Read the symbol table to construct Lazy objects. - for (const Archive::Symbol &Sym : File->symbols()) + for (const Archive::Symbol &Sym : File->symbols()) { Symtab::X->addLazyArchive(this, Sym); + } + + if (File->symbols().begin() == File->symbols().end()) + Config->ArchiveWithoutSymbolsSeen = true; } // Returns a buffer pointing to a member file containing a given symbol. Index: lld/trunk/ELF/Relocations.cpp =================================================================== --- lld/trunk/ELF/Relocations.cpp +++ lld/trunk/ELF/Relocations.cpp @@ -610,10 +610,21 @@ toString(Sym) + "'"; if (Config->UnresolvedSymbols == UnresolvedPolicy::WarnAll || - (Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal)) + (Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal)) { warn(Msg); - else + } else { error(Msg); + if (Config->ArchiveWithoutSymbolsSeen) { + message("At least one archive listed no symbols in its index." + " This can happen when creating archives with a version" + " of ar that does not understand the object files in" + " the archive. For example, if you are using LLVM" + " bitcode objects (such as created by -flto), you may" + " need to use llvm-ar or GNU ar with a plugin."); + // Reset to false so that we print the message only once. + Config->ArchiveWithoutSymbolsSeen = false; + } + } } template