| author | |
| committer | |
| log | f97c2f28fdc3061bc7e30ccfcafaccbee77993b6 |
| tree | a2c4165829d84b35df23346b1808a43e0cccec41 |
| parent | f6873c6b00544923d5699737651f2bc4fe29fd06 |
49 files changed, 226 insertions(+), 355 deletions(-)
lib/compiler/aro/aro/Diagnostics.zig+2-2| ... | ... | @@ -528,7 +528,7 @@ const MsgWriter = struct { |
| 528 | 528 | config: std.io.tty.Config, |
| 529 | 529 | |
| 530 | 530 | fn init(config: std.io.tty.Config) MsgWriter { |
| 531 | std.debug.getStderrMutex().lock(); | |
| 531 | std.debug.lockStdErr(); | |
| 532 | 532 | return .{ |
| 533 | 533 | .w = std.io.bufferedWriter(std.io.getStdErr().writer()), |
| 534 | 534 | .config = config, |
| ... | ... | @@ -537,7 +537,7 @@ const MsgWriter = struct { |
| 537 | 537 | |
| 538 | 538 | pub fn deinit(m: *MsgWriter) void { |
| 539 | 539 | m.w.flush() catch {}; |
| 540 | std.debug.getStderrMutex().unlock(); | |
| 540 | std.debug.unlockStdErr(); | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | pub fn print(m: *MsgWriter, comptime fmt: []const u8, args: anytype) void { |
lib/compiler/build_runner.zig+9-11| ... | ... | @@ -289,8 +289,7 @@ pub fn main() !void { |
| 289 | 289 | .windows_api => {}, |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; | |
| 293 | const main_progress_node = progress.start("", 0); | |
| 292 | const main_progress_node = std.Progress.start(.{}); | |
| 294 | 293 | |
| 295 | 294 | builder.debug_log_scopes = debug_log_scopes.items; |
| 296 | 295 | builder.resolveInstallPrefix(install_prefix, dir_list); |
| ... | ... | @@ -385,7 +384,7 @@ fn runStepNames( |
| 385 | 384 | arena: std.mem.Allocator, |
| 386 | 385 | b: *std.Build, |
| 387 | 386 | step_names: []const []const u8, |
| 388 | parent_prog_node: *std.Progress.Node, | |
| 387 | parent_prog_node: std.Progress.Node, | |
| 389 | 388 | thread_pool_options: std.Thread.Pool.Options, |
| 390 | 389 | run: *Run, |
| 391 | 390 | seed: u32, |
| ... | ... | @@ -452,7 +451,7 @@ fn runStepNames( |
| 452 | 451 | { |
| 453 | 452 | defer parent_prog_node.end(); |
| 454 | 453 | |
| 455 | var step_prog = parent_prog_node.start("steps", step_stack.count()); | |
| 454 | const step_prog = parent_prog_node.start("steps", step_stack.count()); | |
| 456 | 455 | defer step_prog.end(); |
| 457 | 456 | |
| 458 | 457 | var wait_group: std.Thread.WaitGroup = .{}; |
| ... | ... | @@ -467,7 +466,7 @@ fn runStepNames( |
| 467 | 466 | if (step.state == .skipped_oom) continue; |
| 468 | 467 | |
| 469 | 468 | thread_pool.spawnWg(&wait_group, workerMakeOneStep, .{ |
| 470 | &wait_group, &thread_pool, b, step, &step_prog, run, | |
| 469 | &wait_group, &thread_pool, b, step, step_prog, run, | |
| 471 | 470 | }); |
| 472 | 471 | } |
| 473 | 472 | } |
| ... | ... | @@ -891,7 +890,7 @@ fn workerMakeOneStep( |
| 891 | 890 | thread_pool: *std.Thread.Pool, |
| 892 | 891 | b: *std.Build, |
| 893 | 892 | s: *Step, |
| 894 | prog_node: *std.Progress.Node, | |
| 893 | prog_node: std.Progress.Node, | |
| 895 | 894 | run: *Run, |
| 896 | 895 | ) void { |
| 897 | 896 | // First, check the conditions for running this step. If they are not met, |
| ... | ... | @@ -941,11 +940,10 @@ fn workerMakeOneStep( |
| 941 | 940 | } |
| 942 | 941 | } |
| 943 | 942 | |
| 944 | var sub_prog_node = prog_node.start(s.name, 0); | |
| 945 | sub_prog_node.activate(); | |
| 943 | const sub_prog_node = prog_node.start(s.name, 0); | |
| 946 | 944 | defer sub_prog_node.end(); |
| 947 | 945 | |
| 948 | const make_result = s.make(&sub_prog_node); | |
| 946 | const make_result = s.make(sub_prog_node); | |
| 949 | 947 | |
| 950 | 948 | // No matter the result, we want to display error/warning messages. |
| 951 | 949 | const show_compile_errors = !run.prominent_compile_errors and |
| ... | ... | @@ -954,8 +952,8 @@ fn workerMakeOneStep( |
| 954 | 952 | const show_stderr = s.result_stderr.len > 0; |
| 955 | 953 | |
| 956 | 954 | if (show_error_msgs or show_compile_errors or show_stderr) { |
| 957 | sub_prog_node.context.lock_stderr(); | |
| 958 | defer sub_prog_node.context.unlock_stderr(); | |
| 955 | std.debug.lockStdErr(); | |
| 956 | defer std.debug.unlockStdErr(); | |
| 959 | 957 | |
| 960 | 958 | printErrorMessages(b, s, run) catch {}; |
| 961 | 959 | } |
lib/std/Build.zig+5-5| ... | ... | @@ -1059,7 +1059,7 @@ pub fn getUninstallStep(b: *Build) *Step { |
| 1059 | 1059 | return &b.uninstall_tls.step; |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror!void { | |
| 1062 | fn makeUninstall(uninstall_step: *Step, prog_node: std.Progress.Node) anyerror!void { | |
| 1063 | 1063 | _ = prog_node; |
| 1064 | 1064 | const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step); |
| 1065 | 1065 | const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls); |
| ... | ... | @@ -2281,10 +2281,10 @@ pub const LazyPath = union(enum) { |
| 2281 | 2281 | .cwd_relative => |p| return src_builder.pathFromCwd(p), |
| 2282 | 2282 | .generated => |gen| { |
| 2283 | 2283 | var file_path: []const u8 = gen.file.step.owner.pathFromRoot(gen.file.path orelse { |
| 2284 | std.debug.getStderrMutex().lock(); | |
| 2284 | std.debug.lockStdErr(); | |
| 2285 | 2285 | const stderr = std.io.getStdErr(); |
| 2286 | 2286 | dumpBadGetPathHelp(gen.file.step, stderr, src_builder, asking_step) catch {}; |
| 2287 | std.debug.getStderrMutex().unlock(); | |
| 2287 | std.debug.unlockStdErr(); | |
| 2288 | 2288 | @panic("misconfigured build script"); |
| 2289 | 2289 | }); |
| 2290 | 2290 | |
| ... | ... | @@ -2351,8 +2351,8 @@ fn dumpBadDirnameHelp( |
| 2351 | 2351 | comptime msg: []const u8, |
| 2352 | 2352 | args: anytype, |
| 2353 | 2353 | ) anyerror!void { |
| 2354 | debug.getStderrMutex().lock(); | |
| 2355 | defer debug.getStderrMutex().unlock(); | |
| 2354 | debug.lockStdErr(); | |
| 2355 | defer debug.unlockStdErr(); | |
| 2356 | 2356 | |
| 2357 | 2357 | const stderr = io.getStdErr(); |
| 2358 | 2358 | const w = stderr.writer(); |
lib/std/Build/Step.zig+8-14| ... | ... | @@ -58,7 +58,7 @@ pub const TestResults = struct { |
| 58 | 58 | } |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | pub const MakeFn = *const fn (step: *Step, prog_node: *std.Progress.Node) anyerror!void; | |
| 61 | pub const MakeFn = *const fn (step: *Step, prog_node: std.Progress.Node) anyerror!void; | |
| 62 | 62 | |
| 63 | 63 | pub const State = enum { |
| 64 | 64 | precheck_unstarted, |
| ... | ... | @@ -176,7 +176,7 @@ pub fn init(options: StepOptions) Step { |
| 176 | 176 | /// If the Step's `make` function reports `error.MakeFailed`, it indicates they |
| 177 | 177 | /// have already reported the error. Otherwise, we add a simple error report |
| 178 | 178 | /// here. |
| 179 | pub fn make(s: *Step, prog_node: *std.Progress.Node) error{ MakeFailed, MakeSkipped }!void { | |
| 179 | pub fn make(s: *Step, prog_node: std.Progress.Node) error{ MakeFailed, MakeSkipped }!void { | |
| 180 | 180 | const arena = s.owner.allocator; |
| 181 | 181 | |
| 182 | 182 | s.makeFn(s, prog_node) catch |err| switch (err) { |
| ... | ... | @@ -217,7 +217,7 @@ pub fn getStackTrace(s: *Step) ?std.builtin.StackTrace { |
| 217 | 217 | }; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | fn makeNoOp(step: *Step, prog_node: *std.Progress.Node) anyerror!void { | |
| 220 | fn makeNoOp(step: *Step, prog_node: std.Progress.Node) anyerror!void { | |
| 221 | 221 | _ = prog_node; |
| 222 | 222 | |
| 223 | 223 | var all_cached = true; |
| ... | ... | @@ -303,7 +303,7 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO |
| 303 | 303 | pub fn evalZigProcess( |
| 304 | 304 | s: *Step, |
| 305 | 305 | argv: []const []const u8, |
| 306 | prog_node: *std.Progress.Node, | |
| 306 | prog_node: std.Progress.Node, | |
| 307 | 307 | ) !?[]const u8 { |
| 308 | 308 | assert(argv.len != 0); |
| 309 | 309 | const b = s.owner; |
| ... | ... | @@ -313,12 +313,16 @@ pub fn evalZigProcess( |
| 313 | 313 | try handleChildProcUnsupported(s, null, argv); |
| 314 | 314 | try handleVerbose(s.owner, null, argv); |
| 315 | 315 | |
| 316 | const sub_prog_node = prog_node.start("", 0); | |
| 317 | defer sub_prog_node.end(); | |
| 318 | ||
| 316 | 319 | var child = std.process.Child.init(argv, arena); |
| 317 | 320 | child.env_map = &b.graph.env_map; |
| 318 | 321 | child.stdin_behavior = .Pipe; |
| 319 | 322 | child.stdout_behavior = .Pipe; |
| 320 | 323 | child.stderr_behavior = .Pipe; |
| 321 | 324 | child.request_resource_usage_statistics = true; |
| 325 | child.progress_node = sub_prog_node; | |
| 322 | 326 | |
| 323 | 327 | child.spawn() catch |err| return s.fail("unable to spawn {s}: {s}", .{ |
| 324 | 328 | argv[0], @errorName(err), |
| ... | ... | @@ -337,11 +341,6 @@ pub fn evalZigProcess( |
| 337 | 341 | const Header = std.zig.Server.Message.Header; |
| 338 | 342 | var result: ?[]const u8 = null; |
| 339 | 343 | |
| 340 | var node_name: std.ArrayListUnmanaged(u8) = .{}; | |
| 341 | defer node_name.deinit(gpa); | |
| 342 | var sub_prog_node = prog_node.start("", 0); | |
| 343 | defer sub_prog_node.end(); | |
| 344 | ||
| 345 | 344 | const stdout = poller.fifo(.stdout); |
| 346 | 345 | |
| 347 | 346 | poll: while (true) { |
| ... | ... | @@ -379,11 +378,6 @@ pub fn evalZigProcess( |
| 379 | 378 | .extra = extra_array, |
| 380 | 379 | }; |
| 381 | 380 | }, |
| 382 | .progress => { | |
| 383 | node_name.clearRetainingCapacity(); | |
| 384 | try node_name.appendSlice(gpa, body); | |
| 385 | sub_prog_node.setName(node_name.items); | |
| 386 | }, | |
| 387 | 381 | .emit_bin_path => { |
| 388 | 382 | const EbpHdr = std.zig.Server.Message.EmitBinPath; |
| 389 | 383 | const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); |
lib/std/Build/Step/CheckFile.zig+1-1| ... | ... | @@ -46,7 +46,7 @@ pub fn setName(check_file: *CheckFile, name: []const u8) void { |
| 46 | 46 | check_file.step.name = name; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 49 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 50 | 50 | _ = prog_node; |
| 51 | 51 | const b = step.owner; |
| 52 | 52 | const check_file: *CheckFile = @fieldParentPtr("step", step); |
lib/std/Build/Step/CheckObject.zig+1-1| ... | ... | @@ -550,7 +550,7 @@ pub fn checkComputeCompare( |
| 550 | 550 | check_object.checks.append(check) catch @panic("OOM"); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 553 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 554 | 554 | _ = prog_node; |
| 555 | 555 | const b = step.owner; |
| 556 | 556 | const gpa = b.allocator; |
lib/std/Build/Step/Compile.zig+3-3| ... | ... | @@ -967,7 +967,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking |
| 967 | 967 | const maybe_path: ?*GeneratedFile = @field(compile, tag_name); |
| 968 | 968 | |
| 969 | 969 | const generated_file = maybe_path orelse { |
| 970 | std.debug.getStderrMutex().lock(); | |
| 970 | std.debug.lockStdErr(); | |
| 971 | 971 | const stderr = std.io.getStdErr(); |
| 972 | 972 | |
| 973 | 973 | std.Build.dumpBadGetPathHelp(&compile.step, stderr, compile.step.owner, asking_step) catch {}; |
| ... | ... | @@ -976,7 +976,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking |
| 976 | 976 | }; |
| 977 | 977 | |
| 978 | 978 | const path = generated_file.path orelse { |
| 979 | std.debug.getStderrMutex().lock(); | |
| 979 | std.debug.lockStdErr(); | |
| 980 | 980 | const stderr = std.io.getStdErr(); |
| 981 | 981 | |
| 982 | 982 | std.Build.dumpBadGetPathHelp(&compile.step, stderr, compile.step.owner, asking_step) catch {}; |
| ... | ... | @@ -987,7 +987,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking |
| 987 | 987 | return path; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 990 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 991 | 991 | const b = step.owner; |
| 992 | 992 | const arena = b.allocator; |
| 993 | 993 | const compile: *Compile = @fieldParentPtr("step", step); |
lib/std/Build/Step/ConfigHeader.zig+1-1| ... | ... | @@ -164,7 +164,7 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 167 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 168 | 168 | _ = prog_node; |
| 169 | 169 | const b = step.owner; |
| 170 | 170 | const config_header: *ConfigHeader = @fieldParentPtr("step", step); |
lib/std/Build/Step/Fmt.zig+1-1| ... | ... | @@ -36,7 +36,7 @@ pub fn create(owner: *std.Build, options: Options) *Fmt { |
| 36 | 36 | return fmt; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 39 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 40 | 40 | // zig fmt is fast enough that no progress is needed. |
| 41 | 41 | _ = prog_node; |
| 42 | 42 |
lib/std/Build/Step/InstallArtifact.zig+1-1| ... | ... | @@ -115,7 +115,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 115 | 115 | return install_artifact; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 118 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 119 | 119 | _ = prog_node; |
| 120 | 120 | const install_artifact: *InstallArtifact = @fieldParentPtr("step", step); |
| 121 | 121 | const b = step.owner; |
lib/std/Build/Step/InstallDir.zig+1-1| ... | ... | @@ -56,7 +56,7 @@ pub fn create(owner: *std.Build, options: Options) *InstallDir { |
| 56 | 56 | return install_dir; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 59 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 60 | 60 | _ = prog_node; |
| 61 | 61 | const b = step.owner; |
| 62 | 62 | const install_dir: *InstallDir = @fieldParentPtr("step", step); |
lib/std/Build/Step/InstallFile.zig+1-1| ... | ... | @@ -36,7 +36,7 @@ pub fn create( |
| 36 | 36 | return install_file; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 39 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 40 | 40 | _ = prog_node; |
| 41 | 41 | const b = step.owner; |
| 42 | 42 | const install_file: *InstallFile = @fieldParentPtr("step", step); |
lib/std/Build/Step/ObjCopy.zig+1-1| ... | ... | @@ -90,7 +90,7 @@ pub fn getOutputSeparatedDebug(objcopy: *const ObjCopy) ?std.Build.LazyPath { |
| 90 | 90 | return if (objcopy.output_file_debug) |*file| .{ .generated = .{ .file = file } } else null; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 93 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 94 | 94 | const b = step.owner; |
| 95 | 95 | const objcopy: *ObjCopy = @fieldParentPtr("step", step); |
| 96 | 96 |
lib/std/Build/Step/Options.zig+1-1| ... | ... | @@ -410,7 +410,7 @@ pub fn getOutput(options: *Options) LazyPath { |
| 410 | 410 | return .{ .generated = .{ .file = &options.generated_file } }; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 413 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 414 | 414 | // This step completes so quickly that no progress is necessary. |
| 415 | 415 | _ = prog_node; |
| 416 | 416 |
lib/std/Build/Step/RemoveDir.zig+1-1| ... | ... | @@ -22,7 +22,7 @@ pub fn create(owner: *std.Build, dir_path: []const u8) *RemoveDir { |
| 22 | 22 | return remove_dir; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 25 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 26 | 26 | // TODO update progress node while walking file system. |
| 27 | 27 | // Should the standard library support this use case?? |
| 28 | 28 | _ = prog_node; |
lib/std/Build/Step/Run.zig+11-7| ... | ... | @@ -574,7 +574,7 @@ const IndexedOutput = struct { |
| 574 | 574 | tag: @typeInfo(Arg).Union.tag_type.?, |
| 575 | 575 | output: *Output, |
| 576 | 576 | }; |
| 577 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 577 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 578 | 578 | const b = step.owner; |
| 579 | 579 | const arena = b.allocator; |
| 580 | 580 | const run: *Run = @fieldParentPtr("step", step); |
| ... | ... | @@ -878,7 +878,7 @@ fn runCommand( |
| 878 | 878 | argv: []const []const u8, |
| 879 | 879 | has_side_effects: bool, |
| 880 | 880 | output_dir_path: []const u8, |
| 881 | prog_node: *std.Progress.Node, | |
| 881 | prog_node: std.Progress.Node, | |
| 882 | 882 | ) !void { |
| 883 | 883 | const step = &run.step; |
| 884 | 884 | const b = step.owner; |
| ... | ... | @@ -1195,7 +1195,7 @@ fn spawnChildAndCollect( |
| 1195 | 1195 | run: *Run, |
| 1196 | 1196 | argv: []const []const u8, |
| 1197 | 1197 | has_side_effects: bool, |
| 1198 | prog_node: *std.Progress.Node, | |
| 1198 | prog_node: std.Progress.Node, | |
| 1199 | 1199 | ) !ChildProcResult { |
| 1200 | 1200 | const b = run.step.owner; |
| 1201 | 1201 | const arena = b.allocator; |
| ... | ... | @@ -1235,6 +1235,10 @@ fn spawnChildAndCollect( |
| 1235 | 1235 | child.stdin_behavior = .Pipe; |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | if (run.stdio != .zig_test) { | |
| 1239 | child.progress_node = prog_node.start("", 0); | |
| 1240 | } | |
| 1241 | ||
| 1238 | 1242 | try child.spawn(); |
| 1239 | 1243 | var timer = try std.time.Timer.start(); |
| 1240 | 1244 | |
| ... | ... | @@ -1264,7 +1268,7 @@ const StdIoResult = struct { |
| 1264 | 1268 | fn evalZigTest( |
| 1265 | 1269 | run: *Run, |
| 1266 | 1270 | child: *std.process.Child, |
| 1267 | prog_node: *std.Progress.Node, | |
| 1271 | prog_node: std.Progress.Node, | |
| 1268 | 1272 | ) !StdIoResult { |
| 1269 | 1273 | const gpa = run.step.owner.allocator; |
| 1270 | 1274 | const arena = run.step.owner.allocator; |
| ... | ... | @@ -1291,7 +1295,7 @@ fn evalZigTest( |
| 1291 | 1295 | var metadata: ?TestMetadata = null; |
| 1292 | 1296 | |
| 1293 | 1297 | var sub_prog_node: ?std.Progress.Node = null; |
| 1294 | defer if (sub_prog_node) |*n| n.end(); | |
| 1298 | defer if (sub_prog_node) |n| n.end(); | |
| 1295 | 1299 | |
| 1296 | 1300 | poll: while (true) { |
| 1297 | 1301 | while (stdout.readableLength() < @sizeOf(Header)) { |
| ... | ... | @@ -1406,7 +1410,7 @@ const TestMetadata = struct { |
| 1406 | 1410 | expected_panic_msgs: []const u32, |
| 1407 | 1411 | string_bytes: []const u8, |
| 1408 | 1412 | next_index: u32, |
| 1409 | prog_node: *std.Progress.Node, | |
| 1413 | prog_node: std.Progress.Node, | |
| 1410 | 1414 | |
| 1411 | 1415 | fn testName(tm: TestMetadata, index: u32) []const u8 { |
| 1412 | 1416 | return std.mem.sliceTo(tm.string_bytes[tm.names[index]..], 0); |
| ... | ... | @@ -1421,7 +1425,7 @@ fn requestNextTest(in: fs.File, metadata: *TestMetadata, sub_prog_node: *?std.Pr |
| 1421 | 1425 | if (metadata.expected_panic_msgs[i] != 0) continue; |
| 1422 | 1426 | |
| 1423 | 1427 | const name = metadata.testName(i); |
| 1424 | if (sub_prog_node.*) |*n| n.end(); | |
| 1428 | if (sub_prog_node.*) |n| n.end(); | |
| 1425 | 1429 | sub_prog_node.* = metadata.prog_node.start(name, 0); |
| 1426 | 1430 | |
| 1427 | 1431 | try sendRunTestMessage(in, i); |
lib/std/Build/Step/TranslateC.zig+1-1| ... | ... | @@ -116,7 +116,7 @@ pub fn defineCMacroRaw(translate_c: *TranslateC, name_and_value: []const u8) voi |
| 116 | 116 | translate_c.c_macros.append(translate_c.step.owner.dupe(name_and_value)) catch @panic("OOM"); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 119 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 120 | 120 | const b = step.owner; |
| 121 | 121 | const translate_c: *TranslateC = @fieldParentPtr("step", step); |
| 122 | 122 |
lib/std/Build/Step/WriteFile.zig+1-1| ... | ... | @@ -198,7 +198,7 @@ fn maybeUpdateName(write_file: *WriteFile) void { |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | fn make(step: *Step, prog_node: *std.Progress.Node) !void { | |
| 201 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 202 | 202 | _ = prog_node; |
| 203 | 203 | const b = step.owner; |
| 204 | 204 | const write_file: *WriteFile = @fieldParentPtr("step", step); |
lib/std/Progress.zig+39-4| ... | ... | @@ -58,7 +58,7 @@ pub const Options = struct { |
| 58 | 58 | /// cannot fit into this buffer which will look bad but not cause any malfunctions. |
| 59 | 59 | /// |
| 60 | 60 | /// Must be at least 200 bytes. |
| 61 | draw_buffer: []u8, | |
| 61 | draw_buffer: []u8 = &default_draw_buffer, | |
| 62 | 62 | /// How many nanoseconds between writing updates to the terminal. |
| 63 | 63 | refresh_rate_ns: u64 = 60 * std.time.ns_per_ms, |
| 64 | 64 | /// How many nanoseconds to keep the output hidden |
| ... | ... | @@ -67,6 +67,7 @@ pub const Options = struct { |
| 67 | 67 | /// 0 means unknown. |
| 68 | 68 | estimated_total_items: usize = 0, |
| 69 | 69 | root_name: []const u8 = "", |
| 70 | disable_printing: bool = false, | |
| 70 | 71 | }; |
| 71 | 72 | |
| 72 | 73 | /// Represents one unit of progress. Each node can have children nodes, or |
| ... | ... | @@ -203,6 +204,13 @@ pub const Node = struct { |
| 203 | 204 | @atomicStore(u32, &storage.estimated_total_count, std.math.lossyCast(u32, count), .monotonic); |
| 204 | 205 | } |
| 205 | 206 | |
| 207 | /// Thread-safe. | |
| 208 | pub fn increaseEstimatedTotalItems(n: Node, count: usize) void { | |
| 209 | const index = n.index.unwrap() orelse return; | |
| 210 | const storage = storageByIndex(index); | |
| 211 | _ = @atomicRmw(u32, &storage.estimated_total_count, .Add, std.math.lossyCast(u32, count), .monotonic); | |
| 212 | } | |
| 213 | ||
| 206 | 214 | /// Finish a started `Node`. Thread-safe. |
| 207 | 215 | pub fn end(n: Node) void { |
| 208 | 216 | const index = n.index.unwrap() orelse return; |
| ... | ... | @@ -290,6 +298,8 @@ var node_parents_buffer: [default_node_storage_buffer_len]Node.Parent = undefine |
| 290 | 298 | var node_storage_buffer: [default_node_storage_buffer_len]Node.Storage = undefined; |
| 291 | 299 | var node_freelist_buffer: [default_node_storage_buffer_len]Node.OptionalIndex = undefined; |
| 292 | 300 | |
| 301 | var default_draw_buffer: [2000]u8 = undefined; | |
| 302 | ||
| 293 | 303 | /// Initializes a global Progress instance. |
| 294 | 304 | /// |
| 295 | 305 | /// Asserts there is only one global Progress instance. |
| ... | ... | @@ -318,6 +328,9 @@ pub fn start(options: Options) Node { |
| 318 | 328 | } |
| 319 | 329 | } else |env_err| switch (env_err) { |
| 320 | 330 | error.EnvironmentVariableNotFound => { |
| 331 | if (options.disable_printing) { | |
| 332 | return .{ .index = .none }; | |
| 333 | } | |
| 321 | 334 | const stderr = std.io.getStdErr(); |
| 322 | 335 | if (stderr.supportsAnsiEscapeCodes()) { |
| 323 | 336 | global_progress.terminal = stderr; |
| ... | ... | @@ -330,7 +343,7 @@ pub fn start(options: Options) Node { |
| 330 | 343 | global_progress.terminal = stderr; |
| 331 | 344 | } |
| 332 | 345 | |
| 333 | if (global_progress.terminal == null) { | |
| 346 | if (global_progress.terminal == null or !global_progress.supports_ansi_escape_codes) { | |
| 334 | 347 | return .{ .index = .none }; |
| 335 | 348 | } |
| 336 | 349 | |
| ... | ... | @@ -379,7 +392,10 @@ fn updateThreadRun() void { |
| 379 | 392 | return clearTerminal(); |
| 380 | 393 | |
| 381 | 394 | const buffer = computeRedraw(); |
| 382 | write(buffer); | |
| 395 | if (stderr_mutex.tryLock()) { | |
| 396 | defer stderr_mutex.unlock(); | |
| 397 | write(buffer); | |
| 398 | } | |
| 383 | 399 | } |
| 384 | 400 | |
| 385 | 401 | while (true) { |
| ... | ... | @@ -390,10 +406,25 @@ fn updateThreadRun() void { |
| 390 | 406 | return clearTerminal(); |
| 391 | 407 | |
| 392 | 408 | const buffer = computeRedraw(); |
| 393 | write(buffer); | |
| 409 | if (stderr_mutex.tryLock()) { | |
| 410 | defer stderr_mutex.unlock(); | |
| 411 | write(buffer); | |
| 412 | } | |
| 394 | 413 | } |
| 395 | 414 | } |
| 396 | 415 | |
| 416 | /// Allows the caller to freely write to stderr until `unlockStdErr` is called. | |
| 417 | /// | |
| 418 | /// During the lock, any `std.Progress` information is cleared from the terminal. | |
| 419 | pub fn lockStdErr() void { | |
| 420 | stderr_mutex.lock(); | |
| 421 | clearTerminal(); | |
| 422 | } | |
| 423 | ||
| 424 | pub fn unlockStdErr() void { | |
| 425 | stderr_mutex.unlock(); | |
| 426 | } | |
| 427 | ||
| 397 | 428 | fn ipcThreadRun(fd: posix.fd_t) anyerror!void { |
| 398 | 429 | { |
| 399 | 430 | _ = wait(global_progress.initial_delay_ns); |
| ... | ... | @@ -432,6 +463,8 @@ const tree_line = "\x1B\x28\x30\x78\x1B\x28\x42 "; // │ |
| 432 | 463 | const tree_langle = "\x1B\x28\x30\x6d\x71\x1B\x28\x42 "; // └─ |
| 433 | 464 | |
| 434 | 465 | fn clearTerminal() void { |
| 466 | if (global_progress.newline_count == 0) return; | |
| 467 | ||
| 435 | 468 | var i: usize = 0; |
| 436 | 469 | const buf = global_progress.draw_buffer; |
| 437 | 470 | |
| ... | ... | @@ -876,3 +909,5 @@ fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) |
| 876 | 909 | assert(sig == posix.SIG.WINCH); |
| 877 | 910 | global_progress.redraw_event.set(); |
| 878 | 911 | } |
| 912 | ||
| 913 | var stderr_mutex: std.Thread.Mutex = .{}; |
lib/std/debug.zig+15-6| ... | ... | @@ -77,19 +77,28 @@ const PdbOrDwarf = union(enum) { |
| 77 | 77 | } |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | var stderr_mutex = std.Thread.Mutex{}; | |
| 80 | /// Allows the caller to freely write to stderr until `unlockStdErr` is called. | |
| 81 | /// | |
| 82 | /// During the lock, any `std.Progress` information is cleared from the terminal. | |
| 83 | pub fn lockStdErr() void { | |
| 84 | std.Progress.lockStdErr(); | |
| 85 | } | |
| 86 | ||
| 87 | pub fn unlockStdErr() void { | |
| 88 | std.Progress.unlockStdErr(); | |
| 89 | } | |
| 81 | 90 | |
| 82 | 91 | /// Print to stderr, unbuffered, and silently returning on failure. Intended |
| 83 | 92 | /// for use in "printf debugging." Use `std.log` functions for proper logging. |
| 84 | 93 | pub fn print(comptime fmt: []const u8, args: anytype) void { |
| 85 | stderr_mutex.lock(); | |
| 86 | defer stderr_mutex.unlock(); | |
| 94 | lockStdErr(); | |
| 95 | defer unlockStdErr(); | |
| 87 | 96 | const stderr = io.getStdErr().writer(); |
| 88 | 97 | nosuspend stderr.print(fmt, args) catch return; |
| 89 | 98 | } |
| 90 | 99 | |
| 91 | 100 | pub fn getStderrMutex() *std.Thread.Mutex { |
| 92 | return &stderr_mutex; | |
| 101 | @compileError("deprecated. call std.debug.lockStdErr() and std.debug.unlockStdErr() instead which will integrate properly with std.Progress"); | |
| 93 | 102 | } |
| 94 | 103 | |
| 95 | 104 | /// TODO multithreaded awareness |
| ... | ... | @@ -107,8 +116,8 @@ pub fn getSelfDebugInfo() !*DebugInfo { |
| 107 | 116 | /// Tries to print a hexadecimal view of the bytes, unbuffered, and ignores any error returned. |
| 108 | 117 | /// Obtains the stderr mutex while dumping. |
| 109 | 118 | pub fn dump_hex(bytes: []const u8) void { |
| 110 | stderr_mutex.lock(); | |
| 111 | defer stderr_mutex.unlock(); | |
| 119 | lockStdErr(); | |
| 120 | defer unlockStdErr(); | |
| 112 | 121 | dump_hex_fallible(bytes) catch {}; |
| 113 | 122 | } |
| 114 | 123 |
lib/std/json/dynamic.zig+2-2| ... | ... | @@ -52,8 +52,8 @@ pub const Value = union(enum) { |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | pub fn dump(self: Value) void { |
| 55 | std.debug.getStderrMutex().lock(); | |
| 56 | defer std.debug.getStderrMutex().unlock(); | |
| 55 | std.debug.lockStdErr(); | |
| 56 | defer std.debug.unlockStdErr(); | |
| 57 | 57 | |
| 58 | 58 | const stderr = std.io.getStdErr().writer(); |
| 59 | 59 | stringify(self, .{}, stderr) catch return; |
lib/std/log.zig+4-4| ... | ... | @@ -45,8 +45,8 @@ |
| 45 | 45 | //! const prefix = "[" ++ comptime level.asText() ++ "] " ++ scope_prefix; |
| 46 | 46 | //! |
| 47 | 47 | //! // Print the message to stderr, silently ignoring any errors |
| 48 | //! std.debug.getStderrMutex().lock(); | |
| 49 | //! defer std.debug.getStderrMutex().unlock(); | |
| 48 | //! std.debug.lockStdErr(); | |
| 49 | //! defer std.debug.unlockStdErr(); | |
| 50 | 50 | //! const stderr = std.io.getStdErr().writer(); |
| 51 | 51 | //! nosuspend stderr.print(prefix ++ format ++ "\n", args) catch return; |
| 52 | 52 | //! } |
| ... | ... | @@ -152,8 +152,8 @@ pub fn defaultLog( |
| 152 | 152 | var bw = std.io.bufferedWriter(stderr); |
| 153 | 153 | const writer = bw.writer(); |
| 154 | 154 | |
| 155 | std.debug.getStderrMutex().lock(); | |
| 156 | defer std.debug.getStderrMutex().unlock(); | |
| 155 | std.debug.lockStdErr(); | |
| 156 | defer std.debug.unlockStdErr(); | |
| 157 | 157 | nosuspend { |
| 158 | 158 | writer.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return; |
| 159 | 159 | bw.flush() catch return; |
lib/std/zig/ErrorBundle.zig+2-2| ... | ... | @@ -155,8 +155,8 @@ pub const RenderOptions = struct { |
| 155 | 155 | }; |
| 156 | 156 | |
| 157 | 157 | pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void { |
| 158 | std.debug.getStderrMutex().lock(); | |
| 159 | defer std.debug.getStderrMutex().unlock(); | |
| 158 | std.debug.lockStdErr(); | |
| 159 | defer std.debug.unlockStdErr(); | |
| 160 | 160 | const stderr = std.io.getStdErr(); |
| 161 | 161 | return renderToWriter(eb, options, stderr.writer()) catch return; |
| 162 | 162 | } |
lib/std/zig/Server.zig-2| ... | ... | @@ -14,8 +14,6 @@ pub const Message = struct { |
| 14 | 14 | zig_version, |
| 15 | 15 | /// Body is an ErrorBundle. |
| 16 | 16 | error_bundle, |
| 17 | /// Body is a UTF-8 string. | |
| 18 | progress, | |
| 19 | 17 | /// Body is a EmitBinPath. |
| 20 | 18 | emit_bin_path, |
| 21 | 19 | /// Body is a TestMetadata |
src/Compilation.zig+38-63| ... | ... | @@ -1273,8 +1273,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1273 | 1273 | if (options.verbose_llvm_cpu_features) { |
| 1274 | 1274 | if (options.root_mod.resolved_target.llvm_cpu_features) |cf| print: { |
| 1275 | 1275 | const target = options.root_mod.resolved_target.result; |
| 1276 | std.debug.getStderrMutex().lock(); | |
| 1277 | defer std.debug.getStderrMutex().unlock(); | |
| 1276 | std.debug.lockStdErr(); | |
| 1277 | defer std.debug.unlockStdErr(); | |
| 1278 | 1278 | const stderr = std.io.getStdErr().writer(); |
| 1279 | 1279 | nosuspend { |
| 1280 | 1280 | stderr.print("compilation: {s}\n", .{options.root_name}) catch break :print; |
| ... | ... | @@ -1934,7 +1934,7 @@ pub fn getTarget(self: Compilation) Target { |
| 1934 | 1934 | /// Only legal to call when cache mode is incremental and a link file is present. |
| 1935 | 1935 | pub fn hotCodeSwap( |
| 1936 | 1936 | comp: *Compilation, |
| 1937 | prog_node: *std.Progress.Node, | |
| 1937 | prog_node: std.Progress.Node, | |
| 1938 | 1938 | pid: std.process.Child.Id, |
| 1939 | 1939 | ) !void { |
| 1940 | 1940 | const lf = comp.bin_file.?; |
| ... | ... | @@ -1966,7 +1966,7 @@ fn cleanupAfterUpdate(comp: *Compilation) void { |
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | /// Detect changes to source files, perform semantic analysis, and update the output files. |
| 1969 | pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void { | |
| 1969 | pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { | |
| 1970 | 1970 | const tracy_trace = trace(@src()); |
| 1971 | 1971 | defer tracy_trace.end(); |
| 1972 | 1972 | |
| ... | ... | @@ -2256,7 +2256,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void |
| 2256 | 2256 | } |
| 2257 | 2257 | } |
| 2258 | 2258 | |
| 2259 | fn flush(comp: *Compilation, arena: Allocator, prog_node: *std.Progress.Node) !void { | |
| 2259 | fn flush(comp: *Compilation, arena: Allocator, prog_node: std.Progress.Node) !void { | |
| 2260 | 2260 | if (comp.bin_file) |lf| { |
| 2261 | 2261 | // This is needed before reading the error flags. |
| 2262 | 2262 | lf.flush(arena, prog_node) catch |err| switch (err) { |
| ... | ... | @@ -2566,13 +2566,11 @@ pub fn emitLlvmObject( |
| 2566 | 2566 | default_emit: Emit, |
| 2567 | 2567 | bin_emit_loc: ?EmitLoc, |
| 2568 | 2568 | llvm_object: *LlvmObject, |
| 2569 | prog_node: *std.Progress.Node, | |
| 2569 | prog_node: std.Progress.Node, | |
| 2570 | 2570 | ) !void { |
| 2571 | 2571 | if (build_options.only_c) @compileError("unreachable"); |
| 2572 | 2572 | |
| 2573 | var sub_prog_node = prog_node.start("LLVM Emit Object", 0); | |
| 2574 | sub_prog_node.activate(); | |
| 2575 | sub_prog_node.context.refresh(); | |
| 2573 | const sub_prog_node = prog_node.start("LLVM Emit Object", 0); | |
| 2576 | 2574 | defer sub_prog_node.end(); |
| 2577 | 2575 | |
| 2578 | 2576 | try llvm_object.emit(.{ |
| ... | ... | @@ -3249,23 +3247,23 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void { |
| 3249 | 3247 | |
| 3250 | 3248 | pub fn performAllTheWork( |
| 3251 | 3249 | comp: *Compilation, |
| 3252 | main_progress_node: *std.Progress.Node, | |
| 3250 | main_progress_node: std.Progress.Node, | |
| 3253 | 3251 | ) error{ TimerUnsupported, OutOfMemory }!void { |
| 3254 | 3252 | // Here we queue up all the AstGen tasks first, followed by C object compilation. |
| 3255 | 3253 | // We wait until the AstGen tasks are all completed before proceeding to the |
| 3256 | 3254 | // (at least for now) single-threaded main work queue. However, C object compilation |
| 3257 | 3255 | // only needs to be finished by the end of this function. |
| 3258 | 3256 | |
| 3259 | var zir_prog_node = main_progress_node.start("AST Lowering", 0); | |
| 3257 | const zir_prog_node = main_progress_node.start("AST Lowering", 0); | |
| 3260 | 3258 | defer zir_prog_node.end(); |
| 3261 | 3259 | |
| 3262 | var wasm_prog_node = main_progress_node.start("Compile Autodocs", 0); | |
| 3260 | const wasm_prog_node = main_progress_node.start("Compile Autodocs", 0); | |
| 3263 | 3261 | defer wasm_prog_node.end(); |
| 3264 | 3262 | |
| 3265 | var c_obj_prog_node = main_progress_node.start("Compile C Objects", comp.c_source_files.len); | |
| 3263 | const c_obj_prog_node = main_progress_node.start("Compile C Objects", comp.c_source_files.len); | |
| 3266 | 3264 | defer c_obj_prog_node.end(); |
| 3267 | 3265 | |
| 3268 | var win32_resource_prog_node = main_progress_node.start("Compile Win32 Resources", comp.rc_source_files.len); | |
| 3266 | const win32_resource_prog_node = main_progress_node.start("Compile Win32 Resources", comp.rc_source_files.len); | |
| 3269 | 3267 | defer win32_resource_prog_node.end(); |
| 3270 | 3268 | |
| 3271 | 3269 | comp.work_queue_wait_group.reset(); |
| ... | ... | @@ -3274,7 +3272,7 @@ pub fn performAllTheWork( |
| 3274 | 3272 | if (!build_options.only_c and !build_options.only_core_functionality) { |
| 3275 | 3273 | if (comp.docs_emit != null) { |
| 3276 | 3274 | comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerDocsCopy, .{comp}); |
| 3277 | comp.work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, &wasm_prog_node }); | |
| 3275 | comp.work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, wasm_prog_node }); | |
| 3278 | 3276 | } |
| 3279 | 3277 | } |
| 3280 | 3278 | |
| ... | ... | @@ -3313,7 +3311,7 @@ pub fn performAllTheWork( |
| 3313 | 3311 | |
| 3314 | 3312 | while (comp.astgen_work_queue.readItem()) |file| { |
| 3315 | 3313 | comp.thread_pool.spawnWg(&comp.astgen_wait_group, workerAstGenFile, .{ |
| 3316 | comp, file, &zir_prog_node, &comp.astgen_wait_group, .root, | |
| 3314 | comp, file, zir_prog_node, &comp.astgen_wait_group, .root, | |
| 3317 | 3315 | }); |
| 3318 | 3316 | } |
| 3319 | 3317 | |
| ... | ... | @@ -3325,14 +3323,14 @@ pub fn performAllTheWork( |
| 3325 | 3323 | |
| 3326 | 3324 | while (comp.c_object_work_queue.readItem()) |c_object| { |
| 3327 | 3325 | comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerUpdateCObject, .{ |
| 3328 | comp, c_object, &c_obj_prog_node, | |
| 3326 | comp, c_object, c_obj_prog_node, | |
| 3329 | 3327 | }); |
| 3330 | 3328 | } |
| 3331 | 3329 | |
| 3332 | 3330 | if (!build_options.only_core_functionality) { |
| 3333 | 3331 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { |
| 3334 | 3332 | comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerUpdateWin32Resource, .{ |
| 3335 | comp, win32_resource, &win32_resource_prog_node, | |
| 3333 | comp, win32_resource, win32_resource_prog_node, | |
| 3336 | 3334 | }); |
| 3337 | 3335 | } |
| 3338 | 3336 | } |
| ... | ... | @@ -3342,7 +3340,6 @@ pub fn performAllTheWork( |
| 3342 | 3340 | try reportMultiModuleErrors(mod); |
| 3343 | 3341 | try mod.flushRetryableFailures(); |
| 3344 | 3342 | mod.sema_prog_node = main_progress_node.start("Semantic Analysis", 0); |
| 3345 | mod.sema_prog_node.activate(); | |
| 3346 | 3343 | } |
| 3347 | 3344 | defer if (comp.module) |mod| { |
| 3348 | 3345 | mod.sema_prog_node.end(); |
| ... | ... | @@ -3379,7 +3376,7 @@ pub fn performAllTheWork( |
| 3379 | 3376 | } |
| 3380 | 3377 | } |
| 3381 | 3378 | |
| 3382 | fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !void { | |
| 3379 | fn processOneJob(comp: *Compilation, job: Job, prog_node: std.Progress.Node) !void { | |
| 3383 | 3380 | switch (job) { |
| 3384 | 3381 | .codegen_decl => |decl_index| { |
| 3385 | 3382 | const module = comp.module.?; |
| ... | ... | @@ -3803,7 +3800,7 @@ fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8, |
| 3803 | 3800 | } |
| 3804 | 3801 | } |
| 3805 | 3802 | |
| 3806 | fn workerDocsWasm(comp: *Compilation, prog_node: *std.Progress.Node) void { | |
| 3803 | fn workerDocsWasm(comp: *Compilation, prog_node: std.Progress.Node) void { | |
| 3807 | 3804 | workerDocsWasmFallible(comp, prog_node) catch |err| { |
| 3808 | 3805 | comp.lockAndSetMiscFailure(.docs_wasm, "unable to build autodocs: {s}", .{ |
| 3809 | 3806 | @errorName(err), |
| ... | ... | @@ -3811,7 +3808,7 @@ fn workerDocsWasm(comp: *Compilation, prog_node: *std.Progress.Node) void { |
| 3811 | 3808 | }; |
| 3812 | 3809 | } |
| 3813 | 3810 | |
| 3814 | fn workerDocsWasmFallible(comp: *Compilation, prog_node: *std.Progress.Node) anyerror!void { | |
| 3811 | fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void { | |
| 3815 | 3812 | const gpa = comp.gpa; |
| 3816 | 3813 | |
| 3817 | 3814 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| ... | ... | @@ -3952,12 +3949,11 @@ const AstGenSrc = union(enum) { |
| 3952 | 3949 | fn workerAstGenFile( |
| 3953 | 3950 | comp: *Compilation, |
| 3954 | 3951 | file: *Module.File, |
| 3955 | prog_node: *std.Progress.Node, | |
| 3952 | prog_node: std.Progress.Node, | |
| 3956 | 3953 | wg: *WaitGroup, |
| 3957 | 3954 | src: AstGenSrc, |
| 3958 | 3955 | ) void { |
| 3959 | var child_prog_node = prog_node.start(file.sub_file_path, 0); | |
| 3960 | child_prog_node.activate(); | |
| 3956 | const child_prog_node = prog_node.start(file.sub_file_path, 0); | |
| 3961 | 3957 | defer child_prog_node.end(); |
| 3962 | 3958 | |
| 3963 | 3959 | const mod = comp.module.?; |
| ... | ... | @@ -4265,7 +4261,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module |
| 4265 | 4261 | fn workerUpdateCObject( |
| 4266 | 4262 | comp: *Compilation, |
| 4267 | 4263 | c_object: *CObject, |
| 4268 | progress_node: *std.Progress.Node, | |
| 4264 | progress_node: std.Progress.Node, | |
| 4269 | 4265 | ) void { |
| 4270 | 4266 | comp.updateCObject(c_object, progress_node) catch |err| switch (err) { |
| 4271 | 4267 | error.AnalysisFail => return, |
| ... | ... | @@ -4282,7 +4278,7 @@ fn workerUpdateCObject( |
| 4282 | 4278 | fn workerUpdateWin32Resource( |
| 4283 | 4279 | comp: *Compilation, |
| 4284 | 4280 | win32_resource: *Win32Resource, |
| 4285 | progress_node: *std.Progress.Node, | |
| 4281 | progress_node: std.Progress.Node, | |
| 4286 | 4282 | ) void { |
| 4287 | 4283 | comp.updateWin32Resource(win32_resource, progress_node) catch |err| switch (err) { |
| 4288 | 4284 | error.AnalysisFail => return, |
| ... | ... | @@ -4300,7 +4296,7 @@ fn buildCompilerRtOneShot( |
| 4300 | 4296 | comp: *Compilation, |
| 4301 | 4297 | output_mode: std.builtin.OutputMode, |
| 4302 | 4298 | out: *?CRTFile, |
| 4303 | prog_node: *std.Progress.Node, | |
| 4299 | prog_node: std.Progress.Node, | |
| 4304 | 4300 | ) void { |
| 4305 | 4301 | comp.buildOutputFromZig( |
| 4306 | 4302 | "compiler_rt.zig", |
| ... | ... | @@ -4427,7 +4423,7 @@ fn reportRetryableEmbedFileError( |
| 4427 | 4423 | } |
| 4428 | 4424 | } |
| 4429 | 4425 | |
| 4430 | fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.Progress.Node) !void { | |
| 4426 | fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Progress.Node) !void { | |
| 4431 | 4427 | if (comp.config.c_frontend == .aro) { |
| 4432 | 4428 | return comp.failCObj(c_object, "aro does not support compiling C objects yet", .{}); |
| 4433 | 4429 | } |
| ... | ... | @@ -4467,9 +4463,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P |
| 4467 | 4463 | |
| 4468 | 4464 | const c_source_basename = std.fs.path.basename(c_object.src.src_path); |
| 4469 | 4465 | |
| 4470 | c_obj_prog_node.activate(); | |
| 4471 | var child_progress_node = c_obj_prog_node.start(c_source_basename, 0); | |
| 4472 | child_progress_node.activate(); | |
| 4466 | const child_progress_node = c_obj_prog_node.start(c_source_basename, 0); | |
| 4473 | 4467 | defer child_progress_node.end(); |
| 4474 | 4468 | |
| 4475 | 4469 | // Special case when doing build-obj for just one C file. When there are more than one object |
| ... | ... | @@ -4731,7 +4725,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P |
| 4731 | 4725 | }; |
| 4732 | 4726 | } |
| 4733 | 4727 | |
| 4734 | fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32_resource_prog_node: *std.Progress.Node) !void { | |
| 4728 | fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32_resource_prog_node: std.Progress.Node) !void { | |
| 4735 | 4729 | if (!std.process.can_spawn) { |
| 4736 | 4730 | return comp.failWin32Resource(win32_resource, "{s} does not support spawning a child process", .{@tagName(builtin.os.tag)}); |
| 4737 | 4731 | } |
| ... | ... | @@ -4763,9 +4757,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 4763 | 4757 | _ = comp.failed_win32_resources.swapRemove(win32_resource); |
| 4764 | 4758 | } |
| 4765 | 4759 | |
| 4766 | win32_resource_prog_node.activate(); | |
| 4767 | var child_progress_node = win32_resource_prog_node.start(src_basename, 0); | |
| 4768 | child_progress_node.activate(); | |
| 4760 | const child_progress_node = win32_resource_prog_node.start(src_basename, 0); | |
| 4769 | 4761 | defer child_progress_node.end(); |
| 4770 | 4762 | |
| 4771 | 4763 | var man = comp.obtainWin32ResourceCacheManifest(); |
| ... | ... | @@ -4833,7 +4825,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 4833 | 4825 | }); |
| 4834 | 4826 | try argv.appendSlice(&.{ "--", in_rc_path, out_res_path }); |
| 4835 | 4827 | |
| 4836 | try spawnZigRc(comp, win32_resource, src_basename, arena, argv.items, &child_progress_node); | |
| 4828 | try spawnZigRc(comp, win32_resource, arena, argv.items, child_progress_node); | |
| 4837 | 4829 | |
| 4838 | 4830 | break :blk digest; |
| 4839 | 4831 | }; |
| ... | ... | @@ -4901,7 +4893,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 4901 | 4893 | try argv.appendSlice(rc_src.extra_flags); |
| 4902 | 4894 | try argv.appendSlice(&.{ "--", rc_src.src_path, out_res_path }); |
| 4903 | 4895 | |
| 4904 | try spawnZigRc(comp, win32_resource, src_basename, arena, argv.items, &child_progress_node); | |
| 4896 | try spawnZigRc(comp, win32_resource, arena, argv.items, child_progress_node); | |
| 4905 | 4897 | |
| 4906 | 4898 | // Read depfile and update cache manifest |
| 4907 | 4899 | { |
| ... | ... | @@ -4966,10 +4958,9 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 4966 | 4958 | fn spawnZigRc( |
| 4967 | 4959 | comp: *Compilation, |
| 4968 | 4960 | win32_resource: *Win32Resource, |
| 4969 | src_basename: []const u8, | |
| 4970 | 4961 | arena: Allocator, |
| 4971 | 4962 | argv: []const []const u8, |
| 4972 | child_progress_node: *std.Progress.Node, | |
| 4963 | child_progress_node: std.Progress.Node, | |
| 4973 | 4964 | ) !void { |
| 4974 | 4965 | var node_name: std.ArrayListUnmanaged(u8) = .{}; |
| 4975 | 4966 | defer node_name.deinit(arena); |
| ... | ... | @@ -4978,6 +4969,7 @@ fn spawnZigRc( |
| 4978 | 4969 | child.stdin_behavior = .Ignore; |
| 4979 | 4970 | child.stdout_behavior = .Pipe; |
| 4980 | 4971 | child.stderr_behavior = .Pipe; |
| 4972 | child.progress_node = child_progress_node; | |
| 4981 | 4973 | |
| 4982 | 4974 | child.spawn() catch |err| { |
| 4983 | 4975 | return comp.failWin32Resource(win32_resource, "unable to spawn {s} rc: {s}", .{ argv[0], @errorName(err) }); |
| ... | ... | @@ -5019,22 +5011,6 @@ fn spawnZigRc( |
| 5019 | 5011 | }; |
| 5020 | 5012 | return comp.failWin32ResourceWithOwnedBundle(win32_resource, error_bundle); |
| 5021 | 5013 | }, |
| 5022 | .progress => { | |
| 5023 | node_name.clearRetainingCapacity(); | |
| 5024 | // <resinator> is a special string that indicates that the child | |
| 5025 | // process has reached resinator's main function | |
| 5026 | if (std.mem.eql(u8, body, "<resinator>")) { | |
| 5027 | child_progress_node.setName(src_basename); | |
| 5028 | } | |
| 5029 | // Ignore 0-length strings since if multiple zig rc commands | |
| 5030 | // are executed at the same time, only one will send progress strings | |
| 5031 | // while the other(s) will send empty strings. | |
| 5032 | else if (body.len > 0) { | |
| 5033 | try node_name.appendSlice(arena, "build 'zig rc'... "); | |
| 5034 | try node_name.appendSlice(arena, body); | |
| 5035 | child_progress_node.setName(node_name.items); | |
| 5036 | } | |
| 5037 | }, | |
| 5038 | 5014 | else => {}, // ignore other messages |
| 5039 | 5015 | } |
| 5040 | 5016 | |
| ... | ... | @@ -5937,8 +5913,8 @@ pub fn lockAndParseLldStderr(comp: *Compilation, prefix: []const u8, stderr: []c |
| 5937 | 5913 | } |
| 5938 | 5914 | |
| 5939 | 5915 | pub fn dump_argv(argv: []const []const u8) void { |
| 5940 | std.debug.getStderrMutex().lock(); | |
| 5941 | defer std.debug.getStderrMutex().unlock(); | |
| 5916 | std.debug.lockStdErr(); | |
| 5917 | defer std.debug.unlockStdErr(); | |
| 5942 | 5918 | const stderr = std.io.getStdErr().writer(); |
| 5943 | 5919 | for (argv[0 .. argv.len - 1]) |arg| { |
| 5944 | 5920 | nosuspend stderr.print("{s} ", .{arg}) catch return; |
| ... | ... | @@ -5989,11 +5965,10 @@ pub fn updateSubCompilation( |
| 5989 | 5965 | parent_comp: *Compilation, |
| 5990 | 5966 | sub_comp: *Compilation, |
| 5991 | 5967 | misc_task: MiscTask, |
| 5992 | prog_node: *std.Progress.Node, | |
| 5968 | prog_node: std.Progress.Node, | |
| 5993 | 5969 | ) !void { |
| 5994 | 5970 | { |
| 5995 | var sub_node = prog_node.start(@tagName(misc_task), 0); | |
| 5996 | sub_node.activate(); | |
| 5971 | const sub_node = prog_node.start(@tagName(misc_task), 0); | |
| 5997 | 5972 | defer sub_node.end(); |
| 5998 | 5973 | |
| 5999 | 5974 | try sub_comp.update(prog_node); |
| ... | ... | @@ -6024,7 +5999,7 @@ fn buildOutputFromZig( |
| 6024 | 5999 | output_mode: std.builtin.OutputMode, |
| 6025 | 6000 | out: *?CRTFile, |
| 6026 | 6001 | misc_task_tag: MiscTask, |
| 6027 | prog_node: *std.Progress.Node, | |
| 6002 | prog_node: std.Progress.Node, | |
| 6028 | 6003 | ) !void { |
| 6029 | 6004 | const tracy_trace = trace(@src()); |
| 6030 | 6005 | defer tracy_trace.end(); |
| ... | ... | @@ -6131,7 +6106,7 @@ pub fn build_crt_file( |
| 6131 | 6106 | root_name: []const u8, |
| 6132 | 6107 | output_mode: std.builtin.OutputMode, |
| 6133 | 6108 | misc_task_tag: MiscTask, |
| 6134 | prog_node: *std.Progress.Node, | |
| 6109 | prog_node: std.Progress.Node, | |
| 6135 | 6110 | /// These elements have to get mutated to add the owner module after it is |
| 6136 | 6111 | /// created within this function. |
| 6137 | 6112 | c_source_files: []CSourceFile, |
src/Module.zig+2-4| ... | ... | @@ -2991,8 +2991,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void { |
| 2991 | 2991 | try mod.deleteDeclExports(decl_index); |
| 2992 | 2992 | } |
| 2993 | 2993 | |
| 2994 | var decl_prog_node = mod.sema_prog_node.start("", 0); | |
| 2995 | decl_prog_node.activate(); | |
| 2994 | const decl_prog_node = mod.sema_prog_node.start("", 0); | |
| 2996 | 2995 | defer decl_prog_node.end(); |
| 2997 | 2996 | |
| 2998 | 2997 | const sema_result: SemaDeclResult = blk: { |
| ... | ... | @@ -5316,7 +5315,7 @@ fn handleUpdateExports( |
| 5316 | 5315 | |
| 5317 | 5316 | pub fn populateTestFunctions( |
| 5318 | 5317 | mod: *Module, |
| 5319 | main_progress_node: *std.Progress.Node, | |
| 5318 | main_progress_node: std.Progress.Node, | |
| 5320 | 5319 | ) !void { |
| 5321 | 5320 | const gpa = mod.gpa; |
| 5322 | 5321 | const ip = &mod.intern_pool; |
| ... | ... | @@ -5333,7 +5332,6 @@ pub fn populateTestFunctions( |
| 5333 | 5332 | // We have to call `ensureDeclAnalyzed` here in case `builtin.test_functions` |
| 5334 | 5333 | // was not referenced by start code. |
| 5335 | 5334 | mod.sema_prog_node = main_progress_node.start("Semantic Analysis", 0); |
| 5336 | mod.sema_prog_node.activate(); | |
| 5337 | 5335 | defer { |
| 5338 | 5336 | mod.sema_prog_node.end(); |
| 5339 | 5337 | mod.sema_prog_node = undefined; |
src/Package/Fetch.zig+5-9| ... | ... | @@ -35,7 +35,7 @@ name_tok: std.zig.Ast.TokenIndex, |
| 35 | 35 | lazy_status: LazyStatus, |
| 36 | 36 | parent_package_root: Cache.Path, |
| 37 | 37 | parent_manifest_ast: ?*const std.zig.Ast, |
| 38 | prog_node: *std.Progress.Node, | |
| 38 | prog_node: std.Progress.Node, | |
| 39 | 39 | job_queue: *JobQueue, |
| 40 | 40 | /// If true, don't add an error for a missing hash. This flag is not passed |
| 41 | 41 | /// down to recursive dependencies. It's intended to be used only be the CLI. |
| ... | ... | @@ -720,8 +720,7 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 720 | 720 | }; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | // job_queue mutex is locked so this is OK. | |
| 724 | f.prog_node.unprotected_estimated_total_items += new_fetch_index; | |
| 723 | f.prog_node.increaseEstimatedTotalItems(new_fetch_index); | |
| 725 | 724 | |
| 726 | 725 | break :nf .{ new_fetches[0..new_fetch_index], prog_names[0..new_fetch_index] }; |
| 727 | 726 | }; |
| ... | ... | @@ -751,9 +750,8 @@ pub fn relativePathDigest( |
| 751 | 750 | } |
| 752 | 751 | |
| 753 | 752 | pub fn workerRun(f: *Fetch, prog_name: []const u8) void { |
| 754 | var prog_node = f.prog_node.start(prog_name, 0); | |
| 753 | const prog_node = f.prog_node.start(prog_name, 0); | |
| 755 | 754 | defer prog_node.end(); |
| 756 | prog_node.activate(); | |
| 757 | 755 | |
| 758 | 756 | run(f) catch |err| switch (err) { |
| 759 | 757 | error.OutOfMemory => f.oom_flag = true, |
| ... | ... | @@ -1311,9 +1309,8 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource) anyerror!Unpac |
| 1311 | 1309 | var index_file = try pack_dir.createFile("pkg.idx", .{ .read = true }); |
| 1312 | 1310 | defer index_file.close(); |
| 1313 | 1311 | { |
| 1314 | var index_prog_node = f.prog_node.start("Index pack", 0); | |
| 1312 | const index_prog_node = f.prog_node.start("Index pack", 0); | |
| 1315 | 1313 | defer index_prog_node.end(); |
| 1316 | index_prog_node.activate(); | |
| 1317 | 1314 | var index_buffered_writer = std.io.bufferedWriter(index_file.writer()); |
| 1318 | 1315 | try git.indexPack(gpa, pack_file, index_buffered_writer.writer()); |
| 1319 | 1316 | try index_buffered_writer.flush(); |
| ... | ... | @@ -1321,9 +1318,8 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource) anyerror!Unpac |
| 1321 | 1318 | } |
| 1322 | 1319 | |
| 1323 | 1320 | { |
| 1324 | var checkout_prog_node = f.prog_node.start("Checkout", 0); | |
| 1321 | const checkout_prog_node = f.prog_node.start("Checkout", 0); | |
| 1325 | 1322 | defer checkout_prog_node.end(); |
| 1326 | checkout_prog_node.activate(); | |
| 1327 | 1323 | var repository = try git.Repository.init(gpa, pack_file, index_file); |
| 1328 | 1324 | defer repository.deinit(); |
| 1329 | 1325 | var diagnostics: git.Diagnostics = .{ .allocator = arena }; |
src/glibc.zig+3-3| ... | ... | @@ -160,7 +160,7 @@ pub const CRTFile = enum { |
| 160 | 160 | libc_nonshared_a, |
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void { | |
| 163 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progress.Node) !void { | |
| 164 | 164 | if (!build_options.have_llvm) { |
| 165 | 165 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 166 | 166 | } |
| ... | ... | @@ -658,7 +658,7 @@ pub const BuiltSharedObjects = struct { |
| 658 | 658 | |
| 659 | 659 | const all_map_basename = "all.map"; |
| 660 | 660 | |
| 661 | pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !void { | |
| 661 | pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !void { | |
| 662 | 662 | const tracy = trace(@src()); |
| 663 | 663 | defer tracy.end(); |
| 664 | 664 | |
| ... | ... | @@ -1065,7 +1065,7 @@ fn buildSharedLib( |
| 1065 | 1065 | bin_directory: Compilation.Directory, |
| 1066 | 1066 | asm_file_basename: []const u8, |
| 1067 | 1067 | lib: Lib, |
| 1068 | prog_node: *std.Progress.Node, | |
| 1068 | prog_node: std.Progress.Node, | |
| 1069 | 1069 | ) !void { |
| 1070 | 1070 | const tracy = trace(@src()); |
| 1071 | 1071 | defer tracy.end(); |
src/libcxx.zig+2-2| ... | ... | @@ -113,7 +113,7 @@ pub const BuildError = error{ |
| 113 | 113 | ZigCompilerNotBuiltWithLLVMExtensions, |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void { | |
| 116 | pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { | |
| 117 | 117 | if (!build_options.have_llvm) { |
| 118 | 118 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 119 | 119 | } |
| ... | ... | @@ -357,7 +357,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) BuildError |
| 357 | 357 | comp.libcxx_static_lib = try sub_compilation.toCrtFile(); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void { | |
| 360 | pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { | |
| 361 | 361 | if (!build_options.have_llvm) { |
| 362 | 362 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 363 | 363 | } |
src/libtsan.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ pub const BuildError = error{ |
| 13 | 13 | TSANUnsupportedCPUArchitecture, |
| 14 | 14 | }; |
| 15 | 15 | |
| 16 | pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void { | |
| 16 | pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { | |
| 17 | 17 | if (!build_options.have_llvm) { |
| 18 | 18 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 19 | 19 | } |
src/libunwind.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ pub const BuildError = error{ |
| 14 | 14 | ZigCompilerNotBuiltWithLLVMExtensions, |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!void { | |
| 17 | pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { | |
| 18 | 18 | if (!build_options.have_llvm) { |
| 19 | 19 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 20 | 20 | } |
src/link.zig+4-4| ... | ... | @@ -535,7 +535,7 @@ pub const File = struct { |
| 535 | 535 | /// Commit pending changes and write headers. Takes into account final output mode |
| 536 | 536 | /// and `use_lld`, not only `effectiveOutputMode`. |
| 537 | 537 | /// `arena` has the lifetime of the call to `Compilation.update`. |
| 538 | pub fn flush(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void { | |
| 538 | pub fn flush(base: *File, arena: Allocator, prog_node: std.Progress.Node) FlushError!void { | |
| 539 | 539 | if (build_options.only_c) { |
| 540 | 540 | assert(base.tag == .c); |
| 541 | 541 | return @as(*C, @fieldParentPtr("base", base)).flush(arena, prog_node); |
| ... | ... | @@ -572,7 +572,7 @@ pub const File = struct { |
| 572 | 572 | |
| 573 | 573 | /// Commit pending changes and write headers. Works based on `effectiveOutputMode` |
| 574 | 574 | /// rather than final output mode. |
| 575 | pub fn flushModule(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void { | |
| 575 | pub fn flushModule(base: *File, arena: Allocator, prog_node: std.Progress.Node) FlushError!void { | |
| 576 | 576 | switch (base.tag) { |
| 577 | 577 | inline else => |tag| { |
| 578 | 578 | if (tag != .c and build_options.only_c) unreachable; |
| ... | ... | @@ -688,7 +688,7 @@ pub const File = struct { |
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | pub fn linkAsArchive(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void { | |
| 691 | pub fn linkAsArchive(base: *File, arena: Allocator, prog_node: std.Progress.Node) FlushError!void { | |
| 692 | 692 | const tracy = trace(@src()); |
| 693 | 693 | defer tracy.end(); |
| 694 | 694 | |
| ... | ... | @@ -966,7 +966,7 @@ pub const File = struct { |
| 966 | 966 | base: File, |
| 967 | 967 | arena: Allocator, |
| 968 | 968 | llvm_object: *LlvmObject, |
| 969 | prog_node: *std.Progress.Node, | |
| 969 | prog_node: std.Progress.Node, | |
| 970 | 970 | ) !void { |
| 971 | 971 | return base.comp.emitLlvmObject(arena, base.emit, .{ |
| 972 | 972 | .directory = null, |
src/link/C.zig+3-4| ... | ... | @@ -370,7 +370,7 @@ pub fn updateDeclLineNumber(self: *C, zcu: *Zcu, decl_index: InternPool.DeclInde |
| 370 | 370 | _ = decl_index; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | pub fn flush(self: *C, arena: Allocator, prog_node: *std.Progress.Node) !void { | |
| 373 | pub fn flush(self: *C, arena: Allocator, prog_node: std.Progress.Node) !void { | |
| 374 | 374 | return self.flushModule(arena, prog_node); |
| 375 | 375 | } |
| 376 | 376 | |
| ... | ... | @@ -389,14 +389,13 @@ fn abiDefines(self: *C, target: std.Target) !std.ArrayList(u8) { |
| 389 | 389 | return defines; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | pub fn flushModule(self: *C, arena: Allocator, prog_node: *std.Progress.Node) !void { | |
| 392 | pub fn flushModule(self: *C, arena: Allocator, prog_node: std.Progress.Node) !void { | |
| 393 | 393 | _ = arena; // Has the same lifetime as the call to Compilation.update. |
| 394 | 394 | |
| 395 | 395 | const tracy = trace(@src()); |
| 396 | 396 | defer tracy.end(); |
| 397 | 397 | |
| 398 | var sub_prog_node = prog_node.start("Flush Module", 0); | |
| 399 | sub_prog_node.activate(); | |
| 398 | const sub_prog_node = prog_node.start("Flush Module", 0); | |
| 400 | 399 | defer sub_prog_node.end(); |
| 401 | 400 | |
| 402 | 401 | const comp = self.base.comp; |
src/link/Coff.zig+3-4| ... | ... | @@ -1702,7 +1702,7 @@ fn resolveGlobalSymbol(self: *Coff, current: SymbolWithLoc) !void { |
| 1702 | 1702 | gop.value_ptr.* = current; |
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | pub fn flush(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 1705 | pub fn flush(self: *Coff, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 1706 | 1706 | const comp = self.base.comp; |
| 1707 | 1707 | const use_lld = build_options.have_llvm and comp.config.use_lld; |
| 1708 | 1708 | if (use_lld) { |
| ... | ... | @@ -1714,7 +1714,7 @@ pub fn flush(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) link. |
| 1714 | 1714 | } |
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | pub fn flushModule(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 1717 | pub fn flushModule(self: *Coff, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 1718 | 1718 | const tracy = trace(@src()); |
| 1719 | 1719 | defer tracy.end(); |
| 1720 | 1720 | |
| ... | ... | @@ -1726,8 +1726,7 @@ pub fn flushModule(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 1726 | 1726 | return; |
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | var sub_prog_node = prog_node.start("COFF Flush", 0); | |
| 1730 | sub_prog_node.activate(); | |
| 1729 | const sub_prog_node = prog_node.start("COFF Flush", 0); | |
| 1731 | 1730 | defer sub_prog_node.end(); |
| 1732 | 1731 | |
| 1733 | 1732 | const module = comp.module orelse return error.LinkingWithoutZigSourceUnimplemented; |
src/link/Coff/lld.zig+2-4| ... | ... | @@ -16,7 +16,7 @@ const Allocator = mem.Allocator; |
| 16 | 16 | const Coff = @import("../Coff.zig"); |
| 17 | 17 | const Compilation = @import("../../Compilation.zig"); |
| 18 | 18 | |
| 19 | pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) !void { | |
| 19 | pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: std.Progress.Node) !void { | |
| 20 | 20 | const tracy = trace(@src()); |
| 21 | 21 | defer tracy.end(); |
| 22 | 22 | |
| ... | ... | @@ -38,9 +38,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 38 | 38 | } |
| 39 | 39 | } else null; |
| 40 | 40 | |
| 41 | var sub_prog_node = prog_node.start("LLD Link", 0); | |
| 42 | sub_prog_node.activate(); | |
| 43 | sub_prog_node.context.refresh(); | |
| 41 | const sub_prog_node = prog_node.start("LLD Link", 0); | |
| 44 | 42 | defer sub_prog_node.end(); |
| 45 | 43 | |
| 46 | 44 | const is_lib = comp.config.output_mode == .Lib; |
src/link/Elf.zig+5-8| ... | ... | @@ -1064,7 +1064,7 @@ pub fn markDirty(self: *Elf, shdr_index: u32) void { |
| 1064 | 1064 | } |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | pub fn flush(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 1067 | pub fn flush(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 1068 | 1068 | const use_lld = build_options.have_llvm and self.base.comp.config.use_lld; |
| 1069 | 1069 | if (use_lld) { |
| 1070 | 1070 | return self.linkWithLLD(arena, prog_node); |
| ... | ... | @@ -1072,7 +1072,7 @@ pub fn flush(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) link.F |
| 1072 | 1072 | try self.flushModule(arena, prog_node); |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 1075 | pub fn flushModule(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 1076 | 1076 | const tracy = trace(@src()); |
| 1077 | 1077 | defer tracy.end(); |
| 1078 | 1078 | |
| ... | ... | @@ -1085,8 +1085,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) |
| 1085 | 1085 | if (use_lld) return; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | var sub_prog_node = prog_node.start("ELF Flush", 0); | |
| 1089 | sub_prog_node.activate(); | |
| 1088 | const sub_prog_node = prog_node.start("ELF Flush", 0); | |
| 1090 | 1089 | defer sub_prog_node.end(); |
| 1091 | 1090 | |
| 1092 | 1091 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -2147,7 +2146,7 @@ fn scanRelocs(self: *Elf) !void { |
| 2147 | 2146 | } |
| 2148 | 2147 | } |
| 2149 | 2148 | |
| 2150 | fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !void { | |
| 2149 | fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: std.Progress.Node) !void { | |
| 2151 | 2150 | const tracy = trace(@src()); |
| 2152 | 2151 | defer tracy.end(); |
| 2153 | 2152 | |
| ... | ... | @@ -2169,9 +2168,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2169 | 2168 | } |
| 2170 | 2169 | } else null; |
| 2171 | 2170 | |
| 2172 | var sub_prog_node = prog_node.start("LLD Link", 0); | |
| 2173 | sub_prog_node.activate(); | |
| 2174 | sub_prog_node.context.refresh(); | |
| 2171 | const sub_prog_node = prog_node.start("LLD Link", 0); | |
| 2175 | 2172 | defer sub_prog_node.end(); |
| 2176 | 2173 | |
| 2177 | 2174 | const output_mode = comp.config.output_mode; |
src/link/MachO.zig+3-4| ... | ... | @@ -360,11 +360,11 @@ pub fn deinit(self: *MachO) void { |
| 360 | 360 | self.unwind_records.deinit(gpa); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | pub fn flush(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 363 | pub fn flush(self: *MachO, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 364 | 364 | try self.flushModule(arena, prog_node); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 367 | pub fn flushModule(self: *MachO, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 368 | 368 | const tracy = trace(@src()); |
| 369 | 369 | defer tracy.end(); |
| 370 | 370 | |
| ... | ... | @@ -375,8 +375,7 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node |
| 375 | 375 | try self.base.emitLlvmObject(arena, llvm_object, prog_node); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | var sub_prog_node = prog_node.start("MachO Flush", 0); | |
| 379 | sub_prog_node.activate(); | |
| 378 | const sub_prog_node = prog_node.start("MachO Flush", 0); | |
| 380 | 379 | defer sub_prog_node.end(); |
| 381 | 380 | |
| 382 | 381 | const directory = self.base.emit.directory; |
src/link/NvPtx.zig+2-2| ... | ... | @@ -106,11 +106,11 @@ pub fn freeDecl(self: *NvPtx, decl_index: InternPool.DeclIndex) void { |
| 106 | 106 | return self.llvm_object.freeDecl(decl_index); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | pub fn flush(self: *NvPtx, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 109 | pub fn flush(self: *NvPtx, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 110 | 110 | return self.flushModule(arena, prog_node); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | pub fn flushModule(self: *NvPtx, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 113 | pub fn flushModule(self: *NvPtx, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 114 | 114 | if (build_options.skip_non_native) |
| 115 | 115 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 116 | 116 |
src/link/Plan9.zig+3-4| ... | ... | @@ -604,7 +604,7 @@ fn allocateGotIndex(self: *Plan9) usize { |
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | pub fn flush(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 607 | pub fn flush(self: *Plan9, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 608 | 608 | const comp = self.base.comp; |
| 609 | 609 | const use_lld = build_options.have_llvm and comp.config.use_lld; |
| 610 | 610 | assert(!use_lld); |
| ... | ... | @@ -663,7 +663,7 @@ fn atomCount(self: *Plan9) usize { |
| 663 | 663 | return data_decl_count + fn_decl_count + unnamed_const_count + lazy_atom_count + extern_atom_count + anon_atom_count; |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 666 | pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 667 | 667 | if (build_options.skip_non_native and builtin.object_format != .plan9) { |
| 668 | 668 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| 669 | 669 | } |
| ... | ... | @@ -677,8 +677,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node |
| 677 | 677 | const tracy = trace(@src()); |
| 678 | 678 | defer tracy.end(); |
| 679 | 679 | |
| 680 | var sub_prog_node = prog_node.start("Flush Module", 0); | |
| 681 | sub_prog_node.activate(); | |
| 680 | const sub_prog_node = prog_node.start("Flush Module", 0); | |
| 682 | 681 | defer sub_prog_node.end(); |
| 683 | 682 | |
| 684 | 683 | log.debug("flushModule", .{}); |
src/link/SpirV.zig+5-6| ... | ... | @@ -193,11 +193,11 @@ pub fn freeDecl(self: *SpirV, decl_index: InternPool.DeclIndex) void { |
| 193 | 193 | _ = decl_index; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | pub fn flush(self: *SpirV, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 196 | pub fn flush(self: *SpirV, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 197 | 197 | return self.flushModule(arena, prog_node); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | pub fn flushModule(self: *SpirV, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 200 | pub fn flushModule(self: *SpirV, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 201 | 201 | if (build_options.skip_non_native) { |
| 202 | 202 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 203 | 203 | } |
| ... | ... | @@ -205,8 +205,7 @@ pub fn flushModule(self: *SpirV, arena: Allocator, prog_node: *std.Progress.Node |
| 205 | 205 | const tracy = trace(@src()); |
| 206 | 206 | defer tracy.end(); |
| 207 | 207 | |
| 208 | var sub_prog_node = prog_node.start("Flush Module", 0); | |
| 209 | sub_prog_node.activate(); | |
| 208 | const sub_prog_node = prog_node.start("Flush Module", 0); | |
| 210 | 209 | defer sub_prog_node.end(); |
| 211 | 210 | |
| 212 | 211 | const spv = &self.object.spv; |
| ... | ... | @@ -253,7 +252,7 @@ pub fn flushModule(self: *SpirV, arena: Allocator, prog_node: *std.Progress.Node |
| 253 | 252 | const module = try spv.finalize(arena, target); |
| 254 | 253 | errdefer arena.free(module); |
| 255 | 254 | |
| 256 | const linked_module = self.linkModule(arena, module, &sub_prog_node) catch |err| switch (err) { | |
| 255 | const linked_module = self.linkModule(arena, module, sub_prog_node) catch |err| switch (err) { | |
| 257 | 256 | error.OutOfMemory => return error.OutOfMemory, |
| 258 | 257 | else => |other| { |
| 259 | 258 | log.err("error while linking: {s}\n", .{@errorName(other)}); |
| ... | ... | @@ -264,7 +263,7 @@ pub fn flushModule(self: *SpirV, arena: Allocator, prog_node: *std.Progress.Node |
| 264 | 263 | try self.base.file.?.writeAll(std.mem.sliceAsBytes(linked_module)); |
| 265 | 264 | } |
| 266 | 265 | |
| 267 | fn linkModule(self: *SpirV, a: Allocator, module: []Word, progress: *std.Progress.Node) ![]Word { | |
| 266 | fn linkModule(self: *SpirV, a: Allocator, module: []Word, progress: std.Progress.Node) ![]Word { | |
| 268 | 267 | _ = self; |
| 269 | 268 | |
| 270 | 269 | const lower_invocation_globals = @import("SpirV/lower_invocation_globals.zig"); |
src/link/SpirV/deduplicate.zig+2-3| ... | ... | @@ -418,9 +418,8 @@ const EntityHashContext = struct { |
| 418 | 418 | } |
| 419 | 419 | }; |
| 420 | 420 | |
| 421 | pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: *std.Progress.Node) !void { | |
| 422 | var sub_node = progress.start("deduplicate", 0); | |
| 423 | sub_node.activate(); | |
| 421 | pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: std.Progress.Node) !void { | |
| 422 | const sub_node = progress.start("deduplicate", 0); | |
| 424 | 423 | defer sub_node.end(); |
| 425 | 424 | |
| 426 | 425 | var arena = std.heap.ArenaAllocator.init(parser.a); |
src/link/SpirV/lower_invocation_globals.zig+2-3| ... | ... | @@ -682,9 +682,8 @@ const ModuleBuilder = struct { |
| 682 | 682 | } |
| 683 | 683 | }; |
| 684 | 684 | |
| 685 | pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: *std.Progress.Node) !void { | |
| 686 | var sub_node = progress.start("Lower invocation globals", 6); | |
| 687 | sub_node.activate(); | |
| 685 | pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: std.Progress.Node) !void { | |
| 686 | const sub_node = progress.start("Lower invocation globals", 6); | |
| 688 | 687 | defer sub_node.end(); |
| 689 | 688 | |
| 690 | 689 | var arena = std.heap.ArenaAllocator.init(parser.a); |
src/link/SpirV/prune_unused.zig+2-3| ... | ... | @@ -255,9 +255,8 @@ fn removeIdsFromMap(a: Allocator, map: anytype, info: ModuleInfo, alive_marker: |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: *std.Progress.Node) !void { | |
| 259 | var sub_node = progress.start("Prune unused IDs", 0); | |
| 260 | sub_node.activate(); | |
| 258 | pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: std.Progress.Node) !void { | |
| 259 | const sub_node = progress.start("Prune unused IDs", 0); | |
| 261 | 260 | defer sub_node.end(); |
| 262 | 261 | |
| 263 | 262 | var arena = std.heap.ArenaAllocator.init(parser.a); |
src/link/Wasm.zig+5-8| ... | ... | @@ -2464,7 +2464,7 @@ fn appendDummySegment(wasm: *Wasm) !void { |
| 2464 | 2464 | }); |
| 2465 | 2465 | } |
| 2466 | 2466 | |
| 2467 | pub fn flush(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 2467 | pub fn flush(wasm: *Wasm, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 2468 | 2468 | const comp = wasm.base.comp; |
| 2469 | 2469 | const use_lld = build_options.have_llvm and comp.config.use_lld; |
| 2470 | 2470 | |
| ... | ... | @@ -2475,7 +2475,7 @@ pub fn flush(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) link. |
| 2475 | 2475 | } |
| 2476 | 2476 | |
| 2477 | 2477 | /// Uses the in-house linker to link one or multiple object -and archive files into a WebAssembly binary. |
| 2478 | pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void { | |
| 2478 | pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { | |
| 2479 | 2479 | const tracy = trace(@src()); |
| 2480 | 2480 | defer tracy.end(); |
| 2481 | 2481 | |
| ... | ... | @@ -2486,8 +2486,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) |
| 2486 | 2486 | if (use_lld) return; |
| 2487 | 2487 | } |
| 2488 | 2488 | |
| 2489 | var sub_prog_node = prog_node.start("Wasm Flush", 0); | |
| 2490 | sub_prog_node.activate(); | |
| 2489 | const sub_prog_node = prog_node.start("Wasm Flush", 0); | |
| 2491 | 2490 | defer sub_prog_node.end(); |
| 2492 | 2491 | |
| 2493 | 2492 | const directory = wasm.base.emit.directory; // Just an alias to make it shorter to type. |
| ... | ... | @@ -3323,7 +3322,7 @@ fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void { |
| 3323 | 3322 | } |
| 3324 | 3323 | } |
| 3325 | 3324 | |
| 3326 | fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !void { | |
| 3325 | fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: std.Progress.Node) !void { | |
| 3327 | 3326 | const tracy = trace(@src()); |
| 3328 | 3327 | defer tracy.end(); |
| 3329 | 3328 | |
| ... | ... | @@ -3350,9 +3349,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo |
| 3350 | 3349 | } |
| 3351 | 3350 | } else null; |
| 3352 | 3351 | |
| 3353 | var sub_prog_node = prog_node.start("LLD Link", 0); | |
| 3354 | sub_prog_node.activate(); | |
| 3355 | sub_prog_node.context.refresh(); | |
| 3352 | const sub_prog_node = prog_node.start("LLD Link", 0); | |
| 3356 | 3353 | defer sub_prog_node.end(); |
| 3357 | 3354 | |
| 3358 | 3355 | const is_obj = comp.config.output_mode == .Obj; |
src/main.zig+15-135| ... | ... | @@ -4028,22 +4028,7 @@ fn serve( |
| 4028 | 4028 | |
| 4029 | 4029 | var child_pid: ?std.process.Child.Id = null; |
| 4030 | 4030 | |
| 4031 | var progress: std.Progress = .{ | |
| 4032 | .terminal = null, | |
| 4033 | .root = .{ | |
| 4034 | .context = undefined, | |
| 4035 | .parent = null, | |
| 4036 | .name = "", | |
| 4037 | .unprotected_estimated_total_items = 0, | |
| 4038 | .unprotected_completed_items = 0, | |
| 4039 | }, | |
| 4040 | .columns_written = 0, | |
| 4041 | .prev_refresh_timestamp = 0, | |
| 4042 | .timer = null, | |
| 4043 | .done = false, | |
| 4044 | }; | |
| 4045 | const main_progress_node = &progress.root; | |
| 4046 | main_progress_node.context = &progress; | |
| 4031 | const main_progress_node = std.Progress.start(.{}); | |
| 4047 | 4032 | |
| 4048 | 4033 | while (true) { |
| 4049 | 4034 | const hdr = try server.receiveMessage(); |
| ... | ... | @@ -4051,7 +4036,6 @@ fn serve( |
| 4051 | 4036 | switch (hdr.tag) { |
| 4052 | 4037 | .exit => return cleanExit(), |
| 4053 | 4038 | .update => { |
| 4054 | assert(main_progress_node.recently_updated_child == null); | |
| 4055 | 4039 | tracy.frameMark(); |
| 4056 | 4040 | |
| 4057 | 4041 | if (arg_mode == .translate_c) { |
| ... | ... | @@ -4075,21 +4059,7 @@ fn serve( |
| 4075 | 4059 | try comp.makeBinFileWritable(); |
| 4076 | 4060 | } |
| 4077 | 4061 | |
| 4078 | if (builtin.single_threaded) { | |
| 4079 | try comp.update(main_progress_node); | |
| 4080 | } else { | |
| 4081 | var reset: std.Thread.ResetEvent = .{}; | |
| 4082 | ||
| 4083 | var progress_thread = try std.Thread.spawn(.{}, progressThread, .{ | |
| 4084 | &progress, &server, &reset, | |
| 4085 | }); | |
| 4086 | defer { | |
| 4087 | reset.set(); | |
| 4088 | progress_thread.join(); | |
| 4089 | } | |
| 4090 | ||
| 4091 | try comp.update(main_progress_node); | |
| 4092 | } | |
| 4062 | try comp.update(main_progress_node); | |
| 4093 | 4063 | |
| 4094 | 4064 | try comp.makeBinFileExecutable(); |
| 4095 | 4065 | try serveUpdateResults(&server, comp); |
| ... | ... | @@ -4116,7 +4086,6 @@ fn serve( |
| 4116 | 4086 | }, |
| 4117 | 4087 | .hot_update => { |
| 4118 | 4088 | tracy.frameMark(); |
| 4119 | assert(main_progress_node.recently_updated_child == null); | |
| 4120 | 4089 | if (child_pid) |pid| { |
| 4121 | 4090 | try comp.hotCodeSwap(main_progress_node, pid); |
| 4122 | 4091 | try serveUpdateResults(&server, comp); |
| ... | ... | @@ -4146,63 +4115,6 @@ fn serve( |
| 4146 | 4115 | } |
| 4147 | 4116 | } |
| 4148 | 4117 | |
| 4149 | fn progressThread(progress: *std.Progress, server: *const Server, reset: *std.Thread.ResetEvent) void { | |
| 4150 | while (true) { | |
| 4151 | if (reset.timedWait(500 * std.time.ns_per_ms)) |_| { | |
| 4152 | // The Compilation update has completed. | |
| 4153 | return; | |
| 4154 | } else |err| switch (err) { | |
| 4155 | error.Timeout => {}, | |
| 4156 | } | |
| 4157 | ||
| 4158 | var buf: std.BoundedArray(u8, 160) = .{}; | |
| 4159 | ||
| 4160 | { | |
| 4161 | progress.update_mutex.lock(); | |
| 4162 | defer progress.update_mutex.unlock(); | |
| 4163 | ||
| 4164 | var need_ellipse = false; | |
| 4165 | var maybe_node: ?*std.Progress.Node = &progress.root; | |
| 4166 | while (maybe_node) |node| { | |
| 4167 | if (need_ellipse) { | |
| 4168 | buf.appendSlice("... ") catch {}; | |
| 4169 | } | |
| 4170 | need_ellipse = false; | |
| 4171 | const eti = @atomicLoad(usize, &node.unprotected_estimated_total_items, .monotonic); | |
| 4172 | const completed_items = @atomicLoad(usize, &node.unprotected_completed_items, .monotonic); | |
| 4173 | const current_item = completed_items + 1; | |
| 4174 | if (node.name.len != 0 or eti > 0) { | |
| 4175 | if (node.name.len != 0) { | |
| 4176 | buf.appendSlice(node.name) catch {}; | |
| 4177 | need_ellipse = true; | |
| 4178 | } | |
| 4179 | if (eti > 0) { | |
| 4180 | if (need_ellipse) buf.appendSlice(" ") catch {}; | |
| 4181 | buf.writer().print("[{d}/{d}] ", .{ current_item, eti }) catch {}; | |
| 4182 | need_ellipse = false; | |
| 4183 | } else if (completed_items != 0) { | |
| 4184 | if (need_ellipse) buf.appendSlice(" ") catch {}; | |
| 4185 | buf.writer().print("[{d}] ", .{current_item}) catch {}; | |
| 4186 | need_ellipse = false; | |
| 4187 | } | |
| 4188 | } | |
| 4189 | maybe_node = @atomicLoad(?*std.Progress.Node, &node.recently_updated_child, .acquire); | |
| 4190 | } | |
| 4191 | } | |
| 4192 | ||
| 4193 | const progress_string = buf.slice(); | |
| 4194 | ||
| 4195 | server.serveMessage(.{ | |
| 4196 | .tag = .progress, | |
| 4197 | .bytes_len = @as(u32, @intCast(progress_string.len)), | |
| 4198 | }, &.{ | |
| 4199 | progress_string, | |
| 4200 | }) catch |err| { | |
| 4201 | fatal("unable to write to client: {s}", .{@errorName(err)}); | |
| 4202 | }; | |
| 4203 | } | |
| 4204 | } | |
| 4205 | ||
| 4206 | 4118 | fn serveUpdateResults(s: *Server, comp: *Compilation) !void { |
| 4207 | 4119 | const gpa = comp.gpa; |
| 4208 | 4120 | var error_bundle = try comp.getAllErrorsAlloc(); |
| ... | ... | @@ -4472,19 +4384,10 @@ fn runOrTestHotSwap( |
| 4472 | 4384 | fn updateModule(comp: *Compilation, color: Color) !void { |
| 4473 | 4385 | { |
| 4474 | 4386 | // If the terminal is dumb, we dont want to show the user all the output. |
| 4475 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; | |
| 4476 | const main_progress_node = progress.start("", 0); | |
| 4387 | const main_progress_node = std.Progress.start(.{ | |
| 4388 | .disable_printing = color == .off, | |
| 4389 | }); | |
| 4477 | 4390 | defer main_progress_node.end(); |
| 4478 | switch (color) { | |
| 4479 | .off => { | |
| 4480 | progress.terminal = null; | |
| 4481 | }, | |
| 4482 | .on => { | |
| 4483 | progress.terminal = std.io.getStdErr(); | |
| 4484 | progress.supports_ansi_escape_codes = true; | |
| 4485 | }, | |
| 4486 | .auto => {}, | |
| 4487 | } | |
| 4488 | 4391 | |
| 4489 | 4392 | try comp.update(main_progress_node); |
| 4490 | 4393 | } |
| ... | ... | @@ -4736,8 +4639,6 @@ const usage_build = |
| 4736 | 4639 | ; |
| 4737 | 4640 | |
| 4738 | 4641 | fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 4739 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; | |
| 4740 | ||
| 4741 | 4642 | var build_file: ?[]const u8 = null; |
| 4742 | 4643 | var override_lib_dir: ?[]const u8 = try EnvVar.ZIG_LIB_DIR.get(arena); |
| 4743 | 4644 | var override_global_cache_dir: ?[]const u8 = try EnvVar.ZIG_GLOBAL_CACHE_DIR.get(arena); |
| ... | ... | @@ -5051,7 +4952,9 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 5051 | 4952 | config, |
| 5052 | 4953 | ); |
| 5053 | 4954 | } else { |
| 5054 | const root_prog_node = progress.start("Fetch Packages", 0); | |
| 4955 | const root_prog_node = std.Progress.start(.{ | |
| 4956 | .root_name = "Fetch Packages", | |
| 4957 | }); | |
| 5055 | 4958 | defer root_prog_node.end(); |
| 5056 | 4959 | |
| 5057 | 4960 | var job_queue: Package.Fetch.JobQueue = .{ |
| ... | ... | @@ -5473,38 +5376,14 @@ fn jitCmd( |
| 5473 | 5376 | }; |
| 5474 | 5377 | defer comp.destroy(); |
| 5475 | 5378 | |
| 5476 | if (options.server and !builtin.single_threaded) { | |
| 5477 | var reset: std.Thread.ResetEvent = .{}; | |
| 5478 | var progress: std.Progress = .{ | |
| 5479 | .terminal = null, | |
| 5480 | .root = .{ | |
| 5481 | .context = undefined, | |
| 5482 | .parent = null, | |
| 5483 | .name = "", | |
| 5484 | .unprotected_estimated_total_items = 0, | |
| 5485 | .unprotected_completed_items = 0, | |
| 5486 | }, | |
| 5487 | .columns_written = 0, | |
| 5488 | .prev_refresh_timestamp = 0, | |
| 5489 | .timer = null, | |
| 5490 | .done = false, | |
| 5491 | }; | |
| 5492 | const main_progress_node = &progress.root; | |
| 5493 | main_progress_node.context = &progress; | |
| 5379 | if (options.server) { | |
| 5380 | const main_progress_node = std.Progress.start(.{}); | |
| 5494 | 5381 | var server = std.zig.Server{ |
| 5495 | 5382 | .out = std.io.getStdOut(), |
| 5496 | 5383 | .in = undefined, // won't be receiving messages |
| 5497 | 5384 | .receive_fifo = undefined, // won't be receiving messages |
| 5498 | 5385 | }; |
| 5499 | 5386 | |
| 5500 | var progress_thread = try std.Thread.spawn(.{}, progressThread, .{ | |
| 5501 | &progress, &server, &reset, | |
| 5502 | }); | |
| 5503 | defer { | |
| 5504 | reset.set(); | |
| 5505 | progress_thread.join(); | |
| 5506 | } | |
| 5507 | ||
| 5508 | 5387 | try comp.update(main_progress_node); |
| 5509 | 5388 | |
| 5510 | 5389 | var error_bundle = try comp.getAllErrorsAlloc(); |
| ... | ... | @@ -6963,8 +6842,9 @@ fn cmdFetch( |
| 6963 | 6842 | |
| 6964 | 6843 | try http_client.initDefaultProxies(arena); |
| 6965 | 6844 | |
| 6966 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; | |
| 6967 | const root_prog_node = progress.start("Fetch", 0); | |
| 6845 | var root_prog_node = std.Progress.start(.{ | |
| 6846 | .root_name = "Fetch", | |
| 6847 | }); | |
| 6968 | 6848 | defer root_prog_node.end(); |
| 6969 | 6849 | |
| 6970 | 6850 | var global_cache_directory: Compilation.Directory = l: { |
| ... | ... | @@ -7028,8 +6908,8 @@ fn cmdFetch( |
| 7028 | 6908 | |
| 7029 | 6909 | const hex_digest = Package.Manifest.hexDigest(fetch.actual_hash); |
| 7030 | 6910 | |
| 7031 | progress.done = true; | |
| 7032 | progress.refresh(); | |
| 6911 | root_prog_node.end(); | |
| 6912 | root_prog_node = .{ .index = .none }; | |
| 7033 | 6913 | |
| 7034 | 6914 | const name = switch (save) { |
| 7035 | 6915 | .no => { |
src/mingw.zig+3-3| ... | ... | @@ -16,7 +16,7 @@ pub const CRTFile = enum { |
| 16 | 16 | mingw32_lib, |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void { | |
| 19 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progress.Node) !void { | |
| 20 | 20 | if (!build_options.have_llvm) { |
| 21 | 21 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 22 | 22 | } |
| ... | ... | @@ -234,8 +234,8 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 234 | 234 | const include_dir = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "def-include" }); |
| 235 | 235 | |
| 236 | 236 | if (comp.verbose_cc) print: { |
| 237 | std.debug.getStderrMutex().lock(); | |
| 238 | defer std.debug.getStderrMutex().unlock(); | |
| 237 | std.debug.lockStdErr(); | |
| 238 | defer std.debug.unlockStdErr(); | |
| 239 | 239 | const stderr = std.io.getStdErr().writer(); |
| 240 | 240 | nosuspend stderr.print("def file: {s}\n", .{def_file_path}) catch break :print; |
| 241 | 241 | nosuspend stderr.print("include dir: {s}\n", .{include_dir}) catch break :print; |
src/musl.zig+1-1| ... | ... | @@ -19,7 +19,7 @@ pub const CRTFile = enum { |
| 19 | 19 | libc_so, |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void { | |
| 22 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progress.Node) !void { | |
| 23 | 23 | if (!build_options.have_llvm) { |
| 24 | 24 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 25 | 25 | } |
src/wasi_libc.zig+1-1| ... | ... | @@ -57,7 +57,7 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co |
| 57 | 57 | }; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void { | |
| 60 | pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progress.Node) !void { | |
| 61 | 61 | if (!build_options.have_llvm) { |
| 62 | 62 | return error.ZigCompilerNotBuiltWithLLVMExtensions; |
| 63 | 63 | } |
test/standalone/cmakedefine/build.zig+1-1| ... | ... | @@ -80,7 +80,7 @@ pub fn build(b: *std.Build) void { |
| 80 | 80 | test_step.dependOn(&wrapper_header.step); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | fn compare_headers(step: *std.Build.Step, prog_node: *std.Progress.Node) !void { | |
| 83 | fn compare_headers(step: *std.Build.Step, prog_node: std.Progress.Node) !void { | |
| 84 | 84 | _ = prog_node; |
| 85 | 85 | const allocator = step.owner.allocator; |
| 86 | 86 | const expected_fmt = "expected_{s}"; |