]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Clear manifest on recache
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 9 Apr 2024 17:47:44 +0000 (19:47 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 9 Apr 2024 19:52:12 +0000 (21:52 +0200)
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.

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

index bd0497cd21caee535652bf60b6486e8b6ce7580f..6a3a4fbbb9cc325310d23cd9d67857256d03f3d4 100644 (file)
@@ -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);
     }
index 806521e911b93494a6f62de3258716a657a718be..45fac9c0a4ee1d4b7a5b93cf39a4338fc775114f 100644 (file)
@@ -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"
index 8059e7bd54779448cd4364a0c6859cf3364e0272..9ed67e43078565983e66e9ca38e80afde7846632 100644 (file)
@@ -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