cached.cpp: Improve internal cached robustness

Do not memory map files; Windows cannot write to a file that is memory
mapped.
Write cache after llvm building. This ensures the cache won't have a
false positive if llvm fails.
This commit is contained in:
Lucas Perlind
2024-10-22 17:58:54 +11:00
committed by flysand7
parent 182a916092
commit 28d01ce7b5
3 changed files with 75 additions and 55 deletions

View File

@@ -3391,6 +3391,7 @@ int main(int arg_count, char const **arg_ptr) {
Parser *parser = gb_alloc_item(permanent_allocator(), Parser);
Checker *checker = gb_alloc_item(permanent_allocator(), Checker);
bool failed_to_cache_parsing = false;
MAIN_TIME_SECTION("parse files");
@@ -3480,6 +3481,7 @@ int main(int arg_count, char const **arg_ptr) {
if (try_cached_build(checker, args)) {
goto end_of_code_gen;
}
failed_to_cache_parsing = true;
}
#if ALLOW_TILDE
@@ -3545,18 +3547,23 @@ int main(int arg_count, char const **arg_ptr) {
end_of_code_gen:;
if (build_context.show_timings) {
show_timings(checker, &global_timings);
}
if (build_context.export_dependencies_format != DependenciesExportUnspecified) {
export_dependencies(checker);
}
if (build_context.cached) {
MAIN_TIME_SECTION("write cached build");
if (!build_context.build_cache_data.copy_already_done) {
try_copy_executable_to_cache();
}
if (!build_context.build_cache_data.copy_already_done &&
build_context.cached) {
try_copy_executable_to_cache();
if (failed_to_cache_parsing) {
write_cached_build(checker, args);
}
}
if (build_context.show_timings) {
show_timings(checker, &global_timings);
}
if (run_output) {