authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-28 21:14:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
log8acbfafefb635390f6b4da102966b5c4a2f3332e
tree41ec02736ae4053d5d4a6c782ea47b832b4e9d97
parent85b4b6e3b35dd6b70092ac006b6bd621332e258f

compiler: update function accepts a std.Progress.Node

This makes progress be exposed to the top-level caller of update(). I tossed in a bonus change: when the `zig build` subcommand sees exit code 2, it omits the "following command failed" line, and the build runner uses exit code 2 when there are compile errors. This tidies up the output on build failure by a little bit.

9 files changed, 130 insertions(+), 84 deletions(-)

src/Compilation.zig+44-41
......@@ -1847,8 +1847,15 @@ fn cleanupTmpArtifactDirectory(
18471847 }
18481848}
18491849
1850pub fn hotCodeSwap(comp: *Compilation, prog_node: *std.Progress.Node, pid: std.os.pid_t) !void {
1851 comp.bin_file.child_pid = pid;
1852 try comp.makeBinFileWritable();
1853 try comp.update(prog_node);
1854 try comp.makeBinFileExecutable();
1855}
1856
18501857/// Detect changes to source files, perform semantic analysis, and update the output files.
1851pub fn update(comp: *Compilation) !void {
1858pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void {
18521859 const tracy_trace = trace(@src());
18531860 defer tracy_trace.end();
18541861
......@@ -1995,21 +2002,6 @@ pub fn update(comp: *Compilation) !void {
19952002 }
19962003 }
19972004
1998 // If the terminal is dumb, we dont want to show the user all the output.
1999 var progress: std.Progress = .{ .dont_print_on_dumb = true };
2000 const main_progress_node = progress.start("", 0);
2001 defer main_progress_node.end();
2002 switch (comp.color) {
2003 .off => {
2004 progress.terminal = null;
2005 },
2006 .on => {
2007 progress.terminal = std.io.getStdErr();
2008 progress.supports_ansi_escape_codes = true;
2009 },
2010 .auto => {},
2011 }
2012
20132005 try comp.performAllTheWork(main_progress_node);
20142006
20152007 if (comp.bin_file.options.module) |module| {
......@@ -3057,11 +3049,11 @@ pub fn performAllTheWork(
30573049 // backend, preventing anonymous Decls from being prematurely destroyed.
30583050 while (true) {
30593051 if (comp.work_queue.readItem()) |work_item| {
3060 try processOneJob(comp, work_item);
3052 try processOneJob(comp, work_item, main_progress_node);
30613053 continue;
30623054 }
30633055 if (comp.anon_work_queue.readItem()) |work_item| {
3064 try processOneJob(comp, work_item);
3056 try processOneJob(comp, work_item, main_progress_node);
30653057 continue;
30663058 }
30673059 break;
......@@ -3069,16 +3061,16 @@ pub fn performAllTheWork(
30693061
30703062 if (comp.job_queued_compiler_rt_lib) {
30713063 comp.job_queued_compiler_rt_lib = false;
3072 buildCompilerRtOneShot(comp, .Lib, &comp.compiler_rt_lib);
3064 buildCompilerRtOneShot(comp, .Lib, &comp.compiler_rt_lib, main_progress_node);
30733065 }
30743066
30753067 if (comp.job_queued_compiler_rt_obj) {
30763068 comp.job_queued_compiler_rt_obj = false;
3077 buildCompilerRtOneShot(comp, .Obj, &comp.compiler_rt_obj);
3069 buildCompilerRtOneShot(comp, .Obj, &comp.compiler_rt_obj, main_progress_node);
30783070 }
30793071}
30803072
3081fn processOneJob(comp: *Compilation, job: Job) !void {
3073fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !void {
30823074 switch (job) {
30833075 .codegen_decl => |decl_index| {
30843076 const module = comp.bin_file.options.module.?;
......@@ -3230,7 +3222,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
32303222 const named_frame = tracy.namedFrame("glibc_crt_file");
32313223 defer named_frame.end();
32323224
3233 glibc.buildCRTFile(comp, crt_file) catch |err| {
3225 glibc.buildCRTFile(comp, crt_file, prog_node) catch |err| {
32343226 // TODO Surface more error details.
32353227 comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{
32363228 @errorName(err),
......@@ -3241,7 +3233,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
32413233 const named_frame = tracy.namedFrame("glibc_shared_objects");
32423234 defer named_frame.end();
32433235
3244 glibc.buildSharedObjects(comp) catch |err| {
3236 glibc.buildSharedObjects(comp, prog_node) catch |err| {
32453237 // TODO Surface more error details.
32463238 comp.lockAndSetMiscFailure(
32473239 .glibc_shared_objects,
......@@ -3254,7 +3246,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
32543246 const named_frame = tracy.namedFrame("musl_crt_file");
32553247 defer named_frame.end();
32563248
3257 musl.buildCRTFile(comp, crt_file) catch |err| {
3249 musl.buildCRTFile(comp, crt_file, prog_node) catch |err| {
32583250 // TODO Surface more error details.
32593251 comp.lockAndSetMiscFailure(
32603252 .musl_crt_file,
......@@ -3267,7 +3259,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
32673259 const named_frame = tracy.namedFrame("mingw_crt_file");
32683260 defer named_frame.end();
32693261
3270 mingw.buildCRTFile(comp, crt_file) catch |err| {
3262 mingw.buildCRTFile(comp, crt_file, prog_node) catch |err| {
32713263 // TODO Surface more error details.
32723264 comp.lockAndSetMiscFailure(
32733265 .mingw_crt_file,
......@@ -3294,7 +3286,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
32943286 const named_frame = tracy.namedFrame("libunwind");
32953287 defer named_frame.end();
32963288
3297 libunwind.buildStaticLib(comp) catch |err| {
3289 libunwind.buildStaticLib(comp, prog_node) catch |err| {
32983290 // TODO Surface more error details.
32993291 comp.lockAndSetMiscFailure(
33003292 .libunwind,
......@@ -3307,7 +3299,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
33073299 const named_frame = tracy.namedFrame("libcxx");
33083300 defer named_frame.end();
33093301
3310 libcxx.buildLibCXX(comp) catch |err| {
3302 libcxx.buildLibCXX(comp, prog_node) catch |err| {
33113303 // TODO Surface more error details.
33123304 comp.lockAndSetMiscFailure(
33133305 .libcxx,
......@@ -3320,7 +3312,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
33203312 const named_frame = tracy.namedFrame("libcxxabi");
33213313 defer named_frame.end();
33223314
3323 libcxx.buildLibCXXABI(comp) catch |err| {
3315 libcxx.buildLibCXXABI(comp, prog_node) catch |err| {
33243316 // TODO Surface more error details.
33253317 comp.lockAndSetMiscFailure(
33263318 .libcxxabi,
......@@ -3333,7 +3325,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
33333325 const named_frame = tracy.namedFrame("libtsan");
33343326 defer named_frame.end();
33353327
3336 libtsan.buildTsan(comp) catch |err| {
3328 libtsan.buildTsan(comp, prog_node) catch |err| {
33373329 // TODO Surface more error details.
33383330 comp.lockAndSetMiscFailure(
33393331 .libtsan,
......@@ -3346,7 +3338,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
33463338 const named_frame = tracy.namedFrame("wasi_libc_crt_file");
33473339 defer named_frame.end();
33483340
3349 wasi_libc.buildCRTFile(comp, crt_file) catch |err| {
3341 wasi_libc.buildCRTFile(comp, crt_file, prog_node) catch |err| {
33503342 // TODO Surface more error details.
33513343 comp.lockAndSetMiscFailure(
33523344 .wasi_libc_crt_file,
......@@ -3364,6 +3356,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
33643356 .Lib,
33653357 &comp.libssp_static_lib,
33663358 .libssp,
3359 prog_node,
33673360 ) catch |err| switch (err) {
33683361 error.OutOfMemory => return error.OutOfMemory,
33693362 error.SubCompilationFailed => return, // error reported already
......@@ -3383,6 +3376,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
33833376 .Lib,
33843377 &comp.libc_static_lib,
33853378 .zig_libc,
3379 prog_node,
33863380 ) catch |err| switch (err) {
33873381 error.OutOfMemory => return error.OutOfMemory,
33883382 error.SubCompilationFailed => return, // error reported already
......@@ -3723,8 +3717,15 @@ fn buildCompilerRtOneShot(
37233717 comp: *Compilation,
37243718 output_mode: std.builtin.OutputMode,
37253719 out: *?CRTFile,
3720 prog_node: *std.Progress.Node,
37263721) void {
3727 comp.buildOutputFromZig("compiler_rt.zig", output_mode, out, .compiler_rt) catch |err| switch (err) {
3722 comp.buildOutputFromZig(
3723 "compiler_rt.zig",
3724 output_mode,
3725 out,
3726 .compiler_rt,
3727 prog_node,
3728 ) catch |err| switch (err) {
37283729 error.SubCompilationFailed => return, // error reported already
37293730 else => comp.lockAndSetMiscFailure(
37303731 .compiler_rt,
......@@ -5248,8 +5249,15 @@ pub fn updateSubCompilation(
52485249 parent_comp: *Compilation,
52495250 sub_comp: *Compilation,
52505251 misc_task: MiscTask,
5252 prog_node: *std.Progress.Node,
52515253) !void {
5252 try sub_comp.update();
5254 {
5255 var sub_node = prog_node.start(@tagName(misc_task), 0);
5256 sub_node.activate();
5257 defer sub_node.end();
5258
5259 try sub_comp.update(prog_node);
5260 }
52535261
52545262 // Look for compilation errors in this sub compilation
52555263 const gpa = parent_comp.gpa;
......@@ -5276,6 +5284,7 @@ fn buildOutputFromZig(
52765284 output_mode: std.builtin.OutputMode,
52775285 out: *?CRTFile,
52785286 misc_task_tag: MiscTask,
5287 prog_node: *std.Progress.Node,
52795288) !void {
52805289 const tracy_trace = trace(@src());
52815290 defer tracy_trace.end();
......@@ -5342,7 +5351,7 @@ fn buildOutputFromZig(
53425351 });
53435352 defer sub_compilation.destroy();
53445353
5345 try comp.updateSubCompilation(sub_compilation, misc_task_tag);
5354 try comp.updateSubCompilation(sub_compilation, misc_task_tag, prog_node);
53465355
53475356 assert(out.* == null);
53485357 out.* = Compilation.CRTFile{
......@@ -5358,6 +5367,7 @@ pub fn build_crt_file(
53585367 root_name: []const u8,
53595368 output_mode: std.builtin.OutputMode,
53605369 misc_task_tag: MiscTask,
5370 prog_node: *std.Progress.Node,
53615371 c_source_files: []const Compilation.CSourceFile,
53625372) !void {
53635373 const tracy_trace = trace(@src());
......@@ -5418,7 +5428,7 @@ pub fn build_crt_file(
54185428 });
54195429 defer sub_compilation.destroy();
54205430
5421 try comp.updateSubCompilation(sub_compilation, misc_task_tag);
5431 try comp.updateSubCompilation(sub_compilation, misc_task_tag, prog_node);
54225432
54235433 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);
54245434
......@@ -5470,10 +5480,3 @@ pub fn compilerRtStrip(comp: Compilation) bool {
54705480 return true;
54715481 }
54725482}
5473
5474pub fn hotCodeSwap(comp: *Compilation, pid: std.os.pid_t) !void {
5475 comp.bin_file.child_pid = pid;
5476 try comp.makeBinFileWritable();
5477 try comp.update();
5478 try comp.makeBinFileExecutable();
5479}
src/glibc.zig+11-8
......@@ -161,7 +161,7 @@ pub const CRTFile = enum {
161161 libc_nonshared_a,
162162};
163163
164pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
164pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
165165 if (!build_options.have_llvm) {
166166 return error.ZigCompilerNotBuiltWithLLVMExtensions;
167167 }
......@@ -196,7 +196,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
196196 "-DASSEMBLER",
197197 "-Wa,--noexecstack",
198198 });
199 return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", &[1]Compilation.CSourceFile{
199 return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &.{
200200 .{
201201 .src_path = try start_asm_path(comp, arena, "crti.S"),
202202 .cache_exempt_flags = args.items,
......@@ -215,7 +215,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
215215 "-DASSEMBLER",
216216 "-Wa,--noexecstack",
217217 });
218 return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", &[1]Compilation.CSourceFile{
218 return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &.{
219219 .{
220220 .src_path = try start_asm_path(comp, arena, "crtn.S"),
221221 .cache_exempt_flags = args.items,
......@@ -265,7 +265,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
265265 .cache_exempt_flags = args.items,
266266 };
267267 };
268 return comp.build_crt_file("Scrt1", .Obj, .@"glibc Scrt1.o", &[_]Compilation.CSourceFile{ start_o, abi_note_o });
268 return comp.build_crt_file("Scrt1", .Obj, .@"glibc Scrt1.o", prog_node, &.{
269 start_o, abi_note_o,
270 });
269271 },
270272 .libc_nonshared_a => {
271273 const s = path.sep_str;
......@@ -366,7 +368,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
366368 files_index += 1;
367369 }
368370 const files = files_buf[0..files_index];
369 return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", files);
371 return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files);
370372 },
371373 }
372374}
......@@ -639,7 +641,7 @@ pub const BuiltSharedObjects = struct {
639641
640642const all_map_basename = "all.map";
641643
642pub fn buildSharedObjects(comp: *Compilation) !void {
644pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !void {
643645 const tracy = trace(@src());
644646 defer tracy.end();
645647
......@@ -1023,7 +1025,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void {
10231025 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
10241026 try o_directory.handle.writeFile(asm_file_basename, stubs_asm.items);
10251027
1026 try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib);
1028 try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);
10271029 }
10281030
10291031 man.writeManifest() catch |err| {
......@@ -1046,6 +1048,7 @@ fn buildSharedLib(
10461048 bin_directory: Compilation.Directory,
10471049 asm_file_basename: []const u8,
10481050 lib: Lib,
1051 prog_node: *std.Progress.Node,
10491052) !void {
10501053 const tracy = trace(@src());
10511054 defer tracy.end();
......@@ -1105,7 +1108,7 @@ fn buildSharedLib(
11051108 });
11061109 defer sub_compilation.destroy();
11071110
1108 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object");
1111 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
11091112}
11101113
11111114// Return true if glibc has crti/crtn sources for that architecture.
src/libcxx.zig+4-4
......@@ -96,7 +96,7 @@ const libcxx_files = [_][]const u8{
9696 "src/verbose_abort.cpp",
9797};
9898
99pub fn buildLibCXX(comp: *Compilation) !void {
99pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
100100 if (!build_options.have_llvm) {
101101 return error.ZigCompilerNotBuiltWithLLVMExtensions;
102102 }
......@@ -258,7 +258,7 @@ pub fn buildLibCXX(comp: *Compilation) !void {
258258 });
259259 defer sub_compilation.destroy();
260260
261 try comp.updateSubCompilation(sub_compilation, .libcxx);
261 try comp.updateSubCompilation(sub_compilation, .libcxx, prog_node);
262262
263263 assert(comp.libcxx_static_lib == null);
264264 comp.libcxx_static_lib = Compilation.CRTFile{
......@@ -269,7 +269,7 @@ pub fn buildLibCXX(comp: *Compilation) !void {
269269 };
270270}
271271
272pub fn buildLibCXXABI(comp: *Compilation) !void {
272pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
273273 if (!build_options.have_llvm) {
274274 return error.ZigCompilerNotBuiltWithLLVMExtensions;
275275 }
......@@ -418,7 +418,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {
418418 });
419419 defer sub_compilation.destroy();
420420
421 try comp.updateSubCompilation(sub_compilation, .libcxxabi);
421 try comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node);
422422
423423 assert(comp.libcxxabi_static_lib == null);
424424 comp.libcxxabi_static_lib = Compilation.CRTFile{
src/libtsan.zig+2-2
......@@ -5,7 +5,7 @@ const Compilation = @import("Compilation.zig");
55const build_options = @import("build_options");
66const trace = @import("tracy.zig").trace;
77
8pub fn buildTsan(comp: *Compilation) !void {
8pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
99 if (!build_options.have_llvm) {
1010 return error.ZigCompilerNotBuiltWithLLVMExtensions;
1111 }
......@@ -235,7 +235,7 @@ pub fn buildTsan(comp: *Compilation) !void {
235235 });
236236 defer sub_compilation.destroy();
237237
238 try comp.updateSubCompilation(sub_compilation, .libtsan);
238 try comp.updateSubCompilation(sub_compilation, .libtsan, prog_node);
239239
240240 assert(comp.tsan_static_lib == null);
241241 comp.tsan_static_lib = Compilation.CRTFile{
src/libunwind.zig+2-2
......@@ -7,7 +7,7 @@ const Compilation = @import("Compilation.zig");
77const build_options = @import("build_options");
88const trace = @import("tracy.zig").trace;
99
10pub fn buildStaticLib(comp: *Compilation) !void {
10pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
1111 if (!build_options.have_llvm) {
1212 return error.ZigCompilerNotBuiltWithLLVMExtensions;
1313 }
......@@ -130,7 +130,7 @@ pub fn buildStaticLib(comp: *Compilation) !void {
130130 });
131131 defer sub_compilation.destroy();
132132
133 try comp.updateSubCompilation(sub_compilation, .libunwind);
133 try comp.updateSubCompilation(sub_compilation, .libunwind, prog_node);
134134
135135 assert(comp.libunwind_static_lib == null);
136136
src/main.zig+44-4
......@@ -3543,6 +3543,23 @@ fn serve(
35433543 var receive_fifo = std.fifo.LinearFifo(u8, .Dynamic).init(gpa);
35443544 defer receive_fifo.deinit();
35453545
3546 var progress: std.Progress = .{
3547 .terminal = null,
3548 .root = .{
3549 .context = undefined,
3550 .parent = null,
3551 .name = "",
3552 .unprotected_estimated_total_items = 0,
3553 .unprotected_completed_items = 0,
3554 },
3555 .columns_written = 0,
3556 .prev_refresh_timestamp = 0,
3557 .timer = null,
3558 .done = false,
3559 };
3560 const main_progress_node = &progress.root;
3561 main_progress_node.context = &progress;
3562
35463563 while (true) {
35473564 const hdr = try receiveMessage(in, &receive_fifo);
35483565
......@@ -3551,11 +3568,12 @@ fn serve(
35513568 return cleanExit();
35523569 },
35533570 .update => {
3571 assert(main_progress_node.recently_updated_child == null);
35543572 tracy.frameMark();
35553573 if (comp.bin_file.options.output_mode == .Exe) {
35563574 try comp.makeBinFileWritable();
35573575 }
3558 try comp.update();
3576 try comp.update(main_progress_node);
35593577 try comp.makeBinFileExecutable();
35603578 try serveUpdateResults(out, comp);
35613579 },
......@@ -3581,14 +3599,15 @@ fn serve(
35813599 },
35823600 .hot_update => {
35833601 tracy.frameMark();
3602 assert(main_progress_node.recently_updated_child == null);
35843603 if (child_pid) |pid| {
3585 try comp.hotCodeSwap(pid);
3604 try comp.hotCodeSwap(main_progress_node, pid);
35863605 try serveUpdateResults(out, comp);
35873606 } else {
35883607 if (comp.bin_file.options.output_mode == .Exe) {
35893608 try comp.makeBinFileWritable();
35903609 }
3591 try comp.update();
3610 try comp.update(main_progress_node);
35923611 try comp.makeBinFileExecutable();
35933612 try serveUpdateResults(out, comp);
35943613
......@@ -3936,7 +3955,24 @@ const AfterUpdateHook = union(enum) {
39363955};
39373956
39383957fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void {
3939 try comp.update();
3958 {
3959 // If the terminal is dumb, we dont want to show the user all the output.
3960 var progress: std.Progress = .{ .dont_print_on_dumb = true };
3961 const main_progress_node = progress.start("", 0);
3962 defer main_progress_node.end();
3963 switch (comp.color) {
3964 .off => {
3965 progress.terminal = null;
3966 },
3967 .on => {
3968 progress.terminal = std.io.getStdErr();
3969 progress.supports_ansi_escape_codes = true;
3970 },
3971 .auto => {},
3972 }
3973
3974 try comp.update(main_progress_node);
3975 }
39403976
39413977 var errors = try comp.getAllErrorsAlloc();
39423978 defer errors.deinit(comp.gpa);
......@@ -4642,6 +4678,10 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
46424678 switch (term) {
46434679 .Exited => |code| {
46444680 if (code == 0) return cleanExit();
4681 // Indicates that the build runner has reported compile errors
4682 // and this parent process does not need to report any further
4683 // diagnostics.
4684 if (code == 2) process.exit(2);
46454685
46464686 const cmd = try std.mem.join(arena, " ", child_argv);
46474687 fatal("the following build command failed with exit code {d}:\n{s}", .{ code, cmd });
src/mingw.zig+7-7
......@@ -19,7 +19,7 @@ pub const CRTFile = enum {
1919 uuid_lib,
2020};
2121
22pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
22pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
2323 if (!build_options.have_llvm) {
2424 return error.ZigCompilerNotBuiltWithLLVMExtensions;
2525 }
......@@ -41,7 +41,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
4141 //"-D_UNICODE",
4242 //"-DWPRFLAG=1",
4343 });
44 return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", &[1]Compilation.CSourceFile{
44 return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &.{
4545 .{
4646 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
4747 "libc", "mingw", "crt", "crtexe.c",
......@@ -60,7 +60,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
6060 "-U__CRTDLL__",
6161 "-D__MSVCRT__",
6262 });
63 return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", &[1]Compilation.CSourceFile{
63 return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &.{
6464 .{
6565 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
6666 "libc", "mingw", "crt", "crtdll.c",
......@@ -100,7 +100,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
100100 .extra_flags = args.items,
101101 };
102102 }
103 return comp.build_crt_file("mingw32", .Lib, .@"mingw-w64 mingw32.lib", &c_source_files);
103 return comp.build_crt_file("mingw32", .Lib, .@"mingw-w64 mingw32.lib", prog_node, &c_source_files);
104104 },
105105
106106 .msvcrt_os_lib => {
......@@ -148,7 +148,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
148148 };
149149 }
150150 }
151 return comp.build_crt_file("msvcrt-os", .Lib, .@"mingw-w64 msvcrt-os.lib", c_source_files.items);
151 return comp.build_crt_file("msvcrt-os", .Lib, .@"mingw-w64 msvcrt-os.lib", prog_node, c_source_files.items);
152152 },
153153
154154 .mingwex_lib => {
......@@ -211,7 +211,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
211211 } else {
212212 @panic("unsupported arch");
213213 }
214 return comp.build_crt_file("mingwex", .Lib, .@"mingw-w64 mingwex.lib", c_source_files.items);
214 return comp.build_crt_file("mingwex", .Lib, .@"mingw-w64 mingwex.lib", prog_node, c_source_files.items);
215215 },
216216
217217 .uuid_lib => {
......@@ -244,7 +244,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
244244 .extra_flags = extra_flags,
245245 };
246246 }
247 return comp.build_crt_file("uuid", .Lib, .@"mingw-w64 uuid.lib", &c_source_files);
247 return comp.build_crt_file("uuid", .Lib, .@"mingw-w64 uuid.lib", prog_node, &c_source_files);
248248 },
249249 }
250250}
src/musl.zig+8-8
......@@ -17,7 +17,7 @@ pub const CRTFile = enum {
1717 libc_so,
1818};
1919
20pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
20pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
2121 if (!build_options.have_llvm) {
2222 return error.ZigCompilerNotBuiltWithLLVMExtensions;
2323 }
......@@ -33,7 +33,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
3333 try args.appendSlice(&[_][]const u8{
3434 "-Qunused-arguments",
3535 });
36 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", &[1]Compilation.CSourceFile{
36 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &.{
3737 .{
3838 .src_path = try start_asm_path(comp, arena, "crti.s"),
3939 .extra_flags = args.items,
......@@ -46,7 +46,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
4646 try args.appendSlice(&[_][]const u8{
4747 "-Qunused-arguments",
4848 });
49 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", &[1]Compilation.CSourceFile{
49 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &.{
5050 .{
5151 .src_path = try start_asm_path(comp, arena, "crtn.s"),
5252 .extra_flags = args.items,
......@@ -60,7 +60,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
6060 "-fno-stack-protector",
6161 "-DCRT",
6262 });
63 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", &[1]Compilation.CSourceFile{
63 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &.{
6464 .{
6565 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
6666 "libc", "musl", "crt", "crt1.c",
......@@ -77,7 +77,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
7777 "-fno-stack-protector",
7878 "-DCRT",
7979 });
80 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", &[1]Compilation.CSourceFile{
80 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &.{
8181 .{
8282 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
8383 "libc", "musl", "crt", "rcrt1.c",
......@@ -94,7 +94,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
9494 "-fno-stack-protector",
9595 "-DCRT",
9696 });
97 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", &[1]Compilation.CSourceFile{
97 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &.{
9898 .{
9999 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
100100 "libc", "musl", "crt", "Scrt1.c",
......@@ -187,7 +187,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
187187 .extra_flags = args.items,
188188 };
189189 }
190 return comp.build_crt_file("c", .Lib, .@"musl libc.a", c_source_files.items);
190 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items);
191191 },
192192 .libc_so => {
193193 const target = comp.getTarget();
......@@ -241,7 +241,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
241241 });
242242 defer sub_compilation.destroy();
243243
244 try comp.updateSubCompilation(sub_compilation, .@"musl libc.so");
244 try comp.updateSubCompilation(sub_compilation, .@"musl libc.so", prog_node);
245245
246246 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);
247247
src/wasi_libc.zig+8-8
......@@ -59,7 +59,7 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co
5959 };
6060}
6161
62pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
62pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
6363 if (!build_options.have_llvm) {
6464 return error.ZigCompilerNotBuiltWithLLVMExtensions;
6565 }
......@@ -74,7 +74,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
7474 var args = std.ArrayList([]const u8).init(arena);
7575 try addCCArgs(comp, arena, &args, false);
7676 try addLibcBottomHalfIncludes(comp, arena, &args);
77 return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", &[1]Compilation.CSourceFile{
77 return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", prog_node, &.{
7878 .{
7979 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
8080 "libc", try sanitize(arena, crt1_reactor_src_file),
......@@ -87,7 +87,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
8787 var args = std.ArrayList([]const u8).init(arena);
8888 try addCCArgs(comp, arena, &args, false);
8989 try addLibcBottomHalfIncludes(comp, arena, &args);
90 return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", &[1]Compilation.CSourceFile{
90 return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", prog_node, &.{
9191 .{
9292 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
9393 "libc", try sanitize(arena, crt1_command_src_file),
......@@ -145,7 +145,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
145145 }
146146 }
147147
148 try comp.build_crt_file("c", .Lib, .@"wasi libc.a", libc_sources.items);
148 try comp.build_crt_file("c", .Lib, .@"wasi libc.a", prog_node, libc_sources.items);
149149 },
150150 .libwasi_emulated_process_clocks_a => {
151151 var args = std.ArrayList([]const u8).init(arena);
......@@ -161,7 +161,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
161161 .extra_flags = args.items,
162162 });
163163 }
164 try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", emu_clocks_sources.items);
164 try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items);
165165 },
166166 .libwasi_emulated_getpid_a => {
167167 var args = std.ArrayList([]const u8).init(arena);
......@@ -177,7 +177,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
177177 .extra_flags = args.items,
178178 });
179179 }
180 try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", emu_getpid_sources.items);
180 try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items);
181181 },
182182 .libwasi_emulated_mman_a => {
183183 var args = std.ArrayList([]const u8).init(arena);
......@@ -193,7 +193,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
193193 .extra_flags = args.items,
194194 });
195195 }
196 try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", emu_mman_sources.items);
196 try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items);
197197 },
198198 .libwasi_emulated_signal_a => {
199199 var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
......@@ -228,7 +228,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
228228 }
229229 }
230230
231 try comp.build_crt_file("wasi-emulated-signal", .Lib, .@"libwasi-emulated-signal.a", emu_signal_sources.items);
231 try comp.build_crt_file("wasi-emulated-signal", .Lib, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items);
232232 },
233233 }
234234}