aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-17 04:06:51 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-04-17 04:09:35 -0700
commita7c05c06bef1570546cae4c45a76027819c7fa09 (patch)
tree80ae95c7d5edf95f4ed8ed013eb0bf9e27e337fb /src/Compilation.zig
parent2aeaa1cfc4c563a24525fb27fd2783bfd5da808a (diff)
downloadzig-a7c05c06bef1570546cae4c45a76027819c7fa09.tar.gz
zig-a7c05c06bef1570546cae4c45a76027819c7fa09.zip
stage2: expose progress bar API to linker backends
This gives us insight as to what is happening when we are waiting for things such as LLVM emit object and LLD linking.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 6c486de36a..f0e490c67d 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -2084,7 +2084,13 @@ pub fn update(comp: *Compilation) !void {
}
}
- try comp.performAllTheWork();
+ // If the terminal is dumb, we dont want to show the user all the output.
+ var progress: std.Progress = .{ .dont_print_on_dumb = true };
+ const main_progress_node = progress.start("", 0);
+ defer main_progress_node.end();
+ if (comp.color == .off) progress.terminal = null;
+
+ try comp.performAllTheWork(main_progress_node);
if (!use_stage1) {
if (comp.bin_file.options.module) |module| {
@@ -2158,9 +2164,9 @@ pub fn update(comp: *Compilation) !void {
.path = dir_path,
};
- try comp.flush();
+ try comp.flush(main_progress_node);
} else {
- try comp.flush();
+ try comp.flush(main_progress_node);
}
// Failure here only means an unnecessary cache miss.
@@ -2171,7 +2177,7 @@ pub fn update(comp: *Compilation) !void {
assert(comp.bin_file.lock == null);
comp.bin_file.lock = man.toOwnedLock();
} else {
- try comp.flush();
+ try comp.flush(main_progress_node);
}
// Unload all source files to save memory.
@@ -2188,8 +2194,8 @@ pub fn update(comp: *Compilation) !void {
}
}
-fn flush(comp: *Compilation) !void {
- try comp.bin_file.flush(comp); // This is needed before reading the error flags.
+fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
+ try comp.bin_file.flush(comp, prog_node); // This is needed before reading the error flags.
comp.link_error_flags = comp.bin_file.errorFlags();
const use_stage1 = build_options.omit_stage2 or
@@ -2590,14 +2596,10 @@ pub fn getCompileLogOutput(self: *Compilation) []const u8 {
return module.compile_log_text.items;
}
-pub fn performAllTheWork(comp: *Compilation) error{ TimerUnsupported, OutOfMemory }!void {
- // If the terminal is dumb, we dont want to show the user all the
- // output.
- var progress: std.Progress = .{ .dont_print_on_dumb = true };
- var main_progress_node = progress.start("", 0);
- defer main_progress_node.end();
- if (comp.color == .off) progress.terminal = null;
-
+pub fn performAllTheWork(
+ comp: *Compilation,
+ main_progress_node: *std.Progress.Node,
+) error{ TimerUnsupported, OutOfMemory }!void {
// Here we queue up all the AstGen tasks first, followed by C object compilation.
// We wait until the AstGen tasks are all completed before proceeding to the
// (at least for now) single-threaded main work queue. However, C object compilation