This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How would *you* use an intern?


On Wed, May 30, 2001 at 02:50:12PM -0700, Stan Shebs wrote:
> Ideas?

Perhaps too difficult, but would it be possible for him to look
into precompiled header files?

What I am thinking of is actually rather simple, let me explain:

When a compilation unit is compiled, header files tend to generate
code (certainly with all these templates these days), this code
is the same for each compilation unit if the values of all macros
that are involved in the generation of this code is the same.
Therefore, a little database could be build during compilation
in which code generated by headerfiles is stored as function of
1) the name of the header file
2) a headerfile checksum
3) the macro signature that are relevant

I imagine that this could be stored in the filesystem as:

.precompiled-headers/name-of-header-file/data-file

where 'data-file' contains:
1) the checksum of the headerfile at time of generation.
2) all macros that are used in the headerfile and their definition.

Both can be generated during the preprocessing phase.
If during the compilation of a compilation unit a new header file
is preprocessed and there turns out to exist a corresponding
precompiled headerfile with the same checksum and macro signature,
then there is no need to compile it again.

In the case of templates there is one more level; the template
parameter types used.  Code generated for templates can therefore
probably best be stored one level deeper in the file system, ie:

.precompiled-headers/name-of-header-file/mangled-template-name/data-file

where the "mangled-template-name" ensures we talk about a template
with all template parameters fixed.

Imho, this would speed up compilation C++ projects by a factor of 10
or more.  Consider a project that uses a .cc file per class, but
each file includes <iostream> and <string>.  These header files take a
few seconds to compile, while the .cc file in itself can be small and
only take a fraction of a second.

-- 
Carlo Wood <carlo@alinoe.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]