Mainline GCC and gold now support -fsplit-stack for PPC. This means that if you are using mainline GCC with an old version of gold, and you compile with -fsplit-stack, and there is split-stack code that calls non-split-stack code, then gold will give an error because it doesn't know how to handle that case. Current gold nows how to handle it, but old gold does not. Avoid problems with the libgo build when using an old version of gold by testing whether that works. Bootstrapped on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 227784) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -23392287e9a26956977987fe95f337c5be4d6417 +6f0ac34e139755c319368757fe2a093f1e5bde49 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/configure.ac =================================================================== --- libgo/configure.ac (revision 227696) +++ libgo/configure.ac (working copy) @@ -374,7 +374,29 @@ AC_COMPILE_IFELSE([[int i;]], [libgo_cv_c_split_stack_supported=yes], [libgo_cv_c_split_stack_supported=no]) CFLAGS=$CFLAGS_hold]) -if test "$libgo_cv_c_split_stack_supported" = yes; then + +dnl Make sure the linker permits -fsplit-stack. Old versions of gold will +dnl reject split-stack code calling non-split-stack code on targets +dnl they don't support. +AC_CACHE_CHECK([whether linker supports split/non-split linked together], +[libgo_cv_c_linker_split_non_split], +[cat > conftest1.c << EOF +extern void f(); +int main() { f(); return 0; } +EOF +cat > conftest2.c << EOF +void f() {} +EOF +$CC -c -fsplit-stack $CFLAGS $CPPFLAGS conftest1.c +$CC -c $CFLAGS $CPPFLAGS conftest2.c +if $CC -o conftest conftest1.$ac_objext conftest2.$ac_objext; then + libgo_cv_c_linker_split_non_split=yes +else + libgo_cv_c_linker_split_non_split=no +fi +rm -f conftest1.* conftest2.* conftest]) + +if test "$libgo_cv_c_split_stack_supported" = yes -a "$libgo_cv_c_linker_split_non_split" = yes; then SPLIT_STACK=-fsplit-stack AC_DEFINE(USING_SPLIT_STACK, 1, [Define if the compiler supports -fsplit-stack]) @@ -383,13 +405,15 @@ else fi AC_SUBST(SPLIT_STACK) AM_CONDITIONAL(USING_SPLIT_STACK, - test "$libgo_cv_c_split_stack_supported" = yes) + test "$libgo_cv_c_split_stack_supported" = yes -a "$libgo_cv_c_linker_split_non_split" = 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 This is slightly different from the above check, which is whether +dnl the linker permits the call at all. AC_CACHE_CHECK([whether linker supports split stack], [libgo_cv_c_linker_supports_split_stack], [libgo_cv_c_linker_supports_split_stack=no