diff mbox

PR66870 PowerPC64 Enable gold linker with split stack

Message ID 55D39752.5090602@linux.vnet.ibm.com
State New
Headers show

Commit Message

Lynn A. Boger Aug. 18, 2015, 8:36 p.m. UTC
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.

Comments

Ian Lance Taylor Aug. 25, 2015, 10:51 p.m. UTC | #1
On Tue, Aug 18, 2015 at 1:36 PM, Lynn A. Boger
<laboger@linux.vnet.ibm.com> wrote:
>
> 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.

Your version test for gold isn't robust: if the major version >= 3,
then presumably split stack is supported.  And since you have numbers,
I suggest not trying to use switch, but instead writing something like
    if expr "$gold_minor" == 25; then
        ...
    elif expr "$gold_minor" > 25; then
        ...
    fi

If that is fixed, I'm fine with the libgo part of this patch.

Ian
Lynn A. Boger Aug. 26, 2015, 1:57 p.m. UTC | #2
I am working on a new patch to address some of the previous concerns
and plan to post it soon after some final testing.

On 08/25/2015 05:51 PM, Ian Lance Taylor wrote:
> On Tue, Aug 18, 2015 at 1:36 PM, Lynn A. Boger
> <laboger@linux.vnet.ibm.com> wrote:
>> 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.
> Your version test for gold isn't robust: if the major version >= 3,
> then presumably split stack is supported.  And since you have numbers,
> I suggest not trying to use switch, but instead writing something like
>      if expr "$gold_minor" == 25; then
>          ...
>      elif expr "$gold_minor" > 25; then
>          ...
>      fi
>
> If that is fixed, I'm fine with the libgo part of this patch.
>
> Ian
>
>
diff mbox

Patch

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,