From: Joel Rosdahl Date: Wed, 27 Jul 2016 09:22:12 +0000 (+0200) Subject: Bail out on -P at end of -Wp, as well X-Git-Tag: v3.3~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2cf8765aaef9271693e68ecbf26b2ddb2c24d7c;p=thirdparty%2Fccache.git Bail out on -P at end of -Wp, as well --- diff --git a/ccache.c b/ccache.c index 0a2e3b72a..2cb95bb65 100644 --- a/ccache.c +++ b/ccache.c @@ -2401,7 +2401,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args, continue; } if (str_startswith(argv[i], "-Wp,")) { - if (str_eq(argv[i], "-Wp,-P") || strstr(argv[i], ",-P,")) { + if (str_eq(argv[i], "-Wp,-P") + || strstr(argv[i], ",-P,") + || str_endswith(argv[i], ",-P")) { // -P removes preprocessor information in such a way that the object // file from compiling the preprocessed file will not be equal to the // object file produced when compiling without ccache. diff --git a/ccache.h b/ccache.h index 3081d34ef..7ab03212f 100644 --- a/ccache.h +++ b/ccache.h @@ -69,7 +69,11 @@ enum stats { #define SLOPPY_NO_SYSTEM_HEADERS 64 #define str_eq(s1, s2) (strcmp((s1), (s2)) == 0) -#define str_startswith(s, p) (strncmp((s), (p), strlen((p))) == 0) +#define str_startswith(s, prefix) \ + (strncmp((s), (prefix), strlen((prefix))) == 0) +#define str_endswith(s, suffix) \ + (strlen(s) >= strlen(suffix) \ + && str_eq((s) + strlen(s) - strlen(suffix), (suffix))) // ---------------------------------------------------------------------------- // args.c diff --git a/test.sh b/test.sh index abfa000ed..0b0b8dd43 100755 --- a/test.sh +++ b/test.sh @@ -987,24 +987,18 @@ EOF expect_stat 'cache miss' 0 expect_stat 'unsupported compiler option' 1 - $CCACHE_COMPILE -c -Wp,-P test1.c + $CCACHE_COMPILE -c -Wp,-P,-DFOO test1.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 0 expect_stat 'unsupported compiler option' 2 - $CCACHE_COMPILE -c -Wp,-DFOO,-P,-DGOO test1.c + $CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 0 expect_stat 'unsupported compiler option' 3 - $CCACHE_COMPILE -c -Wp,-DFOO,-P,-DGOO test1.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 0 - expect_stat 'unsupported compiler option' 4 - # ------------------------------------------------------------------------- TEST "-Wp,-D" @@ -1018,11 +1012,6 @@ EOF expect_stat 'cache hit (preprocessed)' 1 expect_stat 'cache miss' 1 - $CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 1 - expect_stat 'cache miss' 2 - # ------------------------------------------------------------------------- TEST "Buggy GCC 6 cpp"