--
** use the *-include* compiler option to include the precompiled header
(i.e., don't use *#include* in the source code to include the header); or
+** (Clang compiler) use the *-include-pch* compiler option to include
+ the PCH file generated from the precompiled header; or
** add the *-fpch-preprocess* compiler option when compiling.
If you don't do this, either the non-precompiled version of the header file
static bool profile_generate = false;
/*
- * Whether we are using a precompiled header (either via -include or #include).
+ * Whether we are using a precompiled header (either via -include, #include or clang's -include-pch).
*/
static bool using_precompiled_header = false;
bool
is_precompiled_header(const char *path)
{
- return str_eq(get_extension(path), ".gch");
+ return str_eq(get_extension(path), ".gch") || str_eq(get_extension(path), ".pch");
}
/*
*/
if (compopt_takes_path(argv[i])) {
char *relpath;
- char *pchpath;
if (i == argc-1) {
cc_log("Missing argument to %s", argv[i]);
stats_update(STATS_ARGS);
args_add(stripped_args, relpath);
/* Try to be smart about detecting precompiled headers */
- pchpath = format("%s.gch", argv[i+1]);
- if (stat(pchpath, &st) == 0) {
- cc_log("Detected use of precompiled header: %s", pchpath);
- found_pch = true;
+ if (str_eq(argv[i], "-include-pch")) {
+ if (stat(argv[i+1], &st) == 0) {
+ cc_log("Detected use of precompiled header: %s", argv[i+1]);
+ found_pch = true;
+ }
+ } else {
+ char* gchpath = format("%s.gch", argv[i+1]);
+ if (stat(gchpath, &st) == 0) {
+ cc_log("Detected use of precompiled header: %s", gchpath);
+ found_pch = true;
+ } else {
+ char* pchpath = format("%s.pch", argv[i+1]);
+ if (stat(pchpath, &st) == 0) {
+ cc_log("Detected use of precompiled header: %s", pchpath);
+ found_pch = true;
+ }
+ free(pchpath);
+ }
+ free(gchpath);
}
- free(pchpath);
free(relpath);
i++;
continue;
{"-imacros", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
{"-imultilib", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
{"-include", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
+ {"-include-pch", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
{"-install_name", TAKES_ARG}, /* Darwin linker option */
{"-iprefix", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
{"-iquote", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},