public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR66870 PowerPC64 Enable gold linker with split stack
@ 2015-08-18 21:14 Lynn A. Boger
  2015-08-19 19:37 ` Matthias Klose
  2015-08-25 23:05 ` Ian Lance Taylor
  0 siblings, 2 replies; 36+ messages in thread
From: Lynn A. Boger @ 2015-08-18 21:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: david Edelsohn, Ian Taylor, Alan Modra

[-- Attachment #1: Type: text/plain, Size: 1921 bytes --]

As discussed in PR 66870, for ppc64le and ppc64le it is preferred to
  use the gold linker with gccgo or gcc if the split stack option is 
enabled.
Use of the gold linker with the split stack option results in less storage
allocated for goroutine stacks; if split stack is used without the gold
linker then some testcase failures can occur.

   Since the use of the gold linker has not been well tested
with all gcc compilers on Power, it is only used as the linker if the
split stack option is used.

This adds the capability to the configure for gcc and libgo to determine
if the gold linker is available at build time, either in the path or 
explicitly
  configured, and its version supports split stack.  If that is the case 
then
defines are set that cause the gold linker to be used by the compiler when
-fsplit-stack is used.  This applies to ppc64 and ppc64le.  Other platforms
with split stack work as before.

2015-08-18    Lynn Boger <laboger@linux.vnet.ibm.com>

gcc/
         PR target/66870
         config/rs6000/linux64.h: When HAVE_LD_GOLD_SUPPORTS_SPLIT_STACK
         is defined add -fuse-ld=gold if fsplit-stack and not m32
         config/rs6000/sysv4.h:  Define TARGET_CAN_SPLIT_STACK based on
         LIBC version.
         config.in:  Set up HAVE_LD_GOLD_SUPPORTS_SPLIT_STACK.
         configure.ac:  When gold linker is available and its version
         supports split stack on ppc64, ppc64le, define
         HAVE_LD_GOLD_SUPPORTS_SPLIT_STACK.
         configure:  Regenerate.

libgo/
         PR target/66870
         configure.ac:  When gccgo for building libgo uses the gold version
         containing split stack support on ppc64, ppc64le, define
         LINKER_SUPPORTS_SPLIT_STACK.
         configure:  Regenerate.

For platforms other than ppc64 and ppc64le, the configure for gcc
and libgo behave as before.

Bootstrapped and ran libgo and go testsuite on ppc64, ppc64le, x86_64.




[-- Attachment #2: gccgo-config-gold-pr66870.diff --]
[-- Type: text/x-patch, Size: 5288 bytes --]

Index: gcc/config/rs6000/linux64.h
===================================================================
--- gcc/config/rs6000/linux64.h	(revision 226894)
+++ gcc/config/rs6000/linux64.h	(working copy)
@@ -227,8 +227,12 @@ extern int dot_symbols;
 #endif
 
 #ifndef LINK_OS_EXTRA_SPEC64
+#ifdef HAVE_LD_GOLD_SUPPORTS_SPLIT_STACK
+#define LINK_OS_EXTRA_SPEC64   "%{fsplit-stack: %{!m32: -fuse-ld=gold}}"
+#else
 #define LINK_OS_EXTRA_SPEC64	""
 #endif
+#endif
 
 #ifndef LINK_OS_NEW_DTAGS_SPEC
 #define LINK_OS_NEW_DTAGS_SPEC	""
Index: gcc/config/rs6000/sysv4.h
===================================================================
--- gcc/config/rs6000/sysv4.h	(revision 226894)
+++ gcc/config/rs6000/sysv4.h	(working copy)
@@ -946,6 +946,12 @@ ncrtn.o%s"
 #undef TARGET_ASAN_SHADOW_OFFSET
 #define TARGET_ASAN_SHADOW_OFFSET rs6000_asan_shadow_offset
 
+#undef TARGET_CAN_SPLIT_STACK
+#if TARGET_GLIBC_MAJOR > 2 \
+  || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 18)
+#define TARGET_CAN_SPLIT_STACK 1
+#endif
+
 /* This target uses the sysv4.opt file.  */
 #define TARGET_USES_SYSV4_OPT 1
 
Index: gcc/config.in
===================================================================
--- gcc/config.in	(revision 226894)
+++ gcc/config.in	(working copy)
@@ -1484,6 +1484,11 @@
 #endif
 
 
+/* Define to 1 if there is a gold linker in the path which supports split stack. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LD_GOLD_SUPPORTS_SPLIT_STACK
+#endif
+
 /* Define to 1 if you have the <limits.h> header file. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LIMITS_H
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 226894)
+++ gcc/configure.ac	(working copy)
@@ -5174,7 +5174,41 @@ EOF
       AC_DEFINE_UNQUOTED(POWERPC64_TOC_POINTER_ALIGNMENT, $gcc_cv_ld_toc_align,
     [Define to .TOC. alignment forced by your linker.])
     fi
-    ;;
+
+# Check for split stack support within the gold linker
+    AC_CACHE_CHECK(gold linker supports split stack,
+    gcc_cv_ld_gold_supports_split_stack,
+    [gcc_cv_ld_gold_supports_split_stack=no
+    if test x"$ld_is_gold" = xyes; then
+        gold_linker=$gcc_cv_ld
+    elif "$ORIGINAL_LD_GOLD_FOR_TARGET" --version | grep gold >/dev/null 2>&1; then
+        gold_linker=$ORIGINAL_LD_GOLD_FOR_TARGET
+    else
+        gold_linker=""
+    fi
+    if test "$gold_linker" != ""; then
+        gold_vers=`$gold_linker --version | sed 1q | sed -n -e 's/.*Binutils.* \([[0-9]][[0-9]]*\.[[^)]]*\)).*$/\1/p'`
+        gold_vers_major=`expr "$gold_vers" : '\([[0-9]]*\)'`
+        gold_vers_minor=`expr "$gold_vers" : '[[0-9]]*\.\([[0-9]]*\)'`
+        gold_vers_patch=`expr "$gold_vers" : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+
+        case x"$gold_vers_minor" in
+          x25)
+            if test x"$gold_vers_patch" != ""; then
+              gcc_cv_ld_gold_supports_split_stack=yes
+            fi
+            ;;
+          x2[[6-9]])
+            gcc_cv_ld_gold_supports_split_stack=yes
+            ;;
+        esac     
+   fi
+   ])
+   if test x"$gcc_cv_ld_gold_supports_split_stack" = xyes; then
+      AC_DEFINE(HAVE_LD_GOLD_SUPPORTS_SPLIT_STACK, 1,
+   [Define if your PowerPC64 gold linker supports split stack.])
+   fi
+   ;;
 esac
 
 case "$target" in
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac	(revision 226894)
+++ libgo/configure.ac	(working copy)
@@ -385,16 +385,35 @@ AC_SUBST(SPLIT_STACK)
 AM_CONDITIONAL(USING_SPLIT_STACK,
 	test "$libgo_cv_c_split_stack_supported" = yes)
 
-dnl Check whether the linker does stack munging when calling from
-dnl split-stack into non-split-stack code.  We check this by looking
-dnl at the --help output.  FIXME: This is only half right: it's
-dnl possible for the linker to support this for some targets but not
-dnl others.
+dnl Check whether the gold linker is the linker used by gccgo.
+dnl For ppc64 and ppc64le, check the gold linker version to
+dnl verify it contains split stack support.
 AC_CACHE_CHECK([whether linker supports split stack],
 [libgo_cv_c_linker_supports_split_stack],
 [libgo_cv_c_linker_supports_split_stack=no
-if $GOC -Wl,--help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
-  libgo_cv_c_linker_supports_split_stack=yes
+if test "$is_ppc64" == "yes" || test "$is_ppc64le" == "yes"; then
+  if $GOC -Wl,--version | grep -i gold >/dev/null 2>&1; then
+    gold_vers=`$GOC -Wl,--version | sed 1q | sed -n -e 's/.*Binutils.* \([[0-9]][[0-9]]*\.[[^)]]*\)).*$/\1/p'`
+    gold_vers_major=`expr "$gold_vers" : '\([[0-9]]*\)'`
+    gold_vers_minor=`expr "$gold_vers" : '[[0-9]]*\.\([[0-9]]*\)'`
+    gold_vers_patch=`expr "$gold_vers" : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+
+    case x"$gold_vers_minor" in
+      x25)
+        if test x"$gold_vers_patch" != ""; then
+          libgo_cv_c_linker_supports_split_stack=yes
+        fi
+        ;;
+      x2[[6-9]])
+        libgo_cv_c_linker_supports_split_stack=yes
+        ;;
+      esac
+  fi
+
+else
+  if $GOC -Wl,--help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
+    libgo_cv_c_linker_supports_split_stack=yes
+  fi
 fi])
 if test "$libgo_cv_c_linker_supports_split_stack" = yes; then
   AC_DEFINE(LINKER_SUPPORTS_SPLIT_STACK, 1,

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2015-10-17  0:25 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18 21:14 [PATCH] PR66870 PowerPC64 Enable gold linker with split stack Lynn A. Boger
2015-08-19 19:37 ` Matthias Klose
2015-08-19 19:42   ` David Edelsohn
2015-08-19 22:07   ` Lynn A. Boger
2015-08-20  0:01   ` Lynn A. Boger
2015-08-27 21:37     ` Lynn A. Boger
2015-09-15 16:50       ` Ian Lance Taylor
2015-09-15 18:21       ` David Edelsohn
2015-09-15 18:31         ` Lynn A. Boger
2015-09-15 20:04           ` Ian Lance Taylor
2015-09-17 19:15             ` Lynn A. Boger
2015-09-18 12:59               ` David Edelsohn
2015-09-30 12:46                 ` Lynn A. Boger
     [not found]               ` <CAOyqgcVA_zhivM0+qRFk9bDT42Sot-HX95M1NtZjLVphZy_0vg@mail.gmail.com>
2015-10-03 18:31                 ` Matthias Klose
     [not found]                   ` <56153C00.2000209@linux.vnet.ibm.com>
2015-10-07 17:04                     ` Ian Lance Taylor
2015-10-07 17:25                       ` David Edelsohn
2015-10-07 17:31                     ` Matthias Klose
     [not found]                       ` <5615746C.3030509@linux.vnet.ibm.com>
2015-10-07 21:58                         ` David Edelsohn
2015-10-08 18:56                       ` Lynn A. Boger
2015-10-08 20:46                         ` Matthias Klose
2015-10-09 20:17                           ` Lynn A. Boger
2015-10-10 14:00                             ` David Edelsohn
2015-10-10 21:03                               ` Matthias Klose
2015-10-10 21:25                             ` Andreas Schwab
2015-10-11 13:07                               ` Alan Modra
2015-10-11 14:43                                 ` Andreas Schwab
2015-10-11 18:29                                   ` Ian Lance Taylor
2015-10-11 23:19                                     ` Alan Modra
2015-10-12 15:15                                 ` Lynn A. Boger
2015-10-12 22:53                                   ` Alan Modra
2015-10-13 11:27                                     ` Matthias Klose
2015-10-15 18:40                                 ` David Edelsohn
2015-10-15 19:57                                   ` Lynn A. Boger
2015-10-17  0:37                                 ` Ian Lance Taylor
2015-08-25 23:05 ` Ian Lance Taylor
2015-08-26 14:01   ` Lynn A. Boger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).