<p dir="ltr">libtool (on mac) warns on this, and it's spectacularly unhelpful. We filter out that warning in a wrapper script since there's no flag to turn it off and the warning is just noise in our build. If lld gets this warning, please provide a way to toggle it off.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 30, 2016 12:31 PM, "Reid Kleckner" <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Are you sure we should be warning on empty archives? This comes up in Chromium's build, which apparently has an archive with no symbols:<div><a href="https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinuxLLD/builds/1596/steps/compile/logs/stdio" target="_blank">https://build.chromium.org/p/<wbr>chromium.fyi/builders/<wbr>ClangToTLinuxLLD/builds/1596/<wbr>steps/compile/logs/stdio</a></div><div><br>That build also doesn't involve LTO, so the long explanatory comment isn't helpful.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 28, 2016 at 2:10 PM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Wed Sep 28 16:10:54 2016<br>
New Revision: 282633<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=282633&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=282633&view=rev</a><br>
Log:<br>
Warn on empty archive files.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D25044" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2504<wbr>4</a><br>
<br>
Modified:<br>
    lld/trunk/ELF/InputFiles.cpp<br>
    lld/trunk/test/ELF/empty-archi<wbr>ve.s<br>
<br>
Modified: lld/trunk/ELF/InputFiles.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=282633&r1=282632&r2=282633&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/InputFiles<wbr>.cpp?rev=282633&r1=282632&r2=<wbr>282633&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputFiles.cpp (original)<br>
+++ lld/trunk/ELF/InputFiles.cpp Wed Sep 28 16:10:54 2016<br>
@@ -427,8 +427,17 @@ template <class ELFT> void ArchiveFile::<br>
   File = check(Archive::create(MB), "failed to parse archive");<br>
<br>
   // Read the symbol table to construct Lazy objects.<br>
-  for (const Archive::Symbol &Sym : File->symbols())<br>
+  bool IsEmpty = true;<br>
+  for (const Archive::Symbol &Sym : File->symbols()) {<br>
     Symtab<ELFT>::X->addLazyArchi<wbr>ve(this, Sym);<br>
+    IsEmpty = false;<br>
+  }<br>
+<br>
+  if (IsEmpty)<br>
+    warning(getName() + " has no symbol. Chances are you are doing "<br>
+            "an LTO build and forgot to use an ar command that can create "<br>
+            "a symbol table for LLVM bitcode files. If so, use llvm-ar or "<br>
+            "GNU ar + plugin.");<br>
 }<br>
<br>
 // Returns a buffer pointing to a member file containing a given symbol.<br>
<br>
Modified: lld/trunk/test/ELF/empty-archi<wbr>ve.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/empty-archive.s?rev=282633&r1=282632&r2=282633&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/test/ELF/empty<wbr>-archive.s?rev=282633&r1=28263<wbr>2&r2=282633&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/test/ELF/empty-archi<wbr>ve.s (original)<br>
+++ lld/trunk/test/ELF/empty-archi<wbr>ve.s Wed Sep 28 16:10:54 2016<br>
@@ -1,3 +1,5 @@<br>
 // RUN: llvm-ar rc %t.a<br>
 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o<br>
-// RUN: ld.lld -shared %t.o %t.a -o t<br>
+// RUN: ld.lld -shared %t.o %t.a -o t 2>&1 | FileCheck %s<br>
+<br>
+// CHECK: has no symbol.<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote></div></div>