<div dir="ltr"><div dir="ltr">On Wed, Mar 13, 2019 at 5:30 PM Eli Friedman <<a href="mailto:efriedma@quicinc.com">efriedma@quicinc.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_-6989690609732802227WordSection1">
<p class="MsoNormal">I spent a bit of time looking at this.  By default, llvm-ar will automatically generate a symbol table… which suppresses the lld error because lld never looks at unneeded object files in an archive with a symbol table.  However, there’s
 an exception: if the host is not Darwin, and the archive contains no object files, llvm-ar skips generating a symbol table even if one is requested.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Maybe it makes sense to change the behavior of llvm-ar so it’s more consistent… I’m not sure what the history is behind making the symbol table behavior depend on the archive format.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">On a sort of related note, maybe we want to change lld so it doesn’t generate the “not an ELF file” error for archives which don’t have a symbol table?  That would be more consistent with the behavior of archives with a symbol table.</p></div></div></blockquote><div><br></div><div>We have an interesting (or ugly?) hack for an archive file containing no symbol table.</div><div><br></div><div>If we see an archive file containing no symbol table, it is likely that a user is attempting LTO and using system's ar instead of llvm-ar. Since the system's ar doesn't understand the LLVM bitcode, it cannot create a symbol table, thus such an archive. This is very common error, it seems that virtually everybody once hit when doing LTO for the first time, so we have a workaround in lld that it automatically pulls out files from such an archive and link them according to the archive file semantics.</div><div><br></div><div>(Maybe we should check if all member files in an archive file with no symbol table are bitcode files, though.)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-6989690609732802227WordSection1"><p class="MsoNormal"> </p><p class="MsoNormal"><u></u></p>
<p class="MsoNormal">-Eli<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Rui Ueyama <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> <br>
<b>Sent:</b> Wednesday, March 13, 2019 4:23 PM<br>
<b>To:</b> Eli Friedman <<a href="mailto:efriedma@quicinc.com" target="_blank">efriedma@quicinc.com</a>><br>
<b>Cc:</b> llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>><br>
<b>Subject:</b> [EXT] Re: [lld] r355894 - Fix test to unconditionally create a GNU-format archive.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">lld uses LLVM's libObject to read archive files, and I believe the library supports all variants of archive files, so it is odd that lld can't read some archive variant. Something is not right...<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Mon, Mar 11, 2019 at 7:18 PM Eli Friedman via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: efriedma<br>
Date: Mon Mar 11 19:20:01 2019<br>
New Revision: 355894<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=355894&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=355894&view=rev</a><br>
Log:<br>
Fix test to unconditionally create a GNU-format archive.<br>
<br>
On Darwin targets, llvm-ar creates a Darwin format archive by default,<br>
which ld.lld can't read, so it was printing an unexpected error.<br>
<br>
<br>
Modified:<br>
    lld/trunk/test/ELF/invalid/invalid-elf.test<br>
<br>
Modified: lld/trunk/test/ELF/invalid/invalid-elf.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-elf.test?rev=355894&r1=355893&r2=355894&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-elf.test?rev=355894&r1=355893&r2=355894&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/ELF/invalid/invalid-elf.test (original)<br>
+++ lld/trunk/test/ELF/invalid/invalid-elf.test Mon Mar 11 19:20:01 2019<br>
@@ -2,7 +2,7 @@<br>
 # RUN: rm -rf %t && mkdir -p %t<br>
 # RUN: llvm-mc %s -o %t/simple.o -filetype=obj -triple x86_64-pc-linux<br>
 # RUN: echo > %t/empty.o<br>
-# RUN: llvm-ar cr %t/not-elf.a %t/empty.o<br>
+# RUN: llvm-ar --format=gnu cr %t/not-elf.a %t/empty.o<br>
<br>
 # RUN: not ld.lld %t/simple.o %t/not-elf.a -o %t2 2>&1 | \<br>
 # RUN:   FileCheck --check-prefix=NOT-ELF %s<br>
<br>
<br>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
</div>

</blockquote></div></div>