authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-10-03 19:26:21+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-03 22:11:29-04:00
log52ba2c3a43a88a4db30cff47f2f3eff8c3d5be19
treef1d0c384336665e451746cdf5d4543d997a1107c
parent9917b0576a58946bad67a41b29e56b8a7d67c251

Reintroduce progress bar when compiling C files


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

src/Compilation.zig+19-9
......@@ -1149,7 +1149,15 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
11491149 };
11501150}
11511151
1152pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
1152pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemory }!void {
1153 var progress: std.Progress = .{};
1154 var main_progress_node = try progress.start("", null);
1155 defer main_progress_node.end();
1156 if (self.color == .Off) progress.terminal = null;
1157
1158 var c_comp_progress_node = main_progress_node.start("Compile C Objects", self.c_source_files.len);
1159 defer c_comp_progress_node.end();
1160
11531161 while (self.work_queue.readItem()) |work_item| switch (work_item) {
11541162 .codegen_decl => |decl| switch (decl.analysis) {
11551163 .unreferenced => unreachable,
......@@ -1226,7 +1234,7 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
12261234 };
12271235 },
12281236 .c_object => |c_object| {
1229 self.updateCObject(c_object) catch |err| switch (err) {
1237 self.updateCObject(c_object, &c_comp_progress_node) catch |err| switch (err) {
12301238 error.AnalysisFail => continue,
12311239 else => {
12321240 try self.failed_c_objects.ensureCapacity(self.gpa, self.failed_c_objects.items().len + 1);
......@@ -1312,7 +1320,7 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
13121320 if (!build_options.is_stage1)
13131321 unreachable;
13141322
1315 self.updateStage1Module() catch |err| {
1323 self.updateStage1Module(main_progress_node) catch |err| {
13161324 fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
13171325 };
13181326 },
......@@ -1473,7 +1481,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
14731481 };
14741482}
14751483
1476fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
1484fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *std.Progress.Node) !void {
14771485 if (!build_options.have_llvm) {
14781486 return comp.failCObj(c_object, "clang not available: compiler built without LLVM extensions", .{});
14791487 }
......@@ -1516,6 +1524,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
15161524 const arena = &arena_allocator.allocator;
15171525
15181526 const c_source_basename = std.fs.path.basename(c_object.src.src_path);
1527
1528 c_comp_progress_node.activate();
1529 var child_progress_node = c_comp_progress_node.start(c_source_basename, null);
1530 child_progress_node.activate();
1531 defer child_progress_node.end();
1532
15191533 // Special case when doing build-obj for just one C file. When there are more than one object
15201534 // file and building an object we need to link them together, but with just one it should go
15211535 // directly to the output file.
......@@ -2509,7 +2523,7 @@ fn buildStaticLibFromZig(comp: *Compilation, src_basename: []const u8, out: *?CR
25092523 };
25102524}
25112525
2512fn updateStage1Module(comp: *Compilation) !void {
2526fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node) !void {
25132527 const tracy = trace(@src());
25142528 defer tracy.end();
25152529
......@@ -2615,10 +2629,6 @@ fn updateStage1Module(comp: *Compilation) !void {
26152629 .llvm_cpu_name = if (target.cpu.model.llvm_name) |s| s.ptr else null,
26162630 .llvm_cpu_features = comp.bin_file.options.llvm_cpu_features.?,
26172631 };
2618 var progress: std.Progress = .{};
2619 var main_progress_node = try progress.start("", null);
2620 defer main_progress_node.end();
2621 if (comp.color == .Off) progress.terminal = null;
26222632
26232633 comp.stage1_cache_manifest = &man;
26242634