]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add support for -Wp,-MD and -Wp,-MMD flags
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 2 Dec 2009 18:56:17 +0000 (19:56 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 5 Jan 2010 17:53:02 +0000 (18:53 +0100)
NEWS
ccache.c
test.sh

diff --git a/NEWS b/NEWS
index 47f2744c3b122b3fdf57dbcbdeeff3579e0b8833..946c312525ea41219d6a052d0d51bcb92b6546e9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -47,12 +47,14 @@ Bug fixes:
 
   - User-defined CPPFLAGS and LDFLAGS is now respected in the Makefile.
 
-  - Bail out on profiling flags --coverage, -fprofile-arcs and -ftest-coverage.
-
   - Fixed NFS issues.
 
+  - Bail out on profiling flags --coverage, -fprofile-arcs and -ftest-coverage.
+
   - -MD/-MMD flags without -MT/-MF are now handled correctly.
 
+  - Added support for -Wp,-MD and -Wp,-MMD flags.
+
   - Corrected LRU cleanup handling of object files.
 
   - utimes() is now used instead of utime() when available.
index ef64fca2596e9f16fbed2bb99fc71e447bc1fe7a..81c984dff01204fc9dfe02deea6fc17a85678cee 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1156,7 +1156,8 @@ static void process_args(int argc, char **argv)
                /* These options require special handling, because they
                   behave differently with gcc -E, when the output
                   file is not specified. */
-               if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) {
+               if (strcmp(argv[i], "-MD") == 0
+                   || strcmp(argv[i], "-MMD") == 0) {
                        generating_dependencies = 1;
                }
                if (i < argc - 1) {
@@ -1169,6 +1170,22 @@ static void process_args(int argc, char **argv)
                        }
                }
 
+               if (enable_direct && strncmp(argv[i], "-Wp,", 4) == 0) {
+                       if (strncmp(argv[i], "-Wp,-MD,", 8) == 0) {
+                               generating_dependencies = 1;
+                               dependency_filename_specified = 1;
+                               dependency_path = x_strdup(argv[i] + 8);
+                       } else if (strncmp(argv[i], "-Wp,-MMD,", 9) == 0) {
+                               generating_dependencies = 1;
+                               dependency_filename_specified = 1;
+                               dependency_path = x_strdup(argv[i] + 9);
+                       } else if (enable_direct) {
+                               cc_log("Unsupported compiler option for direct mode: %s\n",
+                                      argv[i]);
+                               enable_direct = 0;
+                       }
+               }
+
                /* options that take an argument */
                {
                        const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
diff --git a/test.sh b/test.sh
index 90f9b4bd3deeafe52af6bf07ff278118797ed05a..67ed900a7369233cbcaa00e9e87d10e4217e7f05 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -353,6 +353,48 @@ EOF
     mv test3.h.saved test3.h
     sleep 1 # Sleep to make the include files trusted.
 
+    rm -f other.d
+
+    ##################################################################
+    # Check that -Wp,-MD,file.d works.
+    testname="-Wp,-MD"
+    $CCACHE -z >/dev/null
+    $CCACHE $COMPILER -c -Wp,-MD,other.d test.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
+    rm -f other.d
+
+    $CCACHE $COMPILER -c -Wp,-MD,other.d test.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
+    rm -f other.d
+
+    ##################################################################
+    # Check that -Wp,-MMD,file.d works.
+    testname="-Wp,-MMD"
+    $CCACHE -z >/dev/null
+    $CCACHE $COMPILER -c -Wp,-MMD,other.d test.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
+    rm -f other.d
+
+    $CCACHE $COMPILER -c -Wp,-MMD,other.d test.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    checkfile other.d "test.o: test.c test1.h test3.h test2.h"
+
+    rm -f other.d
+
     ##################################################################
     # Test some header modifications to get multiple objects in the manifest.
     testname="several objects"