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 {...@@ -1149,7 +1149,15 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
1149 };1149 };
1150}1150}
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
1153 while (self.work_queue.readItem()) |work_item| switch (work_item) {1161 while (self.work_queue.readItem()) |work_item| switch (work_item) {
1154 .codegen_decl => |decl| switch (decl.analysis) {1162 .codegen_decl => |decl| switch (decl.analysis) {
1155 .unreferenced => unreachable,1163 .unreferenced => unreachable,
...@@ -1226,7 +1234,7 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {...@@ -1226,7 +1234,7 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
1226 };1234 };
1227 },1235 },
1228 .c_object => |c_object| {1236 .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) {
1230 error.AnalysisFail => continue,1238 error.AnalysisFail => continue,
1231 else => {1239 else => {
1232 try self.failed_c_objects.ensureCapacity(self.gpa, self.failed_c_objects.items().len + 1);1240 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 {...@@ -1312,7 +1320,7 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
1312 if (!build_options.is_stage1)1320 if (!build_options.is_stage1)
1313 unreachable;1321 unreachable;
13141322
1315 self.updateStage1Module() catch |err| {1323 self.updateStage1Module(main_progress_node) catch |err| {
1316 fatal("unable to build stage1 zig object: {}", .{@errorName(err)});1324 fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
1317 };1325 };
1318 },1326 },
...@@ -1473,7 +1481,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {...@@ -1473,7 +1481,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
1473 };1481 };
1474}1482}
14751483
1476fn updateCObject(comp: *Compilation, c_object: *CObject) !void {1484fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *std.Progress.Node) !void {
1477 if (!build_options.have_llvm) {1485 if (!build_options.have_llvm) {
1478 return comp.failCObj(c_object, "clang not available: compiler built without LLVM extensions", .{});1486 return comp.failCObj(c_object, "clang not available: compiler built without LLVM extensions", .{});
1479 }1487 }
...@@ -1516,6 +1524,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {...@@ -1516,6 +1524,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
1516 const arena = &arena_allocator.allocator;1524 const arena = &arena_allocator.allocator;
15171525
1518 const c_source_basename = std.fs.path.basename(c_object.src.src_path);1526 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
1519 // Special case when doing build-obj for just one C file. When there are more than one object1533 // Special case when doing build-obj for just one C file. When there are more than one object
1520 // file and building an object we need to link them together, but with just one it should go1534 // file and building an object we need to link them together, but with just one it should go
1521 // directly to the output file.1535 // directly to the output file.
...@@ -2509,7 +2523,7 @@ fn buildStaticLibFromZig(comp: *Compilation, src_basename: []const u8, out: *?CR...@@ -2509,7 +2523,7 @@ fn buildStaticLibFromZig(comp: *Compilation, src_basename: []const u8, out: *?CR
2509 };2523 };
2510}2524}
25112525
2512fn updateStage1Module(comp: *Compilation) !void {2526fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node) !void {
2513 const tracy = trace(@src());2527 const tracy = trace(@src());
2514 defer tracy.end();2528 defer tracy.end();
25152529
...@@ -2615,10 +2629,6 @@ fn updateStage1Module(comp: *Compilation) !void {...@@ -2615,10 +2629,6 @@ fn updateStage1Module(comp: *Compilation) !void {
2615 .llvm_cpu_name = if (target.cpu.model.llvm_name) |s| s.ptr else null,2629 .llvm_cpu_name = if (target.cpu.model.llvm_name) |s| s.ptr else null,
2616 .llvm_cpu_features = comp.bin_file.options.llvm_cpu_features.?,2630 .llvm_cpu_features = comp.bin_file.options.llvm_cpu_features.?,
2617 };2631 };
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
2623 comp.stage1_cache_manifest = &man;2633 comp.stage1_cache_manifest = &man;
26242634