Bug 47244 - [4.6 Regression] plugin linker is used unconditionally
Summary: [4.6 Regression] plugin linker is used unconditionally
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.6.0
: P1 normal
Target Milestone: 4.6.0
Assignee: Jan Hubicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-10 16:09 UTC by Richard Biener
Modified: 2011-01-14 14:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-01-11 13:26:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2011-01-10 16:09:21 UTC
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
Comment 1 Jan Hubicka 2011-01-11 13:26:42 UTC
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.
Comment 2 Jan Hubicka 2011-01-11 14:03:29 UTC
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\
Comment 3 Dominique d'Humieres 2011-01-11 14:06:26 UTC
Is pr39968 related (a duplicate) of this pr?
Comment 4 Jan Hubicka 2011-01-11 14:08:41 UTC
> 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
Comment 5 Jan Hubicka 2011-01-11 16:46:40 UTC
path posted. http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00654.html
Comment 6 Jan Hubicka 2011-01-12 15:47:36 UTC
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
Comment 7 Jan Hubicka 2011-01-12 15:48:22 UTC
fixed.
Comment 8 Richard Biener 2011-01-14 12:32:22 UTC
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'
Comment 9 Richard Biener 2011-01-14 14:28:33 UTC
It works.  Got bitten by

> ./xgcc -B. t.c -v
Reading specs from ./specs


... (again)