From: Joel Rosdahl Date: Wed, 26 Oct 2016 21:25:05 +0000 (+0200) Subject: Bail out on usage of .incbin` assembler directives X-Git-Tag: v3.3.3~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6d7cf55028c4e23778fb02595e7d1ee6596a5a8;p=thirdparty%2Fccache.git Bail out on usage of .incbin` assembler directives Fixes #136. --- diff --git a/MANUAL.txt b/MANUAL.txt index ab01886df..dea2fdc86 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -800,13 +800,6 @@ invoke the other wrapper when doing preprocessing (normally by adding *-E*). Caveats ------- -* ccache doesn't handle the GNU Assembler's *.incbin* directive correctly. This - directive can be embedded in the source code inside an *__asm__* statement in - order to include a file verbatim in the object file. If the included file is - modified, ccache doesn't pick up the change since the inclusion isn't done by - the preprocessor. A workaround of this problem is to set - *extra_files_to_hash* to the path of the included file. - * The direct mode fails to pick up new header files in some rare scenarios. See <<_the_direct_mode,THE DIRECT MODE>> above. diff --git a/NEWS.txt b/NEWS.txt index 2c95723c7..b254b0a57 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,16 @@ ccache news =========== +Unreleased 3.3.3 +---------------- + +Bug fixes +~~~~~~~~~ + +- ccache now detects usage of `.incbin` assembler directives in the source code + and avoids caching such compilations. + + ccache 3.3.2 ------------ Release date: 2016-09-28 diff --git a/ccache.c b/ccache.c index 1ad4df95f..b93e027ff 100644 --- a/ccache.c +++ b/ccache.c @@ -815,6 +815,15 @@ process_preprocessed_file(struct mdfour *hash, const char *path) inc_path = make_relative_path(inc_path); remember_include_file(inc_path, hash, system); p = q; + } else if (q[0] == '.' && q[1] == 'i' && q[2] == 'n' && q[3] == 'c' + && q[4] == 'b' && q[5] == 'i' && q[6] == 'n') { + // An assembler .incbin statement (which could be part of inline + // assembly) refers to an external file. If the file changes, the hash + // should change as well, but finding out what file to hash is too hard + // for ccache, so just bail out. + cc_log("Found unsupported .incbin directive in source code"); + stats_update(STATS_UNSUPPORTED_DIRECTIVE); + failed(); } else { q++; } diff --git a/ccache.h b/ccache.h index a79d14419..8b738aba0 100644 --- a/ccache.h +++ b/ccache.h @@ -52,6 +52,7 @@ enum stats { STATS_CANTUSEPCH = 27, STATS_PREPROCESSING = 28, STATS_NUMCLEANUPS = 29, + STATS_UNSUPPORTED_DIRECTIVE = 30, STATS_END }; diff --git a/stats.c b/stats.c index ff352bc6d..5d9fc7378 100644 --- a/stats.c +++ b/stats.c @@ -170,6 +170,12 @@ static struct { NULL, 0 }, + { + STATS_UNSUPPORTED_DIRECTIVE, + "unsupported code directive", + NULL, + 0 + }, { STATS_OUTSTDOUT, "output to stdout", diff --git a/test.sh b/test.sh index 3e0415745..ada869736 100755 --- a/test.sh +++ b/test.sh @@ -1101,6 +1101,18 @@ EOF if [ "$(./c)" != OK ]; then test_failed "Incorrect header file used" fi + + # ------------------------------------------------------------------------- + TEST ".incbin" + + cat <incbin.c +char x[] = ".incbin"; +EOF + + $CCACHE_COMPILE -c incbin.c + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 0 + expect_stat 'unsupported code directive' 1 } # =============================================================================