commit d95dcb2a6238787e18c60f4ae4bfcf8fd757bd0c (tree)
parent a078d55a25ec503158b1b1dfbdfdec2d0fec86aa
Author: Techatrix <techatrix@mailbox.org>
Date: Fri, 12 Jun 2026 19:54:03 +0200
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.
Diffstat:
5 files changed, 2 insertions(+), 41 deletions(-)
diff --git a/lib/compiler/Maker/Step/Compile.zig b/lib/compiler/Maker/Step/Compile.zig
@@ -769,18 +769,6 @@ fn lowerZigArgs(
try zig_args.append(gpa, if (enabled) "--enable-new-dtags" else "--disable-new-dtags");
}
- if (conf_comp.flags3.kind == .@"test" and conf_comp.exec_cmd_args.slice.len != 0) {
- for (conf_comp.exec_cmd_args.slice) |cmd_arg| {
- try zig_args.ensureUnusedCapacity(gpa, 2);
- if (cmd_arg.slice(conf)) |arg| {
- zig_args.appendAssumeCapacity("--test-cmd");
- zig_args.appendAssumeCapacity(arg);
- } else {
- zig_args.appendAssumeCapacity("--test-cmd-bin");
- }
- }
- }
-
if (graph.sysroot) |sysroot| try zig_args.appendSlice(gpa, &.{ "--sysroot", sysroot });
// -I and -L arguments that appear after the last --mod argument apply to all modules.
diff --git a/lib/compiler/configurer.zig b/lib/compiler/configurer.zig
@@ -676,7 +676,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
},
.compile => e: {
const c: *Step.Compile = @fieldParentPtr("step", step);
- const exec_cmd_args: []const ?[]const u8 = c.exec_cmd_args orelse &.{};
const installed_headers: []u32 = try arena.alloc(u32, c.installed_headers.items.len);
for (installed_headers, c.installed_headers.items) |*dst, src| switch (src) {
.file => |file| {
@@ -703,7 +702,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
break :e try wc.addExtraErased(Configuration.Step.Compile, .{
.flags = .{
.filters_len = c.filters.len != 0,
- .exec_cmd_args_len = exec_cmd_args.len != 0,
.installed_headers_len = installed_headers.len != 0,
.force_undefined_symbols_len = c.force_undefined_symbols.entries.len != 0,
@@ -837,7 +835,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
.none, .fast, .uuid, .sha1, .md5 => null,
} else null },
.filters = .{ .slice = try s.initStringList(c.filters) },
- .exec_cmd_args = .{ .slice = try s.initOptionalStringList(exec_cmd_args) },
.installed_headers = .initErased(installed_headers),
.force_undefined_symbols = .{ .slice = try s.initStringList(c.force_undefined_symbols.keys()) },
.expect_errors = .{ .u = if (c.expect_errors) |x| switch (x) {
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
@@ -898,17 +898,7 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
const run_step = Step.Run.create(b, step_name);
run_step.producer = exe;
if (exe.kind == .@"test") {
- if (exe.exec_cmd_args) |exec_cmd_args| {
- for (exec_cmd_args) |cmd_arg| {
- if (cmd_arg) |arg| {
- run_step.addArg(arg);
- } else {
- run_step.addArtifactArg(exe);
- }
- }
- } else {
- run_step.addArtifactArg(exe);
- }
+ run_step.addArtifactArg(exe);
const test_server_mode: bool = s: {
if (exe.test_runner) |r| break :s r.mode == .server;
diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig
@@ -698,7 +698,6 @@ pub const Step = extern struct {
root_name: String,
filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String),
- exec_cmd_args: Storage.FlagLengthPrefixedList(.flags, .exec_cmd_args_len, OptionalString),
installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader)),
force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String),
expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors),
@@ -927,7 +926,6 @@ pub const Step = extern struct {
tag: Tag = .compile,
filters_len: bool,
- exec_cmd_args_len: bool,
installed_headers_len: bool,
force_undefined_symbols_len: bool,
@@ -954,6 +952,7 @@ pub const Step = extern struct {
force_load_objc: bool,
discard_local_symbols: bool,
mingw_unicode_entry_point: bool,
+ _: u1 = 0,
};
pub const Flags2 = packed struct(u32) {
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
@@ -51,7 +51,6 @@ shared_memory: bool = false,
global_base: ?u64 = null,
/// Set via options; intended to be read-only after that.
zig_lib_dir: ?LazyPath,
-exec_cmd_args: ?[]const ?[]const u8,
filters: []const []const u8,
test_runner: ?TestRunner,
wasi_exec_model: ?std.builtin.WasiExecModel = null,
@@ -419,7 +418,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
.out_filename = out_filename,
.installed_headers = .empty,
.zig_lib_dir = null,
- .exec_cmd_args = null,
.filters = options.filters,
.test_runner = null, // set below
.rdynamic = false,
@@ -736,17 +734,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {
return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);
}
-pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void {
- const graph = compile.step.owner.graph;
- const arena = graph.arena;
- assert(compile.kind == .@"test");
- const duped_args = arena.alloc(?[]const u8, args.len) catch @panic("OOM");
- for (args, 0..) |arg, i| {
- duped_args[i] = if (arg) |a| graph.dupeString(a) else null;
- }
- compile.exec_cmd_args = duped_args;
-}
-
pub fn rootModuleTarget(c: *Compile) std.Target {
// The root module is always given a target, so we know this to be non-null.
return c.root_module.resolved_target.?.result;