authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-15 22:23:48-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-15 22:23:48-07:00
log11176d22f82861b4b6967b77f753414f214bc632
tree9057a36dc881cb5d8b87ca00119b5bee3b9605fd
parent05c7968920c6a74debe407c2ea8c23cd60d89611
parent55cc9dda66a24ed2a86a358533ecf5840d47b3d7
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21073 from alexrp/test-changes

`test`: QoL for port work, more mips re-enablement

14 files changed, 140 insertions(+), 69 deletions(-)

build.zig+44-28
......@@ -379,6 +379,8 @@ pub fn build(b: *std.Build) !void {
379379 }
380380
381381 const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
382 const test_target_filters = b.option([]const []const u8, "test-target-filter", "Skip tests whose target triple do not match any filter") orelse &[0][]const u8{};
383 const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false;
382384
383385 const test_cases_options = b.addOptions();
384386
......@@ -455,8 +457,12 @@ pub fn build(b: *std.Build) !void {
455457 });
456458 test_step.dependOn(test_cases_step);
457459
458 test_step.dependOn(tests.addModuleTests(b, .{
460 const test_modules_step = b.step("test-modules", "Run the per-target module tests");
461
462 test_modules_step.dependOn(tests.addModuleTests(b, .{
459463 .test_filters = test_filters,
464 .test_target_filters = test_target_filters,
465 .test_slow_targets = test_slow_targets,
460466 .root_src = "test/behavior.zig",
461467 .name = "behavior",
462468 .desc = "Run the behavior tests",
......@@ -468,8 +474,10 @@ pub fn build(b: *std.Build) !void {
468474 .max_rss = 1 * 1024 * 1024 * 1024,
469475 }));
470476
471 test_step.dependOn(tests.addModuleTests(b, .{
477 test_modules_step.dependOn(tests.addModuleTests(b, .{
472478 .test_filters = test_filters,
479 .test_target_filters = test_target_filters,
480 .test_slow_targets = test_slow_targets,
473481 .root_src = "test/c_import.zig",
474482 .name = "c-import",
475483 .desc = "Run the @cImport tests",
......@@ -480,8 +488,10 @@ pub fn build(b: *std.Build) !void {
480488 .skip_libc = skip_libc,
481489 }));
482490
483 test_step.dependOn(tests.addModuleTests(b, .{
491 test_modules_step.dependOn(tests.addModuleTests(b, .{
484492 .test_filters = test_filters,
493 .test_target_filters = test_target_filters,
494 .test_slow_targets = test_slow_targets,
485495 .root_src = "lib/compiler_rt.zig",
486496 .name = "compiler-rt",
487497 .desc = "Run the compiler_rt tests",
......@@ -493,8 +503,10 @@ pub fn build(b: *std.Build) !void {
493503 .no_builtin = true,
494504 }));
495505
496 test_step.dependOn(tests.addModuleTests(b, .{
506 test_modules_step.dependOn(tests.addModuleTests(b, .{
497507 .test_filters = test_filters,
508 .test_target_filters = test_target_filters,
509 .test_slow_targets = test_slow_targets,
498510 .root_src = "lib/c.zig",
499511 .name = "universal-libc",
500512 .desc = "Run the universal libc tests",
......@@ -506,6 +518,24 @@ pub fn build(b: *std.Build) !void {
506518 .no_builtin = true,
507519 }));
508520
521 test_modules_step.dependOn(tests.addModuleTests(b, .{
522 .test_filters = test_filters,
523 .test_target_filters = test_target_filters,
524 .test_slow_targets = test_slow_targets,
525 .root_src = "lib/std/std.zig",
526 .name = "std",
527 .desc = "Run the standard library tests",
528 .optimize_modes = optimization_modes,
529 .include_paths = &.{},
530 .skip_single_threaded = skip_single_threaded,
531 .skip_non_native = skip_non_native,
532 .skip_libc = skip_libc,
533 // I observed a value of 4572626944 on the M2 CI.
534 .max_rss = 5029889638,
535 }));
536
537 test_step.dependOn(test_modules_step);
538
509539 test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes));
510540 test_step.dependOn(tests.addStandaloneTests(
511541 b,
......@@ -519,39 +549,25 @@ pub fn build(b: *std.Build) !void {
519549 test_step.dependOn(tests.addStackTraceTests(b, test_filters, optimization_modes));
520550 test_step.dependOn(tests.addCliTests(b));
521551 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filters, optimization_modes));
522 test_step.dependOn(tests.addModuleTests(b, .{
523 .test_filters = test_filters,
524 .root_src = "lib/std/std.zig",
525 .name = "std",
526 .desc = "Run the standard library tests",
527 .optimize_modes = optimization_modes,
528 .include_paths = &.{},
529 .skip_single_threaded = skip_single_threaded,
530 .skip_non_native = skip_non_native,
531 .skip_libc = skip_libc,
532 // I observed a value of 4572626944 on the M2 CI.
533 .max_rss = 5029889638,
534 }));
535552
536553 try addWasiUpdateStep(b, version);
537554
538555 const update_mingw_step = b.step("update-mingw", "Update zig's bundled mingw");
539556 const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory");
540 const update_mingw_exe = b.addExecutable(.{
541 .name = "update_mingw",
542 .target = b.graph.host,
543 .root_source_file = b.path("tools/update_mingw.zig"),
544 });
545 const update_mingw_run = b.addRunArtifact(update_mingw_exe);
546 update_mingw_run.addDirectoryArg(b.path("lib"));
547557 if (opt_mingw_src_path) |mingw_src_path| {
558 const update_mingw_exe = b.addExecutable(.{
559 .name = "update_mingw",
560 .target = b.graph.host,
561 .root_source_file = b.path("tools/update_mingw.zig"),
562 });
563 const update_mingw_run = b.addRunArtifact(update_mingw_exe);
564 update_mingw_run.addDirectoryArg(b.path("lib"));
548565 update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });
566
567 update_mingw_step.dependOn(&update_mingw_run.step);
549568 } else {
550 // Intentionally cause an error if this build step is requested.
551 update_mingw_run.addArg("--missing-mingw-source-directory");
569 update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step);
552570 }
553
554 update_mingw_step.dependOn(&update_mingw_run.step);
555571}
556572
557573fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
ci/aarch64-linux-debug.sh+2-1
......@@ -62,7 +62,8 @@ stage3-debug/bin/zig build test docs \
6262 -Dtarget=native-native-musl \
6363 --search-prefix "$PREFIX" \
6464 --zig-lib-dir "$PWD/../lib" \
65 -Denable-tidy
65 -Denable-tidy \
66 -Dtest-slow-targets
6667
6768# Ensure that updating the wasm binary from this commit will result in a viable build.
6869stage3-debug/bin/zig build update-zig1
ci/aarch64-linux-release.sh+2-1
......@@ -62,7 +62,8 @@ stage3-release/bin/zig build test docs \
6262 -Dtarget=native-native-musl \
6363 --search-prefix "$PREFIX" \
6464 --zig-lib-dir "$PWD/../lib" \
65 -Denable-tidy
65 -Denable-tidy \
66 -Dtest-slow-targets
6667
6768# Ensure that stage3 and stage4 are byte-for-byte identical.
6869stage3-release/bin/zig build \
ci/aarch64-macos-debug.sh+2-1
......@@ -55,4 +55,5 @@ stage3-debug/bin/zig build test docs \
5555 -Denable-macos-sdk \
5656 -Dstatic-llvm \
5757 -Dskip-non-native \
58 --search-prefix "$PREFIX"
58 --search-prefix "$PREFIX" \
59 -Dtest-slow-targets
ci/aarch64-macos-release.sh+2-1
......@@ -55,7 +55,8 @@ stage3-release/bin/zig build test docs \
5555 -Denable-macos-sdk \
5656 -Dstatic-llvm \
5757 -Dskip-non-native \
58 --search-prefix "$PREFIX"
58 --search-prefix "$PREFIX" \
59 -Dtest-slow-targets
5960
6061# Ensure that stage3 and stage4 are byte-for-byte identical.
6162stage3-release/bin/zig build \
ci/aarch64-windows.ps1+2-1
......@@ -67,7 +67,8 @@ Write-Output "Main test suite..."
6767 --search-prefix "$PREFIX_PATH" `
6868 -Dstatic-llvm `
6969 -Dskip-non-native `
70 -Denable-symlinks-windows
70 -Denable-symlinks-windows `
71 -Dtest-slow-targets
7172CheckLastExitCode
7273
7374# Ensure that stage3 and stage4 are byte-for-byte identical.
ci/x86_64-linux-debug.sh+2-1
......@@ -70,7 +70,8 @@ stage3-debug/bin/zig build test docs \
7070 -Dtarget=native-native-musl \
7171 --search-prefix "$PREFIX" \
7272 --zig-lib-dir "$PWD/../lib" \
73 -Denable-tidy
73 -Denable-tidy \
74 -Dtest-slow-targets
7475
7576# Ensure that updating the wasm binary from this commit will result in a viable build.
7677stage3-debug/bin/zig build update-zig1
ci/x86_64-linux-release.sh+2-1
......@@ -70,7 +70,8 @@ stage3-release/bin/zig build test docs \
7070 -Dtarget=native-native-musl \
7171 --search-prefix "$PREFIX" \
7272 --zig-lib-dir "$PWD/../lib" \
73 -Denable-tidy
73 -Denable-tidy \
74 -Dtest-slow-targets
7475
7576# Ensure that stage3 and stage4 are byte-for-byte identical.
7677stage3-release/bin/zig build \
ci/x86_64-macos-release.sh+2-1
......@@ -59,7 +59,8 @@ stage3/bin/zig build test docs \
5959 -Denable-macos-sdk \
6060 -Dstatic-llvm \
6161 -Dskip-non-native \
62 --search-prefix "$PREFIX"
62 --search-prefix "$PREFIX" \
63 -Dtest-slow-targets
6364
6465# Ensure that stage3 and stage4 are byte-for-byte identical.
6566stage3/bin/zig build \
ci/x86_64-windows-debug.ps1+2-1
......@@ -68,7 +68,8 @@ Write-Output "Main test suite..."
6868 -Dstatic-llvm `
6969 -Dskip-non-native `
7070 -Dskip-release `
71 -Denable-symlinks-windows
71 -Denable-symlinks-windows `
72 -Dtest-slow-targets
7273CheckLastExitCode
7374
7475Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
ci/x86_64-windows-release.ps1+2-1
......@@ -67,7 +67,8 @@ Write-Output "Main test suite..."
6767 --search-prefix "$PREFIX_PATH" `
6868 -Dstatic-llvm `
6969 -Dskip-non-native `
70 -Denable-symlinks-windows
70 -Denable-symlinks-windows `
71 -Dtest-slow-targets
7172CheckLastExitCode
7273
7374# Ensure that stage3 and stage4 are byte-for-byte identical.
lib/std/zig/system.zig+20-4
......@@ -86,21 +86,37 @@ pub fn getExternalExecutor(
8686 .arm => Executor{ .qemu = "qemu-arm" },
8787 .armeb => Executor{ .qemu = "qemu-armeb" },
8888 .hexagon => Executor{ .qemu = "qemu-hexagon" },
89 .x86 => Executor{ .qemu = "qemu-i386" },
9089 .m68k => Executor{ .qemu = "qemu-m68k" },
9190 .mips => Executor{ .qemu = "qemu-mips" },
9291 .mipsel => Executor{ .qemu = "qemu-mipsel" },
93 .mips64 => Executor{ .qemu = "qemu-mips64" },
94 .mips64el => Executor{ .qemu = "qemu-mips64el" },
92 .mips64 => Executor{
93 .qemu = if (candidate.abi == .gnuabin32)
94 "qemu-mipsn32"
95 else
96 "qemu-mips64",
97 },
98 .mips64el => Executor{
99 .qemu = if (candidate.abi == .gnuabin32)
100 "qemu-mipsn32el"
101 else
102 "qemu-mips64el",
103 },
95104 .powerpc => Executor{ .qemu = "qemu-ppc" },
96105 .powerpc64 => Executor{ .qemu = "qemu-ppc64" },
97106 .powerpc64le => Executor{ .qemu = "qemu-ppc64le" },
98107 .riscv32 => Executor{ .qemu = "qemu-riscv32" },
99108 .riscv64 => Executor{ .qemu = "qemu-riscv64" },
100109 .s390x => Executor{ .qemu = "qemu-s390x" },
101 .sparc => Executor{ .qemu = "qemu-sparc" },
110 .sparc => Executor{
111 .qemu = if (std.Target.sparc.featureSetHas(candidate.cpu.features, .v9))
112 "qemu-sparc32plus"
113 else
114 "qemu-sparc",
115 },
102116 .sparc64 => Executor{ .qemu = "qemu-sparc64" },
117 .x86 => Executor{ .qemu = "qemu-i386" },
103118 .x86_64 => Executor{ .qemu = "qemu-x86_64" },
119 .xtensa => Executor{ .qemu = "qemu-xtensa" },
104120 else => return bad_result,
105121 };
106122 }
src/codegen/llvm.zig+13-2
......@@ -11787,7 +11787,9 @@ fn backendSupportsF16(target: std.Target) bool {
1178711787 .mips64el,
1178811788 .s390x,
1178911789 => false,
11790 .aarch64 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
11790 .aarch64,
11791 .aarch64_be,
11792 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
1179111793 else => true,
1179211794 };
1179311795}
......@@ -11798,9 +11800,18 @@ fn backendSupportsF16(target: std.Target) bool {
1179811800fn backendSupportsF128(target: std.Target) bool {
1179911801 return switch (target.cpu.arch) {
1180011802 .amdgcn,
11803 .mips64,
11804 .mips64el,
1180111805 .sparc,
1180211806 => false,
11803 .aarch64 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
11807 .powerpc,
11808 .powerpcle,
11809 .powerpc64,
11810 .powerpc64le,
11811 => target.os.tag != .aix,
11812 .aarch64,
11813 .aarch64_be,
11814 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
1180411815 else => true,
1180511816 };
1180611817}
test/tests.zig+43-25
......@@ -27,6 +27,12 @@ const TestTarget = struct {
2727 use_lld: ?bool = null,
2828 pic: ?bool = null,
2929 strip: ?bool = null,
30
31 // This is intended for targets that are known to be slow to compile. These are acceptable to
32 // run in CI, but should not be run on developer machines by default. As an example, at the time
33 // of writing, this includes LLVM's MIPS backend which takes upwards of 20 minutes longer to
34 // compile tests than other backends.
35 slow_backend: bool = false,
3036};
3137
3238const test_targets = blk: {
......@@ -310,8 +316,8 @@ const test_targets = blk: {
310316 .os_tag = .linux,
311317 .abi = .none,
312318 },
319 .slow_backend = true,
313320 },
314
315321 .{
316322 .target = .{
317323 .cpu_arch = .mips,
......@@ -319,17 +325,17 @@ const test_targets = blk: {
319325 .abi = .musl,
320326 },
321327 .link_libc = true,
328 .slow_backend = true,
329 },
330 .{
331 .target = .{
332 .cpu_arch = .mips,
333 .os_tag = .linux,
334 .abi = .gnueabihf,
335 },
336 .link_libc = true,
337 .slow_backend = true,
322338 },
323
324 // https://github.com/ziglang/zig/issues/4927
325 //.{
326 // .target = .{
327 // .cpu_arch = .mips,
328 // .os_tag = .linux,
329 // .abi = .gnueabihf,
330 // },
331 // .link_libc = true,
332 //},
333339
334340 .{
335341 .target = .{
......@@ -337,8 +343,8 @@ const test_targets = blk: {
337343 .os_tag = .linux,
338344 .abi = .none,
339345 },
346 .slow_backend = true,
340347 },
341
342348 .{
343349 .target = .{
344350 .cpu_arch = .mipsel,
......@@ -346,17 +352,17 @@ const test_targets = blk: {
346352 .abi = .musl,
347353 },
348354 .link_libc = true,
355 .slow_backend = true,
356 },
357 .{
358 .target = .{
359 .cpu_arch = .mipsel,
360 .os_tag = .linux,
361 .abi = .gnueabihf,
362 },
363 .link_libc = true,
364 .slow_backend = true,
349365 },
350
351 // https://github.com/ziglang/zig/issues/4927
352 //.{
353 // .target = .{
354 // .cpu_arch = .mipsel,
355 // .os_tag = .linux,
356 // .abi = .gnueabihf,
357 // },
358 // .link_libc = true,
359 //},
360366
361367 .{
362368 .target = .{
......@@ -407,7 +413,8 @@ const test_targets = blk: {
407413 .link_libc = true,
408414 },
409415
410 // Disabled until LLVM fixes their O(N^2) codegen.
416 // Disabled until LLVM fixes their O(N^2) codegen. Note that this is so bad that we don't
417 // even want to include this in CI with `slow_backend`.
411418 // https://github.com/ziglang/zig/issues/18872
412419 //.{
413420 // .target = .{
......@@ -418,7 +425,8 @@ const test_targets = blk: {
418425 // .use_llvm = true,
419426 //},
420427
421 // Disabled until LLVM fixes their O(N^2) codegen.
428 // Disabled until LLVM fixes their O(N^2) codegen. Note that this is so bad that we don't
429 // even want to include this in CI with `slow_backend`.
422430 // https://github.com/ziglang/zig/issues/18872
423431 //.{
424432 // .target = .{
......@@ -971,6 +979,8 @@ pub fn addRunTranslatedCTests(
971979
972980const ModuleTestOptions = struct {
973981 test_filters: []const []const u8,
982 test_target_filters: []const []const u8,
983 test_slow_targets: bool,
974984 root_src: []const u8,
975985 name: []const u8,
976986 desc: []const u8,
......@@ -987,11 +997,20 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
987997 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
988998
989999 for (test_targets) |test_target| {
1000 if (!options.test_slow_targets and test_target.slow_backend) continue;
1001
9901002 if (options.skip_non_native and !test_target.target.isNative())
9911003 continue;
9921004
9931005 const resolved_target = b.resolveTargetQuery(test_target.target);
9941006 const target = resolved_target.result;
1007 const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM");
1008
1009 if (options.test_target_filters.len > 0) {
1010 for (options.test_target_filters) |filter| {
1011 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
1012 } else continue;
1013 }
9951014
9961015 if (options.skip_libc and test_target.link_libc == true)
9971016 continue;
......@@ -1040,7 +1059,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10401059 if (!want_this_mode) continue;
10411060
10421061 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
1043 const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM");
10441062 const model_txt = target.cpu.model.name;
10451063
10461064 // wasm32-wasi builds need more RAM, idk why