GCC Speed Tweak
Greg Schafer
diy-linux-dev@diy-linux.org
Wed, 18 Jan 2006 11:40:50 +1100
Hi Guys
GCC bootstrap times slowed down dramatically when GCC-4.x was introduced. A
large proportion of this can be attributed to extra checking in the GCC
`make bootstrap' process. Specifically, STAGE1_CHECKING is defined in the
GCC Makefile unconditionally as:
STAGE1_CHECKING = -DENABLE_CHECKING -DENABLE_ASSERT_CHECKING
and there is unfortunately no easy way to switch it off. I asked about this
issue on the GCC list a while back:
http://gcc.gnu.org/ml/gcc/2005-01/msg00383.html
but as usual, the response was luke warm to say the least. The basic idea is
to "catch some bugs" but even some of the senior GCC devs were not convinced
when the patch was first introduced:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01254.html
Some more anecdotal evidence here:
http://gcc.gnu.org/ml/gcc/2005-04/msg01662.html
In the context of a DIY Reference Build where we overwrite the Pass1 GCC
with Pass2, then end up throwing away the whole Temptools phase anyway, I
feel this extra checking is not very useful and is just unnecessarily
slowing down the build. Here are my latest timings with GCC-4.0.2 on a dual
athlon setup:
real 13m15.246s Normal
user 22m10.019s
sys 1m24.141s
real 13m6.785s --disable-checking
user 21m42.593s
sys 1m23.361s
real 11m35.054s STAGE1_CHECKING = ""
user 18m56.599s
sys 1m24.537s
real 11m24.763s --disable-checking and STAGE1_CHECKING = ""
user 18m22.081s
sys 1m24.145s
As can be seen above, getting rid of STAGE1_CHECKING will save quite a few
minutes on some setups, while `--disable-checking' will also help, but only
save a few seconds. Keep in mind that default GCC-4.x release builds have
ENABLE_ASSERT_CHECKING switched on by default. This is a cheap check which
seems useful and is therefore probably not worth switching off with
`--disable-checking' for subsequent GCC passes because like I said, it only
saves a few seconds anyway.
In summary, for GCC-pass1 I'm going to add `--disable-checking' to configure
and add a sed to remove STAGE1_CHECKING from the GCC Makefile. This is in
order to shave a few minutes off the build. If anyone thinks this is a bad
idea then please let me know. BTW, this doesn't affect GCC-3.4.x
compatibility as the proposed changes are completely ignored there.
Regards
Greg
PS - the website has been popular this week due to the project getting a
mention on Distrowatch. I dunno why it was mentioned there as DIY is not a
distro at all. Oh well, any publicity is good publicity :-)