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(...@@ -1847,8 +1847,15 @@ fn cleanupTmpArtifactDirectory(
1847 }1847 }
1848}1848}
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
1850/// Detect changes to source files, perform semantic analysis, and update the output files.1857/// 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 {
1852 const tracy_trace = trace(@src());1859 const tracy_trace = trace(@src());
1853 defer tracy_trace.end();1860 defer tracy_trace.end();
18541861
...@@ -1995,21 +2002,6 @@ pub fn update(comp: *Compilation) !void {...@@ -1995,21 +2002,6 @@ pub fn update(comp: *Compilation) !void {
1995 }2002 }
1996 }2003 }
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
2013 try comp.performAllTheWork(main_progress_node);2005 try comp.performAllTheWork(main_progress_node);
20142006
2015 if (comp.bin_file.options.module) |module| {2007 if (comp.bin_file.options.module) |module| {
...@@ -3057,11 +3049,11 @@ pub fn performAllTheWork(...@@ -3057,11 +3049,11 @@ pub fn performAllTheWork(
3057 // backend, preventing anonymous Decls from being prematurely destroyed.3049 // backend, preventing anonymous Decls from being prematurely destroyed.
3058 while (true) {3050 while (true) {
3059 if (comp.work_queue.readItem()) |work_item| {3051 if (comp.work_queue.readItem()) |work_item| {
3060 try processOneJob(comp, work_item);3052 try processOneJob(comp, work_item, main_progress_node);
3061 continue;3053 continue;
3062 }3054 }
3063 if (comp.anon_work_queue.readItem()) |work_item| {3055 if (comp.anon_work_queue.readItem()) |work_item| {
3064 try processOneJob(comp, work_item);3056 try processOneJob(comp, work_item, main_progress_node);
3065 continue;3057 continue;
3066 }3058 }
3067 break;3059 break;
...@@ -3069,16 +3061,16 @@ pub fn performAllTheWork(...@@ -3069,16 +3061,16 @@ pub fn performAllTheWork(
30693061
3070 if (comp.job_queued_compiler_rt_lib) {3062 if (comp.job_queued_compiler_rt_lib) {
3071 comp.job_queued_compiler_rt_lib = false;3063 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);
3073 }3065 }
30743066
3075 if (comp.job_queued_compiler_rt_obj) {3067 if (comp.job_queued_compiler_rt_obj) {
3076 comp.job_queued_compiler_rt_obj = false;3068 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);
3078 }3070 }
3079}3071}
30803072
3081fn processOneJob(comp: *Compilation, job: Job) !void {3073fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !void {
3082 switch (job) {3074 switch (job) {
3083 .codegen_decl => |decl_index| {3075 .codegen_decl => |decl_index| {
3084 const module = comp.bin_file.options.module.?;3076 const module = comp.bin_file.options.module.?;
...@@ -3230,7 +3222,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3230,7 +3222,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3230 const named_frame = tracy.namedFrame("glibc_crt_file");3222 const named_frame = tracy.namedFrame("glibc_crt_file");
3231 defer named_frame.end();3223 defer named_frame.end();
32323224
3233 glibc.buildCRTFile(comp, crt_file) catch |err| {3225 glibc.buildCRTFile(comp, crt_file, prog_node) catch |err| {
3234 // TODO Surface more error details.3226 // TODO Surface more error details.
3235 comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{3227 comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{
3236 @errorName(err),3228 @errorName(err),
...@@ -3241,7 +3233,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3241,7 +3233,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3241 const named_frame = tracy.namedFrame("glibc_shared_objects");3233 const named_frame = tracy.namedFrame("glibc_shared_objects");
3242 defer named_frame.end();3234 defer named_frame.end();
32433235
3244 glibc.buildSharedObjects(comp) catch |err| {3236 glibc.buildSharedObjects(comp, prog_node) catch |err| {
3245 // TODO Surface more error details.3237 // TODO Surface more error details.
3246 comp.lockAndSetMiscFailure(3238 comp.lockAndSetMiscFailure(
3247 .glibc_shared_objects,3239 .glibc_shared_objects,
...@@ -3254,7 +3246,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3254,7 +3246,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3254 const named_frame = tracy.namedFrame("musl_crt_file");3246 const named_frame = tracy.namedFrame("musl_crt_file");
3255 defer named_frame.end();3247 defer named_frame.end();
32563248
3257 musl.buildCRTFile(comp, crt_file) catch |err| {3249 musl.buildCRTFile(comp, crt_file, prog_node) catch |err| {
3258 // TODO Surface more error details.3250 // TODO Surface more error details.
3259 comp.lockAndSetMiscFailure(3251 comp.lockAndSetMiscFailure(
3260 .musl_crt_file,3252 .musl_crt_file,
...@@ -3267,7 +3259,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3267,7 +3259,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3267 const named_frame = tracy.namedFrame("mingw_crt_file");3259 const named_frame = tracy.namedFrame("mingw_crt_file");
3268 defer named_frame.end();3260 defer named_frame.end();
32693261
3270 mingw.buildCRTFile(comp, crt_file) catch |err| {3262 mingw.buildCRTFile(comp, crt_file, prog_node) catch |err| {
3271 // TODO Surface more error details.3263 // TODO Surface more error details.
3272 comp.lockAndSetMiscFailure(3264 comp.lockAndSetMiscFailure(
3273 .mingw_crt_file,3265 .mingw_crt_file,
...@@ -3294,7 +3286,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3294,7 +3286,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3294 const named_frame = tracy.namedFrame("libunwind");3286 const named_frame = tracy.namedFrame("libunwind");
3295 defer named_frame.end();3287 defer named_frame.end();
32963288
3297 libunwind.buildStaticLib(comp) catch |err| {3289 libunwind.buildStaticLib(comp, prog_node) catch |err| {
3298 // TODO Surface more error details.3290 // TODO Surface more error details.
3299 comp.lockAndSetMiscFailure(3291 comp.lockAndSetMiscFailure(
3300 .libunwind,3292 .libunwind,
...@@ -3307,7 +3299,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3307,7 +3299,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3307 const named_frame = tracy.namedFrame("libcxx");3299 const named_frame = tracy.namedFrame("libcxx");
3308 defer named_frame.end();3300 defer named_frame.end();
33093301
3310 libcxx.buildLibCXX(comp) catch |err| {3302 libcxx.buildLibCXX(comp, prog_node) catch |err| {
3311 // TODO Surface more error details.3303 // TODO Surface more error details.
3312 comp.lockAndSetMiscFailure(3304 comp.lockAndSetMiscFailure(
3313 .libcxx,3305 .libcxx,
...@@ -3320,7 +3312,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3320,7 +3312,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3320 const named_frame = tracy.namedFrame("libcxxabi");3312 const named_frame = tracy.namedFrame("libcxxabi");
3321 defer named_frame.end();3313 defer named_frame.end();
33223314
3323 libcxx.buildLibCXXABI(comp) catch |err| {3315 libcxx.buildLibCXXABI(comp, prog_node) catch |err| {
3324 // TODO Surface more error details.3316 // TODO Surface more error details.
3325 comp.lockAndSetMiscFailure(3317 comp.lockAndSetMiscFailure(
3326 .libcxxabi,3318 .libcxxabi,
...@@ -3333,7 +3325,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3333,7 +3325,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3333 const named_frame = tracy.namedFrame("libtsan");3325 const named_frame = tracy.namedFrame("libtsan");
3334 defer named_frame.end();3326 defer named_frame.end();
33353327
3336 libtsan.buildTsan(comp) catch |err| {3328 libtsan.buildTsan(comp, prog_node) catch |err| {
3337 // TODO Surface more error details.3329 // TODO Surface more error details.
3338 comp.lockAndSetMiscFailure(3330 comp.lockAndSetMiscFailure(
3339 .libtsan,3331 .libtsan,
...@@ -3346,7 +3338,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3346,7 +3338,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3346 const named_frame = tracy.namedFrame("wasi_libc_crt_file");3338 const named_frame = tracy.namedFrame("wasi_libc_crt_file");
3347 defer named_frame.end();3339 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| {
3350 // TODO Surface more error details.3342 // TODO Surface more error details.
3351 comp.lockAndSetMiscFailure(3343 comp.lockAndSetMiscFailure(
3352 .wasi_libc_crt_file,3344 .wasi_libc_crt_file,
...@@ -3364,6 +3356,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3364,6 +3356,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3364 .Lib,3356 .Lib,
3365 &comp.libssp_static_lib,3357 &comp.libssp_static_lib,
3366 .libssp,3358 .libssp,
3359 prog_node,
3367 ) catch |err| switch (err) {3360 ) catch |err| switch (err) {
3368 error.OutOfMemory => return error.OutOfMemory,3361 error.OutOfMemory => return error.OutOfMemory,
3369 error.SubCompilationFailed => return, // error reported already3362 error.SubCompilationFailed => return, // error reported already
...@@ -3383,6 +3376,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {...@@ -3383,6 +3376,7 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
3383 .Lib,3376 .Lib,
3384 &comp.libc_static_lib,3377 &comp.libc_static_lib,
3385 .zig_libc,3378 .zig_libc,
3379 prog_node,
3386 ) catch |err| switch (err) {3380 ) catch |err| switch (err) {
3387 error.OutOfMemory => return error.OutOfMemory,3381 error.OutOfMemory => return error.OutOfMemory,
3388 error.SubCompilationFailed => return, // error reported already3382 error.SubCompilationFailed => return, // error reported already
...@@ -3723,8 +3717,15 @@ fn buildCompilerRtOneShot(...@@ -3723,8 +3717,15 @@ fn buildCompilerRtOneShot(
3723 comp: *Compilation,3717 comp: *Compilation,
3724 output_mode: std.builtin.OutputMode,3718 output_mode: std.builtin.OutputMode,
3725 out: *?CRTFile,3719 out: *?CRTFile,
3720 prog_node: *std.Progress.Node,
3726) void {3721) 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) {
3728 error.SubCompilationFailed => return, // error reported already3729 error.SubCompilationFailed => return, // error reported already
3729 else => comp.lockAndSetMiscFailure(3730 else => comp.lockAndSetMiscFailure(
3730 .compiler_rt,3731 .compiler_rt,
...@@ -5248,8 +5249,15 @@ pub fn updateSubCompilation(...@@ -5248,8 +5249,15 @@ pub fn updateSubCompilation(
5248 parent_comp: *Compilation,5249 parent_comp: *Compilation,
5249 sub_comp: *Compilation,5250 sub_comp: *Compilation,
5250 misc_task: MiscTask,5251 misc_task: MiscTask,
5252 prog_node: *std.Progress.Node,
5251) !void {5253) !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
5254 // Look for compilation errors in this sub compilation5262 // Look for compilation errors in this sub compilation
5255 const gpa = parent_comp.gpa;5263 const gpa = parent_comp.gpa;
...@@ -5276,6 +5284,7 @@ fn buildOutputFromZig(...@@ -5276,6 +5284,7 @@ fn buildOutputFromZig(
5276 output_mode: std.builtin.OutputMode,5284 output_mode: std.builtin.OutputMode,
5277 out: *?CRTFile,5285 out: *?CRTFile,
5278 misc_task_tag: MiscTask,5286 misc_task_tag: MiscTask,
5287 prog_node: *std.Progress.Node,
5279) !void {5288) !void {
5280 const tracy_trace = trace(@src());5289 const tracy_trace = trace(@src());
5281 defer tracy_trace.end();5290 defer tracy_trace.end();
...@@ -5342,7 +5351,7 @@ fn buildOutputFromZig(...@@ -5342,7 +5351,7 @@ fn buildOutputFromZig(
5342 });5351 });
5343 defer sub_compilation.destroy();5352 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
5347 assert(out.* == null);5356 assert(out.* == null);
5348 out.* = Compilation.CRTFile{5357 out.* = Compilation.CRTFile{
...@@ -5358,6 +5367,7 @@ pub fn build_crt_file(...@@ -5358,6 +5367,7 @@ pub fn build_crt_file(
5358 root_name: []const u8,5367 root_name: []const u8,
5359 output_mode: std.builtin.OutputMode,5368 output_mode: std.builtin.OutputMode,
5360 misc_task_tag: MiscTask,5369 misc_task_tag: MiscTask,
5370 prog_node: *std.Progress.Node,
5361 c_source_files: []const Compilation.CSourceFile,5371 c_source_files: []const Compilation.CSourceFile,
5362) !void {5372) !void {
5363 const tracy_trace = trace(@src());5373 const tracy_trace = trace(@src());
...@@ -5418,7 +5428,7 @@ pub fn build_crt_file(...@@ -5418,7 +5428,7 @@ pub fn build_crt_file(
5418 });5428 });
5419 defer sub_compilation.destroy();5429 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
5423 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);5433 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);
54245434
...@@ -5470,10 +5480,3 @@ pub fn compilerRtStrip(comp: Compilation) bool {...@@ -5470,10 +5480,3 @@ pub fn compilerRtStrip(comp: Compilation) bool {
5470 return true;5480 return true;
5471 }5481 }
5472}5482}
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 {...@@ -161,7 +161,7 @@ pub const CRTFile = enum {
161 libc_nonshared_a,161 libc_nonshared_a,
162};162};
163163
164pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {164pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
165 if (!build_options.have_llvm) {165 if (!build_options.have_llvm) {
166 return error.ZigCompilerNotBuiltWithLLVMExtensions;166 return error.ZigCompilerNotBuiltWithLLVMExtensions;
167 }167 }
...@@ -196,7 +196,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -196,7 +196,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
196 "-DASSEMBLER",196 "-DASSEMBLER",
197 "-Wa,--noexecstack",197 "-Wa,--noexecstack",
198 });198 });
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, &.{
200 .{200 .{
201 .src_path = try start_asm_path(comp, arena, "crti.S"),201 .src_path = try start_asm_path(comp, arena, "crti.S"),
202 .cache_exempt_flags = args.items,202 .cache_exempt_flags = args.items,
...@@ -215,7 +215,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -215,7 +215,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
215 "-DASSEMBLER",215 "-DASSEMBLER",
216 "-Wa,--noexecstack",216 "-Wa,--noexecstack",
217 });217 });
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, &.{
219 .{219 .{
220 .src_path = try start_asm_path(comp, arena, "crtn.S"),220 .src_path = try start_asm_path(comp, arena, "crtn.S"),
221 .cache_exempt_flags = args.items,221 .cache_exempt_flags = args.items,
...@@ -265,7 +265,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -265,7 +265,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
265 .cache_exempt_flags = args.items,265 .cache_exempt_flags = args.items,
266 };266 };
267 };267 };
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 });
269 },271 },
270 .libc_nonshared_a => {272 .libc_nonshared_a => {
271 const s = path.sep_str;273 const s = path.sep_str;
...@@ -366,7 +368,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -366,7 +368,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
366 files_index += 1;368 files_index += 1;
367 }369 }
368 const files = files_buf[0..files_index];370 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);
370 },372 },
371 }373 }
372}374}
...@@ -639,7 +641,7 @@ pub const BuiltSharedObjects = struct {...@@ -639,7 +641,7 @@ pub const BuiltSharedObjects = struct {
639641
640const all_map_basename = "all.map";642const all_map_basename = "all.map";
641643
642pub fn buildSharedObjects(comp: *Compilation) !void {644pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !void {
643 const tracy = trace(@src());645 const tracy = trace(@src());
644 defer tracy.end();646 defer tracy.end();
645647
...@@ -1023,7 +1025,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void {...@@ -1023,7 +1025,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void {
1023 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;1025 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
1024 try o_directory.handle.writeFile(asm_file_basename, stubs_asm.items);1026 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);
1027 }1029 }
10281030
1029 man.writeManifest() catch |err| {1031 man.writeManifest() catch |err| {
...@@ -1046,6 +1048,7 @@ fn buildSharedLib(...@@ -1046,6 +1048,7 @@ fn buildSharedLib(
1046 bin_directory: Compilation.Directory,1048 bin_directory: Compilation.Directory,
1047 asm_file_basename: []const u8,1049 asm_file_basename: []const u8,
1048 lib: Lib,1050 lib: Lib,
1051 prog_node: *std.Progress.Node,
1049) !void {1052) !void {
1050 const tracy = trace(@src());1053 const tracy = trace(@src());
1051 defer tracy.end();1054 defer tracy.end();
...@@ -1105,7 +1108,7 @@ fn buildSharedLib(...@@ -1105,7 +1108,7 @@ fn buildSharedLib(
1105 });1108 });
1106 defer sub_compilation.destroy();1109 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);
1109}1112}
11101113
1111// Return true if glibc has crti/crtn sources for that architecture.1114// 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{...@@ -96,7 +96,7 @@ const libcxx_files = [_][]const u8{
96 "src/verbose_abort.cpp",96 "src/verbose_abort.cpp",
97};97};
9898
99pub fn buildLibCXX(comp: *Compilation) !void {99pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
100 if (!build_options.have_llvm) {100 if (!build_options.have_llvm) {
101 return error.ZigCompilerNotBuiltWithLLVMExtensions;101 return error.ZigCompilerNotBuiltWithLLVMExtensions;
102 }102 }
...@@ -258,7 +258,7 @@ pub fn buildLibCXX(comp: *Compilation) !void {...@@ -258,7 +258,7 @@ pub fn buildLibCXX(comp: *Compilation) !void {
258 });258 });
259 defer sub_compilation.destroy();259 defer sub_compilation.destroy();
260260
261 try comp.updateSubCompilation(sub_compilation, .libcxx);261 try comp.updateSubCompilation(sub_compilation, .libcxx, prog_node);
262262
263 assert(comp.libcxx_static_lib == null);263 assert(comp.libcxx_static_lib == null);
264 comp.libcxx_static_lib = Compilation.CRTFile{264 comp.libcxx_static_lib = Compilation.CRTFile{
...@@ -269,7 +269,7 @@ pub fn buildLibCXX(comp: *Compilation) !void {...@@ -269,7 +269,7 @@ pub fn buildLibCXX(comp: *Compilation) !void {
269 };269 };
270}270}
271271
272pub fn buildLibCXXABI(comp: *Compilation) !void {272pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
273 if (!build_options.have_llvm) {273 if (!build_options.have_llvm) {
274 return error.ZigCompilerNotBuiltWithLLVMExtensions;274 return error.ZigCompilerNotBuiltWithLLVMExtensions;
275 }275 }
...@@ -418,7 +418,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {...@@ -418,7 +418,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {
418 });418 });
419 defer sub_compilation.destroy();419 defer sub_compilation.destroy();
420420
421 try comp.updateSubCompilation(sub_compilation, .libcxxabi);421 try comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node);
422422
423 assert(comp.libcxxabi_static_lib == null);423 assert(comp.libcxxabi_static_lib == null);
424 comp.libcxxabi_static_lib = Compilation.CRTFile{424 comp.libcxxabi_static_lib = Compilation.CRTFile{
src/libtsan.zig+2-2
...@@ -5,7 +5,7 @@ const Compilation = @import("Compilation.zig");...@@ -5,7 +5,7 @@ const Compilation = @import("Compilation.zig");
5const build_options = @import("build_options");5const build_options = @import("build_options");
6const trace = @import("tracy.zig").trace;6const trace = @import("tracy.zig").trace;
77
8pub fn buildTsan(comp: *Compilation) !void {8pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
9 if (!build_options.have_llvm) {9 if (!build_options.have_llvm) {
10 return error.ZigCompilerNotBuiltWithLLVMExtensions;10 return error.ZigCompilerNotBuiltWithLLVMExtensions;
11 }11 }
...@@ -235,7 +235,7 @@ pub fn buildTsan(comp: *Compilation) !void {...@@ -235,7 +235,7 @@ pub fn buildTsan(comp: *Compilation) !void {
235 });235 });
236 defer sub_compilation.destroy();236 defer sub_compilation.destroy();
237237
238 try comp.updateSubCompilation(sub_compilation, .libtsan);238 try comp.updateSubCompilation(sub_compilation, .libtsan, prog_node);
239239
240 assert(comp.tsan_static_lib == null);240 assert(comp.tsan_static_lib == null);
241 comp.tsan_static_lib = Compilation.CRTFile{241 comp.tsan_static_lib = Compilation.CRTFile{
src/libunwind.zig+2-2
...@@ -7,7 +7,7 @@ const Compilation = @import("Compilation.zig");...@@ -7,7 +7,7 @@ const Compilation = @import("Compilation.zig");
7const build_options = @import("build_options");7const build_options = @import("build_options");
8const trace = @import("tracy.zig").trace;8const trace = @import("tracy.zig").trace;
99
10pub fn buildStaticLib(comp: *Compilation) !void {10pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
11 if (!build_options.have_llvm) {11 if (!build_options.have_llvm) {
12 return error.ZigCompilerNotBuiltWithLLVMExtensions;12 return error.ZigCompilerNotBuiltWithLLVMExtensions;
13 }13 }
...@@ -130,7 +130,7 @@ pub fn buildStaticLib(comp: *Compilation) !void {...@@ -130,7 +130,7 @@ pub fn buildStaticLib(comp: *Compilation) !void {
130 });130 });
131 defer sub_compilation.destroy();131 defer sub_compilation.destroy();
132132
133 try comp.updateSubCompilation(sub_compilation, .libunwind);133 try comp.updateSubCompilation(sub_compilation, .libunwind, prog_node);
134134
135 assert(comp.libunwind_static_lib == null);135 assert(comp.libunwind_static_lib == null);
136136
src/main.zig+44-4
...@@ -3543,6 +3543,23 @@ fn serve(...@@ -3543,6 +3543,23 @@ fn serve(
3543 var receive_fifo = std.fifo.LinearFifo(u8, .Dynamic).init(gpa);3543 var receive_fifo = std.fifo.LinearFifo(u8, .Dynamic).init(gpa);
3544 defer receive_fifo.deinit();3544 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
3546 while (true) {3563 while (true) {
3547 const hdr = try receiveMessage(in, &receive_fifo);3564 const hdr = try receiveMessage(in, &receive_fifo);
35483565
...@@ -3551,11 +3568,12 @@ fn serve(...@@ -3551,11 +3568,12 @@ fn serve(
3551 return cleanExit();3568 return cleanExit();
3552 },3569 },
3553 .update => {3570 .update => {
3571 assert(main_progress_node.recently_updated_child == null);
3554 tracy.frameMark();3572 tracy.frameMark();
3555 if (comp.bin_file.options.output_mode == .Exe) {3573 if (comp.bin_file.options.output_mode == .Exe) {
3556 try comp.makeBinFileWritable();3574 try comp.makeBinFileWritable();
3557 }3575 }
3558 try comp.update();3576 try comp.update(main_progress_node);
3559 try comp.makeBinFileExecutable();3577 try comp.makeBinFileExecutable();
3560 try serveUpdateResults(out, comp);3578 try serveUpdateResults(out, comp);
3561 },3579 },
...@@ -3581,14 +3599,15 @@ fn serve(...@@ -3581,14 +3599,15 @@ fn serve(
3581 },3599 },
3582 .hot_update => {3600 .hot_update => {
3583 tracy.frameMark();3601 tracy.frameMark();
3602 assert(main_progress_node.recently_updated_child == null);
3584 if (child_pid) |pid| {3603 if (child_pid) |pid| {
3585 try comp.hotCodeSwap(pid);3604 try comp.hotCodeSwap(main_progress_node, pid);
3586 try serveUpdateResults(out, comp);3605 try serveUpdateResults(out, comp);
3587 } else {3606 } else {
3588 if (comp.bin_file.options.output_mode == .Exe) {3607 if (comp.bin_file.options.output_mode == .Exe) {
3589 try comp.makeBinFileWritable();3608 try comp.makeBinFileWritable();
3590 }3609 }
3591 try comp.update();3610 try comp.update(main_progress_node);
3592 try comp.makeBinFileExecutable();3611 try comp.makeBinFileExecutable();
3593 try serveUpdateResults(out, comp);3612 try serveUpdateResults(out, comp);
35943613
...@@ -3936,7 +3955,24 @@ const AfterUpdateHook = union(enum) {...@@ -3936,7 +3955,24 @@ const AfterUpdateHook = union(enum) {
3936};3955};
39373956
3938fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void {3957fn 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
3941 var errors = try comp.getAllErrorsAlloc();3977 var errors = try comp.getAllErrorsAlloc();
3942 defer errors.deinit(comp.gpa);3978 defer errors.deinit(comp.gpa);
...@@ -4642,6 +4678,10 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -4642,6 +4678,10 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
4642 switch (term) {4678 switch (term) {
4643 .Exited => |code| {4679 .Exited => |code| {
4644 if (code == 0) return cleanExit();4680 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
4646 const cmd = try std.mem.join(arena, " ", child_argv);4686 const cmd = try std.mem.join(arena, " ", child_argv);
4647 fatal("the following build command failed with exit code {d}:\n{s}", .{ code, cmd });4687 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 {...@@ -19,7 +19,7 @@ pub const CRTFile = enum {
19 uuid_lib,19 uuid_lib,
20};20};
2121
22pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {22pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
23 if (!build_options.have_llvm) {23 if (!build_options.have_llvm) {
24 return error.ZigCompilerNotBuiltWithLLVMExtensions;24 return error.ZigCompilerNotBuiltWithLLVMExtensions;
25 }25 }
...@@ -41,7 +41,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -41,7 +41,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
41 //"-D_UNICODE",41 //"-D_UNICODE",
42 //"-DWPRFLAG=1",42 //"-DWPRFLAG=1",
43 });43 });
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, &.{
45 .{45 .{
46 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{46 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
47 "libc", "mingw", "crt", "crtexe.c",47 "libc", "mingw", "crt", "crtexe.c",
...@@ -60,7 +60,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -60,7 +60,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
60 "-U__CRTDLL__",60 "-U__CRTDLL__",
61 "-D__MSVCRT__",61 "-D__MSVCRT__",
62 });62 });
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, &.{
64 .{64 .{
65 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{65 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
66 "libc", "mingw", "crt", "crtdll.c",66 "libc", "mingw", "crt", "crtdll.c",
...@@ -100,7 +100,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -100,7 +100,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
100 .extra_flags = args.items,100 .extra_flags = args.items,
101 };101 };
102 }102 }
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);
104 },104 },
105105
106 .msvcrt_os_lib => {106 .msvcrt_os_lib => {
...@@ -148,7 +148,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -148,7 +148,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
148 };148 };
149 }149 }
150 }150 }
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);
152 },152 },
153153
154 .mingwex_lib => {154 .mingwex_lib => {
...@@ -211,7 +211,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -211,7 +211,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
211 } else {211 } else {
212 @panic("unsupported arch");212 @panic("unsupported arch");
213 }213 }
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);
215 },215 },
216216
217 .uuid_lib => {217 .uuid_lib => {
...@@ -244,7 +244,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -244,7 +244,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
244 .extra_flags = extra_flags,244 .extra_flags = extra_flags,
245 };245 };
246 }246 }
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);
248 },248 },
249 }249 }
250}250}
src/musl.zig+8-8
...@@ -17,7 +17,7 @@ pub const CRTFile = enum {...@@ -17,7 +17,7 @@ pub const CRTFile = enum {
17 libc_so,17 libc_so,
18};18};
1919
20pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {20pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
21 if (!build_options.have_llvm) {21 if (!build_options.have_llvm) {
22 return error.ZigCompilerNotBuiltWithLLVMExtensions;22 return error.ZigCompilerNotBuiltWithLLVMExtensions;
23 }23 }
...@@ -33,7 +33,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -33,7 +33,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
33 try args.appendSlice(&[_][]const u8{33 try args.appendSlice(&[_][]const u8{
34 "-Qunused-arguments",34 "-Qunused-arguments",
35 });35 });
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, &.{
37 .{37 .{
38 .src_path = try start_asm_path(comp, arena, "crti.s"),38 .src_path = try start_asm_path(comp, arena, "crti.s"),
39 .extra_flags = args.items,39 .extra_flags = args.items,
...@@ -46,7 +46,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -46,7 +46,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
46 try args.appendSlice(&[_][]const u8{46 try args.appendSlice(&[_][]const u8{
47 "-Qunused-arguments",47 "-Qunused-arguments",
48 });48 });
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, &.{
50 .{50 .{
51 .src_path = try start_asm_path(comp, arena, "crtn.s"),51 .src_path = try start_asm_path(comp, arena, "crtn.s"),
52 .extra_flags = args.items,52 .extra_flags = args.items,
...@@ -60,7 +60,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -60,7 +60,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
60 "-fno-stack-protector",60 "-fno-stack-protector",
61 "-DCRT",61 "-DCRT",
62 });62 });
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, &.{
64 .{64 .{
65 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{65 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
66 "libc", "musl", "crt", "crt1.c",66 "libc", "musl", "crt", "crt1.c",
...@@ -77,7 +77,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -77,7 +77,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
77 "-fno-stack-protector",77 "-fno-stack-protector",
78 "-DCRT",78 "-DCRT",
79 });79 });
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, &.{
81 .{81 .{
82 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{82 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
83 "libc", "musl", "crt", "rcrt1.c",83 "libc", "musl", "crt", "rcrt1.c",
...@@ -94,7 +94,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -94,7 +94,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
94 "-fno-stack-protector",94 "-fno-stack-protector",
95 "-DCRT",95 "-DCRT",
96 });96 });
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, &.{
98 .{98 .{
99 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{99 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
100 "libc", "musl", "crt", "Scrt1.c",100 "libc", "musl", "crt", "Scrt1.c",
...@@ -187,7 +187,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -187,7 +187,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
187 .extra_flags = args.items,187 .extra_flags = args.items,
188 };188 };
189 }189 }
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);
191 },191 },
192 .libc_so => {192 .libc_so => {
193 const target = comp.getTarget();193 const target = comp.getTarget();
...@@ -241,7 +241,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -241,7 +241,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
241 });241 });
242 defer sub_compilation.destroy();242 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
246 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);246 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...@@ -59,7 +59,7 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co
59 };59 };
60}60}
6161
62pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {62pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progress.Node) !void {
63 if (!build_options.have_llvm) {63 if (!build_options.have_llvm) {
64 return error.ZigCompilerNotBuiltWithLLVMExtensions;64 return error.ZigCompilerNotBuiltWithLLVMExtensions;
65 }65 }
...@@ -74,7 +74,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -74,7 +74,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
74 var args = std.ArrayList([]const u8).init(arena);74 var args = std.ArrayList([]const u8).init(arena);
75 try addCCArgs(comp, arena, &args, false);75 try addCCArgs(comp, arena, &args, false);
76 try addLibcBottomHalfIncludes(comp, arena, &args);76 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, &.{
78 .{78 .{
79 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{79 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
80 "libc", try sanitize(arena, crt1_reactor_src_file),80 "libc", try sanitize(arena, crt1_reactor_src_file),
...@@ -87,7 +87,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -87,7 +87,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
87 var args = std.ArrayList([]const u8).init(arena);87 var args = std.ArrayList([]const u8).init(arena);
88 try addCCArgs(comp, arena, &args, false);88 try addCCArgs(comp, arena, &args, false);
89 try addLibcBottomHalfIncludes(comp, arena, &args);89 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, &.{
91 .{91 .{
92 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{92 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
93 "libc", try sanitize(arena, crt1_command_src_file),93 "libc", try sanitize(arena, crt1_command_src_file),
...@@ -145,7 +145,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -145,7 +145,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
145 }145 }
146 }146 }
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);
149 },149 },
150 .libwasi_emulated_process_clocks_a => {150 .libwasi_emulated_process_clocks_a => {
151 var args = std.ArrayList([]const u8).init(arena);151 var args = std.ArrayList([]const u8).init(arena);
...@@ -161,7 +161,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -161,7 +161,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
161 .extra_flags = args.items,161 .extra_flags = args.items,
162 });162 });
163 }163 }
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);
165 },165 },
166 .libwasi_emulated_getpid_a => {166 .libwasi_emulated_getpid_a => {
167 var args = std.ArrayList([]const u8).init(arena);167 var args = std.ArrayList([]const u8).init(arena);
...@@ -177,7 +177,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -177,7 +177,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
177 .extra_flags = args.items,177 .extra_flags = args.items,
178 });178 });
179 }179 }
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);
181 },181 },
182 .libwasi_emulated_mman_a => {182 .libwasi_emulated_mman_a => {
183 var args = std.ArrayList([]const u8).init(arena);183 var args = std.ArrayList([]const u8).init(arena);
...@@ -193,7 +193,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -193,7 +193,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
193 .extra_flags = args.items,193 .extra_flags = args.items,
194 });194 });
195 }195 }
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);
197 },197 },
198 .libwasi_emulated_signal_a => {198 .libwasi_emulated_signal_a => {
199 var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena);199 var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
...@@ -228,7 +228,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -228,7 +228,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
228 }228 }
229 }229 }
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);
232 },232 },
233 }233 }
234}234}