]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Handle missing dependency file in cache correctly
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 9 Dec 2009 19:08:06 +0000 (20:08 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 5 Jan 2010 17:53:03 +0000 (18:53 +0100)
ccache.c
test.sh

index d746ce3300249d5d4ac47eb8be23bcced2d12e78..6631ee1d19be7e8177130d26db4cbe9a757b066a 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -814,8 +814,6 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
        if (produce_dep_file && stat(dep_file, &st) != 0) {
                cc_log("Dependency file missing in cache\n");
                close(fd_stderr);
-               unlink(stderr_file);
-               unlink(object_path);
                free(stderr_file);
                return;
        }
diff --git a/test.sh b/test.sh
index 1c539179c7aa52775614cee01c9b8d2c440ae7ae..35f13241bc9417572429b3ac3ab3841dd5cc85fa 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -480,6 +480,32 @@ EOF
     checkstat 'cache miss' 1
     checkfile other.d "test.o: test.c test1.h test3.h test2.h"
 
+    ##################################################################
+    # Check that a missing .d file in the cache is handled correctly.
+    testname="missing dependency file"
+    $CCACHE -z >/dev/null
+    $CCACHE -C >/dev/null
+
+    $CCACHE $COMPILER -c -MD test.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
+    $CCACHE $COMPILER -c -MD test.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
+    find $CCACHE_DIR -name '*.d' -exec rm -f '{}' \;
+
+    $CCACHE $COMPILER -c -MD test.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 1
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
     ##################################################################
     # Reset things.
     CCACHE_NODIRECT=1