Path: csiph.com!feeder.erje.net!1.us.feeder.erje.net!news.glorb.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: George Neuner Newsgroups: comp.compilers Subject: Re: Alternative C compilers on x86_64 Linux? Date: Thu, 29 Sep 2016 22:57:49 -0400 Organization: A noiseless patient Spider Lines: 40 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <16-09-043@comp.compilers> References: <16-09-001@comp.compilers> <16-09-033@comp.compilers> <16-09-034@comp.compilers> <16-09-035@comp.compilers> <16-09-037@comp.compilers> <16-09-042@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="24490"; mail-complaints-to="abuse@iecc.com" Keywords: C, performance Posted-Date: 29 Sep 2016 23:22:24 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1782 On Thu, 29 Sep 2016 14:03:55 +0100, BartC wrote: >Most C compilers seem to support multiple C source files as input. This >is similar to my scheme of compiling multiple sources one after the >other. So if the input to a compiler looks like this: > > gcc -c A.c B.c C.c > >where each of A, B and C include the same header file H.h, then once H.h >has been processed for A.c, the results of that (symbol tables and so >on) could be re-used for B and C without needing to process either H.h >or H.pch again. But it isn't done that way: the compilation of each .c file is treated independently. A common header file will be (re)processed for each code file that includes it. Also recall that the standard headers form a nesting hierarchy: some of the more common headers indirectly pull in many others. Nesting also is common in wizard generated code, and in C++ template libraries, etc. A pre-compiled header contains already digested data that can be plugged (more or less) directly into the compiler's internal data structures. Loading a .pch file very often is much faster than (re)compiling its constituent source files, and the time savings grow with the number of files involved. It works best when you have many code files all of which include a common *set* of headers. You extract the common includes from the code files into a single common header file. In each code file you then include that one common header. Then precompile it. For a project with just a handful of files it really doesn't matter ... but with complex projects with hundreds of source files I've gotten ~80% reductions in build time by using precompiled headers. I have seen 45 minute clean builds turn into <10 minutes. George