diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-11 12:47:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-11 12:47:55 -0400 |
| commit | 80e5af2be21427b8590c31e21c8e6b4cae1b7a6e (patch) | |
| tree | 318a78764265ac2c97287fe0eda33e57a1d46cf8 /src/codegen.cpp | |
| parent | 9efa18f687a8c05f6651df6a7455a39c3d42d212 (diff) | |
| parent | 3ff0e8bd96bc6bf1d8eb4985c6d56766dab578f2 (diff) | |
| download | zig-80e5af2be21427b8590c31e21c8e6b4cae1b7a6e.tar.gz zig-80e5af2be21427b8590c31e21c8e6b4cae1b7a6e.zip | |
Merge pull request #2049 from ziglang/problematic-mtime-detection
stage1 caching system: detect problematic mtimes
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 71f9f0217b..332080c2f5 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7724,8 +7724,11 @@ static Error define_builtin_compile_vars(CodeGen *g) { Buf digest = BUF_INIT; buf_resize(&digest, 0); - if ((err = cache_hit(&cache_hash, &digest))) - return err; + if ((err = cache_hit(&cache_hash, &digest))) { + // Treat an invalid format error as a cache miss. + if (err != ErrorInvalidFormat) + return err; + } // We should always get a cache hit because there are no // files in the input hash. @@ -8342,12 +8345,14 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { Buf digest = BUF_INIT; buf_resize(&digest, 0); if ((err = cache_hit(cache_hash, &digest))) { - if (err == ErrorCacheUnavailable) { - // already printed error - } else { - fprintf(stderr, "unable to check cache when compiling C object: %s\n", err_str(err)); + if (err != ErrorInvalidFormat) { + if (err == ErrorCacheUnavailable) { + // already printed error + } else { + fprintf(stderr, "unable to check cache when compiling C object: %s\n", err_str(err)); + } + exit(1); } - exit(1); } bool is_cache_miss = (buf_len(&digest) == 0); if (is_cache_miss) { @@ -8993,7 +8998,10 @@ void codegen_print_timing_report(CodeGen *g, FILE *f) { } void codegen_add_time_event(CodeGen *g, const char *name) { - g->timing_events.append({os_get_time(), name}); + OsTimeStamp timestamp = os_timestamp_monotonic(); + double seconds = (double)timestamp.sec; + seconds += ((double)timestamp.nsec) / 1000000000.0; + g->timing_events.append({seconds, name}); } static void add_cache_pkg(CodeGen *g, CacheHash *ch, ZigPackage *pkg) { @@ -9090,8 +9098,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { cache_list_of_file(ch, g->link_objects.items, g->link_objects.length); buf_resize(digest, 0); - if ((err = cache_hit(ch, digest))) - return err; + if ((err = cache_hit(ch, digest))) { + if (err != ErrorInvalidFormat) + return err; + } if (ch->manifest_file_path != nullptr) { g->caches_to_release.append(ch); |
