From patchwork Thu Sep 17 19:13:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lynn A. Boger" X-Patchwork-Id: 518999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 61F331402BC for ; Fri, 18 Sep 2015 05:13:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=u7PjjYNg; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=b974o5Y2LRFV9aR5M t4OtHDi/4ic2HJHwZrlXqFM5gZyC0+yzFumwF6H+rBrzIH7jz1t2f4tc48tkpg+s 4zhu9jC7iBYNj1tBp0prv0fRniulbSB7qvoW0TjLuYCggxp5yEtYJR9iZuAOae/T TIY+CYZcaOcEPF6A69vqg1Gytk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=ihfTrfnpQOAvN7gXpWoDqVD eZf4=; b=u7PjjYNgW9LEvoaI6xhe/o5ngbbJQlgN/eVZX+ALnUJzx4hW8TPL+qy hHdXiGRw7YNhT4kpaMilI7vtlWncMSnGGorO/Ieydux8Qd15PbUyCZLfW855/5X0 4lHeQ1dmt1xxX9U197+/3VLuSn10XI3RFuvqCacv4VQ2xGgVFsYU= Received: (qmail 1648 invoked by alias); 17 Sep 2015 19:13:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1629 invoked by uid 89); 17 Sep 2015 19:13:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e38.co.us.ibm.com Received: from e38.co.us.ibm.com (HELO e38.co.us.ibm.com) (32.97.110.159) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 17 Sep 2015 19:13:48 +0000 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Sep 2015 13:13:46 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 17 Sep 2015 13:13:45 -0600 X-MailFrom: laboger@linux.vnet.ibm.com X-RcptTo: gcc-patches@gcc.gnu.org Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 4C2A11FF0055 for ; Thu, 17 Sep 2015 13:04:54 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t8HJDjgN41222184 for ; Thu, 17 Sep 2015 12:13:45 -0700 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t8HJDix3013280 for ; Thu, 17 Sep 2015 13:13:44 -0600 Received: from oc2602623110.ibm.com (oc2602623110.ibm.com.rchland.ibm.com [9.10.86.136] (may be forged)) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t8HJDhuK013140; Thu, 17 Sep 2015 13:13:43 -0600 From: "Lynn A. Boger" Subject: Re: [PATCH] PR66870 PowerPC64 Enable gold linker with split stack To: Ian Lance Taylor References: <55D39752.5090602@linux.vnet.ibm.com> <55D4DA0B.6000106@ubuntu.com> <55D50BBA.6060909@linux.vnet.ibm.com> <55DF7A72.2040208@linux.vnet.ibm.com> <55F86277.8010100@linux.vnet.ibm.com> Cc: David Edelsohn , Matthias Klose , gcc-patches , Alan Modra Message-ID: <55FB10E7.9090607@linux.vnet.ibm.com> Date: Thu, 17 Sep 2015 14:13:43 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15091719-0029-0000-0000-00000CAE2D7A X-IsSubscribed: yes Here is my updated patch, with the changes suggested by Ian for gcc/gospec.c and David for gcc/configure.ac. Bootstrap built and tested on ppc64le, ppc64 multilib. 2015-09-17 Lynn Boger gcc/ PR target/66870 config/rs6000/sysv4.h: Define TARGET_CAN_SPLIT_STACK_64BIT config.in: Set up HAVE_GOLD_ALTERNATE_SPLIT_STACK configure.ac: Define HAVE_GOLD_ALTERNATE_SPLIT_STACK on Power based on gold linker version configure: Regenerate gcc.c: Add -fuse-ld=gold to STACK_SPLIT_SPEC if HAVE_GOLD_ALTERNATE_SPLIT_STACK defined go/gospec.c: (lang_specific_driver): Set appropriate split stack options for 64 bit compiles based on TARGET_CAN_SPLIT_STACK_64BIT On 09/15/2015 02:58 PM, Ian Lance Taylor wrote: > On Tue, Sep 15, 2015 at 11:24 AM, Lynn A. Boger > wrote: >> I need some feedback on whether to enable the gold linker at >> all for split stack on platforms other than Power in gcc/configure.ac. >> I don't know if there are gold linker versions that should be verified for >> non-Power platforms. My first patch only enabled it on Power and that >> is what I think should be done. Those who would like to use gold >> with split stack for other platforms can enable it under the appropriate >> conditions. > I think that is fine for now. If you want to enable gold for > i386/x86_64 with -fsplit-stack, that is also fine. > > Ian > > Index: gcc/config/rs6000/sysv4.h =================================================================== --- gcc/config/rs6000/sysv4.h (revision 227812) +++ gcc/config/rs6000/sysv4.h (working copy) @@ -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 Index: gcc/config.in =================================================================== --- gcc/config.in (revision 227812) +++ gcc/config.in (working copy) @@ -1310,6 +1310,12 @@ #endif +/* Define if the gold linker with split stack 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 Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 227812) +++ gcc/configure.ac (working copy) @@ -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 Index: gcc/gcc.c =================================================================== --- gcc/gcc.c (revision 227812) +++ gcc/gcc.c (working copy) @@ -666,7 +666,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 \ Index: gcc/go/gospec.c =================================================================== --- gcc/go/gospec.c (revision 227812) +++ gcc/go/gospec.c (working copy) @@ -106,6 +106,9 @@ lang_specific_driver (struct cl_decoded_option **i /* 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 **i /* Whether the -S option was used. */ bool saw_opt_S = false; + /* Whether the -m32 option was used. */ + bool saw_opt_m32 = 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 **i 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 **i /* Copy the 0th argument, i.e., the name of the program itself. */ new_decoded_options[j++] = decoded_options[i++]; +#ifdef TARGET_CAN_SPLIT_STACK + 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. */ -#ifdef TARGET_CAN_SPLIT_STACK - if (library >= 0) + 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 **i 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