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?

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

Reply via email to