auto old_st = Stat::stat(manifest_path);
+ bool save_timestamp = (g_config.sloppiness() & SLOPPY_FILE_STAT_MATCHES)
+ || output_is_precompiled_header;
+
MTR_BEGIN("manifest", "manifest_put");
cc_log("Adding result name to %s", manifest_path);
- if (!manifest_put(manifest_path, *cached_result_name, g_included_files)) {
+ if (!manifest_put(
+ manifest_path, *cached_result_name, g_included_files, save_timestamp)) {
cc_log("Failed to add result name to %s", manifest_path);
} else {
auto st = Stat::stat(manifest_path, Stat::OnError::log);
void
add_result_entry(
const struct digest& result_digest,
- const std::unordered_map<std::string, digest>& included_files)
+ const std::unordered_map<std::string, digest>& included_files,
+ bool save_timestamp)
{
std::unordered_map<std::string, uint32_t /*index*/> mf_files;
for (uint32_t i = 0; i < files.size(); ++i) {
std::vector<uint32_t> file_info_indexes;
for (const auto& item : included_files) {
- file_info_indexes.push_back(
- get_file_info_index(item.first, item.second, mf_files, mf_file_infos));
+ file_info_indexes.push_back(get_file_info_index(
+ item.first, item.second, mf_files, mf_file_infos, save_timestamp));
}
results.push_back(ResultEntry{std::move(file_info_indexes), result_digest});
const std::string& path,
const digest& digest,
const std::unordered_map<std::string, uint32_t>& mf_files,
- const std::unordered_map<FileInfo, uint32_t>& mf_file_infos)
+ const std::unordered_map<FileInfo, uint32_t>& mf_file_infos,
+ bool save_timestamp)
{
struct FileInfo fi;
//
// file_stat.ctime() may be 0, so we have to check time_of_compilation
// against MAX(mtime, ctime).
+ //
+ // ccache only reads mtime/ctime if sloppy_file_stat_match is setted,
+ // so mtimes/ctimes could store as a dummy value (-1) in other scenarios.
+ // This will effectively control the total number of file infos in
+ // certain scenarios, such as CI.
auto file_stat = Stat::stat(path, Stat::OnError::log);
if (file_stat) {
- if (time_of_compilation
- > std::max(file_stat.mtime(), file_stat.ctime())) {
+ if (save_timestamp
+ && time_of_compilation
+ > std::max(file_stat.mtime(), file_stat.ctime())) {
fi.mtime = file_stat.mtime();
fi.ctime = file_stat.ctime();
} else {
bool
manifest_put(const std::string& path,
const struct digest& result_name,
- const std::unordered_map<std::string, digest>& included_files)
+ const std::unordered_map<std::string, digest>& included_files,
+ bool save_timestamp)
{
// We don't bother to acquire a lock when writing the manifest to disk. A
// race between two processes will only result in one lost entry, which is
mf = std::make_unique<ManifestData>();
}
- mf->add_result_entry(result_name, included_files);
+ mf->add_result_entry(result_name, included_files, save_timestamp);
try {
write_manifest(path, *mf);
extern const uint8_t k_manifest_version;
struct digest* manifest_get(const Config& config, const std::string& path);
-bool
-manifest_put(const std::string& path,
- const struct digest& result_name,
- const std::unordered_map<std::string, digest>& included_files);
+bool manifest_put(const std::string& path,
+ const struct digest& result_name,
+ const std::unordered_map<std::string, digest>& included_files,
+ bool save_timestamp);
bool manifest_dump(const std::string& path, FILE* stream);