[LLVMdev] llvm-gcc with static libraries

Ashay Rane ashay.rane at asu.edu
Tue Aug 9 12:03:54 PDT 2011


`/usr/bin/ld -v' says it is not running gold and I suppose fixing that would
require place LLVMgold.so into /usr/lib/bfd-plugins. Is there any way to
make this work without requiring root access to the machine?

Also, just to confirm, is the gold plugin required even when all of the
files have been compiled/built using llvm-gcc and llvm-ar?

Ashay


On Tue, Aug 9, 2011 at 1:33 PM, Eli Friedman <eli.friedman at gmail.com> wrote:

> On Tue, Aug 9, 2011 at 11:16 AM, Ashay Rane <ashay.rane at asu.edu> wrote:
> > Hello,
> > While linking programs against static libraries built using llvm-ar and
> > llvm-ranlib, I see an error message:
> > could not read symbols: Archive has no index; run ranlib to add one
> > collect2: ld returned 1 exit status
> > Using either /usr/bin/nm or llvm-nm (depending on the use of --emit-llvm
> > flag to llvm-gcc), one of them is able to list the symbols in the archive
> > file. However, the link step fails. Two sample runs follow. Am I missing
> any
> > options? The source code was obtained
> > from:
> http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
> > == Without --emit-llvm ==
> > $ llvm-gcc -c ctest1.c ctest2.c
> > $ file *.o
> > ctest1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
> stripped
> > ctest2.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
> stripped
> > $ llvm-ar cru libctest.a *.o
> > $ ls
> > ctest1.c  ctest1.o  ctest2.c  ctest2.o  libctest.a  prog.c
> > $ llvm-ar t libctest.a
> > ctest1.o
> > ctest2.o
> > $ llvm-nm libctest.a
> > $ nm libctest.a
> > nm: #_LLVM_SYM_TAB_: File format not recognized
> > ctest1.o:
> > 0000000000000000 T ctest1
> > ctest2.o:
> > 0000000000000000 T ctest2
> > $ llvm-ranlib libctest.a
> > $ llvm-gcc prog.c libctest.a -o p
> > libctest.a: could not read symbols: Archive has no index; run ranlib to
> add
> > one
> > collect2: ld returned 1 exit status
>
> http://llvm.org/docs/GoldPlugin.html .  (I'm not completely sure
> that's up-to-date, but should point you in the right direction.)
>
> -Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110809/d44b1dc8/attachment.html>


More information about the llvm-dev mailing list