From: Anders F Björklund Date: Mon, 26 Jun 2017 20:51:17 +0000 (+0200) Subject: Pass the cpp1 flags more selectively X-Git-Tag: v3.4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=148bdc7a4f8b3ec6fbb6c1871652f41df569f0e7;p=thirdparty%2Fccache.git Pass the cpp1 flags more selectively 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. --- diff --git a/ccache.c b/ccache.c index 6d2de7ae4..8b8746cac 100644 --- 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);