[LLVMdev] Unable to perform LLVM LTO using clang
Chunbai YANG
chunbyang2 at gapps.cityu.edu.hk
Mon Dec 2 02:25:27 PST 2013
Hi everyone,
I want to perform whole-program analysis for apache httpd using httpd's
original autoconf system so that I need to generate a single bitcode file.
So I follow the instructions in LLVM document on gold plugin
http://llvm.org/docs/GoldPlugin.html#lto-how-to-build. However, when
running a simple program using LTO, clang fails to link the object file
with the LLVM bitcode.
There're only two c files, a.c and b.c in the source folder.
$ clang -flto a.c -c -o a.o # <-- a.o is LLVM bitcode file$ clang
b.c -c -o b.o # <-- b.o is native object file$ clang -flto
a.o b.o -o main # <-- link with LLVMgold plugin
When executing the last command, it prompts
> a.o: file not recognized: File format not recognized
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
At the same time, performing the command of
ld -plugin=/usr/local/lib/LLVMgold.so a.o b.o -o main
it will successfully generate main.
My libLTO build process is as follows,
1. check out binutils
2. configure with --enable-gold --enable-plugins
3. make
4. make install
5. replace original ld in /usr/local/bin with ld.gold using ln
6. replace ar and nm in /usr/local/bin with ar and nm-new in the
binutils folder just built using ln
7. configure LLVM
with --with-binutils-include=/path/to/binutils/src/include
8. execute make again in LLVM root
It seems the gold linker works well with the LLVMgold.so lib however clang
fails to correctly invoke gold linker.
Could anyone tell me where my mistake is?
Regards,
Chunbai Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131202/1d29aaf4/attachment.html>
More information about the llvm-dev
mailing list