authorgravatar for paul.verigo@gmail.comPavel Verigo <paul.verigo@gmail.com> 2026-07-23 20:53:06+02:00
committergravatar for paul.verigo@gmail.comPavel Verigo <paul.verigo@gmail.com> 2026-07-23 20:53:06+02:00
log6aff551f179c40563e00073792517562d5132b1a
treef80412d9ec70ad207ac23db737b048bb764b8a28
parent97527a42c5a09564fa94d491a0c1d48c0fe66e28
parentbcaf025a6241b80826dfc13aca7ea4a56c467f55

Merge pull request 'Fix some counting errors related to std.Progress in the compiler' (#30616) from rpkak/zig:progress into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30616 Reviewed-by: Pavel Verigo <paul.verigo@gmail.com>

5 files changed, 29 insertions(+), 7 deletions(-)

src/Compilation.zig+14-1
...@@ -2911,7 +2911,20 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE...@@ -2911,7 +2911,20 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
2911 // The linker progress node is set up here instead of in `performAllTheWork`, because2911 // The linker progress node is set up here instead of in `performAllTheWork`, because
2912 // we also want it around during `flush`.2912 // we also want it around during `flush`.
2913 if (comp.bin_file) |lf| {2913 if (comp.bin_file) |lf| {
2914 comp.link_prog_node = main_progress_node.start("Linking", 0);2914 // mirrors logic in `Compilation.flush`:
2915 // Always: linker flush
2916 var initial_estimated_total: usize = 1;
2917 const llvm = if (comp.zcu) |zcu| zcu.llvm_object != null else false;
2918 // For llvm: "LLVM Emit Object" and "Parse Object" with the zcu object
2919 if (llvm) {
2920 initial_estimated_total += 2;
2921 }
2922 // Prelink
2923 if (!lf.post_prelink or llvm) {
2924 initial_estimated_total += 1;
2925 }
2926
2927 comp.link_prog_node = main_progress_node.start("Linking", initial_estimated_total);
2915 lf.startProgress(comp.link_prog_node);2928 lf.startProgress(comp.link_prog_node);
2916 }2929 }
2917 defer if (comp.bin_file) |lf| {2930 defer if (comp.bin_file) |lf| {
src/Zcu/PerThread.zig+1
...@@ -876,6 +876,7 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void {...@@ -876,6 +876,7 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void {
876 const old_line = old_zir.getDeclaration(old_inst).src_line;876 const old_line = old_zir.getDeclaration(old_inst).src_line;
877 const new_line = new_zir.getDeclaration(new_inst).src_line;877 const new_line = new_zir.getDeclaration(new_inst).src_line;
878 if (old_line != new_line) {878 if (old_line != new_line) {
879 comp.link_prog_node.increaseEstimatedTotalItems(1);
879 try comp.link_queue.enqueueZcu(comp, pt.tid, .{ .debug_update_line_number = tracked_inst_index });880 try comp.link_queue.enqueueZcu(comp, pt.tid, .{ .debug_update_line_number = tracked_inst_index });
880 }881 }
881 },882 },
src/link.zig+1-1
...@@ -1242,7 +1242,7 @@ pub const File = struct {...@@ -1242,7 +1242,7 @@ pub const File = struct {
1242 dev.check(tag.devFeature());1242 dev.check(tag.devFeature());
1243 try @as(*tag.Type(), @fieldParentPtr("base", base)).prelink(base.comp.link_prog_node);1243 try @as(*tag.Type(), @fieldParentPtr("base", base)).prelink(base.comp.link_prog_node);
1244 },1244 },
1245 else => {},1245 else => base.comp.link_prog_node.completeOne(),
1246 }1246 }
12471247
1248 base.post_prelink = true;1248 base.post_prelink = true;
src/link/Coff.zig+6-2
...@@ -5370,7 +5370,9 @@ fn loadDll(coff: *Coff, path: std.Build.Cache.Path, fr: *Io.File.Reader) LoadInp...@@ -5370,7 +5370,9 @@ fn loadDll(coff: *Coff, path: std.Build.Cache.Path, fr: *Io.File.Reader) LoadInp
5370}5370}
53715371
5372pub fn prelink(coff: *Coff, prog_node: std.Progress.Node) link.Error!void {5372pub fn prelink(coff: *Coff, prog_node: std.Progress.Node) link.Error!void {
5373 _ = prog_node;5373 const sub_prog_node = prog_node.start("COFF Prelink", 0);
5374 defer sub_prog_node.end();
5375
5374 const base = coff.base;5376 const base = coff.base;
5375 const comp = base.comp;5377 const comp = base.comp;
53765378
...@@ -5886,7 +5888,9 @@ pub fn flush(...@@ -5886,7 +5888,9 @@ pub fn flush(
5886 prog_node: std.Progress.Node,5888 prog_node: std.Progress.Node,
5887) link.Error!void {5889) link.Error!void {
5888 _ = arena;5890 _ = arena;
5889 _ = prog_node;5891 const sub_prog_node = prog_node.start("COFF Flush", 0);
5892 defer sub_prog_node.end();
5893
5890 const comp = coff.base.comp;5894 const comp = coff.base.comp;
58915895
5892 // TODO: When https://github.com/ziglang/zig/issues/23617 is in,5896 // TODO: When https://github.com/ziglang/zig/issues/23617 is in,
src/link/Elf2.zig+7-3
...@@ -5267,7 +5267,7 @@ fn loadObject(...@@ -5267,7 +5267,7 @@ fn loadObject(
5267 .first_symbol_reloc = .none,5267 .first_symbol_reloc = .none,
5268 .first_got_reloc = .none,5268 .first_got_reloc = .none,
5269 };5269 };
5270 elf.synth_prog_node.increaseEstimatedTotalItems(1);5270 elf.input_prog_node.increaseEstimatedTotalItems(1);
5271 }5271 }
5272 var symmap: std.ArrayList(Symbol.Id) = .empty;5272 var symmap: std.ArrayList(Symbol.Id) = .empty;
5273 defer symmap.deinit(gpa);5273 defer symmap.deinit(gpa);
...@@ -5812,7 +5812,9 @@ fn updateInitFiniArraySectionSize(...@@ -5812,7 +5812,9 @@ fn updateInitFiniArraySectionSize(
5812}5812}
58135813
5814pub fn prelink(elf: *Elf, prog_node: std.Progress.Node) link.Error!void {5814pub fn prelink(elf: *Elf, prog_node: std.Progress.Node) link.Error!void {
5815 _ = prog_node;5815 const sub_prog_node = prog_node.start("ELF Prelink", 0);
5816 defer sub_prog_node.end();
5817
5816 const diags = &elf.base.comp.link_diags;5818 const diags = &elf.base.comp.link_diags;
5817 elf.prelinkInner() catch |err| switch (err) {5819 elf.prelinkInner() catch |err| switch (err) {
5818 error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}),5820 error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}),
...@@ -7055,9 +7057,11 @@ pub fn flush(...@@ -7055,9 +7057,11 @@ pub fn flush(
7055) link.Error!void {7057) link.Error!void {
7056 const comp = elf.base.comp;7058 const comp = elf.base.comp;
7057 const diags = &comp.link_diags;7059 const diags = &comp.link_diags;
7058 _ = prog_node;
7059 _ = arena;7060 _ = arena;
70607061
7062 const sub_prog_node = prog_node.start("ELF Flush", 0);
7063 defer sub_prog_node.end();
7064
7061 if (comp.config.output_mode == .Exe) {7065 if (comp.config.output_mode == .Exe) {
7062 var any_undef = false;7066 var any_undef = false;
7063 for (elf.globals.strong_undef.keys()) |name| {7067 for (elf.globals.strong_undef.keys()) |name| {