===================================================================
@@ -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 ""
===================================================================
@@ -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
===================================================================
@@ -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
===================================================================
@@ -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
===================================================================
@@ -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,