From: ryb Date: Sat, 7 Feb 2015 14:01:34 +0000 (+0100) Subject: Don't delete the clang diagnostics file after compiler failures X-Git-Tag: v3.2.2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93e45837ebf5305c0d3abbe205c06123c21905d6;p=thirdparty%2Fccache.git Don't delete the clang diagnostics file after compiler failures move_file() returns an error when called with the same source and destination, causing the diagnostics file to be removed. As of 18a645451 ("Create destination file and then copy into cache instead of the opposite") it is no longer necessary to move the diagnostics file at all after a compiler failure. --- diff --git a/ccache.c b/ccache.c index 913e65640..581d59c41 100644 --- a/ccache.c +++ b/ccache.c @@ -841,29 +841,6 @@ to_cache(struct args *args) close(fd); tmp_unlink(tmp_stderr); - if (output_dia) { - int ret; - x_unlink(output_dia); - /* only make a hardlink if the cache file is uncompressed */ - ret = move_file(output_dia, output_dia, 0); - - if (ret == -1) { - if (errno == ENOENT) { - /* Someone removed the file just before we began copying? */ - cc_log("Diagnostic file %s just disappeared", output_dia); - stats_update(STATS_MISSING); - } else { - cc_log("Failed to move %s to %s: %s", - output_dia, output_dia, strerror(errno)); - stats_update(STATS_ERROR); - failed(); - } - x_unlink(output_dia); - } else { - cc_log("Created %s from %s", output_dia, output_dia); - } - } - exit(status); } diff --git a/test.sh b/test.sh index 0fde54526..cfeb97aba 100755 --- a/test.sh +++ b/test.sh @@ -632,16 +632,45 @@ EOF ################################################################## if [ $COMPILER_TYPE_CLANG -eq 1 ]; then - $CCACHE -Cz > /dev/null testname="serialize-diagnostics" - $CCACHE_COMPILE -c --serialize-diagnostics test.dia test1.c 2> /dev/null + $CCACHE -Cz > /dev/null + $COMPILER -c --serialize-diagnostics expected.dia test1.c 2> /dev/null + # Run with CCACHE_CPP2 to ensure the same diagnostics output as above + CCACHE_CPP2=1 $CCACHE_COMPILE -c --serialize-diagnostics test.dia test1.c 2> /dev/null checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 1 checkstat 'files in cache' 2 - $CCACHE_COMPILE -c --serialize-diagnostics test.dia test1.c 2> /dev/null + compare_file expected.dia test.dia + rm -f test.dia + CCACHE_CPP2=1 $CCACHE_COMPILE -c --serialize-diagnostics test.dia test1.c 2> /dev/null checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 checkstat 'files in cache' 2 + compare_file expected.dia test.dia + + rm -f test.dia + rm -f expected.dia + + testname="serialize-diagnostics-compile-failed" + $CCACHE -Cz > /dev/null + echo "bad source" >error.c + $COMPILER -c --serialize-diagnostics expected.dia error.c 2> /dev/null + if [ $? -eq 0 ]; then + test_failed "expected an error compiling error.c" + fi + CCACHE_CPP2=1 $CCACHE_COMPILE -c --serialize-diagnostics test.dia error.c 2> /dev/null + checkstat 'compile failed' 1 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 0 + checkstat 'files in cache' 0 + compare_file expected.dia test.dia + rm -f test.dia + CCACHE_CPP2=1 $CCACHE_COMPILE -c --serialize-diagnostics test.dia error.c 2> /dev/null + checkstat 'compile failed' 2 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 0 + checkstat 'files in cache' 0 + compare_file expected.dia test.dia fi ##################################################################