Comment 3 for bug 1026359

Revision history for this message
In , Felix Geyer (debfx) wrote :

Created attachment 8821
Patch to pass LTO flags to LDFLAGS and LIBS

LLVMgold.so is not linked against libLTO.so when ld defaults to --as-needed (which is the default on Ubuntu and afaik Fedora).

LLVMgold is built like this:
x86_64-linux-gnu-g++ [...] -lLTO [...] -o /build/buildd/llvm-3.1-3.1/build-llvm/Release/lib/LLVMgold.so /build/buildd/llvm-3.1-3.1/build-llvm/tools/gold/Release/gold-plugin.o [...] -lpthread -lffi -ldl -lm

-lLTO is passed before gold-plugin.o so it is ignored.

I'm attaching a patch that adds "-L$(SharedLibDir)/$(SharedPrefix)" to LDFLAGS and "-lLTO" to LIBS instead of appending both to CXXFLAGS.
Makefile.config overwrites LIBS so I've added that at the bottom of the Makefile.
Maybe there is a better solution for this?

With these changes LLVMgold is built like this:
x86_64-linux-gnu-g++ [...] -o /tmp/buildd/llvm-3.1-3.1/build-llvm/Release/lib/LLVMgold.so /tmp/buildd/llvm-3.1-3.1/build-llvm/tools/gold/Release/gold-plugin.o [...] -lpthread -lffi -ldl -lm -lLTO