From 402565b61f9783473472fcfd729efa8c1e355d2b Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Wed, 30 Sep 2015 18:06:11 -0500 Subject: [PATCH] re PR go/66870 (split stack issues on ppc64le and ppc64) PR target/66870 * config/rs6000/sysv4.h (TARGET_CAN_SPLIT_STACK_64BIT): Define. * configure.ac: Define HAVE_GOLD_ALTERNATE_SPLIT_STACK on Power based on gold linker version. * gcc.c: Add -fuse-ld=gold to STACK_SPLIT_SPEC if HAVE_GOLD_ALTERNATE_SPLIT_STACK defined. * configure, config.in: Regenerate. go: * gospec.c (lang_specific_driver): Set appropriate split stack options for 64 bit compiles based on TARGET_CAN_SPLIT_STACK_64BIT. From-SVN: r228311 --- gcc/ChangeLog | 10 ++++++++++ gcc/config.in | 13 +++++++++++++ gcc/config/rs6000/sysv4.h | 8 ++++++++ gcc/configure | 39 +++++++++++++++++++++++++++++++++++++++ gcc/configure.ac | 36 ++++++++++++++++++++++++++++++++++++ gcc/gcc.c | 4 ++++ gcc/go/ChangeLog | 6 ++++++ gcc/go/gospec.c | 27 +++++++++++++++++++++------ 8 files changed, 137 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7ecb443ed87..c8200dbff5c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-10-01 Lynn Boger + + PR target/66870 + * config/rs6000/sysv4.h (TARGET_CAN_SPLIT_STACK_64BIT): Define. + * configure.ac: Define HAVE_GOLD_ALTERNATE_SPLIT_STACK on Power + based on gold linker version. + * gcc.c: Add -fuse-ld=gold to STACK_SPLIT_SPEC if + HAVE_GOLD_ALTERNATE_SPLIT_STACK defined. + * configure, config.in: Regenerate. + 2015-10-01 Alan Modra * config/rs6000/rs6000.c (rs6000_emit_prologue): Don't set diff --git a/gcc/config.in b/gcc/config.in index 8556986ccfa..093478c2840 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1310,6 +1310,13 @@ #endif +/* Define if the gold linker supports split stack and is available as a + non-default */ +#ifndef USED_FOR_TARGET +#undef HAVE_GOLD_NON_DEFAULT_SPLIT_STACK +#endif + + /* Define if you have the iconv() function. */ #ifndef USED_FOR_TARGET #undef HAVE_ICONV @@ -1839,6 +1846,12 @@ #endif +/* Define if your assembler supports .dwsect 0xB0000 */ +#ifndef USED_FOR_TARGET +#undef HAVE_XCOFF_DWARF_EXTRAS +#endif + + /* Define if isl is in use. */ #ifndef USED_FOR_TARGET #undef HAVE_isl diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index f48af43e7c5..7b2f9bd6f0d 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -940,6 +940,14 @@ ncrtn.o%s" #undef TARGET_ASAN_SHADOW_OFFSET #define TARGET_ASAN_SHADOW_OFFSET rs6000_asan_shadow_offset +/* On ppc64 and ppc64le, split stack is only support for + 64 bit. */ +#undef TARGET_CAN_SPLIT_STACK_64BIT +#if TARGET_GLIBC_MAJOR > 2 \ + || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 18) +#define TARGET_CAN_SPLIT_STACK_64BIT +#endif + /* This target uses the sysv4.opt file. */ #define TARGET_USES_SYSV4_OPT 1 diff --git a/gcc/configure b/gcc/configure index c2b630e1e63..f6ae99062c5 100755 --- a/gcc/configure +++ b/gcc/configure @@ -22015,6 +22015,45 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_is_gold" >&5 $as_echo "$ld_is_gold" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking gold linker with split stack support as non default" >&5 +$as_echo_n "checking gold linker with split stack support as non default... " >&6; } +# Check to see if default ld is not gold, but gold is +# available and has support for split stack. If gcc was configured +# with gold then no checking is done. +# +if test x$ld_is_gold = xno && which ${gcc_cv_ld}.gold >/dev/null 2>&1; then + +# For platforms other than powerpc64*, enable as appropriate. + + gold_non_default=no + ld_gold=`which ${gcc_cv_ld}.gold` +# Make sure this gold has minimal split stack support + if $ld_gold --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then + ld_vers=`$ld_gold --version | sed 1q` + gold_vers=`echo $ld_vers | sed -n \ + -e 's,^[^)]*[ ]\([0-9][0-9]*\.[0-9][0-9]*[^)]*\)) .*$,\1,p'` + case $target in +# check that the gold version contains the complete split stack support +# on powerpc64 big and little endian + powerpc64*-*-*) + case "$gold_vers" in + 2.25.[1-9]*|2.2[6-9][.0-9]*|2.[3-9][.0-9]*|[3-9].[.0-9]*) gold_non_default=yes + ;; + *) gold_non_default=no + ;; + esac + ;; + esac + fi + if test $gold_non_default = yes; then + +$as_echo "#define HAVE_GOLD_NON_DEFAULT_SPLIT_STACK 1" >>confdefs.h + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gold_non_default" >&5 +$as_echo "$gold_non_default" >&6; } + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld case "$ORIGINAL_LD_FOR_TARGET" in diff --git a/gcc/configure.ac b/gcc/configure.ac index 49ca31a45cd..88fb9bf178c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2247,6 +2247,42 @@ if test x$gcc_cv_ld != x; then fi AC_MSG_RESULT($ld_is_gold) +AC_MSG_CHECKING(gold linker with split stack support as non default) +# Check to see if default ld is not gold, but gold is +# available and has support for split stack. If gcc was configured +# with gold then no checking is done. +# +if test x$ld_is_gold = xno && which ${gcc_cv_ld}.gold >/dev/null 2>&1; then + +# For platforms other than powerpc64*, enable as appropriate. + + gold_non_default=no + ld_gold=`which ${gcc_cv_ld}.gold` +# Make sure this gold has minimal split stack support + if $ld_gold --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then + ld_vers=`$ld_gold --version | sed 1q` + gold_vers=`echo $ld_vers | sed -n \ + -e 's,^[[^)]]*[[ ]]\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*[[^)]]*\)) .*$,\1,p'` + case $target in +# check that the gold version contains the complete split stack support +# on powerpc64 big and little endian + powerpc64*-*-*) + case "$gold_vers" in + 2.25.[[1-9]]*|2.2[[6-9]][[.0-9]]*|2.[[3-9]][[.0-9]]*|[[3-9]].[[.0-9]]*) gold_non_default=yes + ;; + *) gold_non_default=no + ;; + esac + ;; + esac + fi + if test $gold_non_default = yes; then + AC_DEFINE(HAVE_GOLD_NON_DEFAULT_SPLIT_STACK, 1, + [Define if the gold linker supports split stack and is available as a non-default]) + fi +fi +AC_MSG_RESULT($gold_non_default) + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld AC_SUBST(ORIGINAL_LD_FOR_TARGET) case "$ORIGINAL_LD_FOR_TARGET" in diff --git a/gcc/gcc.c b/gcc/gcc.c index 55a725583b8..db90796d048 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -667,7 +667,11 @@ proper position among the other output files. */ libgcc. This is not yet a real spec, though it could become one; it is currently just stuffed into LINK_SPEC. FIXME: This wrapping only works with GNU ld and gold. */ +#ifdef HAVE_GOLD_NON_DEFAULT_SPLIT_STACK +#define STACK_SPLIT_SPEC " %{fsplit-stack: -fuse-ld=gold --wrap=pthread_create}" +#else #define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}" +#endif #ifndef LIBASAN_SPEC #define STATIC_LIBASAN_LIBS \ diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 2fa56ab0ac0..a6e8dd5f1ee 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,9 @@ +2015-10-01 Lynn Boger + + PR target/66870 + * gospec.c (lang_specific_driver): Set appropriate split stack + options for 64 bit compiles based on TARGET_CAN_SPLIT_STACK_64BIT. + 2015-09-10 Chris Manghane * go-gcc.cc (Gcc_backend::type_size): Return -1 for diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c index 9ccbe75df44..2c60ee7db8f 100644 --- a/gcc/go/gospec.c +++ b/gcc/go/gospec.c @@ -106,6 +106,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* The total number of arguments with the new stuff. */ int num_args = 1; + /* Supports split stack */ + int supports_split_stack = 0; + /* Whether the -o option was used. */ bool saw_opt_o = false; @@ -117,6 +120,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Whether the -S option was used. */ bool saw_opt_S = false; + /* Whether the -m32 option was used. */ + bool saw_opt_m32 ATTRIBUTE_UNUSED = false; + /* The first input file with an extension of .go. */ const char *first_go_file = NULL; @@ -152,6 +158,10 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, library = (library == 0) ? 1 : library; break; + case OPT_m32: + saw_opt_m32 = true; + break; + case OPT_pg: case OPT_p: saw_profile_flag = true; @@ -236,15 +246,22 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Copy the 0th argument, i.e., the name of the program itself. */ new_decoded_options[j++] = decoded_options[i++]; - /* If we are linking, pass -fsplit-stack if it is supported. */ #ifdef TARGET_CAN_SPLIT_STACK - if (library >= 0) + supports_split_stack = 1; +#endif + +#ifdef TARGET_CAN_SPLIT_STACK_64BIT + if (!saw_opt_m32) + supports_split_stack = 1; +#endif + + /* If we are linking, pass -fsplit-stack if it is supported. */ + if ((library >= 0) && supports_split_stack) { generate_option (OPT_fsplit_stack, NULL, 1, CL_DRIVER, &new_decoded_options[j]); j++; } -#endif /* NOTE: We start at 1 now, not 0. */ while (i < argc) @@ -381,19 +398,17 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, generate_option (OPT_shared_libgcc, NULL, 1, CL_DRIVER, &new_decoded_options[j++]); -#ifdef TARGET_CAN_SPLIT_STACK /* libgcc wraps pthread_create to support split stack, however, due to relative ordering of -lpthread and -lgcc, we can't just mark __real_pthread_create in libgcc as non-weak. But we need to link in pthread_create from pthread if we are statically linking, so we work- around by passing -u pthread_create to the linker. */ - if (static_link) + if (static_link && supports_split_stack) { generate_option (OPT_Wl_, "-u,pthread_create", 1, CL_DRIVER, &new_decoded_options[j]); j++; } -#endif #if defined(TARGET_SOLARIS) && !defined(USE_GLD) /* We use a common symbol for go$zerovalue. On Solaris, when not -- 2.30.2