]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Bail out on -P at end of -Wp, as well
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 27 Jul 2016 09:22:12 +0000 (11:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 27 Jul 2016 18:13:00 +0000 (20:13 +0200)
ccache.c
ccache.h
test.sh

index 0a2e3b72a72e6a7c4bb57f9eaca72f78333a8be6..2cb95bb65da79059d7469962fe9be772092a737e 100644 (file)
--- 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.
index 3081d34ef39f1f3d3eb71509b21f48c0a0bfea1a..7ab03212f605b2658212c0cb999c99a20b360286 100644 (file)
--- 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 abfa000ed196876affde5e8f37a799191d2f52c2..0b0b8dd4370361aff9da6cfdcbd929db594de3a7 100755 (executable)
--- 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"