Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 434414

Summary: sys-devel/llvm-3.1-r2[gold] and sys-devel/clang-3.1-r5 do not run with -flto
Product: Gentoo Linux Reporter: Martin Väth <martin>
Component: [OLD] Core systemAssignee: Bernard Cafarelli <voyageur>
Status: RESOLVED INVALID    
Severity: minor CC: mgorny, ryao
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Martin Väth 2012-09-09 09:40:53 UTC
clang -flto
(tested with sys-devel/llvm-3.1-r2[gold] and sys-devel/clang-3.1-r5)
does not work in gentoo for at least two reasons, one I could identify:

1. The gold plugin will not load if built with the injected --as-needed:
Although it seems that there was an attempt to fix this upstream,
also Ubuntu needed additional patches:
https://bugs.launchpad.net/ubuntu/+source/llvm-3.0/+bug/1026359

For testing, I just exported LD_AS_NEEDED="" when emerging llvm.
Then the linker plugin can be loaded, but there occurs another problem:

2. When actually linking with clang++ -flo,
there occur errors with all .o files:
....o: file not recognized: File format not recognized

No idea yet what is involved for 2; perhaps this is a different issue
(or perhaps not if LD_AS_NEEDED= was just too aggressive;
I did not play with the ubuntu patches yet).
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-09-09 17:39:07 UTC
Sorry for asking the stupid question but have you enabled gold as default linker? I mean made ld symlink point to ld.gold.
Comment 2 Martin Väth 2012-09-10 06:40:06 UTC
(In reply to comment #1)
> Sorry for asking the stupid question

PEBKAC: Switched between bfd and gold so many times (playing with LD=ld.gold
etc) that I did not realize that finally I used the wrong linker.

Strange that "LD_AS_NEEDED= emerge -1 llvm" changed the behavior with
bfd linker, but of course not a bug.

No problems with reemerged llvm and gold linker. Sorry for the noise.