<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - LTO and error adding symbols: archive has no index; run ranlib to add one"
href="https://bugs.llvm.org/show_bug.cgi?id=42684">42684</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LTO and error adding symbols: archive has no index; run ranlib to add one
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>noloader@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>We are trying to document the process of using Link Time Optimizations (LTO) at
<a href="https://www.cryptopp.com/wiki/Link_Time_Optimization">https://www.cryptopp.com/wiki/Link_Time_Optimization</a>. Attempting to use `-flto`
results in the following during link (we drive link through the compiler):
$ CXX=clang++ CXXFLAGS="-DNDEBUG -O2 -flto -g -fPIC -pthread" make -j 4
...
clang++ -o cryptest.exe -DNDEBUG -O2 -flto -g -fPIC -pthread
-DCRYPTOPP_DISABLE_MIXED_ASM -pipe adhoc.o test.o bench1.o bench2.o bench3.o
datatest.o dlltest.o fipsalgt.o validat0.o validat1.o validat2.o validat3.o
validat4.o validat5.o validat6.o validat7.o validat8.o validat9.o validat10.o
regtest1.o regtest2.o regtest3.o regtest4.o ./libcryptopp.a
/bin/ld: ./libcryptopp.a: error adding symbols: archive has no index; run
ranlib to add one
clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [GNUmakefile:1323: cryptest.exe] Error 1
-----
Additionally, adding "AR=clang-ar" and "RANLIB=clang-ranlib" fails due to
missing programs. This is a GCC convention, so I suppose it is not unexpected.
However, using GCC's tools produces the same errors:
$ AR=gcc-ar RANLIB=gcc-ranlib CXX=clang++ CXXFLAGS="-DNDEBUG -O2 -flto -g -fPIC
-pthread" make -j 4
...
/bin/ar: creating libcryptopp.a
gcc-ranlib libcryptopp.a
clang++ -o cryptest.exe ... ./libcryptopp.a
/bin/ld: ./libcryptopp.a: error adding symbols: archive has no index; run
ranlib to add one
clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [GNUmakefile:1323: cryptest.exe] Error 1
I don't know why we are getting messages like "/bin/ar: creating
libcryptopp.a". Our makefile honors AR, ARFLAGS, RANLIB, CXX, CXXFLAGS, etc. We
don't use LD since we drive link through the compiler. Everything is
override-able by the user.
-----
I'm working on Fedora 30 x86_64 (fully updated).
$ uname -a
Linux skylake 5.1.17-300.fc30.x86_64 #1 SMP Wed Jul 10 15:20:27 UTC 2019 x86_64
x86_64 x86_64 GNU/Linux
Here are the installed clang packages:
$ rpm -qa | grep -i -E 'llvm|clang'
clang-tools-extra-8.0.0-1.fc30.x86_64
llvm-libs-8.0.0-6.fc30.x86_64
clang-8.0.0-1.fc30.x86_64
clang-libs-8.0.0-1.fc30.x86_64</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>