Re: reduce compilation times?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



J.C. Pizarro wrote:
On 2007/11/27, Tom St Denis <tstdenis@xxxxxxxxxxxxxxxx> wrote:
This is why you should re-factor your code as to contain only one [or as
few as possible] exportable functions per unit.

If you write an entire 100K line program as "main.c" of course you'll be
hit by slow compiles.

But if you factor the code you can get good savings.  For instance, one
of my OSS projects (if you know who I am you know what I'm talking
about) is ~50K lines and compiles in ~29 seconds on a pentium 4.  It
builds in 8 seconds a quad-core Intel Core2.  For most files [units] I
only have one function, so the line count per file is on average ~200 or so.

It's good idea, "to refactorize the code" and "to split many functions
to many files"
(e.g. one file per one function) with the objective of re-compile-time reduction
(many compiled objects don't need to be recompiled).

GCC needs LTO (Link Time Optimization), too.
It also carries the benefit of making working with others easier as you're putting locks on smaller portions of the overall project.

As for link time optimizations, the only downside really is inlining, and you can always use #define macros for that.

Tom

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux