authorgravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-06-12 19:54:03+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-24 20:57:36+02:00
logd95dcb2a6238787e18c60f4ae4bfcf8fd757bd0c
tree3d675be046988c9f65047fb7ed834e839dba1b8d
parenta078d55a25ec503158b1b1dfbdfdec2d0fec86aa

std.Build.Step.Compile: remove setExecCmd

This function can be used to prepend a list of arguments when running a test step. Instead, the additional arguments should be manually added to the run step which can handle a broader set of use cases.

5 files changed, 2 insertions(+), 41 deletions(-)

lib/compiler/Maker/Step/Compile.zig-12
......@@ -769,18 +769,6 @@ fn lowerZigArgs(
769769 try zig_args.append(gpa, if (enabled) "--enable-new-dtags" else "--disable-new-dtags");
770770 }
771771
772 if (conf_comp.flags3.kind == .@"test" and conf_comp.exec_cmd_args.slice.len != 0) {
773 for (conf_comp.exec_cmd_args.slice) |cmd_arg| {
774 try zig_args.ensureUnusedCapacity(gpa, 2);
775 if (cmd_arg.slice(conf)) |arg| {
776 zig_args.appendAssumeCapacity("--test-cmd");
777 zig_args.appendAssumeCapacity(arg);
778 } else {
779 zig_args.appendAssumeCapacity("--test-cmd-bin");
780 }
781 }
782 }
783
784772 if (graph.sysroot) |sysroot| try zig_args.appendSlice(gpa, &.{ "--sysroot", sysroot });
785773
786774 // -I and -L arguments that appear after the last --mod argument apply to all modules.
lib/compiler/configurer.zig-3
......@@ -676,7 +676,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
676676 },
677677 .compile => e: {
678678 const c: *Step.Compile = @fieldParentPtr("step", step);
679 const exec_cmd_args: []const ?[]const u8 = c.exec_cmd_args orelse &.{};
680679 const installed_headers: []u32 = try arena.alloc(u32, c.installed_headers.items.len);
681680 for (installed_headers, c.installed_headers.items) |*dst, src| switch (src) {
682681 .file => |file| {
......@@ -703,7 +702,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
703702 break :e try wc.addExtraErased(Configuration.Step.Compile, .{
704703 .flags = .{
705704 .filters_len = c.filters.len != 0,
706 .exec_cmd_args_len = exec_cmd_args.len != 0,
707705 .installed_headers_len = installed_headers.len != 0,
708706 .force_undefined_symbols_len = c.force_undefined_symbols.entries.len != 0,
709707
......@@ -837,7 +835,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
837835 .none, .fast, .uuid, .sha1, .md5 => null,
838836 } else null },
839837 .filters = .{ .slice = try s.initStringList(c.filters) },
840 .exec_cmd_args = .{ .slice = try s.initOptionalStringList(exec_cmd_args) },
841838 .installed_headers = .initErased(installed_headers),
842839 .force_undefined_symbols = .{ .slice = try s.initStringList(c.force_undefined_symbols.keys()) },
843840 .expect_errors = .{ .u = if (c.expect_errors) |x| switch (x) {
lib/std/Build.zig+1-11
......@@ -898,17 +898,7 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
898898 const run_step = Step.Run.create(b, step_name);
899899 run_step.producer = exe;
900900 if (exe.kind == .@"test") {
901 if (exe.exec_cmd_args) |exec_cmd_args| {
902 for (exec_cmd_args) |cmd_arg| {
903 if (cmd_arg) |arg| {
904 run_step.addArg(arg);
905 } else {
906 run_step.addArtifactArg(exe);
907 }
908 }
909 } else {
910 run_step.addArtifactArg(exe);
911 }
901 run_step.addArtifactArg(exe);
912902
913903 const test_server_mode: bool = s: {
914904 if (exe.test_runner) |r| break :s r.mode == .server;
lib/std/Build/Configuration.zig+1-2
......@@ -698,7 +698,6 @@ pub const Step = extern struct {
698698 root_name: String,
699699
700700 filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String),
701 exec_cmd_args: Storage.FlagLengthPrefixedList(.flags, .exec_cmd_args_len, OptionalString),
702701 installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader)),
703702 force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String),
704703 expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors),
......@@ -927,7 +926,6 @@ pub const Step = extern struct {
927926 tag: Tag = .compile,
928927
929928 filters_len: bool,
930 exec_cmd_args_len: bool,
931929 installed_headers_len: bool,
932930 force_undefined_symbols_len: bool,
933931
......@@ -954,6 +952,7 @@ pub const Step = extern struct {
954952 force_load_objc: bool,
955953 discard_local_symbols: bool,
956954 mingw_unicode_entry_point: bool,
955 _: u1 = 0,
957956 };
958957
959958 pub const Flags2 = packed struct(u32) {
lib/std/Build/Step/Compile.zig-13
......@@ -51,7 +51,6 @@ shared_memory: bool = false,
5151global_base: ?u64 = null,
5252/// Set via options; intended to be read-only after that.
5353zig_lib_dir: ?LazyPath,
54exec_cmd_args: ?[]const ?[]const u8,
5554filters: []const []const u8,
5655test_runner: ?TestRunner,
5756wasi_exec_model: ?std.builtin.WasiExecModel = null,
......@@ -419,7 +418,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
419418 .out_filename = out_filename,
420419 .installed_headers = .empty,
421420 .zig_lib_dir = null,
422 .exec_cmd_args = null,
423421 .filters = options.filters,
424422 .test_runner = null, // set below
425423 .rdynamic = false,
......@@ -736,17 +734,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {
736734 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);
737735}
738736
739pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void {
740 const graph = compile.step.owner.graph;
741 const arena = graph.arena;
742 assert(compile.kind == .@"test");
743 const duped_args = arena.alloc(?[]const u8, args.len) catch @panic("OOM");
744 for (args, 0..) |arg, i| {
745 duped_args[i] = if (arg) |a| graph.dupeString(a) else null;
746 }
747 compile.exec_cmd_args = duped_args;
748}
749
750737pub fn rootModuleTarget(c: *Compile) std.Target {
751738 // The root module is always given a target, so we know this to be non-null.
752739 return c.root_module.resolved_target.?.result;