ccache normally examines a file's contents to determine whether it matches
the cached version. With this option set, ccache will consider a file as
matching its cached version if the mtimes and ctimes match.
+*file_stat_matches_ctime*::
+ By default, ccache will not consider a file as matching its cached
+ version if the ctimes do not match. This option disables that check.
*include_file_ctime*::
By default, ccache also will not cache a file if it includes a header whose
ctime is too new. This option disables that check.
// Allow us to not include any system headers in the manifest include files,
// similar to -MM versus -M for dependencies.
#define SLOPPY_NO_SYSTEM_HEADERS 64
+// Allow us to ignore ctimes when comparing file stats, so we can fake mtimes
+// if we want to (it is much harder to fake ctimes, requires changing clock)
+#define SLOPPY_FILE_STAT_MATCHES_CTIME 128
#define str_eq(s1, s2) (strcmp((s1), (s2)) == 0)
#define str_startswith(s, prefix) \
*value |= SLOPPY_FILE_MACRO;
} else if (str_eq(word, "file_stat_matches")) {
*value |= SLOPPY_FILE_STAT_MATCHES;
+ } else if (str_eq(word, "file_stat_matches_ctime")) {
+ *value |= SLOPPY_FILE_STAT_MATCHES_CTIME;
} else if (str_eq(word, "include_file_ctime")) {
*value |= SLOPPY_INCLUDE_FILE_CTIME;
} else if (str_eq(word, "include_file_mtime")) {
if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) {
reformat(&s, "%sfile_stat_matches, ", s);
}
+ if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES_CTIME) {
+ reformat(&s, "%sfile_stat_matches_ctime, ", s);
+ }
if (conf->sloppiness & SLOPPY_NO_SYSTEM_HEADERS) {
reformat(&s, "%sno_system_headers, ", s);
}
}
if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) {
- if (fi->mtime == st->mtime && fi->ctime == st->ctime) {
- cc_log("mtime/ctime hit for %s", path);
- continue;
+ if (!(conf->sloppiness & SLOPPY_FILE_STAT_MATCHES_CTIME)) {
+ if (fi->mtime == st->mtime && fi->ctime == st->ctime) {
+ cc_log("mtime/ctime hit for %s", path);
+ continue;
+ } else {
+ cc_log("mtime/ctime miss for %s", path);
+ }
} else {
- cc_log("mtime/ctime miss for %s", path);
+ if (fi->mtime == st->mtime) {
+ cc_log("mtime hit for %s", path);
+ continue;
+ } else {
+ cc_log("mtime miss for %s", path);
+ }
}
}
"read_only_direct = true\n"
"recache = true\n"
"run_second_cpp = false\n"
- "sloppiness = file_macro ,time_macros, include_file_mtime,include_file_ctime,file_stat_matches,pch_defines , no_system_headers \n"
+ "sloppiness = file_macro ,time_macros, include_file_mtime,include_file_ctime,file_stat_matches,file_stat_matches_ctime,pch_defines , no_system_headers \n"
"stats = false\n"
"temporary_dir = ${USER}_foo\n"
"umask = 777\n"
CHECK(!conf->run_second_cpp);
CHECK_INT_EQ(SLOPPY_INCLUDE_FILE_MTIME|SLOPPY_INCLUDE_FILE_CTIME|
SLOPPY_FILE_MACRO|SLOPPY_TIME_MACROS|
- SLOPPY_FILE_STAT_MATCHES|SLOPPY_NO_SYSTEM_HEADERS|
- SLOPPY_PCH_DEFINES,
+ SLOPPY_FILE_STAT_MATCHES|SLOPPY_FILE_STAT_MATCHES_CTIME|
+ SLOPPY_NO_SYSTEM_HEADERS|SLOPPY_PCH_DEFINES,
conf->sloppiness);
CHECK(!conf->stats);
CHECK_STR_EQ_FREE1(format("%s_foo", user), conf->temporary_dir);
.run_second_cpp = false,
SLOPPY_FILE_MACRO|SLOPPY_INCLUDE_FILE_MTIME|
SLOPPY_INCLUDE_FILE_CTIME|SLOPPY_TIME_MACROS|
- SLOPPY_FILE_STAT_MATCHES|SLOPPY_PCH_DEFINES|
- SLOPPY_NO_SYSTEM_HEADERS,
+ SLOPPY_FILE_STAT_MATCHES|SLOPPY_FILE_STAT_MATCHES_CTIME|
+ SLOPPY_PCH_DEFINES|SLOPPY_NO_SYSTEM_HEADERS,
false,
"td",
022,
CHECK_STR_EQ("run_second_cpp = false", received_conf_items[n++].descr);
CHECK_STR_EQ("sloppiness = file_macro, include_file_mtime,"
" include_file_ctime, time_macros, pch_defines,"
- " file_stat_matches, no_system_headers",
+ " file_stat_matches, file_stat_matches_ctime, no_system_headers",
received_conf_items[n++].descr);
CHECK_STR_EQ("stats = false", received_conf_items[n++].descr);
CHECK_STR_EQ("temporary_dir = td", received_conf_items[n++].descr);