clang -O4 -use-gold-plugin fails (LLVMgold.so: undefined symbol: lto_codegen_compile_to_file)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
LLVM |
Fix Released
|
Wishlist
|
|||
llvm-3.0 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
llvm-3.1 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
$ echo 'int main(){return 0;}' > foo.c
$ clang -O4 -use-gold-plugin foo.c
/usr/bin/
/usr/bin/
/usr/bin/
/usr/bin/
/usr/lib/
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ ld.gold -v -plugin /usr/lib/
GNU gold (GNU Binutils for Ubuntu 2.22.52.20120713) 1.11
/usr/bin/
It seems that LLVMgold.so is missing a dependency on libLTO.so. Things work if I set that as an LD_PRELOAD.
ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: llvm-3.0-dev 3.0-9
ProcVersionSign
Uname: Linux 3.5.0-4-generic x86_64
NonfreeKernelMo
ApportVersion: 2.4-0ubuntu2
Architecture: amd64
Date: Wed Jul 18 18:20:18 2012
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Alpha amd64 (20101202)
SourcePackage: llvm-3.0
UpgradeStatus: No upgrade log present (probably fresh install)
Changed in llvm: | |
importance: | Unknown → Wishlist |
status: | Unknown → Confirmed |
Changed in llvm: | |
status: | Confirmed → Fix Released |
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: 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
x86_64-
-lLTO is passed before gold-plugin.o so it is ignored.
I'm attaching a patch that adds "-L$(SharedLibD ir)/$(SharedPre fix)" 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: 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
x86_64-