From 8d121763f2aea8028034b78353250f16448bed9e Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Wed, 9 Dec 2009 20:08:06 +0100 Subject: [PATCH] Handle missing dependency file in cache correctly --- ccache.c | 2 -- test.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ccache.c b/ccache.c index d746ce3..6631ee1 100644 --- 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 1c53917..35f1324 100755 --- 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