]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Only pass implicit -MQ to preprocessor if needed
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 30 Jan 2018 21:38:29 +0000 (22:38 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 30 Jan 2018 21:39:45 +0000 (22:39 +0100)
Fixes #209.

NEWS.txt
ccache.c
test/suites/direct.bash

index 16d7790e025a069e021d93c1bb7ac92d58690e1f..7383b660887ccbe82062c92b741d53c7b9bf2f5e 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -31,6 +31,10 @@ New features and improvements
   `-fdirectives-only` (GCC) or `frewrite-includes` (Clang) to the compiler,
   diagnostics warnings and similar will be correct.
 
+- An implicit `-MQ` is now passed to the preprocessor only if the object file
+  extension is non-standard. This should make it easier to use EDG-based
+  compilers (e.g. GHS) which don't understand `-MQ`.
+
 
 Bug fixes
 ~~~~~~~~~
index 5ed9031863a0836ae67c924a82bc4a2ba62668eb..22a76cf39c3e54f3b8d63443d3a1f5cc5dc36d2d 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2933,7 +2933,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        output_dep = make_relative_path(x_strdup(default_depfile_name));
                }
 
-               if (!dependency_target_specified) {
+               if (!dependency_target_specified
+                   && !str_eq(get_extension(output_dep), ".o")) {
                        args_add(dep_args, "-MQ");
                        args_add(dep_args, output_obj);
                }
index 13d5d66dcdaf84c39fd90a1231622708f5a3dfc0..0b2b3c8a5946522b332374ac99d2b91f79ab5f9b 100644 (file)
@@ -127,8 +127,9 @@ EOF
     TEST "Calculation of dependency file names"
 
     mkdir test.dir
-    for ext in .obj "" . .foo.bar; do
+    for ext in .o .obj "" . .foo.bar; do
         dep_file=test.dir/`echo test$ext | sed 's/\.[^.]*\$//'`.d
+
         $CCACHE_COMPILE -MD -c test.c -o test.dir/test$ext
         rm -f $dep_file
         $CCACHE_COMPILE -MD -c test.c -o test.dir/test$ext
@@ -138,8 +139,19 @@ EOF
         if ! grep "test$ext:" $dep_file >/dev/null 2>&1; then
             test_failed "$dep_file does not contain test$ext"
         fi
+
+        dep_target=foo.bar
+        $CCACHE_COMPILE -MD -MQ $dep_target -c test.c -o test.dir/test$ext
+        rm -f $dep_target
+        $CCACHE_COMPILE -MD -MQ $dep_target -c test.c -o test.dir/test$ext
+        if [ ! -f $dep_file ]; then
+            test_failed "$dep_file missing"
+        fi
+        if ! grep $dep_target $dep_file >/dev/null 2>&1; then
+            test_failed "$dep_file does not contain $dep_target"
+        fi
     done
-    expect_stat 'files in cache' 12
+    expect_stat 'files in cache' 18
 
     # -------------------------------------------------------------------------
     TEST "-MMD for different source files"