link errors with -flto and -Wl,-soname,f.o

Jay Foad jay.foad@gmail.com
Wed Apr 9 11:01:00 GMT 2014


With GCC 4.9 (built from svn r209238 on Linux x86-64) I'm getting these errors:

$ echo "void f() {}" > f.c
$ gcc -flto -c f.c
$ gcc -flto -o f.so -shared -Wl,-soname,f.o f.o
f.c:1:6: error: 'f' has already been defined
 void f() {}
      ^
f.c:1:6: note: previously defined here
lto1: fatal error: errors during merging of translation units
compilation terminated.
lto-wrapper: /home/jay/gcc/local/bin/gcc returned 1 exit status
collect2: error: lto-wrapper returned 1 exit status

I realise that setting the soname to f.o (instead of f.so) is an odd
thing to do, but I don't see why it should provoke these errors.

I don't see the errors with GCC 4.8.1 (at least the version of it
supplied with Ubuntu 13.10).

Thanks,
Jay.



More information about the Gcc-help mailing list