[PATCH] D25044: Warn on empty archive files.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 14:19:46 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL282633: Warn on empty archive files. (authored by ruiu).

Changed prior to commit:
  https://reviews.llvm.org/D25044?vs=72897&id=72899#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25044

Files:
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/test/ELF/empty-archive.s

Index: lld/trunk/test/ELF/empty-archive.s
===================================================================
--- lld/trunk/test/ELF/empty-archive.s
+++ lld/trunk/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.
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -427,8 +427,17 @@
   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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25044.72899.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160928/f94b2553/attachment.bin>


More information about the llvm-commits mailing list