From: Joel Rosdahl Date: Tue, 9 Apr 2024 17:47:44 +0000 (+0200) Subject: feat: Clear manifest on recache X-Git-Tag: v4.10~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cd8da0f06fb6c69daadb1124a1a7937b4ab2d28;p=thirdparty%2Fccache.git feat: Clear manifest on recache If there are bad entries in the manifest it doesn't help to run with recache if the new entry (resulting from the recached compilation) already exists as an older entry in the manifest. Improve this by not populating the manifest in recache mode. --- diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index bd0497cd..6a3a4fbb 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -2093,7 +2093,7 @@ calculate_result_and_manifest_key(Context& ctx, return tl::unexpected(manifest_key_result.error()); } manifest_key = *manifest_key_result; - if (manifest_key) { + if (manifest_key && !ctx.config.recache()) { LOG("Manifest key: {}", util::format_digest(*manifest_key)); result_key = get_result_key_from_manifest(ctx, *manifest_key); } diff --git a/test/suites/direct.bash b/test/suites/direct.bash index 806521e9..45fac9c0 100644 --- a/test/suites/direct.bash +++ b/test/suites/direct.bash @@ -1343,24 +1343,35 @@ EOF expect_stat cache_miss 1 # ------------------------------------------------------------------------- - TEST "CCACHE_RECACHE doesn't add a new manifest entry" + TEST "CCACHE_RECACHE clears existing manifest" $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 0 + expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 expect_stat recache 0 expect_stat files_in_cache 2 # result + manifest - manifest_file=$(find $CCACHE_DIR -name '*M') - cp $manifest_file saved.manifest + mv test3.h test3.h.saved + echo 'int new_content;' >test3.h + backdate test3.h CCACHE_RECACHE=1 $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 0 + expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 expect_stat recache 1 - expect_stat files_in_cache 2 + expect_stat files_in_cache 3 # 2 * result + manifest + + mv test3.h.saved test3.h + backdate test3.h - expect_equal_content $manifest_file saved.manifest + $CCACHE_COMPILE -c test.c + expect_stat direct_cache_hit 0 + expect_stat preprocessed_cache_hit 1 + expect_stat cache_miss 1 + expect_stat recache 1 + expect_stat files_in_cache 3 # 2 * recache + manifest # ------------------------------------------------------------------------- TEST "Detection of appearing include directories" diff --git a/test/suites/remote_file.bash b/test/suites/remote_file.bash index 8059e7bd..9ed67e43 100644 --- a/test/suites/remote_file.bash +++ b/test/suites/remote_file.bash @@ -407,12 +407,12 @@ SUITE_remote_file() { expect_stat local_storage_hit 0 expect_stat local_storage_miss 0 expect_stat local_storage_read_hit 0 - expect_stat local_storage_read_miss 1 # Try to read manifest for updating + expect_stat local_storage_read_miss 0 expect_stat local_storage_write 2 expect_stat remote_storage_hit 0 expect_stat remote_storage_miss 0 expect_stat remote_storage_read_hit 0 - expect_stat remote_storage_read_miss 1 # Try to read manifest for updating + expect_stat remote_storage_read_miss 0 expect_stat remote_storage_write 2 expect_file_count 3 '*' remote # CACHEDIR.TAG + result + manifest @@ -431,13 +431,13 @@ SUITE_remote_file() { expect_stat local_storage_hit 0 expect_stat local_storage_miss 0 expect_stat local_storage_read_hit 0 - expect_stat local_storage_read_miss 2 # Try to read manifest for updating + expect_stat local_storage_read_miss 0 expect_stat local_storage_write 4 expect_stat remote_storage_hit 0 expect_stat remote_storage_miss 0 - expect_stat remote_storage_read_hit 1 # Read manifest for updating - expect_stat remote_storage_read_miss 1 - expect_stat remote_storage_write 3 # Not 4 since result key already present + expect_stat remote_storage_read_hit 0 + expect_stat remote_storage_read_miss 0 + expect_stat remote_storage_write 4 # ------------------------------------------------------------------------- if touch test.c && ln test.c test-if-fs-supports-hard-links.c 2>/dev/null; then