authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-30 19:14:04+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-30 19:14:04+02:00
loge4fd9acc2a7682d0d64d6d42e2882967cf3877aa
tree420f1acf1527afdcda62e9878342c0cc3533bde2
parentfba33ee58cc3dcd832fe9422be4dc05228afce76

CLI: allow using `--debug-compile-errors` with `zig build`


3 files changed, 12 insertions(+), 0 deletions(-)

lib/build_runner.zig+2
...@@ -142,6 +142,8 @@ pub fn main() !void {...@@ -142,6 +142,8 @@ pub fn main() !void {
142 return usageAndErr(builder, false, stderr_stream);142 return usageAndErr(builder, false, stderr_stream);
143 };143 };
144 try debug_log_scopes.append(next_arg);144 try debug_log_scopes.append(next_arg);
145 } else if (mem.eql(u8, arg, "--debug-compile-errors")) {
146 builder.debug_compile_errors = true;
145 } else if (mem.eql(u8, arg, "--glibc-runtimes")) {147 } else if (mem.eql(u8, arg, "--glibc-runtimes")) {
146 builder.glibc_runtimes_dir = nextArg(args, &arg_idx) orelse {148 builder.glibc_runtimes_dir = nextArg(args, &arg_idx) orelse {
147 std.debug.print("Expected argument after --glibc-runtimes\n\n", .{});149 std.debug.print("Expected argument after --glibc-runtimes\n\n", .{});
lib/std/build.zig+5
...@@ -72,6 +72,7 @@ pub const Builder = struct {...@@ -72,6 +72,7 @@ pub const Builder = struct {
72 pkg_config_pkg_list: ?(PkgConfigError![]const PkgConfigPkg) = null,72 pkg_config_pkg_list: ?(PkgConfigError![]const PkgConfigPkg) = null,
73 args: ?[][]const u8 = null,73 args: ?[][]const u8 = null,
74 debug_log_scopes: []const []const u8 = &.{},74 debug_log_scopes: []const []const u8 = &.{},
75 debug_compile_errors: bool = false,
7576
76 /// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.77 /// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.
77 enable_darling: bool = false,78 enable_darling: bool = false,
...@@ -2686,6 +2687,10 @@ pub const LibExeObjStep = struct {...@@ -2686,6 +2687,10 @@ pub const LibExeObjStep = struct {
2686 try zig_args.append(log_scope);2687 try zig_args.append(log_scope);
2687 }2688 }
26882689
2690 if (builder.debug_compile_errors) {
2691 try zig_args.append("--debug-compile-errors");
2692 }
2693
2689 if (builder.verbose_cimport) zig_args.append("--verbose-cimport") catch unreachable;2694 if (builder.verbose_cimport) zig_args.append("--verbose-cimport") catch unreachable;
2690 if (builder.verbose_air) zig_args.append("--verbose-air") catch unreachable;2695 if (builder.verbose_air) zig_args.append("--verbose-air") catch unreachable;
2691 if (builder.verbose_llvm_ir) zig_args.append("--verbose-llvm-ir") catch unreachable;2696 if (builder.verbose_llvm_ir) zig_args.append("--verbose-llvm-ir") catch unreachable;
src/main.zig+5
...@@ -3778,6 +3778,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -3778,6 +3778,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
3778 var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR");3778 var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR");
3779 var child_argv = std.ArrayList([]const u8).init(arena);3779 var child_argv = std.ArrayList([]const u8).init(arena);
3780 var reference_trace: ?u32 = null;3780 var reference_trace: ?u32 = null;
3781 var debug_compile_errors = false;
37813782
3782 const argv_index_exe = child_argv.items.len;3783 const argv_index_exe = child_argv.items.len;
3783 _ = try child_argv.addOne();3784 _ = try child_argv.addOne();
...@@ -3839,6 +3840,9 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -3839,6 +3840,9 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
3839 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {3840 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {
3840 try child_argv.append(arg);3841 try child_argv.append(arg);
3841 reference_trace = null;3842 reference_trace = null;
3843 } else if (mem.eql(u8, arg, "--debug-compile-errors")) {
3844 try child_argv.append(arg);
3845 debug_compile_errors = true;
3842 }3846 }
3843 }3847 }
3844 try child_argv.append(arg);3848 try child_argv.append(arg);
...@@ -3973,6 +3977,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -3973,6 +3977,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
3973 .use_stage1 = use_stage1,3977 .use_stage1 = use_stage1,
3974 .cache_mode = .whole,3978 .cache_mode = .whole,
3975 .reference_trace = reference_trace,3979 .reference_trace = reference_trace,
3980 .debug_compile_errors = debug_compile_errors,
3976 }) catch |err| {3981 }) catch |err| {
3977 fatal("unable to create compilation: {s}", .{@errorName(err)});3982 fatal("unable to create compilation: {s}", .{@errorName(err)});
3978 };3983 };