We now seem to always pass -plugin ./liblto_plugin.so ... to collect2, even when not using LTO. This causes us to always use the linker configured for plugin use (--with-plugin-ld) via the collect-ld script and thus with --with-plugin-ld=gold gold will be always used (which breaks the build of libgo for me as gold is too old appearantly). int main() { return 0; } > strace -e execve -f ./xgcc -B. t.c -v -Wl,-debug 2>&1 | grep gold Configured with: /space/rguenther/src/svn/trunk/configure --disable-bootstrap --disable-nls --disable-libstdcxx-pch --enable-lto --enable-gold --with-plugin-ld=/usr/bin/gold --enable-languages=c,ada,c++,fortran,java,lto,objc,obj-c++,go [pid 7648] execve("/usr/bin/gold", ["/usr/bin/gold", "-plugin", "./liblto_plugin.so", "-plugin-opt=./lto-wrapper", "-plugin-opt=-fresolution=/tmp/cc"..., "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "-plugin-opt=-pass-through=-lc", "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "--eh-frame-hdr", "-m", "elf_x86_64", "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", "/usr/lib/../lib64/crt1.o", ...], [/* 91 vars */]) = 0 rguenther@murzim:/abuild/rguenther/trunk-g/gcc> strace -e execve -f ./xgcc -B. t.c -v -Wl,-debug 2>&1 | grep gold Configured with: /space/rguenther/src/svn/trunk/configure --disable-bootstrap --disable-nls --disable-libstdcxx-pch --enable-lto --enable-gold --with-plugin-ld=/usr/bin/gold --enable-languages=c,ada,c++,fortran,java,lto,objc,obj-c++,go [pid 7667] execve("/usr/bin/gold", ["/usr/bin/gold", "-plugin", "./liblto_plugin.so", "-plugin-opt=./lto-wrapper", "-plugin-opt=-fresolution=/tmp/cc"..., "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "-plugin-opt=-pass-through=-lc", "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "--eh-frame-hdr", "-m", "elf_x86_64", "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", "/usr/lib/../lib64/crt1.o", ...], [/* 91 vars */]) = 0
This change was intentional. We will need to use linker plugin unconditionally for slim LTO support, but per discussion with Richard, we should switch to this only for next stage1 as slim LTO is not getting into 4.6.0. I guess we only need to update SPECs to test -flto, should be easy.
testing the following patch. Index: gcc.c =================================================================== --- gcc.c (revision 168655) +++ gcc.c (working copy) @@ -621,11 +621,18 @@ # endif #endif -/* Conditional to test whether plugin is used or not. */ +/* Conditional to test whether plugin is used or not. + FIXME: For slim LTO we will need to enable plugin unconditionally. This + still cause problems with PLUGIN_LD != LD and when plugin is built but + not useable. For GCC 4.6 we don't support slim LTO and thus we can enable + plugin only when LTO is enabled. We still honor explicit + -fuse-linker-plugin. */ #ifdef HAVE_LTO_PLUGIN -#define PLUGIN_COND "!fno-use-linker-plugin" +#define PLUGIN_COND "!fno-use-linker-plugin:%{flto|flto=*|fuse-linker-plugin" +#define PLUGIN_COND_CLOSE "}" #else #define PLUGIN_COND "fuse-linker-plugin" +#define PLUGIN_COND_CLOSE "" #endif @@ -646,9 +653,9 @@ -plugin-opt=%(lto_wrapper) \ -plugin-opt=-fresolution=%u.res \ %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \ - } \ - %{flto*:%<fcompare-debug*} \ - %{flto*} %l " LINK_PIE_SPEC \ + }"PLUGIN_COND_CLOSE" \ + %{flto,flto=*:%<fcompare-debug*} \ + %{flto,flto=*} %l " LINK_PIE_SPEC \ "%X %{o*} %{e*} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\ %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
Is pr39968 related (a duplicate) of this pr?
> Is pr39968 related (a duplicate) of this pr? No, it is older than the problem and it is about plugins, not lto-plugin. Perhaps plugins Make also needs to play the games with --enable-shared I added into lto-plugin configury. Honza
path posted. http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00654.html
Author: hubicka Date: Wed Jan 12 15:47:29 2011 New Revision: 168717 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168717 Log: PR driver/47244 * gcc.c (PLUGIN_COND): Update to disable plugin unless -flto is used. (PLUGIN_COND_CLOSE): New macro. (LINK_COMMAND_SPEC): Update to use PLUGIN_COND_CLOSE. Modified: trunk/gcc/ChangeLog trunk/gcc/gcc.c
fixed.
Your fix does not work. > /abuild/rguenther/trunk-g/gcc/xgcc -B/abuild/rguenther/trunk-g/gcc/ /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/tree-ssa/pr46076.c -O2 -lm -o pr46076.exe -v ... /abuild/rguenther/trunk-g/gcc/collect2 -plugin /abuild/rguenther/trunk-g/gcc/liblto_plugin.so -plugin-opt=/abuild/rguenther/trunk-g/gcc/lto-wrapper -plugin-opt=-fresolution=/tmp/cc3HveYS.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o pr46076.exe /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /abuild/rguenther/trunk-g/gcc/crtbegin.o -L/abuild/rguenther/trunk-g/gcc -L/lib/../lib64 -L/usr/lib/../lib64 /tmp/cc8pWTze.o -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /abuild/rguenther/trunk-g/gcc/crtend.o /usr/lib/../lib64/crtn.o /usr/bin/gold: /tmp/cc8pWTze.o: in function main:pr46076.c(.text.startup+0x20): error: undefined reference to 'link_error'
It works. Got bitten by > ./xgcc -B. t.c -v Reading specs from ./specs ... (again)