mirror of
https://github.com/reactos/ccache.git
synced 2025-03-03 00:16:47 +00:00
Handle missing or empty object file from compiler properly
This commit is contained in:
parent
196baceaef
commit
131111cd58
4
NEWS
4
NEWS
@ -49,6 +49,10 @@ New features and improvements:
|
||||
- Standard error output from the compiler is now only stored in the cache if
|
||||
it's non-empty.
|
||||
|
||||
- If the compiler produces no object file or an empty object file, but gives
|
||||
a zero exit status (could be due to a file system problem, a buggy program
|
||||
specified by CCACHE_PREFIX, etc.), ccache copes with it properly.
|
||||
|
||||
- Added installcheck and distcheck make targets.
|
||||
|
||||
- Clarified cache size limit options' semantics
|
||||
|
11
ccache.c
11
ccache.c
@ -546,6 +546,17 @@ static void to_cache(ARGS *args)
|
||||
failed();
|
||||
}
|
||||
|
||||
if (stat(tmp_obj, &st) != 0) {
|
||||
cc_log("The compiler didn't produce an object file");
|
||||
stats_update(STATS_NOOUTPUT);
|
||||
failed();
|
||||
}
|
||||
if (st.st_size == 0) {
|
||||
cc_log("The compiler produced an empty object file");
|
||||
stats_update(STATS_EMPTYOUTPUT);
|
||||
failed();
|
||||
}
|
||||
|
||||
compress = !getenv("CCACHE_NOCOMPRESS");
|
||||
|
||||
if (stat(tmp_stderr, &st) != 0) {
|
||||
|
2
ccache.h
2
ccache.h
@ -43,6 +43,8 @@ enum stats {
|
||||
STATS_UNSUPPORTED,
|
||||
STATS_OUTSTDOUT,
|
||||
STATS_CACHEHIT_DIR,
|
||||
STATS_NOOUTPUT,
|
||||
STATS_EMPTYOUTPUT,
|
||||
|
||||
STATS_END
|
||||
};
|
||||
|
2
stats.c
2
stats.c
@ -54,6 +54,8 @@ static struct {
|
||||
{ STATS_LINK, "called for link ", NULL, 0 },
|
||||
{ STATS_MULTIPLE, "multiple source files ", NULL, 0 },
|
||||
{ STATS_STDOUT, "compiler produced stdout ", NULL, 0 },
|
||||
{ STATS_NOOUTPUT, "compiler produced no output ", NULL, 0 },
|
||||
{ STATS_EMPTYOUTPUT, "compiler produced empty output ", NULL, 0 },
|
||||
{ STATS_STATUS, "compile failed ", NULL, 0 },
|
||||
{ STATS_ERROR, "ccache internal error ", NULL, 0 },
|
||||
{ STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 },
|
||||
|
27
test.sh
27
test.sh
@ -275,6 +275,33 @@ base_tests() {
|
||||
checkstat 'cache hit (preprocessed)' 11
|
||||
checkstat 'cache miss' 39
|
||||
|
||||
testname="no object file"
|
||||
cat <<'EOF' >test_no_obj.c
|
||||
int test_no_obj;
|
||||
EOF
|
||||
cat <<'EOF' >prefix-remove.sh
|
||||
#!/bin/sh
|
||||
echo "$*" >>/tmp/foo
|
||||
"$@"
|
||||
[ x$3 = x-o ] && rm $4
|
||||
EOF
|
||||
chmod +x prefix-remove.sh
|
||||
CCACHE_PREFIX=$PWD/prefix-remove.sh $CCACHE_COMPILE -c test_no_obj.c
|
||||
checkstat 'compiler produced no output' 1
|
||||
|
||||
testname="empty object file"
|
||||
cat <<'EOF' >test_empty_obj.c
|
||||
int test_empty_obj;
|
||||
EOF
|
||||
cat <<'EOF' >prefix-empty.sh
|
||||
#!/bin/sh
|
||||
"$@"
|
||||
[ x$3 = x-o ] && cp /dev/null $4
|
||||
EOF
|
||||
chmod +x prefix-empty.sh
|
||||
CCACHE_PREFIX=$PWD/prefix-empty.sh $CCACHE_COMPILE -c test_empty_obj.c
|
||||
checkstat 'compiler produced empty output' 1
|
||||
|
||||
testname="stderr-files"
|
||||
num=`find $CCACHE_DIR -name '*.stderr' | wc -l`
|
||||
if [ $num -ne 0 ]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user