Hi All,
During compiling libdawrd and binutils(readelf) using LLVM, I encountered several linking errors. Unfortunately, their configure scripst does not have many useful options. I googled the problem and I came to the conclusion that it’s better to use LLVM gold Plugin which handles the linking process just like ld for gcc.
I compiled it but it seems there is an incompatibility with LLVM2.9 and I get this error when invoke the plugin:
$ ld -plugin /usr/lib/bfd-plugins/LLVMgold.so ==>
ld: error: /usr/lib/bfd-plugins/LLVMgold.so: could not load plugin library: /usr/lib/bfd-plugins/LLVMgold.so: undefined symbol: lto_codegen_set_cpu
Do you know what’s wrong with it?
Thanks,
Hi All,
During compiling libdawrd and binutils(readelf) using LLVM, I encountered
several linking errors. Unfortunately, their configure scripst does not have
many useful options. I googled the problem and I came to the conclusion that
it's better to use LLVM gold Plugin which handles the linking process just
like ld for gcc.
I compiled it but it seems there is an incompatibility with LLVM2.9 and I
get this error when invoke the plugin:
$ ld -plugin /usr/lib/bfd-plugins/LLVMgold.so ==>
ld: error: /usr/lib/bfd-plugins/LLVMgold.so: could not load plugin library:
/usr/lib/bfd-plugins/LLVMgold.so: undefined symbol: lto_codegen_set_cpu
Do you know what's wrong with it?
Why are you using such an old llvm? Can you try building 3.2 or trunk?
Thanks,
Cheers,
Rafael
I use LLVM generated bytecodes for KLEE which only works with LLVM 2.9!!
I’m getting sick of these errors…
I don' remember what (if anything) changed about this since 2.9, but
on current trunk I have:
$ nm lib/LLVMgold.so | grep lto_codegen_set_cpu
U lto_codegen_set_cpu
$ nm lib/libLTO.so | grep lto_codegen_set_cpu
0000000000233c20 T lto_codegen_set_cpu
So the symbol is defined in libLTO.so. Is it missing in your libLTO.so?
Cheers,
Rafael
No, surprisingly I have it:
nm LLVM/llvm-2.9/Release+Asserts/lib/libLTO.so | grep lto_codegen_set_cpu
00000000001649b0 T lto_codegen_set_cpu
Is the dynamic linker finding it? I get:
ldd lib/LLVMgold.so | grep libLTO
libLTO.so => /home/espindola/llvm/build/lib/libLTO.so
(0x00007ff8c4a4c000)
Cheers,
Rafael
NO, it seems thats the reason!!
so how should I link to it?
here is my ldd output:
ldd /usr/lib/LLVMgold.so
linux-vdso.so.1 => (0x00007fff2e7b3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5750250000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f575004c000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f574fd48000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f574fa4c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f574f836000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f574f476000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57506da000)
I guess this is some bug in 2.9's makefiles. What is the command that
make is using to link LLVMgold.so?
Cheers,
Rafael
I use this make command to compile my source with LLVM:
make CC=“path/to/llvm-gcc -use-gold-plugin”
No, I mean, what command make is running. Try adding VERBOSE=1 to the
command you run and you should see the commands it is executing. Look
for how LLVMgold.so is created.
Cheers,
Rafael
I added VERBOSE=1 to my make command but had no effect! however, I see this command in the output:
path/to/llvm-gcc -use-gold-plugin -g -O2 -o sysinfo sysinfo.o syslex.o
/usr/bin/ld: error: path/to/llvm-gcc4.2-2.9-x86_64-linux/bin/…/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/LLVMgold.so: could not load plugin library: path/to/llvm-gcc4.2-2.9-x86_64-linux/bin/…/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/LLVMgold.so: undefined symbol: lto_codegen_set_cpu
Oh, I think you mean this:
g++ -I/path/to/llvm-2.9/tools/gold -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -fomit-frame-pointer -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -I/path/to/binutilsGold/src/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -lLTO -O3 -Wl,-R -Wl,‘$ORIGIN’ -L/path/to/llvm-2.9/Release+Asserts/lib -L/path/to/llvm-2.9/Release+Asserts/lib -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -shared -o /path/to//llvm-2.9/Release+Asserts/lib/LLVMgold.so /path/to/llvm-2.9/tools/gold/Release+Asserts/gold-plugin.o \
Yes, and here is the bug: It is passing -lLTO before the
gold-plugin.o, so it is not included. This was fixed in r162652. You
might be able to backport the patch.
Cheers,
Rafael