[llvm-bugs] [Bug 42684] New: LTO and error adding symbols: archive has no index; run ranlib to add one

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 18 23:39:38 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42684

            Bug ID: 42684
           Summary: LTO and error adding symbols: archive has no index;
                    run ranlib to add one
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: noloader at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

We are trying to document the process of using Link Time Optimizations (LTO) at
https://www.cryptopp.com/wiki/Link_Time_Optimization. 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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190719/8250c826/attachment-0001.html>


More information about the llvm-bugs mailing list