From: Joel Rosdahl Date: Wed, 9 Dec 2009 19:08:06 +0000 (+0100) Subject: Handle missing dependency file in cache correctly X-Git-Tag: v3.0pre0~145 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d121763f2aea8028034b78353250f16448bed9e;p=thirdparty%2Fccache.git Handle missing dependency file in cache correctly --- diff --git a/ccache.c b/ccache.c index d746ce330..6631ee1d1 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 1c539179c..35f13241b 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