]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Only pass -Wp,-MT and similar to the preprocessor
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 7 Sep 2016 18:46:18 +0000 (20:46 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 7 Sep 2016 18:46:18 +0000 (20:46 +0200)
This fixes an issue when compiler option -Wp,-MT,path is used instead of
-MT path (and similar for -MF, -MP and -MQ) and run_second_cpp
(CCACHE_CPP2) is enabled.

Fixes #129.

NEWS.txt
ccache.c
test/test_argument_processing.c

index fe16d27522747b713c3b92a3b95088f1c4787ed8..58d9496363be42088424a471361deb132d380f7c 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -8,6 +8,10 @@ Unreleased 3.2.8
 Bug fixes
 ~~~~~~~~~
 
+- Fixed an issue when compiler option `-Wp,-MT,path` is used instead of `-MT
+  path` (and similar for `-MF`, `-MP` and `-MQ`) and `run_second_cpp`
+  (`CCACHE_CPP2`) is enabled.
+
 - ccache now understands the undocumented `-coverage` (only one dash) GCC
   option.
 
index 591c7d7cb8be3c2bcec713cb28ffd1a6c58027be..5635cc15da8929fc976a9583bbbd09c6ec99e447 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2249,6 +2249,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,-M")) {
+                               /* -MF, -MP, -MQ, -MT, etc. TODO: Make argument to MF/MQ/MT
+                                * relative. */
+                               args_add(dep_args, argv[i]);
+                               continue;
                        } else if (conf->direct_mode) {
                                /*
                                 * -Wp, can be used to pass too hard options to
@@ -2258,6 +2263,10 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                cc_log("Unsupported compiler option for direct mode: %s", argv[i]);
                                conf->direct_mode = false;
                        }
+
+                       /* Any other -Wp,* arguments are only relevant for the preprocessor. */
+                       args_add(cpp_args, argv[i]);
+                       continue;
                }
                if (str_eq(argv[i], "-MP")) {
                        args_add(dep_args, argv[i]);
index 0ecefd1b3607decb31ac5aad78bc6578448180f1..a1b6ecba257576b87b7afffa6d87ea054c3e0672 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2015 Joel Rosdahl
+ * Copyright (C) 2010-2016 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -57,7 +57,7 @@ TEST(dependency_flags_should_only_be_sent_to_the_preprocessor)
 {
 #define CMD \
        "cc -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2" \
-       " -Wp,-MD,wpmd -Wp,-MMD,wpmmd"
+       " -Wp,-MD,wpmd -Wp,-MMD,wpmmd -Wp,-MP -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf"
        struct args *orig = args_init_from_string(CMD " -c foo.c -o foo.o");
        struct args *exp_cpp = args_init_from_string(CMD);
 #undef CMD
@@ -79,8 +79,9 @@ TEST(preprocessor_only_flags_should_only_be_sent_to_the_preprocessor)
        " -include test.h -include-pch test.pch -iprefix . -iquote ." \
        " -isysroot . -isystem . -iwithprefix . -iwithprefixbefore ." \
        " -DTEST_MACRO -DTEST_MACRO2=1 -F. -trigraphs -fworking-directory" \
-       " -fno-working-directory -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 " \
-       " -MQ mq1 -MQ mq2 -Wp,-MD,wpmd -Wp,-MMD,wpmmd"
+       " -fno-working-directory -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2" \
+       " -MQ mq1 -MQ mq2 -Wp,-MD,wpmd -Wp,-MMD,wpmmd -Wp,-MP -Wp,-MT,wpmt" \
+       " -Wp,-MQ,wpmq -Wp,-MF,wpf"
        struct args *orig = args_init_from_string(CMD " -c foo.c -o foo.o");
        struct args *exp_cpp = args_init_from_string(CMD);
 #undef CMD