Commit 42f4b8ab authored by Christian Dietrich's avatar Christian Dietrich
Browse files

historical: do not clean chash cache

Ok this is a tricky one:

If
a) a commit fails, the repository is reset for the next build
b) now ccache restructs a .o file without creating .hash or .hash.copy files
c) now a semantic change happens, which chash detects, but its cache is broken.

-> ccache makes clang-hash dumber
parent 08c6c287
......@@ -28,7 +28,7 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
outputs = {
"stats": File("summary.dict"),
"ccache_stats": File("ccache.stats"),
"clang_hash_stats": File("clang-hash.stats"),
"clang_hash_log": File("clang-hash.log"),
}
def build_parent(self, commit, from_scratch = False):
......@@ -43,7 +43,7 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
src_path = self.project.path
if from_scratch:
shell("cd %s; git clean -dfx", src_path)
shell("cd %s; git clean -dfx -e '*.hash' -e '*.hash.copy'", src_path)
logging.info("Parent [%s^]: clean build", commit)
shell("cd %s; git reset --hard %s^", src_path, commit)
info = {"commit": commit + "^"}
......@@ -104,6 +104,7 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
time = 0
last_failed = True
while commits:
# Search for a child of the current revision
commit = None
......@@ -131,8 +132,17 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
shell("cd %s; git reset --hard %s", src_path, commit[0])
self.call_reconfigure(src_path)
if os.path.exists("/tmp/clang-hash.log"):
os.unlink("/tmp/clang-hash.log")
# Rebuild and Measure
self.rebuild(src_path, info, fail_ok=True)
if os.path.exists("/tmp/clang-hash.log") and not info.get("failed"):
with open("/tmp/clang-hash.log") as fd:
self.clang_hash_log.value += fd.read()
self.build_info["builds"].append(info)
if not info.get("failed"):
time += info['build-time'] / 1e9
......
......@@ -132,6 +132,7 @@ class ClangHashHelper:
if "clang-hash" in self.mode.value:
log = hash_log.read()
info['clang-hash-log'] = log
info['clang-hash-hits'] = log.count("H")
info['clang-hash-misses'] = log.count("M")
hash_log.close()
......
......@@ -55,7 +55,8 @@ static void link_object_file() {
int fd = open(getenv("CLANG_HASH_LOGFILE"),
O_APPEND | O_WRONLY | O_CREAT,
0644);
write(fd, atexit_mode == ATEXIT_FROM_CACHE ? "H" : "M", 1);
const char* fail = (atexit_mode == ATEXIT_FROM_CACHE ? "H" : "M");
write(fd, fail, 1);
close(fd);
}
......@@ -188,9 +189,9 @@ private:
continue;
}
if (Arg.size() > 2 && Arg.compare(Arg.size() - 2, 2, ".c") == 0)
continue; // don't hash source filename
continue;
if (Arg.size() > 2 && Arg.compare(Arg.size() - 2, 2, ".i") == 0)
continue; // don't hash source filename (ccache preprocessed)
continue;
if (Arg.find("-stop-if-same-hash") != std::string::npos) {
continue; // also don't hash this (plugin argument)
......@@ -244,7 +245,7 @@ protected:
hash_old = strdup(PreviousHashString.c_str());
}
}
// Write hash database to .o.hash if the compiler produces a object file
if ((CI.getFrontendOpts().ProgramAction == frontend::EmitObj
|| CI.getFrontendOpts().ProgramAction == frontend::EmitBC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment