On 29/06/2010 07:36, Basile Starynkevitch wrote:
On Mon, 2010-06-28 at 16:58 -0700, Ian Lance Taylor wrote:
Basile Starynkevitch<bas...@starynkevitch.net>  writes:

What is the role of executable_checksum from c-common.h&  generated by
genchecksum.

It is used for precompiled headers.  It verifies that the precompiled
header was generated by precisely the same compiler as the one trying to
use the precompiled header.  This approach is used because a precompiled
header is essentially a memory dump of the compiler after parsing the
header.  It would not work to use a memory of one compiler in another
compiler.

Thanks for the nice explanation.

However, I see a slightly more general use of executable_checksum (or
something similar) in plugins.  Imagine a plugin that store some
information somewhere (e.g. in a database) and which might reload that
information later.  It could be very useful (for that or such plugin[s])
to store a [nearly] unique identifier of the GCC compiler using it with
the data (to avoid reusing the same data with a slightly different GCC
compiler, eg 4.5.1 vs 4.5.0).  Then that plugin would be happy to use
the executable_checksum to avoid nightmares when incorrectly reusing
some data with a slightly different compiler. And version information is
not exactly adequate (the same gcc 4.5.0 could be built&  configured
differently).


Are you thinking of something like ccache functionality being implemented as a gcc plugin rather than an external program? You could do many nice things with that that are (I think) impossible with external ccache, such as caching parts of the compilation rather than just the whole compilation. Pre-compiled headers could be effectively automated by such a system, and if the cache keys were based on internal structures rather than the cpp output (as ccache uses), then the pre-compiled sections could be re-used despite small changes in the code.


Reply via email to