From patchwork Sat Jul 16 22:13:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 649170 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 3rsNy40H65z9s9N for ; Sun, 17 Jul 2016 08: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=XMZ7ecXX; 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 :date:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=h3Up7Bad3rF7MoZj +PBVvTf31qEwQxcYUVbLC+8lVwvUjHAZZBljs4HZM+AUeDAD1938xG/mVo4w3P6Z oY+RZNfigsqCJQm6Qi/ktboAVOHHpUJytZZLbWY62xSNrG185VdDoaelfALsy03h Nf5abnXXzMblF6oGNY+U/tFo0gU= 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 :date:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=U2ETjTjE4rxpZ1WvnQxPu9 7SbK4=; b=XMZ7ecXXuFxSSRlnolYkL28b8iyFIDkOnYNGnfqbKCMe934Tznp+0O gp6o+MvJ4lIWtAz5cEBorJkei25+EiJwaTrCKBi6p77n/amS0es8lgn0yMkD8/A1 GaDfzm/z5wH7nLYX+W/7R2dPslTQvbSoPVw2h2aXLnVK1IJgaZSfE= Received: (qmail 42868 invoked by alias); 16 Jul 2016 22:13:50 -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 42567 invoked by uid 89); 16 Jul 2016 22:13:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=HTo:D*cx, libdecnumber, Objective, LIBDECNUMBER X-HELO: mail-qk0-f195.google.com Received: from mail-qk0-f195.google.com (HELO mail-qk0-f195.google.com) (209.85.220.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 16 Jul 2016 22:13:39 +0000 Received: by mail-qk0-f195.google.com with SMTP id n202so7387207qke.0 for ; Sat, 16 Jul 2016 15:13:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=TXFi6EqyLzQMO09t7QszbinHG0rfC6VQHR+R2bBSBrQ=; b=X3D1sorEMCF+SPSP7+MMmEqSW6PixnRUbYnSWVX0qZByTDLYkt9+rzG8O/0XOfKClT awYLSwRZx3z9/pwp82jtPLQszYA+46K9dhumjoc7t16qZHBJiCKlY+5slhBNxUCBLLhO ILJRLYrMI2W1oQWe71XlYvXOEmSnpwDSFAfKMEoGWVknGH/Mdi2jCuWFIIRPhqhrC+CT 8NqICXJEOQfvMPOTEWnaz82hDV+vgRGBkXDfYJtVNXtHb2pANhJwW/VLgYpUzi19RPTl ZBawCulAhFtcqw8TRkrqYqhKyezfgfNg8XAITpxUA4dDaFc1jG/X+fVC5F/j2p9S+c5I d3SA== X-Gm-Message-State: ALyK8tIJw0e6JPr25n4ua+RsRDKmIQAOVXz4KOvJsT0bWB9+4QMwknTxMWB5ZuSb5A8BKw== X-Received: by 10.55.181.193 with SMTP id e184mr12735945qkf.181.1468707217425; Sat, 16 Jul 2016 15:13:37 -0700 (PDT) Received: from [192.168.1.130] (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id 123sm1627519qkl.41.2016.07.16.15.13.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jul 2016 15:13:36 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Sat, 16 Jul 2016 18:13:36 -0400 (EDT) To: Patrick Palka cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Avoid invoking ranlib on libbackend.a In-Reply-To: <20160716182648.31308-1-patrick@parcs.ath.cx> Message-ID: References: <20160716182648.31308-1-patrick@parcs.ath.cx> User-Agent: Alpine 2.20.13 (DEB 116 2015-12-14) MIME-Version: 1.0 On Sat, 16 Jul 2016, Patrick Palka wrote: > This patch makes the 0.5GB libbackend.a get built via "ar rcs" instead > of via "ar rc" + "ranlib", if possible. The problem with the latter is > that it's about twice as slow as the former and it makes libbackend.a > get written twice which is wasteful. On my machine this optimization > reduces rebuild time in a --disable-bootstrap tree after touching tree.c > by around 25%, from ~28s to ~21s. This optimization is only performed > when the current ar is GNU ar where we can be reasonably sure that the > "rcs" directive is supported. > > Does this change look reasonable? I am currently bootstrapping it on > x86_64-pc-linux-gnu. > > gcc/ChangeLog: > > * configure.ac (ar_is_gnu): New variable. AC_SUBST it. > * configure: Regenerate. > * Makefile.in (AR_IS_GNU): New variable. > (USE_AR_RCS): New variable. > (libbackend.a): When building this archive, if USE_AR_RCS then > just invoke "ar rcs" instead of invoking "ar rc" followed by > "ranlib". > --- > gcc/Makefile.in | 18 ++++++++++++++++++ > gcc/configure | 15 +++++++++++++-- > gcc/configure.ac | 8 ++++++++ > 3 files changed, 39 insertions(+), 2 deletions(-) > > diff --git a/gcc/Makefile.in b/gcc/Makefile.in > index 0786fa3..5ae6100 100644 > --- a/gcc/Makefile.in > +++ b/gcc/Makefile.in > @@ -237,10 +237,22 @@ FLEX = @FLEX@ > FLEXFLAGS = > AR = @AR@ > AR_FLAGS = rc > +AR_IS_GNU = @ar_is_gnu@ > NM = @NM@ > RANLIB = @RANLIB@ > RANLIB_FLAGS = @ranlib_flags@ > > +# Whether invocations of ar + ranlib can be replaced by a single > +# invocation of "ar rcs". > +USE_AR_RCS = no > +ifeq ($(AR_IS_GNU),yes) > +ifeq ($(AR_FLAGS),rc) > +ifeq ($(RANLIB_FLAGS),) > +USE_AR_RCS = yes > +endif > +endif > +endif > + > # Libraries to use on the host. > HOST_LIBS = @HOST_LIBS@ > > @@ -1882,8 +1894,14 @@ compilations: $(BACKEND) > # This archive is strictly for the host. > libbackend.a: $(OBJS) > -rm -rf libbackend.a > + @# Elide the invocation of ranlib if possible, as doing so > + @# significantly reduces the build time of this archive. > +ifeq ($(USE_AR_RCS),yes) > + $(AR) $(AR_FLAGS)s libbackend.a $(OBJS) > +else > $(AR) $(AR_FLAGS) libbackend.a $(OBJS) > -$(RANLIB) $(RANLIB_FLAGS) libbackend.a > +endif > > libcommon-target.a: $(OBJS-libcommon-target) > -rm -rf libcommon-target.a > diff --git a/gcc/configure b/gcc/configure > index ed44472..db761c8 100755 > --- a/gcc/configure > +++ b/gcc/configure > @@ -749,6 +749,7 @@ CXXDEPMODE > DEPDIR > am__leading_dot > doc_build_sys > +ar_is_gnu > AR > NM > BISON > @@ -8459,6 +8460,16 @@ fi > > fi > > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ar is GNU ar" >&5 > +$as_echo_n "checking whether ar is GNU ar... " >&6; } > +ar_is_gnu=no > +if $AR --version 2>/dev/null | sed 1q | grep "GNU ar" > /dev/null; then > + ar_is_gnu=yes > +fi > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ar_is_gnu" >&5 > +$as_echo "$ar_is_gnu" >&6; } > + > + > # The jit documentation looks better if built with sphinx, but can be > # built with texinfo if sphinx is not available. > # Set "doc_build_sys" to "sphinx" or "texinfo" accordingly. > @@ -18475,7 +18486,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 18478 "configure" > +#line 18489 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > @@ -18581,7 +18592,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 18584 "configure" > +#line 18595 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > diff --git a/gcc/configure.ac b/gcc/configure.ac > index 086d0fc..3749b21 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -1081,6 +1081,14 @@ else > AC_CHECK_PROG(AR, ar, ar, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing ar) > fi > > +AC_MSG_CHECKING(whether ar is GNU ar) > +ar_is_gnu=no > +if $AR --version 2>/dev/null | sed 1q | grep "GNU ar" > /dev/null; then > + ar_is_gnu=yes > +fi > +AC_MSG_RESULT($ar_is_gnu) > +AC_SUBST(ar_is_gnu) > + > # The jit documentation looks better if built with sphinx, but can be > # built with texinfo if sphinx is not available. > # Set "doc_build_sys" to "sphinx" or "texinfo" accordingly. > -- > 2.9.2.321.g3e7e728 > > Even better, why build libbackend.a at all? Why not just pass the list of object files directly to the linker instead of going through an intermediate archive? The following patch cuts rebuild time by 50%, from 28s to 14s by making libbackend.a no longer get built. (The Make-lang.in hunk is apparently necessary to avoid duplicate-reference link errors since incpath.o is already listed in $(OBJS)). diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5ae6100..7b8ec16 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1591,7 +1591,7 @@ endif # compilation or not. ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS) -BACKEND = libbackend.a main.o libcommon-target.a libcommon.a \ +BACKEND = $(OBJS) main.o libcommon-target.a libcommon.a \ $(CPPLIB) $(LIBDECNUMBER) # This is defined to "yes" if Tree checking is enabled, which roughly means diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index cc3337d..d09b449 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -67,7 +67,7 @@ g++-cross$(exeext): xg++$(exeext) # The compiler itself. # Shared with C front end: -CXX_C_OBJS = attribs.o incpath.o \ +CXX_C_OBJS = attribs.o \ $(C_COMMON_OBJS) $(CXX_TARGET_OBJS) # Language-specific object files for C++ and Objective C++.