diff options
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 6ba09d5c6d..8d276980ea 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2302,7 +2302,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { try pt.processExports(); } - if (try comp.totalErrorCount() != 0) { + if (anyErrors(comp)) { // Skip flushing and keep source files loaded for error reporting. comp.link_error_flags = .{}; return; @@ -2392,6 +2392,10 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { .sub_path = o_sub_path, }, .main, main_progress_node); + // Calling `flush` may have produced errors, in which case the + // cache manifest must not be written. + if (anyErrors(comp)) return; + // Failure here only means an unnecessary cache miss. man.writeManifest() catch |err| { log.warn("failed to write cache manifest: {s}", .{@errorName(err)}); @@ -3291,6 +3295,10 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { return bundle.toOwnedBundle(compile_log_text); } +fn anyErrors(comp: *Compilation) bool { + return (totalErrorCount(comp) catch return true) != 0; +} + fn totalErrorCount(comp: *Compilation) !u32 { var errors = try comp.getAllErrorsAlloc(); defer errors.deinit(comp.gpa); |
