public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Oleg Endo <oleg.endo@t-online.de>
To: Richard Biener <richard.guenther@gmail.com>, Michael Matz <matz@suse.de>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Speedup configure and build with system.h
Date: Fri, 22 Jan 2016 12:02:00 -0000	[thread overview]
Message-ID: <1453464154.3681.84.camel@t-online.de> (raw)
In-Reply-To: <CAFiYyc3goTGZPN2KdxT4n=DJakcM00eTkngWpqS5RAS6ve6vyQ@mail.gmail.com>

On Thu, 2016-01-21 at 18:10 +0100, Richard Biener wrote:
> On Thu, Jan 21, 2016 at 5:57 PM, Michael Matz <matz@suse.de> wrote:
> > Hi,
> > 
> > this has bothered me for some time.  The gcc configure with stage1
> > feels
> > like taking forever because some of the decl availability tests
> > (checking
> > for C function) include system.h, and that, since a while,
> > unconditionally
> > includes <string> and <algorithm> under C++, and we meanwhile use
> > the C++
> > compiler for configure tests (which makes sense).  Now, the
> > difference for
> > a debuggable (but not even checking-enabled) cc1plus for a file
> > containing
> > just main():
> > 
> > % cat blaeh.cc
> > #include <stdio.h>
> > #include <cstring>
> > #include <utility>
> > #include <new>
> > int main() {}
> > % cc1plus -quiet -ftime-report blaeh.cc
> >  TOTAL                 :   0.12             0.01             0.14
> > 
> > (This is btw. three times as expensive as with 4.8 headers (i.e.
> > precompile with g++-4.8 then compile with the same cc1plus as
> > above,
> > taking 0.04 seconds; the STL headers bloat quite much over time)
> > 
> > Well, not quite blazing fast but then adding <string>:
> > 
> > % cc1plus -quiet -ftime-report blaeh-string.cc
> >  TOTAL                 :   0.60             0.05             0.66
> > 
> > Meeh.  And adding <algorithm> on top:
> > 
> > % cc1plus -quiet -ftime-report blaeh-string-alg.cc
> >  TOTAL                 :   1.13             0.09             1.23
> > 
> > So, more than a second for checking if some C-only decl is
> > available, just
> > because system.h unconditionally includes mostly useless STL
> > headers.
> > 
> > So, how useless exactly?  A whopping single file of cc1 proper
> > needs
> > <string>, _two_ files need <algorithm>, and a single target has an
> > unlucky
> > interface in its prototypes and also needs <string>.  (One
> > additional
> > header lazily uses std::string for no particular reason).  So we
> > pay about
> > 5 minutes build time per stage (there are ~400 libbackend.a files)
> > for
> > more or less nothing.
> > 
> > So, let's include those headers only conditionally; I'm pretty sure
> > it's
> > not unreasonable for a source file, if it needs a particular STL
> > facility
> > to #define USES_abcheader (like one normally would have to #include
> > <abcheader>) before the "system.h" include.
> > 
> > See the patch.  I've grepped for target or language dependencies on
> > other
> > STL types, and either they were already including the right header,
> > or
> > were covered with the new system.h (i.e. I've built all targets
> > quickly
> > for which grepping for 'std::' returned anything).  The
> > genconditions.c
> > change is for the benefit of aarch64 as well, and it single
> > function
> > aarch64_get_extension_string_for_isa_flags returning a std::string.
> > 
> > What do people think?  Should I pass it through a proper bootstrap
> > and put
> > it to trunk?  It's a (developer time) regression, right? ;-)
> 
> Ok.
> 
> Thanks,
> Richard.
> 
> I'm inclined to say #define INCLUDE_ALGORITHM is a better name,
> but just bike-shedding...  and please convert the (bogus) ISL way of
> achieving a similar thing.
> 
> I'm also inclined to say that we should remove <string> usage.  Not
> sure about algorithm, but I'd say it's the same.
> 

<string> and <algorithm> have been put into system.h because there have
been problems with malloc poisoning and C++ stdlib implementation other
than libstdc++, which sometimes pull other headers which then cause
trouble.  The fix for this set of errors was to include some of the
stdlib headers in system.h before anything else.

Cheers,
Oleg

  reply	other threads:[~2016-01-22 12:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 16:57 Michael Matz
2016-01-21 17:10 ` Richard Biener
2016-01-22 12:02   ` Oleg Endo [this message]
2016-01-22 13:49     ` Michael Matz
2016-01-22 16:59   ` Michael Matz
2016-01-22 20:09 ` H.J. Lu
2016-01-22 20:23   ` Jakub Jelinek
2016-01-22 22:15     ` Jakub Jelinek
2016-01-23  7:30       ` Richard Biener
2016-01-25 12:38       ` Michael Matz
2016-01-25 12:14 Uros Bizjak
2016-01-25 13:53 ` Michael Matz
2016-01-25 14:02   ` Richard Biener
2016-01-26 10:02   ` Uros Bizjak
2016-01-26 16:35     ` Michael Matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453464154.3681.84.camel@t-online.de \
    --to=oleg.endo@t-online.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=matz@suse.de \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).