authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-07-25 06:33:01+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-07-25 06:33:01+02:00
log7c13bdb1c9c7f61def9b58b1f24072a4eddc54c1
treecf48ca1d4072ed9b6454d935fac42e4fd05abcbf
parent546c75ca46eff73e5f038e2b894ff96c65cd8960
parent72c0cebe5c5e6954ae9992d36f8164ae9433df9e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #12059 from Luukdegram/linker-tests-run-step

Implement EmulatableRunStep for linker tests

15 files changed, 413 insertions(+), 125 deletions(-)

ci/zinc/linux_test.sh+1
...@@ -67,6 +67,7 @@ $STAGE1_ZIG build test-cli -fqemu -fwasmtime...@@ -67,6 +67,7 @@ $STAGE1_ZIG build test-cli -fqemu -fwasmtime
67$STAGE1_ZIG build test-run-translated-c -fqemu -fwasmtime67$STAGE1_ZIG build test-run-translated-c -fqemu -fwasmtime
68$STAGE1_ZIG build docs -fqemu -fwasmtime68$STAGE1_ZIG build docs -fqemu -fwasmtime
69$STAGE1_ZIG build test-cases -fqemu -fwasmtime69$STAGE1_ZIG build test-cases -fqemu -fwasmtime
70$STAGE1_ZIG build test-link -fqemu -fwasmtime
7071
71# Produce the experimental std lib documentation.72# Produce the experimental std lib documentation.
72mkdir -p "$RELEASE_STAGING/docs/std"73mkdir -p "$RELEASE_STAGING/docs/std"
lib/std/build.zig+17
...@@ -26,6 +26,7 @@ pub const CheckFileStep = @import("build/CheckFileStep.zig");...@@ -26,6 +26,7 @@ pub const CheckFileStep = @import("build/CheckFileStep.zig");
26pub const CheckObjectStep = @import("build/CheckObjectStep.zig");26pub const CheckObjectStep = @import("build/CheckObjectStep.zig");
27pub const InstallRawStep = @import("build/InstallRawStep.zig");27pub const InstallRawStep = @import("build/InstallRawStep.zig");
28pub const OptionsStep = @import("build/OptionsStep.zig");28pub const OptionsStep = @import("build/OptionsStep.zig");
29pub const EmulatableRunStep = @import("build/EmulatableRunStep.zig");
2930
30pub const Builder = struct {31pub const Builder = struct {
31 install_tls: TopLevelStep,32 install_tls: TopLevelStep,
...@@ -1890,6 +1891,21 @@ pub const LibExeObjStep = struct {...@@ -1890,6 +1891,21 @@ pub const LibExeObjStep = struct {
1890 return run_step;1891 return run_step;
1891 }1892 }
18921893
1894 /// Creates an `EmulatableRunStep` with an executable built with `addExecutable`.
1895 /// Allows running foreign binaries through emulation platforms such as Qemu or Rosetta.
1896 /// When a binary cannot be ran through emulation or the option is disabled, a warning
1897 /// will be printed and the binary will *NOT* be ran.
1898 pub fn runEmulatable(exe: *LibExeObjStep) *EmulatableRunStep {
1899 assert(exe.kind == .exe or exe.kind == .text_exe);
1900
1901 const run_step = EmulatableRunStep.create(exe.builder.fmt("run {s}", .{exe.step.name}), exe);
1902 if (exe.vcpkg_bin_path) |path| {
1903 run_step.addPathDir(path);
1904 }
1905
1906 return run_step;
1907 }
1908
1893 pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {1909 pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
1894 return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);1910 return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);
1895 }1911 }
...@@ -3604,6 +3620,7 @@ pub const Step = struct {...@@ -3604,6 +3620,7 @@ pub const Step = struct {
3604 translate_c,3620 translate_c,
3605 write_file,3621 write_file,
3606 run,3622 run,
3623 emulatable_run,
3607 check_file,3624 check_file,
3608 check_object,3625 check_object,
3609 install_raw,3626 install_raw,
lib/std/build/CheckObjectStep.zig+11
...@@ -12,6 +12,7 @@ const CheckObjectStep = @This();...@@ -12,6 +12,7 @@ const CheckObjectStep = @This();
12const Allocator = mem.Allocator;12const Allocator = mem.Allocator;
13const Builder = build.Builder;13const Builder = build.Builder;
14const Step = build.Step;14const Step = build.Step;
15const EmulatableRunStep = build.EmulatableRunStep;
1516
16pub const base_id = .check_obj;17pub const base_id = .check_obj;
1718
...@@ -37,6 +38,16 @@ pub fn create(builder: *Builder, source: build.FileSource, obj_format: std.Targe...@@ -37,6 +38,16 @@ pub fn create(builder: *Builder, source: build.FileSource, obj_format: std.Targe
37 return self;38 return self;
38}39}
3940
41/// Runs and (optionally) compares the output of a binary.
42/// Asserts `self` was generated from an executable step.
43pub fn runAndCompare(self: *CheckObjectStep) *EmulatableRunStep {
44 const dependencies_len = self.step.dependencies.items.len;
45 assert(dependencies_len > 0);
46 const exe_step = self.step.dependencies.items[dependencies_len - 1];
47 const exe = exe_step.cast(std.build.LibExeObjStep).?;
48 return EmulatableRunStep.create(self.builder, "EmulatableRun", exe);
49}
50
40/// There two types of actions currently suported:51/// There two types of actions currently suported:
41/// * `.match` - is the main building block of standard matchers with optional eat-all token `{*}`52/// * `.match` - is the main building block of standard matchers with optional eat-all token `{*}`
42/// and extractors by name such as `{n_value}`. Please note this action is very simplistic in nature53/// and extractors by name such as `{n_value}`. Please note this action is very simplistic in nature
lib/std/build/EmulatableRunStep.zig created+215
...@@ -0,0 +1,215 @@
1//! Unlike `RunStep` this step will provide emulation, when enabled, to run foreign binaries.
2//! When a binary is foreign, but emulation for the target is disabled, the specified binary
3//! will not be run and therefore also not validated against its output.
4//! This step can be useful when wishing to run a built binary on multiple platforms,
5//! without having to verify if it's possible to be ran against.
6
7const std = @import("../std.zig");
8const build = std.build;
9const Step = std.build.Step;
10const Builder = std.build.Builder;
11const LibExeObjStep = std.build.LibExeObjStep;
12const RunStep = std.build.RunStep;
13
14const fs = std.fs;
15const process = std.process;
16const EnvMap = process.EnvMap;
17
18const EmulatableRunStep = @This();
19
20pub const base_id = .emulatable_run;
21
22const max_stdout_size = 1 * 1024 * 1024; // 1 MiB
23
24step: Step,
25builder: *Builder,
26
27/// The artifact (executable) to be run by this step
28exe: *LibExeObjStep,
29
30/// Set this to `null` to ignore the exit code for the purpose of determining a successful execution
31expected_exit_code: ?u8 = 0,
32
33/// Override this field to modify the environment
34env_map: ?*EnvMap,
35
36/// Set this to modify the current working directory
37cwd: ?[]const u8,
38
39stdout_action: RunStep.StdIoAction = .inherit,
40stderr_action: RunStep.StdIoAction = .inherit,
41
42/// When set to true, hides the warning of skipping a foreign binary which cannot be run on the host
43/// or through emulation.
44hide_foreign_binaries_warning: bool,
45
46/// Creates a step that will execute the given artifact. This step will allow running the
47/// binary through emulation when any of the emulation options such as `enable_rosetta` are set to true.
48/// When set to false, and the binary is foreign, running the executable is skipped.
49/// Asserts given artifact is an executable.
50pub fn create(builder: *Builder, name: []const u8, artifact: *LibExeObjStep) *EmulatableRunStep {
51 std.debug.assert(artifact.kind == .exe or artifact.kind == .test_exe);
52 const self = builder.allocator.create(EmulatableRunStep) catch unreachable;
53
54 const option_name = "hide-foreign-warnings";
55 const hide_warnings = if (builder.available_options_map.get(option_name) == null) warn: {
56 break :warn builder.option(bool, option_name, "Hide the warning when a foreign binary which is incompatible is skipped") orelse false;
57 } else false;
58
59 self.* = .{
60 .builder = builder,
61 .step = Step.init(.emulatable_run, name, builder.allocator, make),
62 .exe = artifact,
63 .env_map = null,
64 .cwd = null,
65 .hide_foreign_binaries_warning = hide_warnings,
66 };
67 self.step.dependOn(&artifact.step);
68
69 return self;
70}
71
72fn make(step: *Step) !void {
73 const self = @fieldParentPtr(EmulatableRunStep, "step", step);
74 const host_info = self.builder.host;
75
76 var argv_list = std.ArrayList([]const u8).init(self.builder.allocator);
77 defer argv_list.deinit();
78
79 const need_cross_glibc = self.exe.target.isGnuLibC() and self.exe.is_linking_libc;
80 switch (host_info.getExternalExecutor(self.exe.target_info, .{
81 .qemu_fixes_dl = need_cross_glibc and self.builder.glibc_runtimes_dir != null,
82 .link_libc = self.exe.is_linking_libc,
83 })) {
84 .native => {},
85 .rosetta => if (!self.builder.enable_rosetta) return warnAboutForeignBinaries(self),
86 .wine => |bin_name| if (self.builder.enable_wine) {
87 try argv_list.append(bin_name);
88 } else return,
89 .qemu => |bin_name| if (self.builder.enable_qemu) {
90 const glibc_dir_arg = if (need_cross_glibc)
91 self.builder.glibc_runtimes_dir orelse return
92 else
93 null;
94 try argv_list.append(bin_name);
95 if (glibc_dir_arg) |dir| {
96 // TODO look into making this a call to `linuxTriple`. This
97 // needs the directory to be called "i686" rather than
98 // "i386" which is why we do it manually here.
99 const fmt_str = "{s}" ++ fs.path.sep_str ++ "{s}-{s}-{s}";
100 const cpu_arch = self.exe.target.getCpuArch();
101 const os_tag = self.exe.target.getOsTag();
102 const abi = self.exe.target.getAbi();
103 const cpu_arch_name: []const u8 = if (cpu_arch == .i386)
104 "i686"
105 else
106 @tagName(cpu_arch);
107 const full_dir = try std.fmt.allocPrint(self.builder.allocator, fmt_str, .{
108 dir, cpu_arch_name, @tagName(os_tag), @tagName(abi),
109 });
110
111 try argv_list.append("-L");
112 try argv_list.append(full_dir);
113 }
114 } else return warnAboutForeignBinaries(self),
115 .darling => |bin_name| if (self.builder.enable_darling) {
116 try argv_list.append(bin_name);
117 } else return warnAboutForeignBinaries(self),
118 .wasmtime => |bin_name| if (self.builder.enable_wasmtime) {
119 try argv_list.append(bin_name);
120 try argv_list.append("--dir=.");
121 } else return warnAboutForeignBinaries(self),
122 else => return warnAboutForeignBinaries(self),
123 }
124
125 if (self.exe.target.isWindows()) {
126 // On Windows we don't have rpaths so we have to add .dll search paths to PATH
127 RunStep.addPathForDynLibsInternal(&self.step, self.builder, self.exe);
128 }
129
130 const executable_path = self.exe.installed_path orelse self.exe.getOutputSource().getPath(self.builder);
131 try argv_list.append(executable_path);
132
133 try RunStep.runCommand(
134 argv_list.items,
135 self.builder,
136 self.expected_exit_code,
137 self.stdout_action,
138 self.stderr_action,
139 .Inherit,
140 self.env_map,
141 self.cwd,
142 false,
143 );
144}
145
146pub fn expectStdErrEqual(self: *EmulatableRunStep, bytes: []const u8) void {
147 self.stderr_action = .{ .expect_exact = self.builder.dupe(bytes) };
148}
149
150pub fn expectStdOutEqual(self: *EmulatableRunStep, bytes: []const u8) void {
151 self.stdout_action = .{ .expect_exact = self.builder.dupe(bytes) };
152}
153
154fn warnAboutForeignBinaries(step: *EmulatableRunStep) void {
155 if (step.hide_foreign_binaries_warning) return;
156 const builder = step.builder;
157 const artifact = step.exe;
158
159 const host_name = builder.host.target.zigTriple(builder.allocator) catch unreachable;
160 const foreign_name = artifact.target.zigTriple(builder.allocator) catch unreachable;
161 const target_info = std.zig.system.NativeTargetInfo.detect(builder.allocator, artifact.target) catch unreachable;
162 const need_cross_glibc = artifact.target.isGnuLibC() and artifact.is_linking_libc;
163 switch (builder.host.getExternalExecutor(target_info, .{
164 .qemu_fixes_dl = need_cross_glibc and builder.glibc_runtimes_dir != null,
165 .link_libc = artifact.is_linking_libc,
166 })) {
167 .native => unreachable,
168 .bad_dl => |foreign_dl| {
169 const host_dl = builder.host.dynamic_linker.get() orelse "(none)";
170 std.debug.print("the host system does not appear to be capable of executing binaries from the target because the host dynamic linker is '{s}', while the target dynamic linker is '{s}'. Consider setting the dynamic linker as '{s}'.\n", .{
171 host_dl, foreign_dl, host_dl,
172 });
173 },
174 .bad_os_or_cpu => {
175 std.debug.print("the host system ({s}) does not appear to be capable of executing binaries from the target ({s}).\n", .{
176 host_name, foreign_name,
177 });
178 },
179 .darling => if (!builder.enable_darling) {
180 std.debug.print(
181 "the host system ({s}) does not appear to be capable of executing binaries " ++
182 "from the target ({s}). Consider enabling darling.\n",
183 .{ host_name, foreign_name },
184 );
185 },
186 .rosetta => if (!builder.enable_rosetta) {
187 std.debug.print(
188 "the host system ({s}) does not appear to be capable of executing binaries " ++
189 "from the target ({s}). Consider enabling rosetta.\n",
190 .{ host_name, foreign_name },
191 );
192 },
193 .wine => if (!builder.enable_wine) {
194 std.debug.print(
195 "the host system ({s}) does not appear to be capable of executing binaries " ++
196 "from the target ({s}). Consider enabling wine.\n",
197 .{ host_name, foreign_name },
198 );
199 },
200 .qemu => if (!builder.enable_qemu) {
201 std.debug.print(
202 "the host system ({s}) does not appear to be capable of executing binaries " ++
203 "from the target ({s}). Consider enabling qemu.\n",
204 .{ host_name, foreign_name },
205 );
206 },
207 .wasmtime => {
208 std.debug.print(
209 "the host system ({s}) does not appear to be capable of executing binaries " ++
210 "from the target ({s}). Consider enabling wasmtime.\n",
211 .{ host_name, foreign_name },
212 );
213 },
214 }
215}
lib/std/build/RunStep.zig+79-34
...@@ -97,24 +97,42 @@ pub fn clearEnvironment(self: *RunStep) void {...@@ -97,24 +97,42 @@ pub fn clearEnvironment(self: *RunStep) void {
97}97}
9898
99pub fn addPathDir(self: *RunStep, search_path: []const u8) void {99pub fn addPathDir(self: *RunStep, search_path: []const u8) void {
100 const env_map = self.getEnvMap();100 addPathDirInternal(&self.step, self.builder, search_path);
101}
102
103/// For internal use only, users of `RunStep` should use `addPathDir` directly.
104fn addPathDirInternal(step: *Step, builder: *Builder, search_path: []const u8) void {
105 const env_map = getEnvMapInternal(step, builder.allocator);
101106
102 const key = "PATH";107 const key = "PATH";
103 var prev_path = env_map.get(key);108 var prev_path = env_map.get(key);
104109
105 if (prev_path) |pp| {110 if (prev_path) |pp| {
106 const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path });111 const new_path = builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path });
107 env_map.put(key, new_path) catch unreachable;112 env_map.put(key, new_path) catch unreachable;
108 } else {113 } else {
109 env_map.put(key, self.builder.dupePath(search_path)) catch unreachable;114 env_map.put(key, builder.dupePath(search_path)) catch unreachable;
110 }115 }
111}116}
112117
113pub fn getEnvMap(self: *RunStep) *EnvMap {118pub fn getEnvMap(self: *RunStep) *EnvMap {
114 return self.env_map orelse {119 return getEnvMapInternal(&self.step, self.builder.allocator);
115 const env_map = self.builder.allocator.create(EnvMap) catch unreachable;120}
116 env_map.* = process.getEnvMap(self.builder.allocator) catch unreachable;121
117 self.env_map = env_map;122fn getEnvMapInternal(step: *Step, allocator: Allocator) *EnvMap {
123 const maybe_env_map = switch (step.id) {
124 .run => step.cast(RunStep).?.env_map,
125 .emulatable_run => step.cast(build.EmulatableRunStep).?.env_map,
126 else => unreachable,
127 };
128 return maybe_env_map orelse {
129 const env_map = allocator.create(EnvMap) catch unreachable;
130 env_map.* = process.getEnvMap(allocator) catch unreachable;
131 switch (step.id) {
132 .run => step.cast(RunStep).?.env_map = env_map,
133 .emulatable_run => step.cast(RunStep).?.env_map = env_map,
134 else => unreachable,
135 }
118 return env_map;136 return env_map;
119 };137 };
120}138}
...@@ -146,10 +164,7 @@ fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo {...@@ -146,10 +164,7 @@ fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo {
146fn make(step: *Step) !void {164fn make(step: *Step) !void {
147 const self = @fieldParentPtr(RunStep, "step", step);165 const self = @fieldParentPtr(RunStep, "step", step);
148166
149 const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root;
150
151 var argv_list = ArrayList([]const u8).init(self.builder.allocator);167 var argv_list = ArrayList([]const u8).init(self.builder.allocator);
152
153 for (self.argv.items) |arg| {168 for (self.argv.items) |arg| {
154 switch (arg) {169 switch (arg) {
155 .bytes => |bytes| try argv_list.append(bytes),170 .bytes => |bytes| try argv_list.append(bytes),
...@@ -165,24 +180,48 @@ fn make(step: *Step) !void {...@@ -165,24 +180,48 @@ fn make(step: *Step) !void {
165 }180 }
166 }181 }
167182
168 const argv = argv_list.items;183 try runCommand(
184 argv_list.items,
185 self.builder,
186 self.expected_exit_code,
187 self.stdout_action,
188 self.stderr_action,
189 self.stdin_behavior,
190 self.env_map,
191 self.cwd,
192 self.print,
193 );
194}
195
196pub fn runCommand(
197 argv: []const []const u8,
198 builder: *Builder,
199 expected_exit_code: ?u8,
200 stdout_action: StdIoAction,
201 stderr_action: StdIoAction,
202 stdin_behavior: std.ChildProcess.StdIo,
203 env_map: ?*EnvMap,
204 maybe_cwd: ?[]const u8,
205 print: bool,
206) !void {
207 const cwd = if (maybe_cwd) |cwd| builder.pathFromRoot(cwd) else builder.build_root;
169208
170 if (!std.process.can_spawn) {209 if (!std.process.can_spawn) {
171 const cmd = try std.mem.join(self.builder.allocator, " ", argv);210 const cmd = try std.mem.join(builder.addInstallDirectory, " ", argv);
172 std.debug.print("the following command cannot be executed ({s} does not support spawning a child process):\n{s}", .{ @tagName(builtin.os.tag), cmd });211 std.debug.print("the following command cannot be executed ({s} does not support spawning a child process):\n{s}", .{ @tagName(builtin.os.tag), cmd });
173 self.builder.allocator.free(cmd);212 builder.allocator.free(cmd);
174 return ExecError.ExecNotSupported;213 return ExecError.ExecNotSupported;
175 }214 }
176215
177 var child = std.ChildProcess.init(argv, self.builder.allocator);216 var child = std.ChildProcess.init(argv, builder.allocator);
178 child.cwd = cwd;217 child.cwd = cwd;
179 child.env_map = self.env_map orelse self.builder.env_map;218 child.env_map = env_map orelse builder.env_map;
180219
181 child.stdin_behavior = self.stdin_behavior;220 child.stdin_behavior = stdin_behavior;
182 child.stdout_behavior = stdIoActionToBehavior(self.stdout_action);221 child.stdout_behavior = stdIoActionToBehavior(stdout_action);
183 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);222 child.stderr_behavior = stdIoActionToBehavior(stderr_action);
184223
185 if (self.print)224 if (print)
186 printCmd(cwd, argv);225 printCmd(cwd, argv);
187226
188 child.spawn() catch |err| {227 child.spawn() catch |err| {
...@@ -193,21 +232,21 @@ fn make(step: *Step) !void {...@@ -193,21 +232,21 @@ fn make(step: *Step) !void {
193 // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O).232 // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O).
194233
195 var stdout: ?[]const u8 = null;234 var stdout: ?[]const u8 = null;
196 defer if (stdout) |s| self.builder.allocator.free(s);235 defer if (stdout) |s| builder.allocator.free(s);
197236
198 switch (self.stdout_action) {237 switch (stdout_action) {
199 .expect_exact, .expect_matches => {238 .expect_exact, .expect_matches => {
200 stdout = child.stdout.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;239 stdout = child.stdout.?.reader().readAllAlloc(builder.allocator, max_stdout_size) catch unreachable;
201 },240 },
202 .inherit, .ignore => {},241 .inherit, .ignore => {},
203 }242 }
204243
205 var stderr: ?[]const u8 = null;244 var stderr: ?[]const u8 = null;
206 defer if (stderr) |s| self.builder.allocator.free(s);245 defer if (stderr) |s| builder.allocator.free(s);
207246
208 switch (self.stderr_action) {247 switch (stderr_action) {
209 .expect_exact, .expect_matches => {248 .expect_exact, .expect_matches => {
210 stderr = child.stderr.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;249 stderr = child.stderr.?.reader().readAllAlloc(builder.allocator, max_stdout_size) catch unreachable;
211 },250 },
212 .inherit, .ignore => {},251 .inherit, .ignore => {},
213 }252 }
...@@ -219,18 +258,18 @@ fn make(step: *Step) !void {...@@ -219,18 +258,18 @@ fn make(step: *Step) !void {
219258
220 switch (term) {259 switch (term) {
221 .Exited => |code| blk: {260 .Exited => |code| blk: {
222 const expected_exit_code = self.expected_exit_code orelse break :blk;261 const expected_code = expected_exit_code orelse break :blk;
223262
224 if (code != expected_exit_code) {263 if (code != expected_code) {
225 if (self.builder.prominent_compile_errors) {264 if (builder.prominent_compile_errors) {
226 std.debug.print("Run step exited with error code {} (expected {})\n", .{265 std.debug.print("Run step exited with error code {} (expected {})\n", .{
227 code,266 code,
228 expected_exit_code,267 expected_code,
229 });268 });
230 } else {269 } else {
231 std.debug.print("The following command exited with error code {} (expected {}):\n", .{270 std.debug.print("The following command exited with error code {} (expected {}):\n", .{
232 code,271 code,
233 expected_exit_code,272 expected_code,
234 });273 });
235 printCmd(cwd, argv);274 printCmd(cwd, argv);
236 }275 }
...@@ -245,7 +284,7 @@ fn make(step: *Step) !void {...@@ -245,7 +284,7 @@ fn make(step: *Step) !void {
245 },284 },
246 }285 }
247286
248 switch (self.stderr_action) {287 switch (stderr_action) {
249 .inherit, .ignore => {},288 .inherit, .ignore => {},
250 .expect_exact => |expected_bytes| {289 .expect_exact => |expected_bytes| {
251 if (!mem.eql(u8, expected_bytes, stderr.?)) {290 if (!mem.eql(u8, expected_bytes, stderr.?)) {
...@@ -277,7 +316,7 @@ fn make(step: *Step) !void {...@@ -277,7 +316,7 @@ fn make(step: *Step) !void {
277 },316 },
278 }317 }
279318
280 switch (self.stdout_action) {319 switch (stdout_action) {
281 .inherit, .ignore => {},320 .inherit, .ignore => {},
282 .expect_exact => |expected_bytes| {321 .expect_exact => |expected_bytes| {
283 if (!mem.eql(u8, expected_bytes, stdout.?)) {322 if (!mem.eql(u8, expected_bytes, stdout.?)) {
...@@ -319,12 +358,18 @@ fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {...@@ -319,12 +358,18 @@ fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
319}358}
320359
321fn addPathForDynLibs(self: *RunStep, artifact: *LibExeObjStep) void {360fn addPathForDynLibs(self: *RunStep, artifact: *LibExeObjStep) void {
361 addPathForDynLibsInternal(&self.step, self.builder, artifact);
362}
363
364/// This should only be used for internal usage, this is called automatically
365/// for the user.
366pub fn addPathForDynLibsInternal(step: *Step, builder: *Builder, artifact: *LibExeObjStep) void {
322 for (artifact.link_objects.items) |link_object| {367 for (artifact.link_objects.items) |link_object| {
323 switch (link_object) {368 switch (link_object) {
324 .other_step => |other| {369 .other_step => |other| {
325 if (other.target.isWindows() and other.isDynamicLibrary()) {370 if (other.target.isWindows() and other.isDynamicLibrary()) {
326 self.addPathDir(fs.path.dirname(other.getOutputSource().getPath(self.builder)).?);371 addPathDirInternal(step, builder, fs.path.dirname(other.getOutputSource().getPath(builder)).?);
327 self.addPathForDynLibs(other);372 addPathForDynLibsInternal(step, builder, other);
328 }373 }
329 },374 },
330 else => {},375 else => {},
test/link.zig+63-65
...@@ -47,69 +47,67 @@ pub fn addCases(cases: *tests.StandaloneContext) void {...@@ -47,69 +47,67 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
47 .requires_stage2 = true,47 .requires_stage2 = true,
48 });48 });
4949
50 if (builtin.os.tag == .macos) {50 cases.addBuildFile("test/link/macho/entry/build.zig", .{
51 cases.addBuildFile("test/link/macho/entry/build.zig", .{51 .build_modes = true,
52 .build_modes = true,52 });
53 });53
5454 cases.addBuildFile("test/link/macho/pagezero/build.zig", .{
55 cases.addBuildFile("test/link/macho/pagezero/build.zig", .{55 .build_modes = false,
56 .build_modes = false,56 });
57 });57
5858 cases.addBuildFile("test/link/macho/dylib/build.zig", .{
59 cases.addBuildFile("test/link/macho/dylib/build.zig", .{59 .build_modes = true,
60 .build_modes = true,60 });
61 });61
6262 cases.addBuildFile("test/link/macho/dead_strip/build.zig", .{
63 cases.addBuildFile("test/link/macho/dead_strip/build.zig", .{63 .build_modes = false,
64 .build_modes = false,64 });
65 });65
6666 cases.addBuildFile("test/link/macho/dead_strip_dylibs/build.zig", .{
67 cases.addBuildFile("test/link/macho/dead_strip_dylibs/build.zig", .{67 .build_modes = true,
68 .build_modes = true,68 .requires_macos_sdk = true,
69 .requires_macos_sdk = true,69 });
70 });70
7171 cases.addBuildFile("test/link/macho/needed_library/build.zig", .{
72 cases.addBuildFile("test/link/macho/needed_library/build.zig", .{72 .build_modes = true,
73 .build_modes = true,73 });
74 });74
7575 cases.addBuildFile("test/link/macho/weak_library/build.zig", .{
76 cases.addBuildFile("test/link/macho/weak_library/build.zig", .{76 .build_modes = true,
77 .build_modes = true,77 });
78 });78
7979 cases.addBuildFile("test/link/macho/needed_framework/build.zig", .{
80 cases.addBuildFile("test/link/macho/needed_framework/build.zig", .{80 .build_modes = true,
81 .build_modes = true,81 .requires_macos_sdk = true,
82 .requires_macos_sdk = true,82 });
83 });83
8484 cases.addBuildFile("test/link/macho/weak_framework/build.zig", .{
85 cases.addBuildFile("test/link/macho/weak_framework/build.zig", .{85 .build_modes = true,
86 .build_modes = true,86 .requires_macos_sdk = true,
87 .requires_macos_sdk = true,87 });
88 });88
8989 // Try to build and run an Objective-C executable.
90 // Try to build and run an Objective-C executable.90 cases.addBuildFile("test/link/macho/objc/build.zig", .{
91 cases.addBuildFile("test/link/macho/objc/build.zig", .{91 .build_modes = true,
92 .build_modes = true,92 .requires_macos_sdk = true,
93 .requires_macos_sdk = true,93 });
94 });94
9595 // Try to build and run an Objective-C++ executable.
96 // Try to build and run an Objective-C++ executable.96 cases.addBuildFile("test/link/macho/objcpp/build.zig", .{
97 cases.addBuildFile("test/link/macho/objcpp/build.zig", .{97 .build_modes = true,
98 .build_modes = true,98 .requires_macos_sdk = true,
99 .requires_macos_sdk = true,99 });
100 });100
101101 cases.addBuildFile("test/link/macho/stack_size/build.zig", .{
102 cases.addBuildFile("test/link/macho/stack_size/build.zig", .{102 .build_modes = true,
103 .build_modes = true,103 });
104 });104
105105 cases.addBuildFile("test/link/macho/search_strategy/build.zig", .{
106 cases.addBuildFile("test/link/macho/search_strategy/build.zig", .{106 .build_modes = true,
107 .build_modes = true,107 });
108 });108
109109 cases.addBuildFile("test/link/macho/headerpad/build.zig", .{
110 cases.addBuildFile("test/link/macho/headerpad/build.zig", .{110 .build_modes = true,
111 .build_modes = true,111 .requires_macos_sdk = true,
112 .requires_macos_sdk = true,112 });
113 });
114 }
115}113}
test/link/macho/dead_strip/build.zig+2-6
...@@ -16,9 +16,7 @@ pub fn build(b: *Builder) void {...@@ -16,9 +16,7 @@ pub fn build(b: *Builder) void {
16 check.checkInSymtab();16 check.checkInSymtab();
17 check.checkNext("{*} (__TEXT,__text) external _iAmUnused");17 check.checkNext("{*} (__TEXT,__text) external _iAmUnused");
1818
19 test_step.dependOn(&check.step);19 const run_cmd = check.runAndCompare();
20
21 const run_cmd = exe.run();
22 run_cmd.expectStdOutEqual("Hello!\n");20 run_cmd.expectStdOutEqual("Hello!\n");
23 test_step.dependOn(&run_cmd.step);21 test_step.dependOn(&run_cmd.step);
24 }22 }
...@@ -32,9 +30,7 @@ pub fn build(b: *Builder) void {...@@ -32,9 +30,7 @@ pub fn build(b: *Builder) void {
32 check.checkInSymtab();30 check.checkInSymtab();
33 check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");31 check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");
3432
35 test_step.dependOn(&check.step);33 const run_cmd = check.runAndCompare();
36
37 const run_cmd = exe.run();
38 run_cmd.expectStdOutEqual("Hello!\n");34 run_cmd.expectStdOutEqual("Hello!\n");
39 test_step.dependOn(&run_cmd.step);35 test_step.dependOn(&run_cmd.step);
40 }36 }
test/link/macho/dylib/build.zig+4-3
...@@ -3,12 +3,14 @@ const Builder = std.build.Builder;...@@ -3,12 +3,14 @@ const Builder = std.build.Builder;
33
4pub fn build(b: *Builder) void {4pub fn build(b: *Builder) void {
5 const mode = b.standardReleaseOptions();5 const mode = b.standardReleaseOptions();
6 const target: std.zig.CrossTarget = .{ .os_tag = .macos };
67
7 const test_step = b.step("test", "Test");8 const test_step = b.step("test", "Test");
8 test_step.dependOn(b.getInstallStep());9 test_step.dependOn(b.getInstallStep());
910
10 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));11 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));
11 dylib.setBuildMode(mode);12 dylib.setBuildMode(mode);
13 dylib.setTarget(target);
12 dylib.addCSourceFile("a.c", &.{});14 dylib.addCSourceFile("a.c", &.{});
13 dylib.linkLibC();15 dylib.linkLibC();
14 dylib.install();16 dylib.install();
...@@ -23,6 +25,7 @@ pub fn build(b: *Builder) void {...@@ -23,6 +25,7 @@ pub fn build(b: *Builder) void {
23 test_step.dependOn(&check_dylib.step);25 test_step.dependOn(&check_dylib.step);
2426
25 const exe = b.addExecutable("main", null);27 const exe = b.addExecutable("main", null);
28 exe.setTarget(target);
26 exe.setBuildMode(mode);29 exe.setBuildMode(mode);
27 exe.addCSourceFile("main.c", &.{});30 exe.addCSourceFile("main.c", &.{});
28 exe.linkSystemLibrary("a");31 exe.linkSystemLibrary("a");
...@@ -40,9 +43,7 @@ pub fn build(b: *Builder) void {...@@ -40,9 +43,7 @@ pub fn build(b: *Builder) void {
40 check_exe.checkStart("cmd RPATH");43 check_exe.checkStart("cmd RPATH");
41 check_exe.checkNext(std.fmt.allocPrint(b.allocator, "path {s}", .{b.pathFromRoot("zig-out/lib")}) catch unreachable);44 check_exe.checkNext(std.fmt.allocPrint(b.allocator, "path {s}", .{b.pathFromRoot("zig-out/lib")}) catch unreachable);
4245
43 test_step.dependOn(&check_exe.step);46 const run = check_exe.runAndCompare();
44
45 const run = exe.run();
46 run.cwd = b.pathFromRoot(".");47 run.cwd = b.pathFromRoot(".");
47 run.expectStdOutEqual("Hello world");48 run.expectStdOutEqual("Hello world");
48 test_step.dependOn(&run.step);49 test_step.dependOn(&run.step);
test/link/macho/entry/build.zig+2-3
...@@ -8,6 +8,7 @@ pub fn build(b: *Builder) void {...@@ -8,6 +8,7 @@ pub fn build(b: *Builder) void {
8 test_step.dependOn(b.getInstallStep());8 test_step.dependOn(b.getInstallStep());
99
10 const exe = b.addExecutable("main", null);10 const exe = b.addExecutable("main", null);
11 exe.setTarget(.{ .os_tag = .macos });
11 exe.setBuildMode(mode);12 exe.setBuildMode(mode);
12 exe.addCSourceFile("main.c", &.{});13 exe.addCSourceFile("main.c", &.{});
13 exe.linkLibC();14 exe.linkLibC();
...@@ -26,9 +27,7 @@ pub fn build(b: *Builder) void {...@@ -26,9 +27,7 @@ pub fn build(b: *Builder) void {
2627
27 check_exe.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } });28 check_exe.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } });
2829
29 test_step.dependOn(&check_exe.step);30 const run = check_exe.runAndCompare();
30
31 const run = exe.run();
32 run.expectStdOutEqual("42");31 run.expectStdOutEqual("42");
33 test_step.dependOn(&run.step);32 test_step.dependOn(&run.step);
34}33}
test/link/macho/needed_library/build.zig+4-2
...@@ -4,11 +4,13 @@ const LibExeObjectStep = std.build.LibExeObjStep;...@@ -4,11 +4,13 @@ const LibExeObjectStep = std.build.LibExeObjStep;
44
5pub fn build(b: *Builder) void {5pub fn build(b: *Builder) void {
6 const mode = b.standardReleaseOptions();6 const mode = b.standardReleaseOptions();
7 const target: std.zig.CrossTarget = .{ .os_tag = .macos };
78
8 const test_step = b.step("test", "Test the program");9 const test_step = b.step("test", "Test the program");
9 test_step.dependOn(b.getInstallStep());10 test_step.dependOn(b.getInstallStep());
1011
11 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));12 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));
13 dylib.setTarget(target);
12 dylib.setBuildMode(mode);14 dylib.setBuildMode(mode);
13 dylib.addCSourceFile("a.c", &.{});15 dylib.addCSourceFile("a.c", &.{});
14 dylib.linkLibC();16 dylib.linkLibC();
...@@ -19,6 +21,7 @@ pub fn build(b: *Builder) void {...@@ -19,6 +21,7 @@ pub fn build(b: *Builder) void {
19 const exe = b.addExecutable("test", null);21 const exe = b.addExecutable("test", null);
20 exe.addCSourceFile("main.c", &[0][]const u8{});22 exe.addCSourceFile("main.c", &[0][]const u8{});
21 exe.setBuildMode(mode);23 exe.setBuildMode(mode);
24 exe.setTarget(target);
22 exe.linkLibC();25 exe.linkLibC();
23 exe.linkSystemLibraryNeeded("a");26 exe.linkSystemLibraryNeeded("a");
24 exe.addLibraryPath(b.pathFromRoot("zig-out/lib"));27 exe.addLibraryPath(b.pathFromRoot("zig-out/lib"));
...@@ -28,8 +31,7 @@ pub fn build(b: *Builder) void {...@@ -28,8 +31,7 @@ pub fn build(b: *Builder) void {
28 const check = exe.checkObject(.macho);31 const check = exe.checkObject(.macho);
29 check.checkStart("cmd LOAD_DYLIB");32 check.checkStart("cmd LOAD_DYLIB");
30 check.checkNext("name @rpath/liba.dylib");33 check.checkNext("name @rpath/liba.dylib");
31 test_step.dependOn(&check.step);
3234
33 const run_cmd = exe.run();35 const run_cmd = check.runAndCompare();
34 test_step.dependOn(&run_cmd.step);36 test_step.dependOn(&run_cmd.step);
35}37}
test/link/macho/objc/build.zig+1-2
...@@ -7,7 +7,6 @@ pub fn build(b: *Builder) void {...@@ -7,7 +7,6 @@ pub fn build(b: *Builder) void {
7 const test_step = b.step("test", "Test the program");7 const test_step = b.step("test", "Test the program");
88
9 const exe = b.addExecutable("test", null);9 const exe = b.addExecutable("test", null);
10 b.default_step.dependOn(&exe.step);
11 exe.addIncludePath(".");10 exe.addIncludePath(".");
12 exe.addCSourceFile("Foo.m", &[0][]const u8{});11 exe.addCSourceFile("Foo.m", &[0][]const u8{});
13 exe.addCSourceFile("test.m", &[0][]const u8{});12 exe.addCSourceFile("test.m", &[0][]const u8{});
...@@ -17,6 +16,6 @@ pub fn build(b: *Builder) void {...@@ -17,6 +16,6 @@ pub fn build(b: *Builder) void {
17 // populate paths to the sysroot here.16 // populate paths to the sysroot here.
18 exe.linkFramework("Foundation");17 exe.linkFramework("Foundation");
1918
20 const run_cmd = exe.run();19 const run_cmd = std.build.EmulatableRunStep.create(b, "run", exe);
21 test_step.dependOn(&run_cmd.step);20 test_step.dependOn(&run_cmd.step);
22}21}
test/link/macho/pagezero/build.zig+2
...@@ -9,6 +9,7 @@ pub fn build(b: *Builder) void {...@@ -9,6 +9,7 @@ pub fn build(b: *Builder) void {
99
10 {10 {
11 const exe = b.addExecutable("pagezero", null);11 const exe = b.addExecutable("pagezero", null);
12 exe.setTarget(.{ .os_tag = .macos });
12 exe.setBuildMode(mode);13 exe.setBuildMode(mode);
13 exe.addCSourceFile("main.c", &.{});14 exe.addCSourceFile("main.c", &.{});
14 exe.linkLibC();15 exe.linkLibC();
...@@ -28,6 +29,7 @@ pub fn build(b: *Builder) void {...@@ -28,6 +29,7 @@ pub fn build(b: *Builder) void {
2829
29 {30 {
30 const exe = b.addExecutable("no_pagezero", null);31 const exe = b.addExecutable("no_pagezero", null);
32 exe.setTarget(.{ .os_tag = .macos });
31 exe.setBuildMode(mode);33 exe.setBuildMode(mode);
32 exe.addCSourceFile("main.c", &.{});34 exe.addCSourceFile("main.c", &.{});
33 exe.linkLibC();35 exe.linkLibC();
test/link/macho/search_strategy/build.zig+6-4
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const Builder = std.build.Builder;2const Builder = std.build.Builder;
3const LibExeObjectStep = std.build.LibExeObjStep;3const LibExeObjectStep = std.build.LibExeObjStep;
4const target: std.zig.CrossTarget = .{ .os_tag = .macos };
45
5pub fn build(b: *Builder) void {6pub fn build(b: *Builder) void {
6 const mode = b.standardReleaseOptions();7 const mode = b.standardReleaseOptions();
...@@ -17,9 +18,7 @@ pub fn build(b: *Builder) void {...@@ -17,9 +18,7 @@ pub fn build(b: *Builder) void {
17 check.checkStart("cmd LOAD_DYLIB");18 check.checkStart("cmd LOAD_DYLIB");
18 check.checkNext("name @rpath/liba.dylib");19 check.checkNext("name @rpath/liba.dylib");
1920
20 test_step.dependOn(&check.step);21 const run = check.runAndCompare();
21
22 const run = exe.run();
23 run.cwd = b.pathFromRoot(".");22 run.cwd = b.pathFromRoot(".");
24 run.expectStdOutEqual("Hello world");23 run.expectStdOutEqual("Hello world");
25 test_step.dependOn(&run.step);24 test_step.dependOn(&run.step);
...@@ -30,7 +29,7 @@ pub fn build(b: *Builder) void {...@@ -30,7 +29,7 @@ pub fn build(b: *Builder) void {
30 const exe = createScenario(b, mode);29 const exe = createScenario(b, mode);
31 exe.search_strategy = .paths_first;30 exe.search_strategy = .paths_first;
3231
33 const run = exe.run();32 const run = std.build.EmulatableRunStep.create(b, "run", exe);
34 run.cwd = b.pathFromRoot(".");33 run.cwd = b.pathFromRoot(".");
35 run.expectStdOutEqual("Hello world");34 run.expectStdOutEqual("Hello world");
36 test_step.dependOn(&run.step);35 test_step.dependOn(&run.step);
...@@ -39,6 +38,7 @@ pub fn build(b: *Builder) void {...@@ -39,6 +38,7 @@ pub fn build(b: *Builder) void {
3938
40fn createScenario(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {39fn createScenario(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {
41 const static = b.addStaticLibrary("a", null);40 const static = b.addStaticLibrary("a", null);
41 static.setTarget(target);
42 static.setBuildMode(mode);42 static.setBuildMode(mode);
43 static.addCSourceFile("a.c", &.{});43 static.addCSourceFile("a.c", &.{});
44 static.linkLibC();44 static.linkLibC();
...@@ -48,6 +48,7 @@ fn createScenario(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {...@@ -48,6 +48,7 @@ fn createScenario(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {
48 static.install();48 static.install();
4949
50 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));50 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));
51 dylib.setTarget(target);
51 dylib.setBuildMode(mode);52 dylib.setBuildMode(mode);
52 dylib.addCSourceFile("a.c", &.{});53 dylib.addCSourceFile("a.c", &.{});
53 dylib.linkLibC();54 dylib.linkLibC();
...@@ -57,6 +58,7 @@ fn createScenario(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {...@@ -57,6 +58,7 @@ fn createScenario(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {
57 dylib.install();58 dylib.install();
5859
59 const exe = b.addExecutable("main", null);60 const exe = b.addExecutable("main", null);
61 exe.setTarget(target);
60 exe.setBuildMode(mode);62 exe.setBuildMode(mode);
61 exe.addCSourceFile("main.c", &.{});63 exe.addCSourceFile("main.c", &.{});
62 exe.linkSystemLibraryName("a");64 exe.linkSystemLibraryName("a");
test/link/macho/stack_size/build.zig+2-3
...@@ -8,6 +8,7 @@ pub fn build(b: *Builder) void {...@@ -8,6 +8,7 @@ pub fn build(b: *Builder) void {
8 test_step.dependOn(b.getInstallStep());8 test_step.dependOn(b.getInstallStep());
99
10 const exe = b.addExecutable("main", null);10 const exe = b.addExecutable("main", null);
11 exe.setTarget(.{ .os_tag = .macos });
11 exe.setBuildMode(mode);12 exe.setBuildMode(mode);
12 exe.addCSourceFile("main.c", &.{});13 exe.addCSourceFile("main.c", &.{});
13 exe.linkLibC();14 exe.linkLibC();
...@@ -17,8 +18,6 @@ pub fn build(b: *Builder) void {...@@ -17,8 +18,6 @@ pub fn build(b: *Builder) void {
17 check_exe.checkStart("cmd MAIN");18 check_exe.checkStart("cmd MAIN");
18 check_exe.checkNext("stacksize 100000000");19 check_exe.checkNext("stacksize 100000000");
1920
20 test_step.dependOn(&check_exe.step);21 const run = check_exe.runAndCompare();
21
22 const run = exe.run();
23 test_step.dependOn(&run.step);22 test_step.dependOn(&run.step);
24}23}
test/link/macho/weak_library/build.zig+4-3
...@@ -4,11 +4,13 @@ const LibExeObjectStep = std.build.LibExeObjStep;...@@ -4,11 +4,13 @@ const LibExeObjectStep = std.build.LibExeObjStep;
44
5pub fn build(b: *Builder) void {5pub fn build(b: *Builder) void {
6 const mode = b.standardReleaseOptions();6 const mode = b.standardReleaseOptions();
7 const target: std.zig.CrossTarget = .{ .os_tag = .macos };
78
8 const test_step = b.step("test", "Test the program");9 const test_step = b.step("test", "Test the program");
9 test_step.dependOn(b.getInstallStep());10 test_step.dependOn(b.getInstallStep());
1011
11 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));12 const dylib = b.addSharedLibrary("a", null, b.version(1, 0, 0));
13 dylib.setTarget(target);
12 dylib.setBuildMode(mode);14 dylib.setBuildMode(mode);
13 dylib.addCSourceFile("a.c", &.{});15 dylib.addCSourceFile("a.c", &.{});
14 dylib.linkLibC();16 dylib.linkLibC();
...@@ -16,6 +18,7 @@ pub fn build(b: *Builder) void {...@@ -16,6 +18,7 @@ pub fn build(b: *Builder) void {
1618
17 const exe = b.addExecutable("test", null);19 const exe = b.addExecutable("test", null);
18 exe.addCSourceFile("main.c", &[0][]const u8{});20 exe.addCSourceFile("main.c", &[0][]const u8{});
21 exe.setTarget(target);
19 exe.setBuildMode(mode);22 exe.setBuildMode(mode);
20 exe.linkLibC();23 exe.linkLibC();
21 exe.linkSystemLibraryWeak("a");24 exe.linkSystemLibraryWeak("a");
...@@ -30,9 +33,7 @@ pub fn build(b: *Builder) void {...@@ -30,9 +33,7 @@ pub fn build(b: *Builder) void {
30 check.checkNext("(undefined) weak external _a (from liba)");33 check.checkNext("(undefined) weak external _a (from liba)");
31 check.checkNext("(undefined) weak external _asStr (from liba)");34 check.checkNext("(undefined) weak external _asStr (from liba)");
3235
33 test_step.dependOn(&check.step);36 const run_cmd = check.runAndCompare();
34
35 const run_cmd = exe.run();
36 run_cmd.expectStdOutEqual("42 42");37 run_cmd.expectStdOutEqual("42 42");
37 test_step.dependOn(&run_cmd.step);38 test_step.dependOn(&run_cmd.step);
38}39}