]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Don’t update manifest on preprocessed hit with disabled direct mode
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 28 Sep 2021 18:36:17 +0000 (20:36 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 28 Sep 2021 19:23:42 +0000 (21:23 +0200)
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.

src/ccache.cpp
test/suites/direct.bash

index 93b860a632d3aa2083bb2508ba7f02c45fd7841b..f23f50ef766a1edeacaa5094df7c9b69bc7ac5eb 100644 (file)
@@ -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;
index c17d8b613074601b4e4075490e0bddb83a464825..be62f1f4588d01884a69b92cd66405a7adef8a20 100644 (file)
@@ -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"