From: Joel Rosdahl Date: Tue, 28 Sep 2021 18:36:17 +0000 (+0200) Subject: fix: Don’t update manifest on preprocessed hit with disabled direct mode X-Git-Tag: v4.4.2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=792b27b801a03f81f559e8622ffeef644f38fe9a;p=thirdparty%2Fccache.git fix: Don’t update manifest on preprocessed hit with disabled direct mode After c7c0837a23fe9dc79613bf3dd4ddd8d91c58d541, update_manifest_file can be called erroneously if the direct mode is disabled when there has been a preprocessed hit. Fix this by asserting that update_manifest_file is only called when direct mode is enabled, fixing the call site and adding the test case that should already have existed. Fixes #935. --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 93b860a63..f23f50ef7 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -728,6 +728,8 @@ update_manifest_file(Context& ctx, return; } + ASSERT(ctx.config.direct_mode()); + MTR_SCOPE("manifest", "manifest_put"); // See comment in get_file_hash_index for why saving of timestamps is forced @@ -2163,7 +2165,7 @@ do_cache_compilation(Context& ctx, const char* const* argv) // If we can return from cache at this point then do. const auto found = from_cache(ctx, FromCacheCallMode::cpp, *result_key); if (found) { - if (manifest_key && put_result_in_manifest) { + if (ctx.config.direct_mode() && manifest_key && put_result_in_manifest) { update_manifest_file(ctx, *manifest_key, *result_key); } return Statistic::preprocessed_cache_hit; diff --git a/test/suites/direct.bash b/test/suites/direct.bash index c17d8b613..be62f1f45 100644 --- a/test/suites/direct.bash +++ b/test/suites/direct.bash @@ -830,6 +830,11 @@ EOF expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 + $CCACHE_COMPILE -c time_h.c + expect_stat direct_cache_hit 0 + expect_stat preprocessed_cache_hit 2 + expect_stat cache_miss 1 + # ------------------------------------------------------------------------- TEST "__TIME__ in source file ignored if sloppy"