]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Disable ccache for too hard compiler option -Wp,-P
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 28 Oct 2012 16:27:23 +0000 (17:27 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 28 Oct 2012 16:27:23 +0000 (17:27 +0100)
ccache.c
test.sh

index 70ba11fce3d95e3a5d1f3fe54775ad589b0722fb..2973c7e2f0294d0b769aba080b945907de36216c 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1671,7 +1671,15 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
                if (str_startswith(argv[i], "-Wp,")) {
-                       if (str_startswith(argv[i], "-Wp,-MD,") && !strchr(argv[i] + 8, ',')) {
+                       if (str_eq(argv[i], "-Wp,-P") || strstr(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. */
+                               cc_log("Too hard option -Wp,-P detected");
+                               stats_update(STATS_UNSUPPORTED);
+                               failed();
+                       } else if (str_startswith(argv[i], "-Wp,-MD,")
+                                  && !strchr(argv[i] + 8, ',')) {
                                generating_dependencies = true;
                                dependency_filename_specified = true;
                                free(output_dep);
diff --git a/test.sh b/test.sh
index d1ea0a3f71a85b472c3c604c0063cc9fbbc1a862..4c786178e1b98c7b91d63533a4d4bda1aab91162 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -583,6 +583,36 @@ EOF
         checkstat 'files in cache' 4
     fi
 
+    ##################################################################
+    # Check that -Wp,-P disables ccache. (-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.)
+    testname="-Wp,-P"
+    $CCACHE -Cz >/dev/null
+    $CCACHE $COMPILER -c -Wp,-P test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 0
+    checkstat 'unsupported compiler option' 1
+    $CCACHE $COMPILER -c -Wp,-P test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 0
+    checkstat 'unsupported compiler option' 2
+    $CCACHE $COMPILER -c -Wp,-DFOO,-P,-DGOO test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 0
+    checkstat 'unsupported compiler option' 3
+    $CCACHE $COMPILER -c -Wp,-DFOO,-P,-DGOO test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 0
+    checkstat 'unsupported compiler option' 4
+
+    ##################################################################
+
     rm -f test1.c
 }
 
@@ -810,46 +840,6 @@ EOF
 
     rm -f other.d
 
-    ##################################################################
-    # Check that -Wp,-MD,file.d,-P disables direct mode.
-    # currently clang does not support -Wp form of options
-    if [ $COMPILER_TYPE_GCC -eq 1 ]; then
-        testname="-Wp,-MD,file.d,-P"
-        $CCACHE -z >/dev/null
-        $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c
-        checkstat 'cache hit (direct)' 0
-        checkstat 'cache hit (preprocessed)' 0
-        checkstat 'cache miss' 1
-        CCACHE_DISABLE=1 $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c -o reference_test.o
-        compare_file reference_test.o test.o
-
-        $CCACHE $COMPILER -c -Wp,-MD,$DEVNULL,-P test.c
-        checkstat 'cache hit (direct)' 0
-        checkstat 'cache hit (preprocessed)' 1
-        checkstat 'cache miss' 1
-        compare_file reference_test.o test.o
-    fi
-
-    ##################################################################
-    # Check that -Wp,-MMD,file.d,-P disables direct mode.
-    # currently clang does not support -Wp form of options
-    if [ $COMPILER_TYPE_GCC -eq 1 ]; then
-        testname="-Wp,-MDD,file.d,-P"
-        $CCACHE -z >/dev/null
-        $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c
-        checkstat 'cache hit (direct)' 0
-        checkstat 'cache hit (preprocessed)' 0
-        checkstat 'cache miss' 1
-        CCACHE_DISABLE=1 $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c -o reference_test.o
-        compare_file reference_test.o test.o
-
-        $CCACHE $COMPILER -c -Wp,-MMD,$DEVNULL,-P test.c
-        checkstat 'cache hit (direct)' 0
-        checkstat 'cache hit (preprocessed)' 1
-        checkstat 'cache miss' 1
-        compare_file reference_test.o test.o
-    fi
-
     ##################################################################
     # Test some header modifications to get multiple objects in the manifest.
     testname="several objects"