summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-09-28 21:10:54 +0000
committerRui Ueyama <ruiu@google.com>2016-09-28 21:10:54 +0000
commitcb85d7f840b1d2398fcbd1998c4f10755dfeb0bb (patch)
tree3299e8a12df831212b093208b1a5f198b9e58741
parent7ae1a67ed9d3d26ecf30279907e267f546eb43d3 (diff)
downloadbcm5719-llvm-cb85d7f840b1d2398fcbd1998c4f10755dfeb0bb.tar.gz
bcm5719-llvm-cb85d7f840b1d2398fcbd1998c4f10755dfeb0bb.zip
Warn on empty archive files.
Differential Revision: https://reviews.llvm.org/D25044 llvm-svn: 282633
-rw-r--r--lld/ELF/InputFiles.cpp11
-rw-r--r--lld/test/ELF/empty-archive.s4
2 files changed, 13 insertions, 2 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index d15a705a86e..9ec47a05bd0 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -427,8 +427,17 @@ template <class ELFT> void ArchiveFile::parse() {
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<ELFT>::X->addLazyArchive(this, Sym);
+ IsEmpty = false;
+ }
+
+ if (IsEmpty)
+ warning(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.
diff --git a/lld/test/ELF/empty-archive.s b/lld/test/ELF/empty-archive.s
index ffb0a781441..a5ac59aea1d 100644
--- a/lld/test/ELF/empty-archive.s
+++ b/lld/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.
OpenPOWER on IntegriCloud