]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add support for -Wp,-D in direct mode
authorOrion Poplawski <orion@cora.nwra.com>
Tue, 14 Jun 2016 16:50:25 +0000 (10:50 -0600)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 11 Jul 2016 19:18:30 +0000 (21:18 +0200)
MANUAL.txt
NEWS.txt
ccache.c
test.sh

index 6d5d8fb5aa696ef42515c309609936664c4b97ba..0d9b7a3970932aa2779de62edfaa9d59cca589be 100644 (file)
@@ -621,8 +621,8 @@ The direct mode will be disabled if any of the following holds:
   race condition)
 * the unifier is enabled (the configuration setting *unify* is true)
 * a compiler option not supported by the direct mode is used:
-** a *-Wp,_X_* compiler option other than *-Wp,-MD,_path_* and
-   *-Wp,-MMD,_path_*
+** a *-Wp,_X_* compiler option other than *-Wp,-MD,_path_*,
+   *-Wp,-MMD,_path_* and *-Wp,-D_define_*
 ** *-Xpreprocessor*
 * the string ``\_\_TIME__'' is present in the source code
 
@@ -829,8 +829,8 @@ problems and what may be done to increase the hit rate:
 ** Compiler arguments that are hashed in the direct mode but not in the
    preprocessor mode have changed (*-I*, *-include*, *-D*, etc) and they didn't
    affect the preprocessor output.
-** The compiler option *-Xpreprocessor* or *-Wp,_X_* (except *-Wp,-MD,_path_*
-   and *Wp,-MMD,_path_*) is used.
+** The compiler option *-Xpreprocessor* or *-Wp,_X_* (except *-Wp,-MD,_path_*,
+   *-Wp,-MMD,_path_*, and *-Wp,-D_define_*) is used.
 ** This was the first compilation with a new value of the base directory
    setting.
 ** A modification time of one of the include files is too new (created the same
index 2aac6ae37de096fc594791e7392554a759ef506d..189bb2c842f2aeaaba085cf9cbb1b4d1fbb4c64c 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -43,6 +43,8 @@ New features and improvements
 
 - Improved parsing of `-g*` options.
 
+- Made ccache understand `-Wp,-D*` options.
+
 
 Bug fixes
 ~~~~~~~~~
index 500dc0beb7cccb6579d50f613ae89eaeedc7b408..34f8352debe0cacc8fd8c73d9ac0c65451dcc277 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2480,6 +2480,11 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                output_dep = make_relative_path(x_strdup(argv[i] + 9));
                                args_add(dep_args, argv[i]);
                                continue;
+                       } else if (str_startswith(argv[i], "-Wp,-D")
+                                  && !strchr(argv[i] + 6, ',')) {
+                               /* Treat it like -D */
+                               args_add(dep_args, argv[i] + 4);
+                               continue;
                        } else if (conf->direct_mode) {
                                /*
                                 * -Wp, can be used to pass too hard options to
diff --git a/test.sh b/test.sh
index 35cfdbd399be5e5d0ea0928c0959c9fcabbd7a0c..abc14274fa614f9d5c1cf6a69cef193dbbed8d13 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -686,6 +686,23 @@ EOF
     checkstat 'cache miss' 0
     checkstat 'unsupported compiler option' 4
 
+    ##################################################################
+    # Check that -Wp,-D works
+    testname="-Wp,-D"
+    $CCACHE -Cz >/dev/null
+    $CCACHE_COMPILE -c -Wp,-DFOO test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    $CCACHE_COMPILE -c -DFOO test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 1
+    checkstat 'cache miss' 1
+    $CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 1
+    checkstat 'cache miss' 2
+
     ##################################################################
 
     if [ $COMPILER_TYPE_CLANG -eq 1 ]; then
@@ -987,6 +1004,23 @@ EOF
 
     rm -f different_name.d
 
+    ##################################################################
+    # Check that -Wp,-D works
+    testname="-Wp,-D"
+    $CCACHE -Cz >/dev/null
+    $CCACHE_COMPILE -c -Wp,-DFOO test.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    $CCACHE_COMPILE -c -DFOO test.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    $CCACHE_COMPILE -c -Wp,-DFOO,-P test.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 2
+
     ##################################################################
     # Test some header modifications to get multiple objects in the manifest.
     testname="several objects"