[cfe-dev] Recommendation on -flto & -use-gold-plugin

Sylvestre Ledru sylvestre at debian.org
Thu Mar 15 15:06:53 PDT 2012


Hi,

Reported as bug #662742 in the Debian bug tracker [1], the following
code fails:
 echo 'int main () { return 0; }' > foo.cc
 clang++ -c -flto -O2 foo.cc -o foo.o
 clang++ -flto -use-gold-plugin -O2 foo.o -o foo
with:
/usr/bin/ld: error: foo.o:1:3: invalid character
/usr/bin/ld: error: foo.o:1:3: syntax error, unexpected $end
/usr/bin/ld: error: foo.o: not an object or archive
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o(.text
+0x20): error: undefined reference to 'main'

With binutils-gold (contains ld gold), adding "-use-gold-plugin" to the
last line fixes the issue. 

In order to simplify the usage of the -flto to any user of the clang
Debian packages, I have two questions:
* does it make sense to force the installation binutils-gold with clang
or it is too risky ?
* should I automagically/transparently add -use-gold-plugin when using
-flto ?

Thanks for the input,
Sylvestre

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=662742




More information about the cfe-dev mailing list