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 {
445445 false, // skip_single_threaded
446446 skip_non_native,
447447 skip_libc,
448 skip_stage1,
449 omit_stage2,
450 is_stage1,
448451 ));
449452
450453 toolchain_step.dependOn(tests.addPkgTests(
......@@ -457,6 +460,9 @@ pub fn build(b: *Builder) !void {
457460 true, // skip_single_threaded
458461 skip_non_native,
459462 true, // skip_libc
463 skip_stage1,
464 omit_stage2 or true, // TODO get these all passing
465 is_stage1,
460466 ));
461467
462468 toolchain_step.dependOn(tests.addPkgTests(
......@@ -469,6 +475,9 @@ pub fn build(b: *Builder) !void {
469475 true, // skip_single_threaded
470476 skip_non_native,
471477 true, // skip_libc
478 skip_stage1,
479 omit_stage2 or true, // TODO get these all passing
480 is_stage1,
472481 ));
473482
474483 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
......@@ -494,6 +503,9 @@ pub fn build(b: *Builder) !void {
494503 false,
495504 skip_non_native,
496505 skip_libc,
506 skip_stage1,
507 omit_stage2 or true, // TODO get these all passing
508 is_stage1,
497509 );
498510
499511 const test_step = b.step("test", "Run all the tests");
ci/zinc/linux_test.sh+11-19
......@@ -48,25 +48,19 @@ cd $WORKSPACE
4848$ZIG fmt --check . --exclude test/cases/
4949
5050# 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
5353# Ensure that stage2 can build itself.
54./stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
55
56stage2/bin/zig test test/behavior.zig -I test -fLLVM
57stage2/bin/zig test test/behavior.zig -I test -fno-LLVM
58stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin
59stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin
60stage2/bin/zig test test/behavior.zig -I test -ofmt=c
61stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin
62stage2/bin/zig test test/behavior.zig -I test -fLLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin
63stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target arm-linux --test-cmd qemu-arm --test-cmd-bin
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
54stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
55stage2/bin/zig build # test building self-hosted without LLVM
56stage2/bin/zig build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm
57
58# Here we use stage2 instead of stage3 because of two bugs remaining:
59# * https://github.com/ziglang/zig/issues/11367 (and corresponding workaround in compiler source)
60# * https://github.com/ziglang/zig/pull/11492#issuecomment-1112871321
61stage2/bin/zig build test-behavior -fqemu -fwasmtime
62
63$ZIG build test-behavior -fqemu -fwasmtime -Domit-stage2
7064$ZIG build test-compiler-rt -fqemu -fwasmtime
7165$ZIG build test-std -fqemu -fwasmtime
7266$ZIG build test-minilibc -fqemu -fwasmtime
......@@ -79,8 +73,6 @@ $ZIG build test-runtime-safety -fqemu -fwasmtime
7973$ZIG build test-translate-c -fqemu -fwasmtime
8074$ZIG build test-run-translated-c -fqemu -fwasmtime
8175$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
8476$ZIG build test-fmt -fqemu -fwasmtime
8577$ZIG build test-stage2 -fqemu -fwasmtime
8678
lib/std/build.zig+14
......@@ -1590,6 +1590,8 @@ pub const LibExeObjStep = struct {
15901590
15911591 want_lto: ?bool = null,
15921592 use_stage1: ?bool = null,
1593 use_llvm: ?bool = null,
1594 ofmt: ?std.Target.ObjectFormat = null,
15931595
15941596 output_path_source: GeneratedFile,
15951597 output_lib_path_source: GeneratedFile,
......@@ -2351,6 +2353,18 @@ pub const LibExeObjStep = struct {
23512353 }
23522354 }
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
23542368 if (self.entry_symbol_name) |entry| {
23552369 try zig_args.append("--entry");
23562370 try zig_args.append(entry);
test/tests.zig+133-46
......@@ -34,6 +34,7 @@ const TestTarget = struct {
3434 link_libc: bool = false,
3535 single_threaded: bool = false,
3636 disable_native: bool = false,
37 backend: ?std.builtin.CompilerBackend = null,
3738};
3839
3940const test_targets = blk: {
......@@ -42,15 +43,73 @@ const test_targets = blk: {
4243 // lot of branches)
4344 @setEvalBranchQuota(50000);
4445 break :blk [_]TestTarget{
45 TestTarget{},
46 TestTarget{
46 .{},
47 .{
4748 .link_libc = true,
4849 },
49 TestTarget{
50 .{
5051 .single_threaded = true,
5152 },
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 .{
54113 .target = .{
55114 .cpu_arch = .wasm32,
56115 .os_tag = .wasi,
......@@ -58,7 +117,7 @@ const test_targets = blk: {
58117 .link_libc = false,
59118 .single_threaded = true,
60119 },
61 TestTarget{
120 .{
62121 .target = .{
63122 .cpu_arch = .wasm32,
64123 .os_tag = .wasi,
......@@ -67,14 +126,14 @@ const test_targets = blk: {
67126 .single_threaded = true,
68127 },
69128
70 TestTarget{
129 .{
71130 .target = .{
72131 .cpu_arch = .x86_64,
73132 .os_tag = .linux,
74133 .abi = .none,
75134 },
76135 },
77 TestTarget{
136 .{
78137 .target = .{
79138 .cpu_arch = .x86_64,
80139 .os_tag = .linux,
......@@ -82,7 +141,7 @@ const test_targets = blk: {
82141 },
83142 .link_libc = true,
84143 },
85 TestTarget{
144 .{
86145 .target = .{
87146 .cpu_arch = .x86_64,
88147 .os_tag = .linux,
......@@ -91,14 +150,14 @@ const test_targets = blk: {
91150 .link_libc = true,
92151 },
93152
94 TestTarget{
153 .{
95154 .target = .{
96155 .cpu_arch = .i386,
97156 .os_tag = .linux,
98157 .abi = .none,
99158 },
100159 },
101 TestTarget{
160 .{
102161 .target = .{
103162 .cpu_arch = .i386,
104163 .os_tag = .linux,
......@@ -106,7 +165,7 @@ const test_targets = blk: {
106165 },
107166 .link_libc = true,
108167 },
109 TestTarget{
168 .{
110169 .target = .{
111170 .cpu_arch = .i386,
112171 .os_tag = .linux,
......@@ -115,14 +174,14 @@ const test_targets = blk: {
115174 .link_libc = true,
116175 },
117176
118 TestTarget{
177 .{
119178 .target = .{
120179 .cpu_arch = .aarch64,
121180 .os_tag = .linux,
122181 .abi = .none,
123182 },
124183 },
125 TestTarget{
184 .{
126185 .target = .{
127186 .cpu_arch = .aarch64,
128187 .os_tag = .linux,
......@@ -130,7 +189,7 @@ const test_targets = blk: {
130189 },
131190 .link_libc = true,
132191 },
133 TestTarget{
192 .{
134193 .target = .{
135194 .cpu_arch = .aarch64,
136195 .os_tag = .linux,
......@@ -138,7 +197,7 @@ const test_targets = blk: {
138197 },
139198 .link_libc = true,
140199 },
141 TestTarget{
200 .{
142201 .target = .{
143202 .cpu_arch = .aarch64,
144203 .os_tag = .windows,
......@@ -147,13 +206,13 @@ const test_targets = blk: {
147206 .link_libc = true,
148207 },
149208
150 TestTarget{
209 .{
151210 .target = CrossTarget.parse(.{
152211 .arch_os_abi = "arm-linux-none",
153212 .cpu_features = "generic+v8a",
154213 }) catch unreachable,
155214 },
156 TestTarget{
215 .{
157216 .target = CrossTarget.parse(.{
158217 .arch_os_abi = "arm-linux-musleabihf",
159218 .cpu_features = "generic+v8a",
......@@ -161,7 +220,7 @@ const test_targets = blk: {
161220 .link_libc = true,
162221 },
163222 // https://github.com/ziglang/zig/issues/3287
164 //TestTarget{
223 //.{
165224 // .target = CrossTarget.parse(.{
166225 // .arch_os_abi = "arm-linux-gnueabihf",
167226 // .cpu_features = "generic+v8a",
......@@ -169,7 +228,7 @@ const test_targets = blk: {
169228 // .link_libc = true,
170229 //},
171230
172 TestTarget{
231 .{
173232 .target = .{
174233 .cpu_arch = .mips,
175234 .os_tag = .linux,
......@@ -177,7 +236,7 @@ const test_targets = blk: {
177236 },
178237 },
179238
180 TestTarget{
239 .{
181240 .target = .{
182241 .cpu_arch = .mips,
183242 .os_tag = .linux,
......@@ -187,7 +246,7 @@ const test_targets = blk: {
187246 },
188247
189248 // https://github.com/ziglang/zig/issues/4927
190 //TestTarget{
249 //.{
191250 // .target = .{
192251 // .cpu_arch = .mips,
193252 // .os_tag = .linux,
......@@ -196,7 +255,7 @@ const test_targets = blk: {
196255 // .link_libc = true,
197256 //},
198257
199 TestTarget{
258 .{
200259 .target = .{
201260 .cpu_arch = .mipsel,
202261 .os_tag = .linux,
......@@ -204,7 +263,7 @@ const test_targets = blk: {
204263 },
205264 },
206265
207 TestTarget{
266 .{
208267 .target = .{
209268 .cpu_arch = .mipsel,
210269 .os_tag = .linux,
......@@ -214,7 +273,7 @@ const test_targets = blk: {
214273 },
215274
216275 // https://github.com/ziglang/zig/issues/4927
217 //TestTarget{
276 //.{
218277 // .target = .{
219278 // .cpu_arch = .mipsel,
220279 // .os_tag = .linux,
......@@ -223,14 +282,14 @@ const test_targets = blk: {
223282 // .link_libc = true,
224283 //},
225284
226 TestTarget{
285 .{
227286 .target = .{
228287 .cpu_arch = .powerpc,
229288 .os_tag = .linux,
230289 .abi = .none,
231290 },
232291 },
233 TestTarget{
292 .{
234293 .target = .{
235294 .cpu_arch = .powerpc,
236295 .os_tag = .linux,
......@@ -239,7 +298,7 @@ const test_targets = blk: {
239298 .link_libc = true,
240299 },
241300 // https://github.com/ziglang/zig/issues/2256
242 //TestTarget{
301 //.{
243302 // .target = .{
244303 // .cpu_arch = .powerpc,
245304 // .os_tag = .linux,
......@@ -248,7 +307,7 @@ const test_targets = blk: {
248307 // .link_libc = true,
249308 //},
250309
251 TestTarget{
310 .{
252311 .target = .{
253312 .cpu_arch = .riscv64,
254313 .os_tag = .linux,
......@@ -256,7 +315,7 @@ const test_targets = blk: {
256315 },
257316 },
258317
259 TestTarget{
318 .{
260319 .target = .{
261320 .cpu_arch = .riscv64,
262321 .os_tag = .linux,
......@@ -266,7 +325,7 @@ const test_targets = blk: {
266325 },
267326
268327 // https://github.com/ziglang/zig/issues/3340
269 //TestTarget{
328 //.{
270329 // .target = .{
271330 // .cpu_arch = .riscv64,
272331 // .os = .linux,
......@@ -275,7 +334,7 @@ const test_targets = blk: {
275334 // .link_libc = true,
276335 //},
277336
278 TestTarget{
337 .{
279338 .target = .{
280339 .cpu_arch = .x86_64,
281340 .os_tag = .macos,
......@@ -283,7 +342,7 @@ const test_targets = blk: {
283342 },
284343 },
285344
286 TestTarget{
345 .{
287346 .target = .{
288347 .cpu_arch = .aarch64,
289348 .os_tag = .macos,
......@@ -291,7 +350,7 @@ const test_targets = blk: {
291350 },
292351 },
293352
294 TestTarget{
353 .{
295354 .target = .{
296355 .cpu_arch = .i386,
297356 .os_tag = .windows,
......@@ -299,7 +358,7 @@ const test_targets = blk: {
299358 },
300359 },
301360
302 TestTarget{
361 .{
303362 .target = .{
304363 .cpu_arch = .x86_64,
305364 .os_tag = .windows,
......@@ -307,7 +366,7 @@ const test_targets = blk: {
307366 },
308367 },
309368
310 TestTarget{
369 .{
311370 .target = .{
312371 .cpu_arch = .i386,
313372 .os_tag = .windows,
......@@ -316,7 +375,7 @@ const test_targets = blk: {
316375 .link_libc = true,
317376 },
318377
319 TestTarget{
378 .{
320379 .target = .{
321380 .cpu_arch = .x86_64,
322381 .os_tag = .windows,
......@@ -326,38 +385,38 @@ const test_targets = blk: {
326385 },
327386
328387 // Do the release tests last because they take a long time
329 TestTarget{
388 .{
330389 .mode = .ReleaseFast,
331390 },
332 TestTarget{
391 .{
333392 .link_libc = true,
334393 .mode = .ReleaseFast,
335394 },
336 TestTarget{
395 .{
337396 .mode = .ReleaseFast,
338397 .single_threaded = true,
339398 },
340399
341 TestTarget{
400 .{
342401 .mode = .ReleaseSafe,
343402 },
344 TestTarget{
403 .{
345404 .link_libc = true,
346405 .mode = .ReleaseSafe,
347406 },
348 TestTarget{
407 .{
349408 .mode = .ReleaseSafe,
350409 .single_threaded = true,
351410 },
352411
353 TestTarget{
412 .{
354413 .mode = .ReleaseSmall,
355414 },
356 TestTarget{
415 .{
357416 .link_libc = true,
358417 .mode = .ReleaseSmall,
359418 },
360 TestTarget{
419 .{
361420 .mode = .ReleaseSmall,
362421 .single_threaded = true,
363422 },
......@@ -524,6 +583,9 @@ pub fn addPkgTests(
524583 skip_single_threaded: bool,
525584 skip_non_native: bool,
526585 skip_libc: bool,
586 skip_stage1: bool,
587 skip_stage2: bool,
588 is_stage1: bool,
527589) *build.Step {
528590 const step = b.step(b.fmt("test-{s}", .{name}), desc);
529591
......@@ -549,6 +611,11 @@ pub fn addPkgTests(
549611 continue;
550612 }
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
552619 const want_this_mode = for (modes) |m| {
553620 if (m == test_target.mode) break true;
554621 } else false;
......@@ -565,12 +632,14 @@ pub fn addPkgTests(
565632
566633 const these_tests = b.addTest(root_src);
567634 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} ", .{
569637 name,
570638 triple_prefix,
571639 @tagName(test_target.mode),
572640 libc_prefix,
573641 single_threaded_txt,
642 backend_txt,
574643 }));
575644 these_tests.single_threaded = test_target.single_threaded;
576645 these_tests.setFilter(test_filter);
......@@ -581,6 +650,24 @@ pub fn addPkgTests(
581650 }
582651 these_tests.overrideZigLibDir("lib");
583652 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
585672 step.dependOn(&these_tests.step);
586673 }