From patchwork Fri Nov 29 13:29:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Klose X-Patchwork-Id: 295317 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DFF6B2C00EF for ; Sat, 30 Nov 2013 00:31:44 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=bIgTtvZmupUBvM96eNG6yyeAw3aRskLUIfXmnPEWhSu wBDKL+/fRiOETAZQhpebaMAZmV8eEGMRyaetmh/BFvk+oeGKAsO0/FknAodV+Erq fZkebHEljC+3W6qk6fanMe2uR1SFaSKzMIKS1zINYNQSDQby/A7rXBv4QFh15eAU = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=y5I/NfjTi8xNybLlvQSPhH/a8W0=; b=LH1QdAiS5BAmSgFIM Y18VnuZtH+F3CYx9pdPINxtjhNFmOZtP+9WsJCtmkXXsqxr9VdwWCz4f9hRFwPXU hi9798DuqFb7hQ/6perqfonpXFGxlLpanjKtSnGmBE1k7FvF5hF4I8fJ9QxS0Og+ qv6NrGPTar90kUJmiYaCbeE/MQ= Received: (qmail 2552 invoked by alias); 29 Nov 2013 13:31:03 -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 2513 invoked by uid 89); 29 Nov 2013 13:31:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: einhorn.in-berlin.de Received: from Unknown (HELO einhorn.in-berlin.de) (192.109.42.8) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 29 Nov 2013 13:30:00 +0000 X-Envelope-From: doko@ubuntu.com Received: from [192.168.42.220] (dslb-088-073-114-231.pools.arcor-ip.net [88.73.114.231]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id rATDTou2004567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 29 Nov 2013 14:29:51 +0100 Message-ID: <529896C7.6040905@ubuntu.com> Date: Fri, 29 Nov 2013 14:29:43 +0100 From: Matthias Klose User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: GCC Patches CC: Ian Lance Taylor Subject: [patch] Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack to get full advantage of the -fsplit-stack option, gccgo binaries have to be linked with gold, not the bfd linker. When the system linker defaults to the bfd linker, then gccgo should explicitly use the gold linker, passing fuse-ld=gold, unless another -fuse-ld option is present. Tested with and without having ld.gold on the system. Matthias # DP: Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack gcc/go/ * gospec.c (lang_specific_driver): Pass -fuse-ld=gold on targets supporting -fsplit-stack, unless overwritten. gcc/ * configure.ac: New define HAVE_GOLD_NON_DEFAULT. * config.in: Regenerate. libgo/ * configure.ac (libgo_cv_c_linker_supports_split_stack): Fix quoting. Check the linker used by the gccgo driver. Index: b/src/gcc/go/gospec.c =================================================================== --- a/src/gcc/go/gospec.c +++ b/src/gcc/go/gospec.c @@ -117,6 +117,10 @@ /* Whether the -S option was used. */ bool saw_opt_S = false; + /* "-fuse-ld=" if it appears on the command line. */ + bool saw_use_ld = false; + int need_gold = 0; + /* The first input file with an extension of .go. */ const char *first_go_file = NULL; @@ -217,6 +221,11 @@ } break; + + case OPT_fuse_ld_bfd: + case OPT_fuse_ld_gold: + saw_use_ld = true; + break; } } @@ -226,8 +235,14 @@ shared_libgcc = 0; #endif +#if defined(TARGET_CAN_SPLIT_STACK) && defined(HAVE_GOLD_NON_DEFAULT) + if (!saw_use_ld) + need_gold = 1; +#endif + /* Make sure to have room for the trailing NULL argument. */ - num_args = argc + need_math + shared_libgcc + (library > 0) * 5 + 10; + num_args = argc + need_math + shared_libgcc + need_gold + + (library > 0) * 5 + 10; new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args); i = 0; @@ -244,6 +259,14 @@ &new_decoded_options[j]); j++; } +#ifdef HAVE_GOLD_NON_DEFAULT + if (need_gold) + { + generate_option (OPT_fuse_ld_gold, NULL, 1, CL_DRIVER, + &new_decoded_options[j]); + j++; + } +#endif #endif /* NOTE: We start at 1 now, not 0. */ Index: b/src/libgo/configure.ac =================================================================== --- a/src/libgo/configure.ac +++ b/src/libgo/configure.ac @@ -348,10 +348,10 @@ dnl others. AC_CACHE_CHECK([whether linker supports split stack], [libgo_cv_c_linker_supports_split_stack], -libgo_cv_c_linker_supports_split_stack=no -if $LD --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then +[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 -fi) +fi]) if test "$libgo_cv_c_linker_supports_split_stack" = yes; then AC_DEFINE(LINKER_SUPPORTS_SPLIT_STACK, 1, [Define if the linker support split stack adjustments]) Index: b/src/gcc/config.in =================================================================== --- a/src/gcc/config.in +++ b/src/gcc/config.in @@ -1133,6 +1133,12 @@ #endif +/* Define if the gold linker is available as a non-default */ +#ifndef USED_FOR_TARGET +#undef HAVE_GOLD_NON_DEFAULT +#endif + + /* Define if you have the iconv() function. */ #ifndef USED_FOR_TARGET #undef HAVE_ICONV Index: b/src/gcc/configure.ac =================================================================== --- a/src/gcc/configure.ac +++ b/src/gcc/configure.ac @@ -2060,6 +2060,12 @@ fi AC_MSG_RESULT($ld_is_gold) +# Check to see if ld is used, and gold is available +if test x$ld_is_gold = xno && which ${gcc_cv_ld}.gold >/dev/null 2>&1; then + AC_DEFINE(HAVE_GOLD_NON_DEFAULT, 1, + [Define if the gold linker is available as a non-default]) +fi + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld AC_SUBST(ORIGINAL_LD_FOR_TARGET) case "$ORIGINAL_LD_FOR_TARGET" in