From 5a5b5b75daea3beb7b21a78100adf76176317f65 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Thu, 9 Aug 2012 15:04:26 +0200 Subject: [PATCH] Remove any previous .stderr from cache if recaching --- ccache.c | 4 ++++ test.sh | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ccache.c b/ccache.c index ccb129997..0e9348603 100644 --- a/ccache.c +++ b/ccache.c @@ -722,6 +722,10 @@ to_cache(struct args *args) added_files += 1; } else { tmp_unlink(tmp_stderr); + if (conf->recache) { + /* If recaching, we need to remove any previous .stderr. */ + x_unlink(cached_stderr); + } } if (output_to_real_object_first) { diff --git a/test.sh b/test.sh index 72da50b08..f1362f814 100755 --- a/test.sh +++ b/test.sh @@ -446,7 +446,26 @@ EOF fi checkstat 'compiler check failed' 1 + testname="recache should remove previous .stderr" + $CCACHE -Cz >/dev/null + $CCACHE_COMPILE -c test1.c + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 1 + num=`find $CCACHE_DIR -name '*.stderr' | wc -l` + if [ $num -ne 0 ]; then + test_failed "$num stderr files found, expected 0 (#1)" + fi + obj_file=`find $CCACHE_DIR -name '*.o'` + stderr_file=`echo $obj_file | sed 's/..$/.stderr/'` + echo "Warning: foo" >$stderr_file + CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c + num=`find $CCACHE_DIR -name '*.stderr' | wc -l` + if [ $num -ne 0 ]; then + test_failed "$num stderr files found, expected 0 (#2)" + fi + testname="no object file" + $CCACHE -Cz >/dev/null cat <<'EOF' >test_no_obj.c int test_no_obj; EOF -- 2.47.3