From 476484f09c98a3a49e0a6be3b92d563ad362ee04 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 27 Dec 2023 12:56:14 -0700 Subject: Compilation: inline the flush function There is only one call to this function and this made it easier to troubleshoot the logic. --- src/Compilation.zig | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 06b406a59c..6b0bd7345c 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2202,10 +2202,26 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void return; } - // Flush takes care of -femit-bin, but we still have -femit-llvm-ir, -femit-llvm-bc, and - // -femit-asm to handle, in the case of C objects. + // Flush below handles -femit-bin but there is still -femit-llvm-ir, + // -femit-llvm-bc, and -femit-asm, in the case of C objects. comp.emitOthers(); - try comp.flush(main_progress_node); + + { + if (comp.bin_file) |lf| { + // This is needed before reading the error flags. + lf.flush(comp, main_progress_node) catch |err| switch (err) { + error.FlushFailure => {}, // error reported through link_error_flags + error.LLDReportedFailure => {}, // error reported via lockAndParseLldStderr + else => |e| return e, + }; + comp.link_error_flags = lf.error_flags; + } + + if (comp.module) |module| { + try link.File.C.flushEmitH(module); + } + } + if (comp.totalErrorCount() != 0) return; try maybeGenerateAutodocs(comp, main_progress_node); @@ -2323,22 +2339,6 @@ fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !voi } } -fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void { - if (comp.bin_file) |lf| { - // This is needed before reading the error flags. - lf.flush(comp, prog_node) catch |err| switch (err) { - error.FlushFailure => {}, // error reported through link_error_flags - error.LLDReportedFailure => {}, // error reported via lockAndParseLldStderr - else => |e| return e, - }; - comp.link_error_flags = lf.error_flags; - } - - if (comp.module) |module| { - try link.File.C.flushEmitH(module); - } -} - /// Communicate the output binary location to parent Compilations. fn wholeCacheModeSetBinFilePath( comp: *Compilation, -- cgit v1.2.3