authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-21 20:28:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-05 22:29:25-07:00
log496eb69273d363f21ca3923f00714b229882e42a
tree97229b0fe671e43e2aeafa3ac5d315bc2d8f44fd
parentdf38dfa4d1c9028453f90c7e37dd6c06f829a995

CI: add non-LLVM backends to the test matrix

We can't yet run the behavior tests with stage3, but at least we can run them with stage2, and we can use the proper test matrix. This commit also adds use_llvm and ofmt to the zig build system.

4 files changed, 170 insertions(+), 65 deletions(-)

build.zig+12
...@@ -445,6 +445,9 @@ pub fn build(b: *Builder) !void {...@@ -445,6 +445,9 @@ pub fn build(b: *Builder) !void {
445 false, // skip_single_threaded445 false, // skip_single_threaded
446 skip_non_native,446 skip_non_native,
447 skip_libc,447 skip_libc,
448 skip_stage1,
449 omit_stage2,
450 is_stage1,
448 ));451 ));
449452
450 toolchain_step.dependOn(tests.addPkgTests(453 toolchain_step.dependOn(tests.addPkgTests(
...@@ -457,6 +460,9 @@ pub fn build(b: *Builder) !void {...@@ -457,6 +460,9 @@ pub fn build(b: *Builder) !void {
457 true, // skip_single_threaded460 true, // skip_single_threaded
458 skip_non_native,461 skip_non_native,
459 true, // skip_libc462 true, // skip_libc
463 skip_stage1,
464 omit_stage2 or true, // TODO get these all passing
465 is_stage1,
460 ));466 ));
461467
462 toolchain_step.dependOn(tests.addPkgTests(468 toolchain_step.dependOn(tests.addPkgTests(
...@@ -469,6 +475,9 @@ pub fn build(b: *Builder) !void {...@@ -469,6 +475,9 @@ pub fn build(b: *Builder) !void {
469 true, // skip_single_threaded475 true, // skip_single_threaded
470 skip_non_native,476 skip_non_native,
471 true, // skip_libc477 true, // skip_libc
478 skip_stage1,
479 omit_stage2 or true, // TODO get these all passing
480 is_stage1,
472 ));481 ));
473482
474 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));483 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
...@@ -494,6 +503,9 @@ pub fn build(b: *Builder) !void {...@@ -494,6 +503,9 @@ pub fn build(b: *Builder) !void {
494 false,503 false,
495 skip_non_native,504 skip_non_native,
496 skip_libc,505 skip_libc,
506 skip_stage1,
507 omit_stage2 or true, // TODO get these all passing
508 is_stage1,
497 );509 );
498510
499 const test_step = b.step("test", "Run all the tests");511 const test_step = b.step("test", "Run all the tests");
ci/zinc/linux_test.sh+11-19
...@@ -48,25 +48,19 @@ cd $WORKSPACE...@@ -48,25 +48,19 @@ cd $WORKSPACE
48$ZIG fmt --check . --exclude test/cases/48$ZIG fmt --check . --exclude test/cases/
4949
50# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt.50# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt.
51$ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"51$ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
5252
53# Ensure that stage2 can build itself.53# Ensure that stage2 can build itself.
54./stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"54stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
5555stage2/bin/zig build # test building self-hosted without LLVM
56stage2/bin/zig test test/behavior.zig -I test -fLLVM56stage2/bin/zig build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm
57stage2/bin/zig test test/behavior.zig -I test -fno-LLVM57
58stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin58# Here we use stage2 instead of stage3 because of two bugs remaining:
59stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin59# * https://github.com/ziglang/zig/issues/11367 (and corresponding workaround in compiler source)
60stage2/bin/zig test test/behavior.zig -I test -ofmt=c60# * https://github.com/ziglang/zig/pull/11492#issuecomment-1112871321
61stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin61stage2/bin/zig build test-behavior -fqemu -fwasmtime
62stage2/bin/zig test test/behavior.zig -I test -fLLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin62
63stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target arm-linux --test-cmd qemu-arm --test-cmd-bin63$ZIG build test-behavior -fqemu -fwasmtime -Domit-stage2
64stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-macos --test-no-exec
65stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-macos --test-no-exec
66stage2/bin/zig test test/behavior.zig -I test -fLLVM -target x86_64-macos --test-no-exec
67stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target x86_64-macos --test-no-exec
68
69$ZIG build test-behavior -fqemu -fwasmtime
70$ZIG build test-compiler-rt -fqemu -fwasmtime64$ZIG build test-compiler-rt -fqemu -fwasmtime
71$ZIG build test-std -fqemu -fwasmtime65$ZIG build test-std -fqemu -fwasmtime
72$ZIG build test-minilibc -fqemu -fwasmtime66$ZIG build test-minilibc -fqemu -fwasmtime
...@@ -79,8 +73,6 @@ $ZIG build test-runtime-safety -fqemu -fwasmtime...@@ -79,8 +73,6 @@ $ZIG build test-runtime-safety -fqemu -fwasmtime
79$ZIG build test-translate-c -fqemu -fwasmtime73$ZIG build test-translate-c -fqemu -fwasmtime
80$ZIG build test-run-translated-c -fqemu -fwasmtime74$ZIG build test-run-translated-c -fqemu -fwasmtime
81$ZIG build docs -fqemu -fwasmtime75$ZIG build docs -fqemu -fwasmtime
82$ZIG build # test building self-hosted without LLVM
83$ZIG build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm
84$ZIG build test-fmt -fqemu -fwasmtime76$ZIG build test-fmt -fqemu -fwasmtime
85$ZIG build test-stage2 -fqemu -fwasmtime77$ZIG build test-stage2 -fqemu -fwasmtime
8678
lib/std/build.zig+14
...@@ -1590,6 +1590,8 @@ pub const LibExeObjStep = struct {...@@ -1590,6 +1590,8 @@ pub const LibExeObjStep = struct {
15901590
1591 want_lto: ?bool = null,1591 want_lto: ?bool = null,
1592 use_stage1: ?bool = null,1592 use_stage1: ?bool = null,
1593 use_llvm: ?bool = null,
1594 ofmt: ?std.Target.ObjectFormat = null,
15931595
1594 output_path_source: GeneratedFile,1596 output_path_source: GeneratedFile,
1595 output_lib_path_source: GeneratedFile,1597 output_lib_path_source: GeneratedFile,
...@@ -2351,6 +2353,18 @@ pub const LibExeObjStep = struct {...@@ -2351,6 +2353,18 @@ pub const LibExeObjStep = struct {
2351 }2353 }
2352 }2354 }
23532355
2356 if (self.use_llvm) |use_llvm| {
2357 if (use_llvm) {
2358 try zig_args.append("-fLLVM");
2359 } else {
2360 try zig_args.append("-fno-LLVM");
2361 }
2362 }
2363
2364 if (self.ofmt) |ofmt| {
2365 try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)}));
2366 }
2367
2354 if (self.entry_symbol_name) |entry| {2368 if (self.entry_symbol_name) |entry| {
2355 try zig_args.append("--entry");2369 try zig_args.append("--entry");
2356 try zig_args.append(entry);2370 try zig_args.append(entry);
test/tests.zig+133-46
...@@ -34,6 +34,7 @@ const TestTarget = struct {...@@ -34,6 +34,7 @@ const TestTarget = struct {
34 link_libc: bool = false,34 link_libc: bool = false,
35 single_threaded: bool = false,35 single_threaded: bool = false,
36 disable_native: bool = false,36 disable_native: bool = false,
37 backend: ?std.builtin.CompilerBackend = null,
37};38};
3839
39const test_targets = blk: {40const test_targets = blk: {
...@@ -42,15 +43,73 @@ const test_targets = blk: {...@@ -42,15 +43,73 @@ const test_targets = blk: {
42 // lot of branches)43 // lot of branches)
43 @setEvalBranchQuota(50000);44 @setEvalBranchQuota(50000);
44 break :blk [_]TestTarget{45 break :blk [_]TestTarget{
45 TestTarget{},46 .{},
46 TestTarget{47 .{
47 .link_libc = true,48 .link_libc = true,
48 },49 },
49 TestTarget{50 .{
50 .single_threaded = true,51 .single_threaded = true,
51 },52 },
5253
53 TestTarget{54 .{
55 .link_libc = true,
56 .backend = .stage2_c,
57 },
58 .{
59 .target = .{
60 .cpu_arch = .x86_64,
61 .os_tag = .linux,
62 .abi = .none,
63 },
64 .backend = .stage2_x86_64,
65 },
66 .{
67 .target = .{
68 .cpu_arch = .aarch64,
69 .os_tag = .linux,
70 },
71 .backend = .stage2_aarch64,
72 },
73 .{
74 .target = .{
75 .cpu_arch = .wasm32,
76 .os_tag = .wasi,
77 },
78 .single_threaded = true,
79 .backend = .stage2_wasm,
80 },
81 .{
82 .target = .{
83 .cpu_arch = .arm,
84 .os_tag = .linux,
85 },
86 .backend = .stage2_wasm,
87 },
88 .{
89 .target = CrossTarget.parse(.{
90 .arch_os_abi = "arm-linux-none",
91 .cpu_features = "generic+v8a",
92 }) catch unreachable,
93 .backend = .stage2_arm,
94 },
95 .{
96 .target = .{
97 .cpu_arch = .aarch64,
98 .os_tag = .macos,
99 .abi = .gnu,
100 },
101 .backend = .stage2_aarch64,
102 },
103 .{
104 .target = .{
105 .cpu_arch = .x86_64,
106 .os_tag = .macos,
107 .abi = .gnu,
108 },
109 .backend = .stage2_x86_64,
110 },
111
112 .{
54 .target = .{113 .target = .{
55 .cpu_arch = .wasm32,114 .cpu_arch = .wasm32,
56 .os_tag = .wasi,115 .os_tag = .wasi,
...@@ -58,7 +117,7 @@ const test_targets = blk: {...@@ -58,7 +117,7 @@ const test_targets = blk: {
58 .link_libc = false,117 .link_libc = false,
59 .single_threaded = true,118 .single_threaded = true,
60 },119 },
61 TestTarget{120 .{
62 .target = .{121 .target = .{
63 .cpu_arch = .wasm32,122 .cpu_arch = .wasm32,
64 .os_tag = .wasi,123 .os_tag = .wasi,
...@@ -67,14 +126,14 @@ const test_targets = blk: {...@@ -67,14 +126,14 @@ const test_targets = blk: {
67 .single_threaded = true,126 .single_threaded = true,
68 },127 },
69128
70 TestTarget{129 .{
71 .target = .{130 .target = .{
72 .cpu_arch = .x86_64,131 .cpu_arch = .x86_64,
73 .os_tag = .linux,132 .os_tag = .linux,
74 .abi = .none,133 .abi = .none,
75 },134 },
76 },135 },
77 TestTarget{136 .{
78 .target = .{137 .target = .{
79 .cpu_arch = .x86_64,138 .cpu_arch = .x86_64,
80 .os_tag = .linux,139 .os_tag = .linux,
...@@ -82,7 +141,7 @@ const test_targets = blk: {...@@ -82,7 +141,7 @@ const test_targets = blk: {
82 },141 },
83 .link_libc = true,142 .link_libc = true,
84 },143 },
85 TestTarget{144 .{
86 .target = .{145 .target = .{
87 .cpu_arch = .x86_64,146 .cpu_arch = .x86_64,
88 .os_tag = .linux,147 .os_tag = .linux,
...@@ -91,14 +150,14 @@ const test_targets = blk: {...@@ -91,14 +150,14 @@ const test_targets = blk: {
91 .link_libc = true,150 .link_libc = true,
92 },151 },
93152
94 TestTarget{153 .{
95 .target = .{154 .target = .{
96 .cpu_arch = .i386,155 .cpu_arch = .i386,
97 .os_tag = .linux,156 .os_tag = .linux,
98 .abi = .none,157 .abi = .none,
99 },158 },
100 },159 },
101 TestTarget{160 .{
102 .target = .{161 .target = .{
103 .cpu_arch = .i386,162 .cpu_arch = .i386,
104 .os_tag = .linux,163 .os_tag = .linux,
...@@ -106,7 +165,7 @@ const test_targets = blk: {...@@ -106,7 +165,7 @@ const test_targets = blk: {
106 },165 },
107 .link_libc = true,166 .link_libc = true,
108 },167 },
109 TestTarget{168 .{
110 .target = .{169 .target = .{
111 .cpu_arch = .i386,170 .cpu_arch = .i386,
112 .os_tag = .linux,171 .os_tag = .linux,
...@@ -115,14 +174,14 @@ const test_targets = blk: {...@@ -115,14 +174,14 @@ const test_targets = blk: {
115 .link_libc = true,174 .link_libc = true,
116 },175 },
117176
118 TestTarget{177 .{
119 .target = .{178 .target = .{
120 .cpu_arch = .aarch64,179 .cpu_arch = .aarch64,
121 .os_tag = .linux,180 .os_tag = .linux,
122 .abi = .none,181 .abi = .none,
123 },182 },
124 },183 },
125 TestTarget{184 .{
126 .target = .{185 .target = .{
127 .cpu_arch = .aarch64,186 .cpu_arch = .aarch64,
128 .os_tag = .linux,187 .os_tag = .linux,
...@@ -130,7 +189,7 @@ const test_targets = blk: {...@@ -130,7 +189,7 @@ const test_targets = blk: {
130 },189 },
131 .link_libc = true,190 .link_libc = true,
132 },191 },
133 TestTarget{192 .{
134 .target = .{193 .target = .{
135 .cpu_arch = .aarch64,194 .cpu_arch = .aarch64,
136 .os_tag = .linux,195 .os_tag = .linux,
...@@ -138,7 +197,7 @@ const test_targets = blk: {...@@ -138,7 +197,7 @@ const test_targets = blk: {
138 },197 },
139 .link_libc = true,198 .link_libc = true,
140 },199 },
141 TestTarget{200 .{
142 .target = .{201 .target = .{
143 .cpu_arch = .aarch64,202 .cpu_arch = .aarch64,
144 .os_tag = .windows,203 .os_tag = .windows,
...@@ -147,13 +206,13 @@ const test_targets = blk: {...@@ -147,13 +206,13 @@ const test_targets = blk: {
147 .link_libc = true,206 .link_libc = true,
148 },207 },
149208
150 TestTarget{209 .{
151 .target = CrossTarget.parse(.{210 .target = CrossTarget.parse(.{
152 .arch_os_abi = "arm-linux-none",211 .arch_os_abi = "arm-linux-none",
153 .cpu_features = "generic+v8a",212 .cpu_features = "generic+v8a",
154 }) catch unreachable,213 }) catch unreachable,
155 },214 },
156 TestTarget{215 .{
157 .target = CrossTarget.parse(.{216 .target = CrossTarget.parse(.{
158 .arch_os_abi = "arm-linux-musleabihf",217 .arch_os_abi = "arm-linux-musleabihf",
159 .cpu_features = "generic+v8a",218 .cpu_features = "generic+v8a",
...@@ -161,7 +220,7 @@ const test_targets = blk: {...@@ -161,7 +220,7 @@ const test_targets = blk: {
161 .link_libc = true,220 .link_libc = true,
162 },221 },
163 // https://github.com/ziglang/zig/issues/3287222 // https://github.com/ziglang/zig/issues/3287
164 //TestTarget{223 //.{
165 // .target = CrossTarget.parse(.{224 // .target = CrossTarget.parse(.{
166 // .arch_os_abi = "arm-linux-gnueabihf",225 // .arch_os_abi = "arm-linux-gnueabihf",
167 // .cpu_features = "generic+v8a",226 // .cpu_features = "generic+v8a",
...@@ -169,7 +228,7 @@ const test_targets = blk: {...@@ -169,7 +228,7 @@ const test_targets = blk: {
169 // .link_libc = true,228 // .link_libc = true,
170 //},229 //},
171230
172 TestTarget{231 .{
173 .target = .{232 .target = .{
174 .cpu_arch = .mips,233 .cpu_arch = .mips,
175 .os_tag = .linux,234 .os_tag = .linux,
...@@ -177,7 +236,7 @@ const test_targets = blk: {...@@ -177,7 +236,7 @@ const test_targets = blk: {
177 },236 },
178 },237 },
179238
180 TestTarget{239 .{
181 .target = .{240 .target = .{
182 .cpu_arch = .mips,241 .cpu_arch = .mips,
183 .os_tag = .linux,242 .os_tag = .linux,
...@@ -187,7 +246,7 @@ const test_targets = blk: {...@@ -187,7 +246,7 @@ const test_targets = blk: {
187 },246 },
188247
189 // https://github.com/ziglang/zig/issues/4927248 // https://github.com/ziglang/zig/issues/4927
190 //TestTarget{249 //.{
191 // .target = .{250 // .target = .{
192 // .cpu_arch = .mips,251 // .cpu_arch = .mips,
193 // .os_tag = .linux,252 // .os_tag = .linux,
...@@ -196,7 +255,7 @@ const test_targets = blk: {...@@ -196,7 +255,7 @@ const test_targets = blk: {
196 // .link_libc = true,255 // .link_libc = true,
197 //},256 //},
198257
199 TestTarget{258 .{
200 .target = .{259 .target = .{
201 .cpu_arch = .mipsel,260 .cpu_arch = .mipsel,
202 .os_tag = .linux,261 .os_tag = .linux,
...@@ -204,7 +263,7 @@ const test_targets = blk: {...@@ -204,7 +263,7 @@ const test_targets = blk: {
204 },263 },
205 },264 },
206265
207 TestTarget{266 .{
208 .target = .{267 .target = .{
209 .cpu_arch = .mipsel,268 .cpu_arch = .mipsel,
210 .os_tag = .linux,269 .os_tag = .linux,
...@@ -214,7 +273,7 @@ const test_targets = blk: {...@@ -214,7 +273,7 @@ const test_targets = blk: {
214 },273 },
215274
216 // https://github.com/ziglang/zig/issues/4927275 // https://github.com/ziglang/zig/issues/4927
217 //TestTarget{276 //.{
218 // .target = .{277 // .target = .{
219 // .cpu_arch = .mipsel,278 // .cpu_arch = .mipsel,
220 // .os_tag = .linux,279 // .os_tag = .linux,
...@@ -223,14 +282,14 @@ const test_targets = blk: {...@@ -223,14 +282,14 @@ const test_targets = blk: {
223 // .link_libc = true,282 // .link_libc = true,
224 //},283 //},
225284
226 TestTarget{285 .{
227 .target = .{286 .target = .{
228 .cpu_arch = .powerpc,287 .cpu_arch = .powerpc,
229 .os_tag = .linux,288 .os_tag = .linux,
230 .abi = .none,289 .abi = .none,
231 },290 },
232 },291 },
233 TestTarget{292 .{
234 .target = .{293 .target = .{
235 .cpu_arch = .powerpc,294 .cpu_arch = .powerpc,
236 .os_tag = .linux,295 .os_tag = .linux,
...@@ -239,7 +298,7 @@ const test_targets = blk: {...@@ -239,7 +298,7 @@ const test_targets = blk: {
239 .link_libc = true,298 .link_libc = true,
240 },299 },
241 // https://github.com/ziglang/zig/issues/2256300 // https://github.com/ziglang/zig/issues/2256
242 //TestTarget{301 //.{
243 // .target = .{302 // .target = .{
244 // .cpu_arch = .powerpc,303 // .cpu_arch = .powerpc,
245 // .os_tag = .linux,304 // .os_tag = .linux,
...@@ -248,7 +307,7 @@ const test_targets = blk: {...@@ -248,7 +307,7 @@ const test_targets = blk: {
248 // .link_libc = true,307 // .link_libc = true,
249 //},308 //},
250309
251 TestTarget{310 .{
252 .target = .{311 .target = .{
253 .cpu_arch = .riscv64,312 .cpu_arch = .riscv64,
254 .os_tag = .linux,313 .os_tag = .linux,
...@@ -256,7 +315,7 @@ const test_targets = blk: {...@@ -256,7 +315,7 @@ const test_targets = blk: {
256 },315 },
257 },316 },
258317
259 TestTarget{318 .{
260 .target = .{319 .target = .{
261 .cpu_arch = .riscv64,320 .cpu_arch = .riscv64,
262 .os_tag = .linux,321 .os_tag = .linux,
...@@ -266,7 +325,7 @@ const test_targets = blk: {...@@ -266,7 +325,7 @@ const test_targets = blk: {
266 },325 },
267326
268 // https://github.com/ziglang/zig/issues/3340327 // https://github.com/ziglang/zig/issues/3340
269 //TestTarget{328 //.{
270 // .target = .{329 // .target = .{
271 // .cpu_arch = .riscv64,330 // .cpu_arch = .riscv64,
272 // .os = .linux,331 // .os = .linux,
...@@ -275,7 +334,7 @@ const test_targets = blk: {...@@ -275,7 +334,7 @@ const test_targets = blk: {
275 // .link_libc = true,334 // .link_libc = true,
276 //},335 //},
277336
278 TestTarget{337 .{
279 .target = .{338 .target = .{
280 .cpu_arch = .x86_64,339 .cpu_arch = .x86_64,
281 .os_tag = .macos,340 .os_tag = .macos,
...@@ -283,7 +342,7 @@ const test_targets = blk: {...@@ -283,7 +342,7 @@ const test_targets = blk: {
283 },342 },
284 },343 },
285344
286 TestTarget{345 .{
287 .target = .{346 .target = .{
288 .cpu_arch = .aarch64,347 .cpu_arch = .aarch64,
289 .os_tag = .macos,348 .os_tag = .macos,
...@@ -291,7 +350,7 @@ const test_targets = blk: {...@@ -291,7 +350,7 @@ const test_targets = blk: {
291 },350 },
292 },351 },
293352
294 TestTarget{353 .{
295 .target = .{354 .target = .{
296 .cpu_arch = .i386,355 .cpu_arch = .i386,
297 .os_tag = .windows,356 .os_tag = .windows,
...@@ -299,7 +358,7 @@ const test_targets = blk: {...@@ -299,7 +358,7 @@ const test_targets = blk: {
299 },358 },
300 },359 },
301360
302 TestTarget{361 .{
303 .target = .{362 .target = .{
304 .cpu_arch = .x86_64,363 .cpu_arch = .x86_64,
305 .os_tag = .windows,364 .os_tag = .windows,
...@@ -307,7 +366,7 @@ const test_targets = blk: {...@@ -307,7 +366,7 @@ const test_targets = blk: {
307 },366 },
308 },367 },
309368
310 TestTarget{369 .{
311 .target = .{370 .target = .{
312 .cpu_arch = .i386,371 .cpu_arch = .i386,
313 .os_tag = .windows,372 .os_tag = .windows,
...@@ -316,7 +375,7 @@ const test_targets = blk: {...@@ -316,7 +375,7 @@ const test_targets = blk: {
316 .link_libc = true,375 .link_libc = true,
317 },376 },
318377
319 TestTarget{378 .{
320 .target = .{379 .target = .{
321 .cpu_arch = .x86_64,380 .cpu_arch = .x86_64,
322 .os_tag = .windows,381 .os_tag = .windows,
...@@ -326,38 +385,38 @@ const test_targets = blk: {...@@ -326,38 +385,38 @@ const test_targets = blk: {
326 },385 },
327386
328 // Do the release tests last because they take a long time387 // Do the release tests last because they take a long time
329 TestTarget{388 .{
330 .mode = .ReleaseFast,389 .mode = .ReleaseFast,
331 },390 },
332 TestTarget{391 .{
333 .link_libc = true,392 .link_libc = true,
334 .mode = .ReleaseFast,393 .mode = .ReleaseFast,
335 },394 },
336 TestTarget{395 .{
337 .mode = .ReleaseFast,396 .mode = .ReleaseFast,
338 .single_threaded = true,397 .single_threaded = true,
339 },398 },
340399
341 TestTarget{400 .{
342 .mode = .ReleaseSafe,401 .mode = .ReleaseSafe,
343 },402 },
344 TestTarget{403 .{
345 .link_libc = true,404 .link_libc = true,
346 .mode = .ReleaseSafe,405 .mode = .ReleaseSafe,
347 },406 },
348 TestTarget{407 .{
349 .mode = .ReleaseSafe,408 .mode = .ReleaseSafe,
350 .single_threaded = true,409 .single_threaded = true,
351 },410 },
352411
353 TestTarget{412 .{
354 .mode = .ReleaseSmall,413 .mode = .ReleaseSmall,
355 },414 },
356 TestTarget{415 .{
357 .link_libc = true,416 .link_libc = true,
358 .mode = .ReleaseSmall,417 .mode = .ReleaseSmall,
359 },418 },
360 TestTarget{419 .{
361 .mode = .ReleaseSmall,420 .mode = .ReleaseSmall,
362 .single_threaded = true,421 .single_threaded = true,
363 },422 },
...@@ -524,6 +583,9 @@ pub fn addPkgTests(...@@ -524,6 +583,9 @@ pub fn addPkgTests(
524 skip_single_threaded: bool,583 skip_single_threaded: bool,
525 skip_non_native: bool,584 skip_non_native: bool,
526 skip_libc: bool,585 skip_libc: bool,
586 skip_stage1: bool,
587 skip_stage2: bool,
588 is_stage1: bool,
527) *build.Step {589) *build.Step {
528 const step = b.step(b.fmt("test-{s}", .{name}), desc);590 const step = b.step(b.fmt("test-{s}", .{name}), desc);
529591
...@@ -549,6 +611,11 @@ pub fn addPkgTests(...@@ -549,6 +611,11 @@ pub fn addPkgTests(
549 continue;611 continue;
550 }612 }
551613
614 if (test_target.backend) |backend| switch (backend) {
615 .stage1 => if (skip_stage1) continue,
616 else => if (skip_stage2) continue,
617 } else if (is_stage1 and skip_stage1) continue;
618
552 const want_this_mode = for (modes) |m| {619 const want_this_mode = for (modes) |m| {
553 if (m == test_target.mode) break true;620 if (m == test_target.mode) break true;
554 } else false;621 } else false;
...@@ -565,12 +632,14 @@ pub fn addPkgTests(...@@ -565,12 +632,14 @@ pub fn addPkgTests(
565632
566 const these_tests = b.addTest(root_src);633 const these_tests = b.addTest(root_src);
567 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";634 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
568 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s} ", .{635 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
636 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s}-{s} ", .{
569 name,637 name,
570 triple_prefix,638 triple_prefix,
571 @tagName(test_target.mode),639 @tagName(test_target.mode),
572 libc_prefix,640 libc_prefix,
573 single_threaded_txt,641 single_threaded_txt,
642 backend_txt,
574 }));643 }));
575 these_tests.single_threaded = test_target.single_threaded;644 these_tests.single_threaded = test_target.single_threaded;
576 these_tests.setFilter(test_filter);645 these_tests.setFilter(test_filter);
...@@ -581,6 +650,24 @@ pub fn addPkgTests(...@@ -581,6 +650,24 @@ pub fn addPkgTests(
581 }650 }
582 these_tests.overrideZigLibDir("lib");651 these_tests.overrideZigLibDir("lib");
583 these_tests.addIncludePath("test");652 these_tests.addIncludePath("test");
653 if (test_target.backend) |backend| switch (backend) {
654 .stage1 => {
655 these_tests.use_stage1 = true;
656 },
657 .stage2_llvm => {
658 these_tests.use_stage1 = false;
659 these_tests.use_llvm = true;
660 },
661 .stage2_c => {
662 these_tests.use_stage1 = false;
663 these_tests.use_llvm = false;
664 these_tests.ofmt = .c;
665 },
666 else => {
667 these_tests.use_stage1 = false;
668 these_tests.use_llvm = false;
669 },
670 };
584671
585 step.dependOn(&these_tests.step);672 step.dependOn(&these_tests.step);
586 }673 }