[ccache] ccache and precompiled headers

Joel Rosdahl joel at rosdahl.net
Sat Aug 21 08:30:26 MDT 2010

On 2010-07-03 14:22, Tor Arne Vestbø wrote:
> [...]
> As you can see removing pch from the build increases the total build
> time for the initial build (empty cache), but speeds up builds when
> there's something in the cache since we're hitting direct mode in
> almost all cases. When pch and ccache is used together the initial
> build time decreases, _but_ builds with a filled cache now take
> longer.
> Seems like we're hitting a lot more preprocessed cases for some
> reason. Dunno why that might be?

I've started implementing support for preprocessed headers (.gch) and
now I know why you get lots of preprocessed hits with your suggested
patch. The thing is that a .gch file created by GCC is apparently not
"stable"; the content is different each time for the same input. And
since ccache currently doesn't know how to cache the creation of a
precompiled header, a new and thus different .gch file is created, so
the direct mode will therefore miss.

Another issue is that the direct mode hashing of source code skips over
comments. This means that if there happens to be a "/*" or "//" in the
.gch (which is a binary file), parts of the file will not contribute to
the hash sum, which is bad.

Both issues should be easy to handle, though.

-- Joel

More information about the ccache mailing list