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(...@@ -769,18 +769,6 @@ fn lowerZigArgs(
769 try zig_args.append(gpa, if (enabled) "--enable-new-dtags" else "--disable-new-dtags");769 try zig_args.append(gpa, if (enabled) "--enable-new-dtags" else "--disable-new-dtags");
770 }770 }
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
784 if (graph.sysroot) |sysroot| try zig_args.appendSlice(gpa, &.{ "--sysroot", sysroot });772 if (graph.sysroot) |sysroot| try zig_args.appendSlice(gpa, &.{ "--sysroot", sysroot });
785773
786 // -I and -L arguments that appear after the last --mod argument apply to all modules.774 // -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 {...@@ -676,7 +676,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
676 },676 },
677 .compile => e: {677 .compile => e: {
678 const c: *Step.Compile = @fieldParentPtr("step", step);678 const c: *Step.Compile = @fieldParentPtr("step", step);
679 const exec_cmd_args: []const ?[]const u8 = c.exec_cmd_args orelse &.{};
680 const installed_headers: []u32 = try arena.alloc(u32, c.installed_headers.items.len);679 const installed_headers: []u32 = try arena.alloc(u32, c.installed_headers.items.len);
681 for (installed_headers, c.installed_headers.items) |*dst, src| switch (src) {680 for (installed_headers, c.installed_headers.items) |*dst, src| switch (src) {
682 .file => |file| {681 .file => |file| {
...@@ -703,7 +702,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {...@@ -703,7 +702,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
703 break :e try wc.addExtraErased(Configuration.Step.Compile, .{702 break :e try wc.addExtraErased(Configuration.Step.Compile, .{
704 .flags = .{703 .flags = .{
705 .filters_len = c.filters.len != 0,704 .filters_len = c.filters.len != 0,
706 .exec_cmd_args_len = exec_cmd_args.len != 0,
707 .installed_headers_len = installed_headers.len != 0,705 .installed_headers_len = installed_headers.len != 0,
708 .force_undefined_symbols_len = c.force_undefined_symbols.entries.len != 0,706 .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 {...@@ -837,7 +835,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
837 .none, .fast, .uuid, .sha1, .md5 => null,835 .none, .fast, .uuid, .sha1, .md5 => null,
838 } else null },836 } else null },
839 .filters = .{ .slice = try s.initStringList(c.filters) },837 .filters = .{ .slice = try s.initStringList(c.filters) },
840 .exec_cmd_args = .{ .slice = try s.initOptionalStringList(exec_cmd_args) },
841 .installed_headers = .initErased(installed_headers),838 .installed_headers = .initErased(installed_headers),
842 .force_undefined_symbols = .{ .slice = try s.initStringList(c.force_undefined_symbols.keys()) },839 .force_undefined_symbols = .{ .slice = try s.initStringList(c.force_undefined_symbols.keys()) },
843 .expect_errors = .{ .u = if (c.expect_errors) |x| switch (x) {840 .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 {...@@ -898,17 +898,7 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
898 const run_step = Step.Run.create(b, step_name);898 const run_step = Step.Run.create(b, step_name);
899 run_step.producer = exe;899 run_step.producer = exe;
900 if (exe.kind == .@"test") {900 if (exe.kind == .@"test") {
901 if (exe.exec_cmd_args) |exec_cmd_args| {901 run_step.addArtifactArg(exe);
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 }
912902
913 const test_server_mode: bool = s: {903 const test_server_mode: bool = s: {
914 if (exe.test_runner) |r| break :s r.mode == .server;904 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 {...@@ -698,7 +698,6 @@ pub const Step = extern struct {
698 root_name: String,698 root_name: String,
699699
700 filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String),700 filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String),
701 exec_cmd_args: Storage.FlagLengthPrefixedList(.flags, .exec_cmd_args_len, OptionalString),
702 installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader)),701 installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader)),
703 force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String),702 force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String),
704 expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors),703 expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors),
...@@ -927,7 +926,6 @@ pub const Step = extern struct {...@@ -927,7 +926,6 @@ pub const Step = extern struct {
927 tag: Tag = .compile,926 tag: Tag = .compile,
928927
929 filters_len: bool,928 filters_len: bool,
930 exec_cmd_args_len: bool,
931 installed_headers_len: bool,929 installed_headers_len: bool,
932 force_undefined_symbols_len: bool,930 force_undefined_symbols_len: bool,
933931
...@@ -954,6 +952,7 @@ pub const Step = extern struct {...@@ -954,6 +952,7 @@ pub const Step = extern struct {
954 force_load_objc: bool,952 force_load_objc: bool,
955 discard_local_symbols: bool,953 discard_local_symbols: bool,
956 mingw_unicode_entry_point: bool,954 mingw_unicode_entry_point: bool,
955 _: u1 = 0,
957 };956 };
958957
959 pub const Flags2 = packed struct(u32) {958 pub const Flags2 = packed struct(u32) {
lib/std/Build/Step/Compile.zig-13
...@@ -51,7 +51,6 @@ shared_memory: bool = false,...@@ -51,7 +51,6 @@ shared_memory: bool = false,
51global_base: ?u64 = null,51global_base: ?u64 = null,
52/// Set via options; intended to be read-only after that.52/// Set via options; intended to be read-only after that.
53zig_lib_dir: ?LazyPath,53zig_lib_dir: ?LazyPath,
54exec_cmd_args: ?[]const ?[]const u8,
55filters: []const []const u8,54filters: []const []const u8,
56test_runner: ?TestRunner,55test_runner: ?TestRunner,
57wasi_exec_model: ?std.builtin.WasiExecModel = null,56wasi_exec_model: ?std.builtin.WasiExecModel = null,
...@@ -419,7 +418,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile {...@@ -419,7 +418,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
419 .out_filename = out_filename,418 .out_filename = out_filename,
420 .installed_headers = .empty,419 .installed_headers = .empty,
421 .zig_lib_dir = null,420 .zig_lib_dir = null,
422 .exec_cmd_args = null,
423 .filters = options.filters,421 .filters = options.filters,
424 .test_runner = null, // set below422 .test_runner = null, // set below
425 .rdynamic = false,423 .rdynamic = false,
...@@ -736,17 +734,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {...@@ -736,17 +734,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {
736 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);734 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);
737}735}
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
750pub fn rootModuleTarget(c: *Compile) std.Target {737pub fn rootModuleTarget(c: *Compile) std.Target {
751 // The root module is always given a target, so we know this to be non-null.738 // The root module is always given a target, so we know this to be non-null.
752 return c.root_module.resolved_target.?.result;739 return c.root_module.resolved_target.?.result;