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).
Sorry for asking the stupid question but have you enabled gold as default linker? I mean made ld symlink point to ld.gold.
(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.