This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Should the build system use ar rcs instead of ranlib + ar rc?
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Patrick Palka <patrick at parcs dot ath dot cx>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Fri, 15 Jul 2016 20:00:47 -0700
- Subject: Re: Should the build system use ar rcs instead of ranlib + ar rc?
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.13.1607152122590.1419@idea>
On Fri, Jul 15, 2016 at 6:46 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> The build step that invokes "ranlib libbackend.a" (which immediately
> follows the invocation of "ar rc libbackend.a ...") takes over 7 seconds
> on my machine and causes the entire 450MB archive to be rewritten. By
> instead making the build system use ar rcs -- so that the archive and
> its index are built at once -- the time it takes for the compiler to get
> rebuilt gets reduced by 25%, from 27s to 20s (in a --disable-bootstrap
> tree after touching a random source file). This is a pretty significant
> reduction in compile time and disk io.
>
> Is this a good idea?
Yes and no. Do we know if all ar support rcs now? Or is it just binutils's ar?
Thanks,
Andrew
>
> Here's the patchlet I used:
>
> -- >8 --
>
> diff --git a/Makefile.in b/Makefile.in
> index 117fbf5..5ebc3a3 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -393,7 +393,7 @@ MAKEINFOFLAGS = --split-size=5000000
>
> AS = @AS@
> AR = @AR@
> -AR_FLAGS = rc
> +AR_FLAGS = rcs
> CC = @CC@
> CXX = @CXX@
> DLLTOOL = @DLLTOOL@
> diff --git a/Makefile.tpl b/Makefile.tpl
> index 94a4f79..72ba24b 100644
> --- a/Makefile.tpl
> +++ b/Makefile.tpl
> @@ -396,7 +396,7 @@ MAKEINFOFLAGS = --split-size=5000000
>
> AS = @AS@
> AR = @AR@
> -AR_FLAGS = rc
> +AR_FLAGS = rcs
> CC = @CC@
> CXX = @CXX@
> DLLTOOL = @DLLTOOL@
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 0786fa3..1c3a637 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -236,7 +236,7 @@ BISONFLAGS =
> FLEX = @FLEX@
> FLEXFLAGS =
> AR = @AR@
> -AR_FLAGS = rc
> +AR_FLAGS = rcs
> NM = @NM@
> RANLIB = @RANLIB@
> RANLIB_FLAGS = @ranlib_flags@
> @@ -1883,17 +1883,14 @@ compilations: $(BACKEND)
> libbackend.a: $(OBJS)
> -rm -rf libbackend.a
> $(AR) $(AR_FLAGS) libbackend.a $(OBJS)
> - -$(RANLIB) $(RANLIB_FLAGS) libbackend.a
>
> libcommon-target.a: $(OBJS-libcommon-target)
> -rm -rf libcommon-target.a
> $(AR) $(AR_FLAGS) libcommon-target.a $(OBJS-libcommon-target)
> - -$(RANLIB) $(RANLIB_FLAGS) libcommon-target.a
>
> libcommon.a: $(OBJS-libcommon)
> -rm -rf libcommon.a
> $(AR) $(AR_FLAGS) libcommon.a $(OBJS-libcommon)
> - -$(RANLIB) $(RANLIB_FLAGS) libcommon.a
>
> # We call this executable `xgcc' rather than `gcc'
> # to avoid confusion if the current directory is in the path