From: Geert Kloosterman Date: Mon, 19 Feb 2018 14:24:55 +0000 (+0100) Subject: Allow a pre-computed checksum file for precompiled headers X-Git-Tag: v3.5~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27cac6ff668d8a38ad08bd9e29320f2240024902;p=thirdparty%2Fccache.git Allow a pre-computed checksum file for precompiled headers Having large precompiled header files slows down direct mode off CCache considerably. Allow CCache to check against a (much smaller) pre-computed checksum file instead of the precompiled header file itself. This checksum file will be used in the manifest instead of the actual precompiled header file. Note that to make this to work, the build system needs to keep a checksum file in sync with the precompiled header. The behavior can be activated by the `pch_external_checksum` option. --- diff --git a/doc/MANUAL.txt b/doc/MANUAL.txt index 421b939c5..ff3116bfe 100644 --- a/doc/MANUAL.txt +++ b/doc/MANUAL.txt @@ -451,6 +451,14 @@ might be incorrect. matching the compiler name in the normal *PATH* that isn't a symbolic link to ccache itself. +*pch_external_checksum* (*CCACHE_PCH_EXTSUM*):: + + When this option is set, and ccache finds a precompiled header file, + ccache will look for a file with the extension ``.sum`` added + (e.g. ``pre.h.gch.sum``), and if found, it will hash this file instead + of the precompiled header itself. To work around the performance + penalty of hashing of very large files. + *prefix_command* (*CCACHE_PREFIX*):: This option adds a list of prefixes (separated by space) to the command diff --git a/src/ccache.c b/src/ccache.c index 950317414..53bd46d77 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -638,13 +638,28 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system) bool is_pch = is_precompiled_header(path); if (is_pch) { + bool using_pch_sum = false; + if (conf->pch_external_checksum) { + // hash pch.sum instead of pch when it exists + // to prevent hashing a very large .pch file every time + char * pch_sum_path = format("%s.sum", path); + if (x_stat(pch_sum_path, &st) == 0) { + char * old_path = path; + path = pch_sum_path; + pch_sum_path = old_path; + using_pch_sum = true; + cc_log("Using pch.sum file %s", path); + } + free(pch_sum_path); + } + if (!hash_file(&fhash, path)) { goto failure; } struct file_hash pch_hash; hash_result_as_bytes(&fhash, pch_hash.hash); pch_hash.size = fhash.totalN; - hash_delimiter(cpp_hash, "pch_hash"); + hash_delimiter(cpp_hash, using_pch_sum ? "pch_sum_hash" : "pch_hash"); hash_buffer(cpp_hash, pch_hash.hash, sizeof(pch_hash.hash)); } diff --git a/src/conf.c b/src/conf.c index 20e744a02..fbc06af77 100644 --- a/src/conf.c +++ b/src/conf.c @@ -340,6 +340,7 @@ conf_create(void) conf->max_files = 0; conf->max_size = (uint64_t)5 * 1000 * 1000 * 1000; conf->path = x_strdup(""); + conf->pch_external_checksum = false; conf->prefix_command = x_strdup(""); conf->prefix_command_cpp = x_strdup(""); conf->read_only = false; @@ -607,6 +608,11 @@ conf_print_items(struct conf *conf, reformat(&s, "path = %s", conf->path); printer(s, conf->item_origins[find_conf("path")->number], context); + reformat(&s, "pch_external_checksum = %s", + bool_to_string(conf->pch_external_checksum)); + printer(s, conf->item_origins[find_conf("pch_external_checksum")->number], + context); + reformat(&s, "prefix_command = %s", conf->prefix_command); printer(s, conf->item_origins[find_conf("prefix_command")->number], context); diff --git a/src/conf.h b/src/conf.h index 232dcfd55..3ea756c73 100644 --- a/src/conf.h +++ b/src/conf.h @@ -24,6 +24,7 @@ struct conf { unsigned max_files; uint64_t max_size; char *path; + bool pch_external_checksum; char *prefix_command; char *prefix_command_cpp; bool read_only; diff --git a/src/confitems.gperf b/src/confitems.gperf index 531bc92d8..eef78c5f9 100644 --- a/src/confitems.gperf +++ b/src/confitems.gperf @@ -27,14 +27,15 @@ log_file, 16, ITEM(log_file, env_string) max_files, 17, ITEM(max_files, unsigned) max_size, 18, ITEM(max_size, size) path, 19, ITEM(path, env_string) -prefix_command, 20, ITEM(prefix_command, env_string) -prefix_command_cpp, 21, ITEM(prefix_command_cpp, env_string) -read_only, 22, ITEM(read_only, bool) -read_only_direct, 23, ITEM(read_only_direct, bool) -recache, 24, ITEM(recache, bool) -run_second_cpp, 25, ITEM(run_second_cpp, bool) -sloppiness, 26, ITEM(sloppiness, sloppiness) -stats, 27, ITEM(stats, bool) -temporary_dir, 28, ITEM(temporary_dir, env_string) -umask, 29, ITEM(umask, umask) -unify, 30, ITEM(unify, bool) +pch_external_checksum, 20, ITEM(pch_external_checksum, bool) +prefix_command, 21, ITEM(prefix_command, env_string) +prefix_command_cpp, 22, ITEM(prefix_command_cpp, env_string) +read_only, 23, ITEM(read_only, bool) +read_only_direct, 24, ITEM(read_only_direct, bool) +recache, 25, ITEM(recache, bool) +run_second_cpp, 26, ITEM(run_second_cpp, bool) +sloppiness, 27, ITEM(sloppiness, sloppiness) +stats, 28, ITEM(stats, bool) +temporary_dir, 29, ITEM(temporary_dir, env_string) +umask, 30, ITEM(umask, umask) +unify, 31, ITEM(unify, bool) diff --git a/src/confitems_lookup.c b/src/confitems_lookup.c index 63f0da090..04458d225 100644 --- a/src/confitems_lookup.c +++ b/src/confitems_lookup.c @@ -54,7 +54,7 @@ confitems_hash (register const char *str, register unsigned int len) 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 0, 13, 0, + 50, 50, 50, 50, 50, 50, 50, 0, 35, 0, 5, 10, 50, 0, 30, 20, 50, 0, 10, 20, 5, 0, 0, 50, 5, 0, 10, 15, 50, 50, 20, 50, 50, 50, 50, 50, 50, 50, 50, 50, @@ -87,7 +87,7 @@ confitems_get (register const char *str, register unsigned int len) { enum { - TOTAL_KEYWORDS = 31, + TOTAL_KEYWORDS = 32, MIN_WORD_LENGTH = 4, MAX_WORD_LENGTH = 26, MIN_HASH_VALUE = 4, @@ -114,28 +114,28 @@ confitems_get (register const char *str, register unsigned int len) {"cpp_extension", 7, ITEM(cpp_extension, string)}, #line 14 "src/confitems.gperf" {"compiler_check", 4, ITEM(compiler_check, string)}, -#line 37 "src/confitems.gperf" - {"stats", 27, ITEM(stats, bool)}, +#line 38 "src/confitems.gperf" + {"stats", 28, ITEM(stats, bool)}, #line 12 "src/confitems.gperf" {"cache_dir_levels", 2, ITEM_V(cache_dir_levels, unsigned, dir_levels)}, #line 16 "src/confitems.gperf" {"compression_level", 6, ITEM(compression_level, unsigned)}, #line 26 "src/confitems.gperf" {"log_file", 16, ITEM(log_file, env_string)}, -#line 30 "src/confitems.gperf" - {"prefix_command", 20, ITEM(prefix_command, env_string)}, -#line 36 "src/confitems.gperf" - {"sloppiness", 26, ITEM(sloppiness, sloppiness)}, -#line 10 "src/confitems.gperf" - {"base_dir", 0, ITEM_V(base_dir, env_string, absolute_path)}, -#line 34 "src/confitems.gperf" - {"recache", 24, ITEM(recache, bool)}, #line 31 "src/confitems.gperf" - {"prefix_command_cpp", 21, ITEM(prefix_command_cpp, env_string)}, + {"prefix_command", 21, ITEM(prefix_command, env_string)}, +#line 37 "src/confitems.gperf" + {"sloppiness", 27, ITEM(sloppiness, sloppiness)}, +#line 30 "src/confitems.gperf" + {"pch_external_checksum", 20, ITEM(pch_external_checksum, bool)}, +#line 35 "src/confitems.gperf" + {"recache", 25, ITEM(recache, bool)}, #line 32 "src/confitems.gperf" - {"read_only", 22, ITEM(read_only, bool)}, -#line 40 "src/confitems.gperf" - {"unify", 30, ITEM(unify, bool)}, + {"prefix_command_cpp", 22, ITEM(prefix_command_cpp, env_string)}, +#line 33 "src/confitems.gperf" + {"read_only", 23, ITEM(read_only, bool)}, +#line 41 "src/confitems.gperf" + {"unify", 31, ITEM(unify, bool)}, {"",0,NULL,0,NULL}, #line 24 "src/confitems.gperf" {"keep_comments_cpp", 14, ITEM(keep_comments_cpp, bool)}, @@ -144,14 +144,14 @@ confitems_get (register const char *str, register unsigned int len) #line 27 "src/confitems.gperf" {"max_files", 17, ITEM(max_files, unsigned)}, {"",0,NULL,0,NULL}, -#line 33 "src/confitems.gperf" - {"read_only_direct", 23, ITEM(read_only_direct, bool)}, +#line 34 "src/confitems.gperf" + {"read_only_direct", 24, ITEM(read_only_direct, bool)}, #line 19 "src/confitems.gperf" {"disable", 9, ITEM(disable, bool)}, -#line 38 "src/confitems.gperf" - {"temporary_dir", 28, ITEM(temporary_dir, env_string)}, -#line 35 "src/confitems.gperf" - {"run_second_cpp", 25, ITEM(run_second_cpp, bool)}, +#line 39 "src/confitems.gperf" + {"temporary_dir", 29, ITEM(temporary_dir, env_string)}, +#line 36 "src/confitems.gperf" + {"run_second_cpp", 26, ITEM(run_second_cpp, bool)}, {"",0,NULL,0,NULL}, #line 18 "src/confitems.gperf" {"direct_mode", 8, ITEM(direct_mode, bool)}, @@ -160,10 +160,11 @@ confitems_get (register const char *str, register unsigned int len) {"hash_dir", 12, ITEM(hash_dir, bool)}, #line 21 "src/confitems.gperf" {"hard_link", 11, ITEM(hard_link, bool)}, -#line 39 "src/confitems.gperf" - {"umask", 29, ITEM(umask, umask)}, +#line 40 "src/confitems.gperf" + {"umask", 30, ITEM(umask, umask)}, {"",0,NULL,0,NULL}, {"",0,NULL,0,NULL}, - {"",0,NULL,0,NULL}, +#line 10 "src/confitems.gperf" + {"base_dir", 0, ITEM_V(base_dir, env_string, absolute_path)}, #line 25 "src/confitems.gperf" {"limit_multiple", 15, ITEM(limit_multiple, float)}, {"",0,NULL,0,NULL}, @@ -188,4 +189,4 @@ confitems_get (register const char *str, register unsigned int len) } return 0; } -static const size_t CONFITEMS_TOTAL_KEYWORDS = 31; +static const size_t CONFITEMS_TOTAL_KEYWORDS = 32; diff --git a/src/envtoconfitems.gperf b/src/envtoconfitems.gperf index 7b598b6f2..47abe5e62 100644 --- a/src/envtoconfitems.gperf +++ b/src/envtoconfitems.gperf @@ -30,6 +30,7 @@ MAXFILES, "max_files" MAXSIZE, "max_size" NLEVELS, "cache_dir_levels" PATH, "path" +PCH_EXTSUM, "pch_external_checksum" PREFIX, "prefix_command" PREFIX_CPP, "prefix_command_cpp" READONLY, "read_only" diff --git a/src/envtoconfitems_lookup.c b/src/envtoconfitems_lookup.c index 2b4f42dce..16a905f93 100644 --- a/src/envtoconfitems_lookup.c +++ b/src/envtoconfitems_lookup.c @@ -1,6 +1,6 @@ /* ANSI-C code produced by gperf version 3.0.4 */ /* Command-line: gperf src/envtoconfitems.gperf */ -/* Computed positions: -k'1,5' */ +/* Computed positions: -k'4-5' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -31,7 +31,7 @@ #line 9 "src/envtoconfitems.gperf" struct env_to_conf_item; -/* maximum key range = 47, duplicates = 0 */ +/* maximum key range = 52, duplicates = 0 */ #ifdef __GNUC__ __inline @@ -45,45 +45,45 @@ envtoconfitems_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 20, 0, 0, 10, - 35, 49, 5, 20, 0, 49, 10, 25, 0, 0, - 5, 10, 5, 15, 10, 5, 49, 49, 49, 49, - 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49 + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 0, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 25, 10, 0, 0, 15, + 10, 54, 5, 0, 54, 10, 35, 15, 0, 25, + 0, 54, 15, 20, 0, 54, 15, 54, 54, 0, + 54, 54, 54, 54, 54, 5, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54 }; register int hval = len; switch (hval) { default: - hval += asso_values[(unsigned char)str[4]+1]; + hval += asso_values[(unsigned char)str[4]]; /*FALLTHROUGH*/ case 4: + hval += asso_values[(unsigned char)str[3]]; + /*FALLTHROUGH*/ case 3: case 2: - case 1: - hval += asso_values[(unsigned char)str[0]]; break; } return hval; @@ -101,11 +101,11 @@ envtoconfitems_get (register const char *str, register unsigned int len) { enum { - TOTAL_KEYWORDS = 32, + TOTAL_KEYWORDS = 33, MIN_WORD_LENGTH = 2, MAX_WORD_LENGTH = 15, MIN_HASH_VALUE = 2, - MAX_HASH_VALUE = 48 + MAX_HASH_VALUE = 53 }; static const struct env_to_conf_item wordlist[] = @@ -117,74 +117,76 @@ envtoconfitems_get (register const char *str, register unsigned int len) {"DIR", "cache_dir"}, #line 17 "src/envtoconfitems.gperf" {"CPP2", "run_second_cpp"}, - {"",""}, -#line 20 "src/envtoconfitems.gperf" - {"DIRECT", "direct_mode"}, -#line 21 "src/envtoconfitems.gperf" - {"DISABLE", "disable"}, + {"",""}, {"",""}, +#line 41 "src/envtoconfitems.gperf" + {"TEMPDIR", "temporary_dir"}, #line 13 "src/envtoconfitems.gperf" {"COMPILER", "compiler"}, #line 32 "src/envtoconfitems.gperf" {"PATH", "path"}, -#line 42 "src/envtoconfitems.gperf" - {"UNIFY", "unify"}, -#line 33 "src/envtoconfitems.gperf" - {"PREFIX", "prefix_command"}, -#line 37 "src/envtoconfitems.gperf" - {"RECACHE", "recache"}, +#line 39 "src/envtoconfitems.gperf" + {"SLOPPINESS", "sloppiness"}, + {"",""}, +#line 25 "src/envtoconfitems.gperf" + {"HASHDIR", "hash_dir"}, #line 14 "src/envtoconfitems.gperf" {"COMPILERCHECK", "compiler_check"}, - {"",""}, +#line 27 "src/envtoconfitems.gperf" + {"LIMIT_MULTIPLE", "limit_multiple"}, +#line 43 "src/envtoconfitems.gperf" + {"UNIFY", "unify"}, #line 34 "src/envtoconfitems.gperf" - {"PREFIX_CPP", "prefix_command_cpp"}, - {"",""}, + {"PREFIX", "prefix_command"}, #line 28 "src/envtoconfitems.gperf" {"LOGFILE", "log_file"}, -#line 35 "src/envtoconfitems.gperf" - {"READONLY", "read_only"}, -#line 22 "src/envtoconfitems.gperf" - {"EXTENSION", "cpp_extension"}, -#line 41 "src/envtoconfitems.gperf" - {"UMASK", "umask"}, +#line 29 "src/envtoconfitems.gperf" + {"MAXFILES", "max_files"}, {"",""}, -#line 25 "src/envtoconfitems.gperf" - {"HASHDIR", "hash_dir"}, +#line 35 "src/envtoconfitems.gperf" + {"PREFIX_CPP", "prefix_command_cpp"}, +#line 20 "src/envtoconfitems.gperf" + {"DIRECT", "direct_mode"}, +#line 11 "src/envtoconfitems.gperf" + {"BASEDIR", "base_dir"}, #line 15 "src/envtoconfitems.gperf" {"COMPRESS", "compression"}, - {"",""}, -#line 36 "src/envtoconfitems.gperf" - {"READONLY_DIRECT", "read_only_direct"}, - {"",""}, +#line 22 "src/envtoconfitems.gperf" + {"EXTENSION", "cpp_extension"}, #line 40 "src/envtoconfitems.gperf" - {"TEMPDIR", "temporary_dir"}, -#line 16 "src/envtoconfitems.gperf" - {"COMPRESSLEVEL", "compression_level"}, -#line 27 "src/envtoconfitems.gperf" - {"LIMIT_MULTIPLE", "limit_multiple"}, -#line 39 "src/envtoconfitems.gperf" {"STATS", "stats"}, {"",""}, #line 30 "src/envtoconfitems.gperf" {"MAXSIZE", "max_size"}, -#line 29 "src/envtoconfitems.gperf" - {"MAXFILES", "max_files"}, +#line 16 "src/envtoconfitems.gperf" + {"COMPRESSLEVEL", "compression_level"}, {"",""}, -#line 38 "src/envtoconfitems.gperf" - {"SLOPPINESS", "sloppiness"}, +#line 33 "src/envtoconfitems.gperf" + {"PCH_EXTSUM", "pch_external_checksum"}, {"",""}, -#line 11 "src/envtoconfitems.gperf" - {"BASEDIR", "base_dir"}, -#line 24 "src/envtoconfitems.gperf" - {"HARDLINK", "hard_link"}, +#line 38 "src/envtoconfitems.gperf" + {"RECACHE", "recache"}, +#line 36 "src/envtoconfitems.gperf" + {"READONLY", "read_only"}, {"",""}, -#line 23 "src/envtoconfitems.gperf" - {"EXTRAFILES", "extra_files_to_hash"}, +#line 42 "src/envtoconfitems.gperf" + {"UMASK", "umask"}, {"",""}, #line 31 "src/envtoconfitems.gperf" {"NLEVELS", "cache_dir_levels"}, #line 18 "src/envtoconfitems.gperf" {"COMMENTS", "keep_comments_cpp"}, - {"",""}, {"",""}, {"",""}, {"",""}, + {"",""}, +#line 37 "src/envtoconfitems.gperf" + {"READONLY_DIRECT", "read_only_direct"}, + {"",""}, +#line 21 "src/envtoconfitems.gperf" + {"DISABLE", "disable"}, +#line 24 "src/envtoconfitems.gperf" + {"HARDLINK", "hard_link"}, + {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, +#line 23 "src/envtoconfitems.gperf" + {"EXTRAFILES", "extra_files_to_hash"}, + {"",""}, {"",""}, #line 26 "src/envtoconfitems.gperf" {"IGNOREHEADERS", "ignore_headers_in_manifest"} }; @@ -203,4 +205,4 @@ envtoconfitems_get (register const char *str, register unsigned int len) } return 0; } -static const size_t ENVTOCONFITEMS_TOTAL_KEYWORDS = 32; +static const size_t ENVTOCONFITEMS_TOTAL_KEYWORDS = 33; diff --git a/test/suites/pch.bash b/test/suites/pch.bash index c098e7f41..d317e251b 100644 --- a/test/suites/pch.bash +++ b/test/suites/pch.bash @@ -290,6 +290,61 @@ pch_suite_gcc() { expect_stat 'cache hit (direct)' 3 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 3 + + # ------------------------------------------------------------------------- + TEST "Use .gch, -fpch-preprocess, PCH_EXTSUM=1" + + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + echo "original checksum" > pch.h.gch.sum + + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + echo "other checksum" > pch.h.gch.sum + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + echo "original checksum" > pch.h.gch.sum + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + # ------------------------------------------------------------------------- + TEST "Use .gch, -fpch-preprocess, no PCH_EXTSUM" + + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + echo "original checksum" > pch.h.gch.sum + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + # external checksum not used, so no cache miss when changed + echo "other checksum" > pch.h.gch.sum + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 } pch_suite_clang() { diff --git a/unittest/test_conf.c b/unittest/test_conf.c index 9f88133bc..a3ded4260 100644 --- a/unittest/test_conf.c +++ b/unittest/test_conf.c @@ -18,7 +18,7 @@ #include "framework.h" #include "util.h" -#define N_CONFIG_ITEMS 31 +#define N_CONFIG_ITEMS 32 static struct { char *descr; const char *origin; @@ -69,6 +69,7 @@ TEST(conf_create) CHECK_INT_EQ(0, conf->max_files); CHECK_INT_EQ((uint64_t)5 * 1000 * 1000 * 1000, conf->max_size); CHECK_STR_EQ("", conf->path); + CHECK(!conf->pch_external_checksum); CHECK_STR_EQ("", conf->prefix_command); CHECK_STR_EQ("", conf->prefix_command_cpp); CHECK(!conf->read_only); @@ -120,6 +121,7 @@ TEST(conf_read_valid_config) "max_files = 17\n" "max_size = 123M\n" "path = $USER.x\n" + "pch_external_checksum = true\n" "prefix_command = x$USER\n" "prefix_command_cpp = y\n" "read_only = true\n" @@ -158,6 +160,7 @@ TEST(conf_read_valid_config) CHECK_INT_EQ(17, conf->max_files); CHECK_INT_EQ(123 * 1000 * 1000, conf->max_size); CHECK_STR_EQ_FREE1(format("%s.x", user), conf->path); + CHECK(conf->pch_external_checksum); CHECK_STR_EQ_FREE1(format("x%s", user), conf->prefix_command); CHECK_STR_EQ("y", conf->prefix_command_cpp); CHECK(conf->read_only); @@ -386,6 +389,7 @@ TEST(conf_print_items) 4711, 98.7 * 1000 * 1000, "p", + true, "pc", "pcc", true, @@ -436,6 +440,7 @@ TEST(conf_print_items) CHECK_STR_EQ("max_files = 4711", received_conf_items[n++].descr); CHECK_STR_EQ("max_size = 98.7M", received_conf_items[n++].descr); CHECK_STR_EQ("path = p", received_conf_items[n++].descr); + CHECK_STR_EQ("pch_external_checksum = true", received_conf_items[n++].descr); CHECK_STR_EQ("prefix_command = pc", received_conf_items[n++].descr); CHECK_STR_EQ("prefix_command_cpp = pcc", received_conf_items[n++].descr); CHECK_STR_EQ("read_only = true", received_conf_items[n++].descr);