summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-09-30 17:56:20 +0000
committerRui Ueyama <ruiu@google.com>2016-09-30 17:56:20 +0000
commit3d0f77b28193224fc33059a2b034000418fc4d1c (patch)
tree2b465ccf2fa5de09c3e7d89a62396bb5482ea65e /lld/ELF/InputFiles.cpp
parent14a5ca0498552a4ae3e9b99cb339dcffac6a5a12 (diff)
downloadbcm5719-llvm-3d0f77b28193224fc33059a2b034000418fc4d1c.tar.gz
bcm5719-llvm-3d0f77b28193224fc33059a2b034000418fc4d1c.zip
Improve error check for an empty archive.
Previously, it warned on any archive file that has no symbol. It turned out that that is too noisy. With this patch, it warns on such archive file that contains no file. Differential Revision: https://reviews.llvm.org/D25111 llvm-svn: 282885
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 7605ab007b5..c1b59c12d0f 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -425,18 +425,16 @@ SymbolBody *elf::ObjectFile<ELFT>::createSymbolBody(const Elf_Sym *Sym) {
template <class ELFT> void ArchiveFile::parse() {
File = check(Archive::create(MB), "failed to parse archive");
+ // Checks for a common usage error of an ar command.
+ if (File->getNumberOfSymbols() == 0 && !File->isEmpty())
+ warn(getName() + " has no symbol."
+ " Chances are you are doing an LTO build and forgot to use an ar"
+ " command that can create a symbol table for LLVM bitcode files."
+ " If so, use llvm-ar or GNU ar + plugin.");
+
// Read the symbol table to construct Lazy objects.
- bool IsEmpty = true;
- for (const Archive::Symbol &Sym : File->symbols()) {
+ for (const Archive::Symbol &Sym : File->symbols())
Symtab<ELFT>::X->addLazyArchive(this, Sym);
- IsEmpty = false;
- }
-
- if (IsEmpty)
- warn(getName() + " has no symbol. Chances are you are doing "
- "an LTO build and forgot to use an ar command that can create "
- "a symbol table for LLVM bitcode files. If so, use llvm-ar or "
- "GNU ar + plugin.");
}
// Returns a buffer pointing to a member file containing a given symbol.
OpenPOWER on IntegriCloud