]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Pass the cpp1 flags more selectively
authorAnders F Björklund <anders.f.bjorklund@gmail.com>
Mon, 26 Jun 2017 20:51:17 +0000 (22:51 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 30 Jan 2018 20:39:24 +0000 (21:39 +0100)
The -fdirectives-only flag is needed for *both* cpp and cc/c++,
but the -frewrite-includes is only needed for cpp (not cc/c++).

Also make it easier to follow along in the gcc manual by passing
-fpreprocess explicitly, just like we pass the language to clang.

ccache.c

index 6d2de7ae43a94242ad681332fce5a35bca51dad0..8b8746cac95d6aaa77e1a68260def4aeceabefc6 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2598,10 +2598,12 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                // GCC
                if (str_eq(argv[i], "-fdirectives-only")) {
                        found_directives_only = true;
+                       continue;
                }
                // Clang
                if (str_eq(argv[i], "-frewrite-includes")) {
                        found_rewrite_includes = true;
+                       continue;
                }
 
                // Options taking an argument that we may want to rewrite to relative paths
@@ -2955,7 +2957,14 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        } else if (found_directives_only || found_rewrite_includes) {
                // Need to pass the macros and any other preprocessor directives again
                args_extend(*compiler_args, cpp_args);
+               if (found_directives_only) {
+                       args_add(cpp_args, "-fdirectives-only");
+                       // The preprocessed source code still needs some more preprocessing
+                       args_add(*compiler_args, "-fpreprocessed");
+                       args_add(*compiler_args, "-fdirectives-only");
+               }
                if (found_rewrite_includes) {
+                       args_add(cpp_args, "-frewrite-includes");
                        // The preprocessed source code still needs some more preprocessing
                        args_add(*compiler_args, "-x");
                        args_add(*compiler_args, actual_language);