[ccache] ccacje direct mode without fall back to running the preprocessor

vkr venkatakrishnarao.ks at gmail.com
Thu Dec 10 19:32:10 UTC 2015

Sorry. It is not the manifest file that it tries to update. But the ".d"
files. I think it is a real bug.

In read-only mode, when ccache tries to run cache look up in preprocessor
mode, it tries to put_file_in_cache for .d file unconditionally.

        if (generating_dependencies && mode == FROMCACHE_CPP_MODE) {
                put_file_in_cache(output_dep, cached_dep);

This is buggy, as it should check also check we are in
read-only/read-only-direct mode, like so:

if (generating_dependencies && mode == FROMCACHE_CPP_MODE &&
(!conf->read_only && !conf->read_only_direct)) {

Or even better, if put_file_in_cache returns if we are in
read-only/read-only-direct mode, which should fix more such hidden cases,
in future.

What do you think? Which one is better?


On Thu, Dec 10, 2015 at 6:00 PM, Andrew Stubbs <ams at codesourcery.com> wrote:

> On 10/12/15 11:38, vkr wrote:
>>   *  >> (*) If I use CCACHE_READONLY - then, there is a huge number of
>>     files not hitting cache(direct-cache look up fails), and build fails
>>     because of the cache storage being read-only, and the preprocessor
>>     lookup that ran after direct-lookup failure, tries to update the
>>     manifest file back in the cache. We can't go by this, as we want a
>>     pure-read-only cache.
> Huh? It still tries to write the manifest even in CCACHE_READONLY mode?
> I just tested it and no, it doesn't do that. If I edit a comment in a
> header file then I see "cache hit (preprocessed)" increment when I
> recompile. If I turn off CCACHE_READONLY then it rewrites the manifest, as
> expected, and the direct-mode starts working again.
> If I make the cache files read-only (chmod -R -w .ccache) then I see no
> error when CCACHE_READONLY is set (and CCACHE_TEMPDIR also), and the
> expected error writing the manifest otherwise.
> If I set the read-only in the config file (ccache -o read_only=true) then
> it works without the environment variable set.
> Are you sure your configuration is set right? Perhaps you should have
> "read_only=true" in your cache config, and then CCACHE_NOREADONLY=1 in your
> jenkins environment?
> I'm using the dev version of ccache, but this ought to work for all 3.2.x
> releases.
> Thinking about it, if you have multiple users sharing a writeable cache
> and one of them has a modified header that doesn't affect the preprocessed
> code, then you would end up with the manifest file flip-flopping between
> the two states. Maybe the read-only cache is a good idea, for the majority
> of users who have not modified any files?
> Andrew

More information about the ccache mailing list