authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-10 00:47:26+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-10 22:19:02+02:00
logad120ff12f5514d19465d3ae6acd6ee4a9da0722
treee63c283aeaf0ac690790d0039d0f328c0d0e64a9
parent6217b02f2540e32acedee8d0f2f3830ea8ae0d28

test: refine the list of targets that get run in stack/error trace tests

Stack trace tests now run for most of the targets that we build module tests for. However, we omit explicit targets that have no meaningful way of executing on a non-native platform - whether through an emulator or 32-bit compatibility layer. (There's no point building them if we cannot run them.) We also omit soft float targets because there's nothing about float ABI that would affect stack tracing. Finally, we currently omit Thumb targets because it turns out the stack trace code does not work well at all on Thumb, and fixing this will likely require us to implement ARM EHABI unwinding (#30931). Error trace tests run on an even further reduced set of targets because we don't care if libc is linked for those. Thumb is enabled here, though, since error tracing seems unaffected by the aforementioned issue. Also make these tests respect the various build options. As far as CI goes, x86_64-linux will run the full set of tests (modulo -Dtest-extra-targets) while all other machines only run native-compatible tests.

4 files changed, 1311 insertions(+), 70 deletions(-)

build.zig+30-2
......@@ -660,8 +660,36 @@ pub fn build(b: *std.Build) !void {
660660 .skip_llvm = skip_llvm,
661661 .max_rss = 100_000_000,
662662 }));
663 test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native));
664 test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimize_modes, skip_non_native));
663 test_step.dependOn(tests.addStackTraceTests(b, .{
664 .test_filters = test_filters,
665 .test_target_filters = test_target_filters,
666 .test_extra_targets = test_extra_targets,
667 .optimize_modes = optimize_modes,
668 .skip_non_native = skip_non_native,
669 .skip_freebsd = skip_freebsd,
670 .skip_netbsd = skip_netbsd,
671 .skip_openbsd = skip_openbsd,
672 .skip_windows = skip_windows,
673 .skip_darwin = skip_darwin,
674 .skip_linux = skip_linux,
675 .skip_llvm = skip_llvm,
676 .skip_libc = skip_libc,
677 }));
678 test_step.dependOn(tests.addErrorTraceTests(b, .{
679 .test_filters = test_filters,
680 .test_target_filters = test_target_filters,
681 .test_extra_targets = test_extra_targets,
682 .optimize_modes = optimize_modes,
683 .skip_non_native = skip_non_native,
684 .skip_freebsd = skip_freebsd,
685 .skip_netbsd = skip_netbsd,
686 .skip_openbsd = skip_openbsd,
687 .skip_windows = skip_windows,
688 .skip_darwin = skip_darwin,
689 .skip_linux = skip_linux,
690 .skip_llvm = skip_llvm,
691 .skip_libc = skip_libc,
692 }));
665693 test_step.dependOn(tests.addCliTests(b));
666694 if (tests.addDebuggerTests(b, .{
667695 .test_filters = test_filters,
test/src/ErrorTrace.zig+323-25
......@@ -7,29 +7,292 @@ const Step = std.Build.Step;
77const OptimizeMode = std.lang.Optimize;
88const mem = std.mem;
99
10const tests = @import("../tests.zig");
1011const error_traces_cases = @import("../error_traces.zig");
1112
1213b: *std.Build,
1314step: *Step,
14test_filters: []const []const u8,
15skip_non_native: bool,
16optimize_modes: []const OptimizeMode,
15options: Options,
1716convert_exe: *std.Build.Step.Compile,
1817
19pub const CaseParameters = @import("StackTrace.zig").CaseParameters;
18pub const Options = struct {
19 test_filters: []const []const u8,
20 test_target_filters: []const []const u8,
21 test_extra_targets: bool,
22 optimize_modes: []const OptimizeMode,
23 skip_non_native: bool,
24 skip_freebsd: bool,
25 skip_netbsd: bool,
26 skip_openbsd: bool,
27 skip_windows: bool,
28 skip_darwin: bool,
29 skip_linux: bool,
30 skip_llvm: bool,
31 skip_libc: bool,
32};
33
34pub const CaseParameters = struct {
35 target: std.Target.Query = .{},
36 optimize: std.builtin.OptimizeMode = .debug,
37 use_llvm: ?bool = null,
38 use_lld: ?bool = null,
39
40 // This is intended for targets that, for any reason, shouldn't be run as part of a normal test
41 // invocation. This could be because of a slow backend, requiring a newer LLVM version, being
42 // too niche, etc.
43 extra_target: bool = false,
44};
2045
21const param_sets = [_]CaseParameters{
46/// See the comment in `StackTrace.zig`.
47pub const param_sets = [_]CaseParameters{
2248 .{},
49
50 // FreeBSD Targets
51
52 .{
53 .target = .{
54 .cpu_arch = .arm,
55 .os_tag = .freebsd,
56 .abi = .eabihf,
57 },
58 },
59
60 .{
61 .target = .{
62 .cpu_arch = .x86,
63 .os_tag = .freebsd,
64 .abi = .none,
65 },
66 },
67
68 // Linux Targets
69
70 .{
71 .target = .{
72 .cpu_arch = .aarch64,
73 .os_tag = .linux,
74 .abi = .none,
75 },
76 },
77
78 .{
79 .target = .{
80 .cpu_arch = .aarch64_be,
81 .os_tag = .linux,
82 .abi = .none,
83 },
84 },
85
86 .{
87 .target = .{
88 .cpu_arch = .arm,
89 .os_tag = .linux,
90 .abi = .eabihf,
91 },
92 },
93
94 .{
95 .target = .{
96 .cpu_arch = .armeb,
97 .os_tag = .linux,
98 .abi = .eabihf,
99 },
100 },
101
102 .{
103 .target = .{
104 .cpu_arch = .hexagon,
105 .os_tag = .linux,
106 .abi = .none,
107 },
108 },
109
110 .{
111 .target = .{
112 .cpu_arch = .loongarch32,
113 .os_tag = .linux,
114 .abi = .none,
115 },
116 },
117
23118 .{
24 .link_libc = true,
119 .target = .{
120 .cpu_arch = .loongarch64,
121 .os_tag = .linux,
122 .abi = .none,
123 },
124 },
125
126 .{
127 .target = .{
128 .cpu_arch = .mips,
129 .os_tag = .linux,
130 .abi = .eabihf,
131 },
132 },
133
134 .{
135 .target = .{
136 .cpu_arch = .mipsel,
137 .os_tag = .linux,
138 .abi = .eabihf,
139 },
25140 },
141
142 .{
143 .target = .{
144 .cpu_arch = .mips64,
145 .os_tag = .linux,
146 .abi = .none,
147 },
148 },
149 .{
150 .target = .{
151 .cpu_arch = .mips64,
152 .os_tag = .linux,
153 .abi = .abin32,
154 },
155 },
156
157 .{
158 .target = .{
159 .cpu_arch = .mips64el,
160 .os_tag = .linux,
161 .abi = .none,
162 },
163 },
164 .{
165 .target = .{
166 .cpu_arch = .mips64el,
167 .os_tag = .linux,
168 .abi = .abin32,
169 },
170 },
171
172 .{
173 .target = .{
174 .cpu_arch = .powerpc,
175 .os_tag = .linux,
176 .abi = .eabihf,
177 },
178 },
179
180 .{
181 .target = .{
182 .cpu_arch = .powerpc64,
183 .os_tag = .linux,
184 .abi = .none,
185 },
186 },
187
188 .{
189 .target = .{
190 .cpu_arch = .powerpc64le,
191 .os_tag = .linux,
192 .abi = .none,
193 },
194 },
195
26196 .{
197 .target = .{
198 .cpu_arch = .riscv32,
199 .os_tag = .linux,
200 .abi = .none,
201 },
202 },
203
204 .{
205 .target = .{
206 .cpu_arch = .riscv64,
207 .os_tag = .linux,
208 .abi = .none,
209 },
210 },
211
212 .{
213 .target = .{
214 .cpu_arch = .s390x,
215 .os_tag = .linux,
216 .abi = .none,
217 },
218 },
219
220 .{
221 .target = .{
222 .cpu_arch = .sparc64,
223 .os_tag = .linux,
224 .abi = .none,
225 },
226 },
227
228 .{
229 .target = .{
230 .cpu_arch = .thumb,
231 .os_tag = .linux,
232 .abi = .eabihf,
233 },
234 },
235
236 .{
237 .target = .{
238 .cpu_arch = .thumbeb,
239 .os_tag = .linux,
240 .abi = .eabihf,
241 },
242 },
243
244 .{
245 .target = .{
246 .cpu_arch = .x86,
247 .os_tag = .linux,
248 .abi = .none,
249 },
250 },
251
252 .{
253 .target = .{
254 .cpu_arch = .x86_64,
255 .os_tag = .linux,
256 .abi = .none,
257 },
258 },
259 .{
260 .target = .{
261 .cpu_arch = .x86_64,
262 .os_tag = .linux,
263 .abi = .none,
264 },
27265 .use_llvm = true,
28266 .use_lld = true,
29267 },
30268 .{
31 .pie = true,
269 .target = .{
270 .cpu_arch = .x86_64,
271 .os_tag = .linux,
272 .abi = .x32,
273 },
274 },
275
276 // NetBSD Targets
277
278 .{
279 .target = .{
280 .cpu_arch = .riscv32,
281 .os_tag = .netbsd,
282 .abi = .none,
283 },
284 },
285
286 .{
287 .target = .{
288 .cpu_arch = .x86,
289 .os_tag = .netbsd,
290 .abi = .none,
291 },
32292 },
293
294 // Windows Targets
295
33296 .{
34297 .target = .{
35298 .cpu_arch = .aarch64,
......@@ -39,11 +302,27 @@ const param_sets = [_]CaseParameters{
39302 },
40303 .{
41304 .target = .{
42 .cpu_arch = .x86_64,
305 .cpu_arch = .aarch64,
306 .os_tag = .windows,
307 .abi = .gnu,
308 },
309 },
310
311 .{
312 .target = .{
313 .cpu_arch = .thumb,
314 .os_tag = .windows,
315 .abi = .msvc,
316 },
317 },
318 .{
319 .target = .{
320 .cpu_arch = .thumb,
43321 .os_tag = .windows,
44322 .abi = .gnu,
45323 },
46324 },
325
47326 .{
48327 .target = .{
49328 .cpu_arch = .x86,
......@@ -53,22 +332,24 @@ const param_sets = [_]CaseParameters{
53332 },
54333 .{
55334 .target = .{
56 .cpu_arch = .aarch64,
57 .os_tag = .macos,
335 .cpu_arch = .x86,
336 .os_tag = .windows,
337 .abi = .gnu,
58338 },
59339 },
340
60341 .{
61342 .target = .{
62 .cpu_arch = .s390x,
63 .os_tag = .linux,
64 .abi = .none,
343 .cpu_arch = .x86_64,
344 .os_tag = .windows,
345 .abi = .msvc,
65346 },
66347 },
67348 .{
68349 .target = .{
69 .cpu_arch = .loongarch32,
70 .os_tag = .linux,
71 .abi = .none,
350 .cpu_arch = .x86_64,
351 .os_tag = .windows,
352 .abi = .gnu,
72353 },
73354 },
74355};
......@@ -97,17 +378,34 @@ pub fn addCases(self: *ErrorTrace) void {
97378
98379 for (&param_sets) |*params| {
99380 const resolved_target = b.resolveTargetQuery(params.target);
381 const target = &resolved_target.result;
100382
101 if (self.skip_non_native and !resolved_target.query.isNative()) continue;
383 if (!self.options.test_extra_targets and params.extra_target) continue;
102384
103 // To avoid redundant testing, skip cross-compilation targets matching the host.
104 if (resolved_target.result.os.tag == builtin.target.os.tag and
105 resolved_target.result.cpu.arch == builtin.target.cpu.arch)
106 {
107 continue;
385 if (self.options.skip_non_native and !tests.isNative(&resolved_target, &b.graph.host.result)) continue;
386
387 if (self.options.skip_freebsd and target.os.tag == .freebsd) continue;
388 if (self.options.skip_netbsd and target.os.tag == .netbsd) continue;
389 if (self.options.skip_openbsd and target.os.tag == .openbsd) continue;
390 if (self.options.skip_windows and target.os.tag == .windows) continue;
391 if (self.options.skip_darwin and target.os.tag.isDarwin()) continue;
392 if (self.options.skip_linux and target.os.tag == .linux) continue;
393
394 const would_use_llvm = tests.wouldUseLlvm(params.use_llvm, params.target, params.optimize);
395 if (self.options.skip_llvm and would_use_llvm) continue;
396
397 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
398
399 if (self.options.test_target_filters.len > 0) {
400 for (self.options.test_target_filters) |filter| {
401 if (std.mem.find(u8, triple_txt, filter) != null) break;
402 } else continue;
108403 }
109404
110 for (self.optimize_modes) |optimize| {
405 if (self.options.skip_libc and std.os.targetRequiresLibC(target))
406 continue;
407
408 for (self.options.optimize_modes) |optimize| {
111409 if (optimize == params.optimize) break;
112410 } else return;
113411
......@@ -154,8 +452,8 @@ pub fn addCase(self: *ErrorTrace, case: Case) void {
154452 params.optimize,
155453 backend_string,
156454 });
157 if (self.test_filters.len > 0) {
158 for (self.test_filters) |test_filter| {
455 if (self.options.test_filters.len > 0) {
456 for (self.options.test_filters) |test_filter| {
159457 if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
160458 } else return;
161459 }
test/src/StackTrace.zig+954-30
......@@ -7,15 +7,32 @@ const Step = std.Build.Step;
77const OptimizeMode = std.lang.Optimize;
88const mem = std.mem;
99
10const tests = @import("../tests.zig");
1011const stack_traces_cases = @import("../stack_traces.zig");
1112
1213b: *std.Build,
1314step: *Step,
14test_filters: []const []const u8,
15skip_non_native: bool,
15options: Options,
1616convert_exe: *std.Build.Step.Compile,
1717
18pub const Options = struct {
19 test_filters: []const []const u8,
20 test_target_filters: []const []const u8,
21 test_extra_targets: bool,
22 optimize_modes: []const OptimizeMode,
23 skip_non_native: bool,
24 skip_freebsd: bool,
25 skip_netbsd: bool,
26 skip_openbsd: bool,
27 skip_windows: bool,
28 skip_darwin: bool,
29 skip_linux: bool,
30 skip_llvm: bool,
31 skip_libc: bool,
32};
33
1834pub const CaseParameters = struct {
35 linkage: ?std.builtin.LinkMode = null,
1936 target: std.Target.Query = .{},
2037 optimize: std.builtin.OptimizeMode = .debug,
2138 link_libc: ?bool = null,
......@@ -26,20 +43,814 @@ pub const CaseParameters = struct {
2643 /// * The compiler needs to gain the ability to strip only debug info (not symbols)
2744 /// * `std.Build.Step.ObjCopy` needs to be un-regressed
2845 strip: ?bool = false,
46
47 // This is intended for targets that, for any reason, shouldn't be run as part of a normal test
48 // invocation. This could be because of a slow backend, requiring a newer LLVM version, being
49 // too niche, etc.
50 extra_target: bool = false,
2951};
3052
31const param_sets = [_]CaseParameters{
32 .{},
53/// Only add a non-native target to this set if there's a way to emulate it, or if it can built on a
54/// platform with the same arch/OS but has a different ABI. For example, it makes little sense to
55/// add `riscv64-netbsd` here because there's no QEMU user-mode emulation for it anyway, and it'll
56/// still be covered by the native entries when run on a real `riscv64-netbsd` system. But adding
57/// `aarch64-windows-msvc` is valuable because the native entries will default to `gnu` on Windows.
58pub const param_sets = [_]CaseParameters{
59 .{},
60 .{
61 .link_libc = true,
62 },
63 .{
64 .pie = true,
65 },
66 .{
67 .link_libc = true,
68 .pie = true,
69 },
70
71 // FreeBSD Targets
72
73 .{
74 .target = .{
75 .cpu_arch = .arm,
76 .os_tag = .freebsd,
77 .abi = .eabihf,
78 },
79 },
80
81 .{
82 .target = .{
83 .cpu_arch = .x86,
84 .os_tag = .freebsd,
85 .abi = .none,
86 },
87 },
88
89 // Linux Targets
90
91 .{
92 .target = .{
93 .cpu_arch = .aarch64,
94 .os_tag = .linux,
95 .abi = .none,
96 },
97 },
98 .{
99 .target = .{
100 .cpu_arch = .aarch64,
101 .os_tag = .linux,
102 .abi = .musl,
103 },
104 .link_libc = true,
105 },
106 .{
107 .target = .{
108 .cpu_arch = .aarch64,
109 .os_tag = .linux,
110 .abi = .musl,
111 },
112 .linkage = .dynamic,
113 .link_libc = true,
114 .extra_target = true,
115 },
116 .{
117 .target = .{
118 .cpu_arch = .aarch64,
119 .os_tag = .linux,
120 .abi = .gnu,
121 },
122 .link_libc = true,
123 },
124
125 .{
126 .target = .{
127 .cpu_arch = .aarch64_be,
128 .os_tag = .linux,
129 .abi = .none,
130 },
131 },
132 .{
133 .target = .{
134 .cpu_arch = .aarch64_be,
135 .os_tag = .linux,
136 .abi = .musl,
137 },
138 .link_libc = true,
139 },
140 .{
141 .target = .{
142 .cpu_arch = .aarch64_be,
143 .os_tag = .linux,
144 .abi = .musl,
145 },
146 .linkage = .dynamic,
147 .link_libc = true,
148 .extra_target = true,
149 },
150 .{
151 .target = .{
152 .cpu_arch = .aarch64_be,
153 .os_tag = .linux,
154 .abi = .gnu,
155 },
156 .link_libc = true,
157 },
158
159 .{
160 .target = .{
161 .cpu_arch = .arm,
162 .os_tag = .linux,
163 .abi = .eabihf,
164 },
165 },
166 .{
167 .target = .{
168 .cpu_arch = .arm,
169 .os_tag = .linux,
170 .abi = .musleabihf,
171 },
172 .link_libc = true,
173 },
174 .{
175 .target = .{
176 .cpu_arch = .arm,
177 .os_tag = .linux,
178 .abi = .musleabihf,
179 },
180 .linkage = .dynamic,
181 .link_libc = true,
182 .extra_target = true,
183 },
184 .{
185 .target = .{
186 .cpu_arch = .arm,
187 .os_tag = .linux,
188 .abi = .gnueabihf,
189 },
190 .link_libc = true,
191 },
192
193 .{
194 .target = .{
195 .cpu_arch = .armeb,
196 .os_tag = .linux,
197 .abi = .eabihf,
198 },
199 },
200 .{
201 .target = .{
202 .cpu_arch = .armeb,
203 .os_tag = .linux,
204 .abi = .musleabihf,
205 },
206 .link_libc = true,
207 },
208 // Crashes in weird ways when applying relocations.
209 // .{
210 // .target = .{
211 // .cpu_arch = .armeb,
212 // .os_tag = .linux,
213 // .abi = .musleabihf,
214 // },
215 // .linkage = .dynamic,
216 // .link_libc = true,
217 // .extra_target = true,
218 // },
219 .{
220 .target = .{
221 .cpu_arch = .armeb,
222 .os_tag = .linux,
223 .abi = .gnueabihf,
224 },
225 .link_libc = true,
226 },
227
228 .{
229 .target = .{
230 .cpu_arch = .hexagon,
231 .os_tag = .linux,
232 .abi = .none,
233 },
234 },
235 .{
236 .target = .{
237 .cpu_arch = .hexagon,
238 .os_tag = .linux,
239 .abi = .musl,
240 },
241 .link_libc = true,
242 },
243 .{
244 .target = .{
245 .cpu_arch = .hexagon,
246 .os_tag = .linux,
247 .abi = .musl,
248 },
249 .linkage = .dynamic,
250 .link_libc = true,
251 .extra_target = true,
252 },
253
254 .{
255 .target = .{
256 .cpu_arch = .loongarch32,
257 .os_tag = .linux,
258 .abi = .none,
259 },
260 },
261 .{
262 .target = .{
263 .cpu_arch = .loongarch32,
264 .os_tag = .linux,
265 .abi = .gnu,
266 },
267 .link_libc = true,
268 },
269
270 .{
271 .target = .{
272 .cpu_arch = .loongarch64,
273 .os_tag = .linux,
274 .abi = .none,
275 },
276 },
277 .{
278 .target = .{
279 .cpu_arch = .loongarch64,
280 .os_tag = .linux,
281 .abi = .musl,
282 },
283 .link_libc = true,
284 },
285 .{
286 .target = .{
287 .cpu_arch = .loongarch64,
288 .os_tag = .linux,
289 .abi = .musl,
290 },
291 .linkage = .dynamic,
292 .link_libc = true,
293 .extra_target = true,
294 },
295 .{
296 .target = .{
297 .cpu_arch = .loongarch64,
298 .os_tag = .linux,
299 .abi = .gnu,
300 },
301 .link_libc = true,
302 },
303
304 .{
305 .target = .{
306 .cpu_arch = .mips,
307 .os_tag = .linux,
308 .abi = .eabihf,
309 },
310 },
311 .{
312 .target = .{
313 .cpu_arch = .mips,
314 .os_tag = .linux,
315 .abi = .musleabihf,
316 },
317 .link_libc = true,
318 },
319 .{
320 .target = .{
321 .cpu_arch = .mips,
322 .os_tag = .linux,
323 .abi = .musleabihf,
324 },
325 .linkage = .dynamic,
326 .link_libc = true,
327 .extra_target = true,
328 },
329 .{
330 .target = .{
331 .cpu_arch = .mips,
332 .os_tag = .linux,
333 .abi = .gnueabihf,
334 },
335 .link_libc = true,
336 },
337
338 .{
339 .target = .{
340 .cpu_arch = .mipsel,
341 .os_tag = .linux,
342 .abi = .eabihf,
343 },
344 },
345 .{
346 .target = .{
347 .cpu_arch = .mipsel,
348 .os_tag = .linux,
349 .abi = .musleabihf,
350 },
351 .link_libc = true,
352 },
353 .{
354 .target = .{
355 .cpu_arch = .mipsel,
356 .os_tag = .linux,
357 .abi = .musleabihf,
358 },
359 .linkage = .dynamic,
360 .link_libc = true,
361 .extra_target = true,
362 },
363 .{
364 .target = .{
365 .cpu_arch = .mipsel,
366 .os_tag = .linux,
367 .abi = .gnueabihf,
368 },
369 .link_libc = true,
370 },
371
372 .{
373 .target = .{
374 .cpu_arch = .mips64,
375 .os_tag = .linux,
376 .abi = .none,
377 },
378 },
379 .{
380 .target = .{
381 .cpu_arch = .mips64,
382 .os_tag = .linux,
383 .abi = .abin32,
384 },
385 },
386 .{
387 .target = .{
388 .cpu_arch = .mips64,
389 .os_tag = .linux,
390 .abi = .muslabi64,
391 },
392 .link_libc = true,
393 },
394 .{
395 .target = .{
396 .cpu_arch = .mips64,
397 .os_tag = .linux,
398 .abi = .muslabi64,
399 },
400 .linkage = .dynamic,
401 .link_libc = true,
402 .extra_target = true,
403 },
404 .{
405 .target = .{
406 .cpu_arch = .mips64,
407 .os_tag = .linux,
408 .abi = .muslabin32,
409 },
410 .link_libc = true,
411 },
412 .{
413 .target = .{
414 .cpu_arch = .mips64,
415 .os_tag = .linux,
416 .abi = .muslabin32,
417 },
418 .linkage = .dynamic,
419 .link_libc = true,
420 .extra_target = true,
421 },
422 .{
423 .target = .{
424 .cpu_arch = .mips64,
425 .os_tag = .linux,
426 .abi = .gnuabi64,
427 },
428 .link_libc = true,
429 },
430 .{
431 .target = .{
432 .cpu_arch = .mips64,
433 .os_tag = .linux,
434 .abi = .gnuabin32,
435 },
436 .link_libc = true,
437 },
438
439 .{
440 .target = .{
441 .cpu_arch = .mips64el,
442 .os_tag = .linux,
443 .abi = .none,
444 },
445 },
446 .{
447 .target = .{
448 .cpu_arch = .mips64el,
449 .os_tag = .linux,
450 .abi = .abin32,
451 },
452 },
453 .{
454 .target = .{
455 .cpu_arch = .mips64el,
456 .os_tag = .linux,
457 .abi = .muslabi64,
458 },
459 .link_libc = true,
460 },
461 .{
462 .target = .{
463 .cpu_arch = .mips64el,
464 .os_tag = .linux,
465 .abi = .muslabi64,
466 },
467 .linkage = .dynamic,
468 .link_libc = true,
469 .extra_target = true,
470 },
471 .{
472 .target = .{
473 .cpu_arch = .mips64el,
474 .os_tag = .linux,
475 .abi = .muslabin32,
476 },
477 .link_libc = true,
478 .extra_target = true,
479 },
480 .{
481 .target = .{
482 .cpu_arch = .mips64el,
483 .os_tag = .linux,
484 .abi = .muslabin32,
485 },
486 .linkage = .dynamic,
487 .link_libc = true,
488 .extra_target = true,
489 },
490 .{
491 .target = .{
492 .cpu_arch = .mips64el,
493 .os_tag = .linux,
494 .abi = .gnuabi64,
495 },
496 .link_libc = true,
497 },
498 .{
499 .target = .{
500 .cpu_arch = .mips64el,
501 .os_tag = .linux,
502 .abi = .gnuabin32,
503 },
504 .link_libc = true,
505 .extra_target = true,
506 },
507
508 .{
509 .target = .{
510 .cpu_arch = .powerpc,
511 .os_tag = .linux,
512 .abi = .eabihf,
513 },
514 },
515 .{
516 .target = .{
517 .cpu_arch = .powerpc,
518 .os_tag = .linux,
519 .abi = .musleabihf,
520 },
521 .link_libc = true,
522 },
523 .{
524 .target = .{
525 .cpu_arch = .powerpc,
526 .os_tag = .linux,
527 .abi = .musleabihf,
528 },
529 .linkage = .dynamic,
530 .link_libc = true,
531 .extra_target = true,
532 },
533
534 .{
535 .target = .{
536 .cpu_arch = .powerpc64,
537 .os_tag = .linux,
538 .abi = .none,
539 },
540 },
541 .{
542 .target = .{
543 .cpu_arch = .powerpc64,
544 .os_tag = .linux,
545 .abi = .musl,
546 },
547 .link_libc = true,
548 },
549 .{
550 .target = .{
551 .cpu_arch = .powerpc64,
552 .os_tag = .linux,
553 .abi = .musl,
554 },
555 .linkage = .dynamic,
556 .link_libc = true,
557 .extra_target = true,
558 },
559
560 .{
561 .target = .{
562 .cpu_arch = .powerpc64le,
563 .os_tag = .linux,
564 .abi = .none,
565 },
566 },
567 .{
568 .target = .{
569 .cpu_arch = .powerpc64le,
570 .os_tag = .linux,
571 .abi = .musl,
572 },
573 .link_libc = true,
574 },
575 .{
576 .target = .{
577 .cpu_arch = .powerpc64le,
578 .os_tag = .linux,
579 .abi = .musl,
580 },
581 .linkage = .dynamic,
582 .link_libc = true,
583 .extra_target = true,
584 },
585 .{
586 .target = .{
587 .cpu_arch = .powerpc64le,
588 .os_tag = .linux,
589 .abi = .gnu,
590 },
591 .link_libc = true,
592 },
593
594 .{
595 .target = .{
596 .cpu_arch = .riscv32,
597 .os_tag = .linux,
598 .abi = .none,
599 },
600 },
601 .{
602 .target = .{
603 .cpu_arch = .riscv32,
604 .os_tag = .linux,
605 .abi = .musl,
606 },
607 .link_libc = true,
608 },
609 .{
610 .target = .{
611 .cpu_arch = .riscv32,
612 .os_tag = .linux,
613 .abi = .musl,
614 },
615 .linkage = .dynamic,
616 .link_libc = true,
617 .extra_target = true,
618 },
619 .{
620 .target = .{
621 .cpu_arch = .riscv32,
622 .os_tag = .linux,
623 .abi = .gnu,
624 },
625 .link_libc = true,
626 },
627
628 .{
629 .target = .{
630 .cpu_arch = .riscv64,
631 .os_tag = .linux,
632 .abi = .none,
633 },
634 },
635 .{
636 .target = .{
637 .cpu_arch = .riscv64,
638 .os_tag = .linux,
639 .abi = .musl,
640 },
641 .link_libc = true,
642 },
643 .{
644 .target = .{
645 .cpu_arch = .riscv64,
646 .os_tag = .linux,
647 .abi = .musl,
648 },
649 .linkage = .dynamic,
650 .link_libc = true,
651 .extra_target = true,
652 },
653 .{
654 .target = .{
655 .cpu_arch = .riscv64,
656 .os_tag = .linux,
657 .abi = .gnu,
658 },
659 .link_libc = true,
660 },
661
662 .{
663 .target = .{
664 .cpu_arch = .s390x,
665 .os_tag = .linux,
666 .abi = .none,
667 },
668 },
669 .{
670 .target = .{
671 .cpu_arch = .s390x,
672 .os_tag = .linux,
673 .abi = .musl,
674 },
675 .link_libc = true,
676 },
677 // Currently hangs in qemu-s390x.
678 // .{
679 // .target = .{
680 // .cpu_arch = .s390x,
681 // .os_tag = .linux,
682 // .abi = .musl,
683 // },
684 // .linkage = .dynamic,
685 // .link_libc = true,
686 // .extra_target = true,
687 // },
688 .{
689 .target = .{
690 .cpu_arch = .s390x,
691 .os_tag = .linux,
692 .abi = .gnu,
693 },
694 .link_libc = true,
695 },
696
697 .{
698 .target = .{
699 .cpu_arch = .sparc64,
700 .os_tag = .linux,
701 .abi = .none,
702 },
703 },
704 // SPARC linking support is currently incomplete.
705 // .{
706 // .target = .{
707 // .cpu_arch = .sparc64,
708 // .os_tag = .linux,
709 // .abi = .gnu,
710 // },
711 // .link_libc = true,
712 // },
713
714 .{
715 .target = .{
716 .cpu_arch = .x86,
717 .os_tag = .linux,
718 .abi = .none,
719 },
720 },
721 .{
722 .target = .{
723 .cpu_arch = .x86,
724 .os_tag = .linux,
725 .abi = .musl,
726 },
727 .link_libc = true,
728 },
729 .{
730 .target = .{
731 .cpu_arch = .x86,
732 .os_tag = .linux,
733 .abi = .musl,
734 },
735 .linkage = .dynamic,
736 .link_libc = true,
737 .extra_target = true,
738 },
33739 .{
740 .target = .{
741 .cpu_arch = .x86,
742 .os_tag = .linux,
743 .abi = .gnu,
744 },
34745 .link_libc = true,
35746 },
747
748 .{
749 .target = .{
750 .cpu_arch = .x86_64,
751 .os_tag = .linux,
752 .abi = .none,
753 },
754 },
36755 .{
756 .target = .{
757 .cpu_arch = .x86_64,
758 .os_tag = .linux,
759 .abi = .none,
760 },
37761 .use_llvm = true,
38762 .use_lld = true,
39763 },
40764 .{
41 .pie = true,
765 .target = .{
766 .cpu_arch = .x86_64,
767 .os_tag = .linux,
768 .abi = .x32,
769 },
770 },
771 .{
772 .target = .{
773 .cpu_arch = .x86_64,
774 .os_tag = .linux,
775 .abi = .musl,
776 },
777 .link_libc = true,
778 },
779 .{
780 .target = .{
781 .cpu_arch = .x86_64,
782 .os_tag = .linux,
783 .abi = .musl,
784 },
785 .linkage = .dynamic,
786 .link_libc = true,
787 .extra_target = true,
788 },
789 .{
790 .target = .{
791 .cpu_arch = .x86_64,
792 .os_tag = .linux,
793 .abi = .musl,
794 },
795 .link_libc = true,
796 .use_llvm = true,
797 .use_lld = false,
798 },
799 .{
800 .target = .{
801 .cpu_arch = .x86_64,
802 .os_tag = .linux,
803 .abi = .muslx32,
804 },
805 .link_libc = true,
806 },
807 .{
808 .target = .{
809 .cpu_arch = .x86_64,
810 .os_tag = .linux,
811 .abi = .muslx32,
812 },
813 .linkage = .dynamic,
814 .link_libc = true,
815 .extra_target = true,
816 },
817 .{
818 .target = .{
819 .cpu_arch = .x86_64,
820 .os_tag = .linux,
821 .abi = .gnu,
822 },
823 .link_libc = true,
824 },
825 .{
826 .target = .{
827 .cpu_arch = .x86_64,
828 .os_tag = .linux,
829 .abi = .gnux32,
830 },
831 .link_libc = true,
832 },
833
834 // NetBSD Targets
835
836 .{
837 .target = .{
838 .cpu_arch = .riscv32,
839 .os_tag = .netbsd,
840 .abi = .none,
841 },
842 },
843
844 .{
845 .target = .{
846 .cpu_arch = .x86,
847 .os_tag = .netbsd,
848 .abi = .none,
849 },
42850 },
851
852 // Windows Targets
853
43854 .{
44855 .target = .{
45856 .cpu_arch = .aarch64,
......@@ -49,11 +860,59 @@ const param_sets = [_]CaseParameters{
49860 },
50861 .{
51862 .target = .{
52 .cpu_arch = .x86_64,
863 .cpu_arch = .aarch64,
864 .os_tag = .windows,
865 .abi = .msvc,
866 },
867 .link_libc = true,
868 },
869 .{
870 .target = .{
871 .cpu_arch = .aarch64,
872 .os_tag = .windows,
873 .abi = .gnu,
874 },
875 },
876 .{
877 .target = .{
878 .cpu_arch = .aarch64,
879 .os_tag = .windows,
880 .abi = .gnu,
881 },
882 .link_libc = true,
883 },
884
885 .{
886 .target = .{
887 .cpu_arch = .thumb,
888 .os_tag = .windows,
889 .abi = .msvc,
890 },
891 },
892 .{
893 .target = .{
894 .cpu_arch = .thumb,
895 .os_tag = .windows,
896 .abi = .msvc,
897 },
898 .link_libc = true,
899 },
900 .{
901 .target = .{
902 .cpu_arch = .thumb,
903 .os_tag = .windows,
904 .abi = .gnu,
905 },
906 },
907 .{
908 .target = .{
909 .cpu_arch = .thumb,
53910 .os_tag = .windows,
54911 .abi = .gnu,
55912 },
913 .link_libc = true,
56914 },
915
57916 .{
58917 .target = .{
59918 .cpu_arch = .x86,
......@@ -63,23 +922,57 @@ const param_sets = [_]CaseParameters{
63922 },
64923 .{
65924 .target = .{
66 .cpu_arch = .aarch64,
67 .os_tag = .macos,
925 .cpu_arch = .x86,
926 .os_tag = .windows,
927 .abi = .msvc,
68928 },
929 .link_libc = true,
69930 },
70931 .{
71932 .target = .{
72 .cpu_arch = .s390x,
73 .os_tag = .linux,
74 .abi = .none,
933 .cpu_arch = .x86,
934 .os_tag = .windows,
935 .abi = .gnu,
75936 },
76937 },
77938 .{
78939 .target = .{
79 .cpu_arch = .loongarch32,
80 .os_tag = .linux,
81 .abi = .none,
940 .cpu_arch = .x86,
941 .os_tag = .windows,
942 .abi = .gnu,
943 },
944 .link_libc = true,
945 },
946
947 .{
948 .target = .{
949 .cpu_arch = .x86_64,
950 .os_tag = .windows,
951 .abi = .msvc,
952 },
953 },
954 .{
955 .target = .{
956 .cpu_arch = .x86_64,
957 .os_tag = .windows,
958 .abi = .msvc,
959 },
960 .link_libc = true,
961 },
962 .{
963 .target = .{
964 .cpu_arch = .x86_64,
965 .os_tag = .windows,
966 .abi = .gnu,
967 },
968 },
969 .{
970 .target = .{
971 .cpu_arch = .x86_64,
972 .os_tag = .windows,
973 .abi = .gnu,
82974 },
975 .link_libc = true,
83976 },
84977};
85978
......@@ -112,16 +1005,41 @@ pub fn addCases(self: *StackTrace) void {
1121005
1131006 for (&param_sets) |*params| {
1141007 const resolved_target = b.resolveTargetQuery(params.target);
1008 const target = &resolved_target.result;
1151009
116 if (self.skip_non_native and !resolved_target.query.isNative()) continue;
1010 if (!self.options.test_extra_targets and params.extra_target) continue;
1171011
118 // To avoid redundant testing, skip cross-compilation targets matching the host.
119 if (resolved_target.result.os.tag == builtin.target.os.tag and
120 resolved_target.result.cpu.arch == builtin.target.cpu.arch)
121 {
122 continue;
1012 if (self.options.skip_non_native and !tests.isNative(&resolved_target, &b.graph.host.result)) continue;
1013
1014 if (self.options.skip_freebsd and target.os.tag == .freebsd) continue;
1015 if (self.options.skip_netbsd and target.os.tag == .netbsd) continue;
1016 if (self.options.skip_openbsd and target.os.tag == .openbsd) continue;
1017 if (self.options.skip_windows and target.os.tag == .windows) continue;
1018 if (self.options.skip_darwin and target.os.tag.isDarwin()) continue;
1019 if (self.options.skip_linux and target.os.tag == .linux) continue;
1020
1021 const would_use_llvm = tests.wouldUseLlvm(params.use_llvm, params.target, params.optimize);
1022 if (self.options.skip_llvm and would_use_llvm) continue;
1023
1024 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
1025
1026 if (self.options.test_target_filters.len > 0) {
1027 for (self.options.test_target_filters) |filter| {
1028 if (std.mem.find(u8, triple_txt, filter) != null) break;
1029 } else continue;
1231030 }
1241031
1032 if (self.options.skip_libc and (params.link_libc == true or std.os.targetRequiresLibC(target)))
1033 continue;
1034
1035 // We can't provide MSVC libc when cross-compiling.
1036 if (target.abi == .msvc and params.link_libc == true and builtin.os.tag != .windows)
1037 continue;
1038
1039 for (self.options.optimize_modes) |optimize| {
1040 if (optimize == params.optimize) break;
1041 } else return;
1042
1251043 stack_traces_cases.addCases(self, params, &resolved_target.result);
1261044 }
1271045}
......@@ -163,7 +1081,7 @@ pub fn addCase(self: *StackTrace, config: Config) void {
1631081 else => .unsafe,
1641082 };
1651083 const supports_unwind_tables = switch (target.os.tag) {
166 // x86-windows just has no way to do stack unwinding other then using frame pointers.
1084 // x86-windows just has no way to do stack unwinding other than using frame pointers.
1671085 .windows => target.cpu.arch != .x86,
1681086 else => true,
1691087 };
......@@ -255,19 +1173,22 @@ fn addCaseInstance(
2551173 else
2561174 "";
2571175
258 const annotated_case_name = b.fmt("check {s} ({s}{s}{s}{s}{s}{s}{s}{s})", .{
1176 const annotated_case_name = b.fmt("check {s} ({s}{s}{s}{s}{s}{s}{s}{s}{s})", .{
2591177 name,
2601178 triple orelse "",
2611179 if (triple != null) " " else "",
2621180 backend_string,
2631181 if (params.pie == true) " pie" else "",
2641182 if (params.link_libc == true) " libc" else "",
1183 if (params.linkage) |linkage| switch (linkage) {
1184 inline else => |t| " " ++ @tagName(t),
1185 } else "",
2651186 strip_string,
2661187 if (strip_unwind) " no_unwind" else "",
2671188 if (omit_frame_pointer) " no_fp" else "",
2681189 });
269 if (self.test_filters.len > 0) {
270 for (self.test_filters) |test_filter| {
1190 if (self.options.test_filters.len > 0) {
1191 for (self.options.test_filters) |test_filter| {
2711192 if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
2721193 } else return;
2731194 }
......@@ -278,7 +1199,7 @@ fn addCaseInstance(
2781199 .name = "test",
2791200 .root_module = b.createModule(.{
2801201 .root_source_file = source_zig,
281 .optimize = .Debug,
1202 .optimize = params.optimize,
2821203 .target = resolved_target,
2831204 .omit_frame_pointer = omit_frame_pointer,
2841205 .link_libc = params.link_libc,
......@@ -289,6 +1210,7 @@ fn addCaseInstance(
2891210 .use_llvm = params.use_llvm,
2901211 .use_lld = params.use_lld,
2911212 });
1213 exe.linkage = params.linkage;
2921214 exe.pie = params.pie;
2931215 exe.bundle_ubsan_rt = false;
2941216
......@@ -296,11 +1218,13 @@ fn addCaseInstance(
2961218 run.skip_foreign_checks = true;
2971219 run.removeEnvironmentVariable("CLICOLOR_FORCE");
2981220 run.setEnvironmentVariable("NO_COLOR", "1");
299 run.addCheck(.{ .expect_term = term: {
300 if (!expect_panic) break :term .{ .exited = 0 };
301 if (resolved_target.result.os.tag == .windows) break :term .{ .exited = 3 };
302 break :term .{ .signal = @fromBackingInt(@intCast(6)) };
303 } });
1221 run.addCheck(.{
1222 .expect_term = term: {
1223 if (!expect_panic) break :term .{ .exited = 0 };
1224 if (resolved_target.result.os.tag == .windows) break :term .{ .exited = 3 };
1225 break :term .{ .signal = @fromBackingInt(@intCast(6)) }; // SIGABRT
1226 },
1227 });
3041228 run.expectStdOutEqual("");
3051229
3061230 const check_run = b.addRunArtifact(self.convert_exe);
test/tests.zig+4-13
......@@ -747,7 +747,6 @@ const module_test_targets = blk: {
747747 .os_tag = .linux,
748748 .abi = .abin32,
749749 },
750 .extra_target = true,
751750 },
752751 .{
753752 .target = .{
......@@ -2379,7 +2378,7 @@ pub fn isNative(actual_target: *const std.Build.ResolvedTarget, host: *const std
23792378 return true;
23802379}
23812380
2382pub fn addStackTraceTests(b: *std.Build, test_filters: []const []const u8, skip_non_native: bool) *Step {
2381pub fn addStackTraceTests(b: *std.Build, options: StackTracesContext.Options) *Step {
23832382 const step = b.step("test-stack-traces", "Run the stack trace tests");
23842383
23852384 const convert_exe = b.addExecutable(.{
......@@ -2395,8 +2394,7 @@ pub fn addStackTraceTests(b: *std.Build, test_filters: []const []const u8, skip_
23952394 stack_traces_context.* = .{
23962395 .b = b,
23972396 .step = step,
2398 .test_filters = test_filters,
2399 .skip_non_native = skip_non_native,
2397 .options = options,
24002398 .convert_exe = convert_exe,
24012399 };
24022400 stack_traces_context.addCases();
......@@ -2404,12 +2402,7 @@ pub fn addStackTraceTests(b: *std.Build, test_filters: []const []const u8, skip_
24042402 return step;
24052403}
24062404
2407pub fn addErrorTraceTests(
2408 b: *std.Build,
2409 test_filters: []const []const u8,
2410 optimize_modes: []const OptimizeMode,
2411 skip_non_native: bool,
2412) *Step {
2405pub fn addErrorTraceTests(b: *std.Build, options: ErrorTracesContext.Options) *Step {
24132406 const step = b.step("test-error-traces", "Run the error trace tests");
24142407
24152408 const convert_exe = b.addExecutable(.{
......@@ -2425,9 +2418,7 @@ pub fn addErrorTraceTests(
24252418 error_traces_context.* = .{
24262419 .b = b,
24272420 .step = step,
2428 .test_filters = test_filters,
2429 .skip_non_native = skip_non_native,
2430 .optimize_modes = optimize_modes,
2421 .options = options,
24312422 .convert_exe = convert_exe,
24322423 };
24332424 error_traces_context.addCases();