authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-27 12:56:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 19:49:07-07:00
log476484f09c98a3a49e0a6be3b92d563ad362ee04
tree4422b28092e0d93b0e78bbfc409b8f50c41703e5
parent4c3342ed76f543f2043c51c11596acae61e933ea

Compilation: inline the flush function

There is only one call to this function and this made it easier to troubleshoot the logic.

1 files changed, 19 insertions(+), 19 deletions(-)

src/Compilation.zig+19-19
...@@ -2202,10 +2202,26 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2202,10 +2202,26 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2202 return;2202 return;
2203 }2203 }
22042204
2205 // Flush takes care of -femit-bin, but we still have -femit-llvm-ir, -femit-llvm-bc, and2205 // Flush below handles -femit-bin but there is still -femit-llvm-ir,
2206 // -femit-asm to handle, in the case of C objects.2206 // -femit-llvm-bc, and -femit-asm, in the case of C objects.
2207 comp.emitOthers();2207 comp.emitOthers();
2208 try comp.flush(main_progress_node);2208
2209 {
2210 if (comp.bin_file) |lf| {
2211 // This is needed before reading the error flags.
2212 lf.flush(comp, main_progress_node) catch |err| switch (err) {
2213 error.FlushFailure => {}, // error reported through link_error_flags
2214 error.LLDReportedFailure => {}, // error reported via lockAndParseLldStderr
2215 else => |e| return e,
2216 };
2217 comp.link_error_flags = lf.error_flags;
2218 }
2219
2220 if (comp.module) |module| {
2221 try link.File.C.flushEmitH(module);
2222 }
2223 }
2224
2209 if (comp.totalErrorCount() != 0) return;2225 if (comp.totalErrorCount() != 0) return;
2210 try maybeGenerateAutodocs(comp, main_progress_node);2226 try maybeGenerateAutodocs(comp, main_progress_node);
22112227
...@@ -2323,22 +2339,6 @@ fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !voi...@@ -2323,22 +2339,6 @@ fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !voi
2323 }2339 }
2324}2340}
23252341
2326fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
2327 if (comp.bin_file) |lf| {
2328 // This is needed before reading the error flags.
2329 lf.flush(comp, prog_node) catch |err| switch (err) {
2330 error.FlushFailure => {}, // error reported through link_error_flags
2331 error.LLDReportedFailure => {}, // error reported via lockAndParseLldStderr
2332 else => |e| return e,
2333 };
2334 comp.link_error_flags = lf.error_flags;
2335 }
2336
2337 if (comp.module) |module| {
2338 try link.File.C.flushEmitH(module);
2339 }
2340}
2341
2342/// Communicate the output binary location to parent Compilations.2342/// Communicate the output binary location to parent Compilations.
2343fn wholeCacheModeSetBinFilePath(2343fn wholeCacheModeSetBinFilePath(
2344 comp: *Compilation,2344 comp: *Compilation,