This is the mail archive of the
mailing list for the GCC project.
Re: PR/15448: add a compiler timestamp to PCH files (take 3)
After thinking about this, I'm pretty sure this is the wrong direction
to go. It doesn't check everything that needs to be checked, does
check things that don't need to be checked, and isn't as effective or
as efficient as a proper solution. I believe I considered doing
something like this when I was implementing PCH, and rejected it for
the reasons I've mentioned above.
It's not just the issues of adding a global, or a field to a structure.
It's also about what happens when the semantics of the existing
structures change; for instance, adding an extra value to the middle of
an enum, or interpreting a NULL_TREE value in a different way, or
deciding that a particular field has to be a CONST_INT.
The proper solution is to implement a validation check that actually
does check that the executable is the same. For instance, create a
small C file that contains a checksum of the executable, initially all
zeros, and link (possibly with -s to strip) the executable with that
file; then checksum the result, create a new C file that has the
correct checksum, and link again. (You could avoid the double link,
but doing so portably would be inelegant, and linking doesn't take very
I expect that implementing this would actually take fewer lines of code
than we already have to try to partially do the same thing, and much
less than we'd have after this patch.
Description: S/MIME cryptographic signature