mirror of
https://github.com/reactos/ccache.git
synced 2024-11-23 03:39:44 +00:00
support for precompiled headers with clang
Support the clang-specific -include-pch option, which references the PCH file itself, and support the .pch extension when using the gcc -include way.
This commit is contained in:
parent
d24b26cb1c
commit
8d9e955ba9
@ -629,6 +629,8 @@ things to make it work properly:
|
||||
--
|
||||
** 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
|
||||
|
29
ccache.c
29
ccache.c
@ -167,7 +167,7 @@ static bool profile_use = false;
|
||||
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;
|
||||
|
||||
@ -1355,7 +1355,7 @@ find_compiler(char** argv)
|
||||
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");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1680,7 +1680,6 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
|
||||
*/
|
||||
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);
|
||||
@ -1693,13 +1692,27 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_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;
|
||||
|
@ -61,6 +61,7 @@ static const struct compopt compopts[] = {
|
||||
{"-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},
|
||||
|
Loading…
Reference in New Issue
Block a user