From patchwork Tue Oct 9 22:45:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 190505 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]) by ozlabs.org (Postfix) with SMTP id 328942C0040 for ; Wed, 10 Oct 2012 09:49:58 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350427799; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=oRCc+sOKbRG6MetZV+mbJ3SzQjs=; b=fuO8Wny/p0VTW5H riu47TU6ZrPslirHHK6geSpGDnOblCMFZbHpFwm+7PK6BEokbsXSybkfQCn+Qd5x bZEJpqhS+peH7FcQzxNcflHzB0g0wa1p+m0KPOwwBSwOcxmA7/aLxEB/qKXeo6iv fRoRV/PPXIYgqfeujlmvLGsFvFFk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=uKfnRMfl30PO0DwmBdzhUCJm3vtxhpL7OuokJ+qsqzmRUSWGfMQmn/oL9TMWQV Q8HB0QgdoQzbyNpQpl1335tlBPzlHDS3oivRNdJpeFYVeziUlq366+cq+lKhUt8k VhMdC6CerJLp3cPzoi23Szf5m7t1V3zGWAbbGRjxVD6PA=; Received: (qmail 22860 invoked by alias); 9 Oct 2012 22:49:53 -0000 Received: (qmail 22848 invoked by uid 22791); 9 Oct 2012 22:49:52 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Oct 2012 22:49:44 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E488D290028 for ; Wed, 10 Oct 2012 00:49:54 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7K3KOnqqiA7r for ; Wed, 10 Oct 2012 00:49:54 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id AEC7A290023 for ; Wed, 10 Oct 2012 00:49:54 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR bootstrap/54820 Date: Wed, 10 Oct 2012 00:45:28 +0200 Message-ID: <6538779.exI3fxXHMp@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 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 Hi, native compilers are now built with -static-libstdc++ -static-libgcc (if bootstrapped) because the switches are added to LDFLAGS during stage 2 and 3. Nothing is done for stage 1 or cross-compilers, except for Ada where we force the switches, but this is far from ideal as reported under the PR. The attached patch enables -static-libstdc++ -static-libgcc for stage 1 and cross-compilers if g++ is detected and the switches work, using the same idea as for later stages (i.e. setting --with-stage1-ldflags if not already set). It turns out that --with-stage1-ldflags is currently broken: LDFLAGS is correctly passed and set in gcc/ at configure time during stage 1, but a 'make' invocation from the toplevel passes an empty LDFLAGS to gcc/. Tested on x86_64-suse-linux, OK for the mainline? 2012-10-09 Eric Botcazou PR bootstrap/54820 * Makefile.tpl (STAGE1_FLAGS_TO_PASS): New variable. (host_modules): Add STAGE1_FLAGS_TO_PASS to args. * Makefile.in: Regenerate. * configure.ac (have_static_libs): New variable and associated check. (stage1-ldflags): Move to after stage1_libs and set to -static-libstdc++ -static-libgcc if stage1_libs is empty and have_static_libs is yes. * configure: Regenerate. gcc/ada * gcc-interface/Make-lang.in (GCC_LINK): Remove -static-libstdc++ -static-libgcc. Index: Makefile.tpl =================================================================== --- Makefile.tpl (revision 192137) +++ Makefile.tpl (working copy) @@ -615,6 +615,12 @@ EXTRA_HOST_FLAGS = \ FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) +# Flags to pass to stage1 or when not bootstrapping. + +STAGE1_FLAGS_TO_PASS = \ + LDFLAGS="$${LDFLAGS}" \ + HOST_LIBS="$${HOST_LIBS}" + # Flags to pass to stage2 and later makes. POSTSTAGE1_FLAGS_TO_PASS = \ @@ -1161,7 +1167,7 @@ clean-stage[+id+]-[+prefix+][+module+]: [+ all prefix="" subdir="$(HOST_SUBDIR)" exports="$(HOST_EXPORTS)" poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)" - args="$(EXTRA_HOST_FLAGS)" + args="$(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)" poststage1_args="$(POSTSTAGE1_FLAGS_TO_PASS)" +] .PHONY: check-[+module+] maybe-check-[+module+] Index: configure.ac =================================================================== --- configure.ac (revision 192137) +++ configure.ac (working copy) @@ -1182,6 +1182,22 @@ if test -z "$LD"; then fi fi +# Check whether -static-libstdc++ -static-libgcc is supported +have_static_libs=no +if test "$GCC" = yes; then + saved_LDFLAGS="$LDFLAGS" + + LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc" + AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc]) + AC_LANG_PUSH(C++) + AC_LINK_IFELSE([int main() {}], + [AC_MSG_RESULT([yes]); have_static_libs=yes], + [AC_MSG_RESULT([no])]) + AC_LANG_POP(C++) + + LDFLAGS="$saved_LDFLAGS" +fi + ACX_PROG_GNAT ACX_PROG_CMP_IGNORE_INITIAL @@ -1478,17 +1494,6 @@ case $with_host_libstdcxx in ;; esac -# Linker flags to use for stage1 or when not boostrapping. -AC_ARG_WITH(stage1-ldflags, -[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])], -[if test "$withval" = "no" -o "$withval" = "yes"; then - stage1_ldflags= - else - stage1_ldflags=$withval - fi], -[stage1_ldflags=]) -AC_SUBST(stage1_ldflags) - # Libraries to use for stage1 or when not bootstrapping. AC_ARG_WITH(stage1-libs, [AS_HELP_STRING([--with-stage1-libs=LIBS], [libraries for stage1])], @@ -1500,6 +1505,23 @@ AC_ARG_WITH(stage1-libs, [stage1_libs=$with_host_libstdcxx]) AC_SUBST(stage1_libs) +# Linker flags to use for stage1 or when not bootstrapping. +AC_ARG_WITH(stage1-ldflags, +[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])], +[if test "$withval" = "no" -o "$withval" = "yes"; then + stage1_ldflags= + else + stage1_ldflags=$withval + fi], +[stage1_ldflags= + # In stage 1, default to linking libstdc++ and libgcc statically with GCC + # if supported. But if the user explicitly specified the libraries to use, + # trust that they are doing what they want. + if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then + stage1_ldflags="-static-libstdc++ -static-libgcc" + fi]) +AC_SUBST(stage1_ldflags) + # Libraries to use for stage2 and later builds. This defaults to the # argument passed to --with-host-libstdcxx. AC_ARG_WITH(boot-libs, Index: gcc/ada/gcc-interface/Make-lang.in =================================================================== --- gcc/ada/gcc-interface/Make-lang.in (revision 192137) +++ gcc/ada/gcc-interface/Make-lang.in (working copy) @@ -172,7 +172,7 @@ endif # Strip -Werror during linking for the LTO bootstrap GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) -GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) -static-libgcc -static-libstdc++ $(LDFLAGS) +GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS) # Lists of files for various purposes.