]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't pass -c to the preprocessor
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 23 Jan 2011 16:07:15 +0000 (17:07 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 23 Jan 2011 16:07:15 +0000 (17:07 +0100)
Solaris' C++ compiler doesn't like -c in combination with -E, and other
compilers seem to cope well without it as well.

ccache.c
test.sh
test/test_argument_processing.c

index 5e68269d798201a8b1760a86c5b6f69eda71fc19..29cad06c4d86484fb2592160e38d39c98d49ccdf 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1311,7 +1311,6 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
 
                /* we must have -c */
                if (str_eq(argv[i], "-c")) {
-                       args_add(stripped_args, argv[i]);
                        found_c_opt = true;
                        continue;
                }
@@ -1733,6 +1732,10 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
                *compiler_args = args_copy(*preprocessor_args);
        }
 
+       if (found_c_opt) {
+               args_add(*compiler_args, "-c");
+       }
+
        /*
         * Only pass dependency arguments to the preprocesor since Intel's C++
         * compiler doesn't produce a correct .d file when compiling preprocessed
diff --git a/test.sh b/test.sh
index a9701f4673c6cb11655b6e6a2ab46efc095f46ee..230d31ba9ad4ee0ee75c1c7005e2104b1f0507d6 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1673,7 +1673,7 @@ EOF
     fi
 
     testname="create .gch, no -c, -o"
-    $CCACHE -z >/dev/null
+    $CCACHE -Cz >/dev/null
     $CCACHE $COMPILER pch.h -o pch.gch
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
index 2514eb3856322fd5d38916e7e28f681479d0c3a3..6d5400551d7eaf5f38c6ab89fb5dc880eb3d05a1 100644 (file)
@@ -41,9 +41,9 @@ TEST(dash_E_should_be_unsupported)
 TEST(dependency_flags_should_only_be_sent_to_the_preprocessor)
 {
 #define CMD \
-       "cc -c -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2" \
+       "cc -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2" \
        " -Wp,-MD,wpmd -Wp,-MMD,wpmmd"
-       struct args *orig = args_init_from_string(CMD " foo.c -o foo.o");
+       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
        struct args *exp_cc = args_init_from_string("cc -c");
@@ -62,7 +62,7 @@ TEST(dependency_flags_that_take_an_argument_should_not_require_space_delimiter)
        struct args *orig = args_init_from_string(
                "cc -c -MMD -MFfoo.d -MTmt -MQmq foo.c -o foo.o");
        struct args *exp_cpp = args_init_from_string(
-               "cc -c -MMD -MFfoo.d -MTmt -MQmq");
+               "cc -MMD -MFfoo.d -MTmt -MQmq");
        struct args *exp_cc = args_init_from_string("cc -c");
        struct args *act_cpp = NULL, *act_cc = NULL;
        create_file("foo.c", "");