Skip to content

Commit

Permalink
Merge pull request #21073 from alexrp/test-changes
Browse files Browse the repository at this point in the history
`test`: QoL for port work, more mips re-enablement
  • Loading branch information
andrewrk authored Aug 16, 2024
2 parents 05c7968 + 55cc9dd commit 11176d2
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 69 deletions.
72 changes: 44 additions & 28 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ pub fn build(b: *std.Build) !void {
}

const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
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{};
const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false;

const test_cases_options = b.addOptions();

Expand Down Expand Up @@ -455,8 +457,12 @@ pub fn build(b: *std.Build) !void {
});
test_step.dependOn(test_cases_step);

test_step.dependOn(tests.addModuleTests(b, .{
const test_modules_step = b.step("test-modules", "Run the per-target module tests");

test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "test/behavior.zig",
.name = "behavior",
.desc = "Run the behavior tests",
Expand All @@ -468,8 +474,10 @@ pub fn build(b: *std.Build) !void {
.max_rss = 1 * 1024 * 1024 * 1024,
}));

test_step.dependOn(tests.addModuleTests(b, .{
test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "test/c_import.zig",
.name = "c-import",
.desc = "Run the @cImport tests",
Expand All @@ -480,8 +488,10 @@ pub fn build(b: *std.Build) !void {
.skip_libc = skip_libc,
}));

test_step.dependOn(tests.addModuleTests(b, .{
test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/compiler_rt.zig",
.name = "compiler-rt",
.desc = "Run the compiler_rt tests",
Expand All @@ -493,8 +503,10 @@ pub fn build(b: *std.Build) !void {
.no_builtin = true,
}));

test_step.dependOn(tests.addModuleTests(b, .{
test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/c.zig",
.name = "universal-libc",
.desc = "Run the universal libc tests",
Expand All @@ -506,6 +518,24 @@ pub fn build(b: *std.Build) !void {
.no_builtin = true,
}));

test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/std/std.zig",
.name = "std",
.desc = "Run the standard library tests",
.optimize_modes = optimization_modes,
.include_paths = &.{},
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_libc = skip_libc,
// I observed a value of 4572626944 on the M2 CI.
.max_rss = 5029889638,
}));

test_step.dependOn(test_modules_step);

test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addStandaloneTests(
b,
Expand All @@ -519,39 +549,25 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addStackTraceTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addCliTests(b));
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.root_src = "lib/std/std.zig",
.name = "std",
.desc = "Run the standard library tests",
.optimize_modes = optimization_modes,
.include_paths = &.{},
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_libc = skip_libc,
// I observed a value of 4572626944 on the M2 CI.
.max_rss = 5029889638,
}));

try addWasiUpdateStep(b, version);

const update_mingw_step = b.step("update-mingw", "Update zig's bundled mingw");
const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory");
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.graph.host,
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(b.path("lib"));
if (opt_mingw_src_path) |mingw_src_path| {
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.graph.host,
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(b.path("lib"));
update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });

update_mingw_step.dependOn(&update_mingw_run.step);
} else {
// Intentionally cause an error if this build step is requested.
update_mingw_run.addArg("--missing-mingw-source-directory");
update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step);
}

update_mingw_step.dependOn(&update_mingw_run.step);
}

fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
Expand Down
3 changes: 2 additions & 1 deletion ci/aarch64-linux-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ stage3-debug/bin/zig build test docs \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
-Denable-tidy
-Denable-tidy \
-Dtest-slow-targets

# Ensure that updating the wasm binary from this commit will result in a viable build.
stage3-debug/bin/zig build update-zig1
Expand Down
3 changes: 2 additions & 1 deletion ci/aarch64-linux-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ stage3-release/bin/zig build test docs \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
-Denable-tidy
-Denable-tidy \
-Dtest-slow-targets

# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \
Expand Down
3 changes: 2 additions & 1 deletion ci/aarch64-macos-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ stage3-debug/bin/zig build test docs \
-Denable-macos-sdk \
-Dstatic-llvm \
-Dskip-non-native \
--search-prefix "$PREFIX"
--search-prefix "$PREFIX" \
-Dtest-slow-targets
3 changes: 2 additions & 1 deletion ci/aarch64-macos-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ stage3-release/bin/zig build test docs \
-Denable-macos-sdk \
-Dstatic-llvm \
-Dskip-non-native \
--search-prefix "$PREFIX"
--search-prefix "$PREFIX" \
-Dtest-slow-targets

# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \
Expand Down
3 changes: 2 additions & 1 deletion ci/aarch64-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ Write-Output "Main test suite..."
--search-prefix "$PREFIX_PATH" `
-Dstatic-llvm `
-Dskip-non-native `
-Denable-symlinks-windows
-Denable-symlinks-windows `
-Dtest-slow-targets
CheckLastExitCode

# Ensure that stage3 and stage4 are byte-for-byte identical.
Expand Down
3 changes: 2 additions & 1 deletion ci/x86_64-linux-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ stage3-debug/bin/zig build test docs \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
-Denable-tidy
-Denable-tidy \
-Dtest-slow-targets

# Ensure that updating the wasm binary from this commit will result in a viable build.
stage3-debug/bin/zig build update-zig1
Expand Down
3 changes: 2 additions & 1 deletion ci/x86_64-linux-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ stage3-release/bin/zig build test docs \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
-Denable-tidy
-Denable-tidy \
-Dtest-slow-targets

# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \
Expand Down
3 changes: 2 additions & 1 deletion ci/x86_64-macos-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ stage3/bin/zig build test docs \
-Denable-macos-sdk \
-Dstatic-llvm \
-Dskip-non-native \
--search-prefix "$PREFIX"
--search-prefix "$PREFIX" \
-Dtest-slow-targets

# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3/bin/zig build \
Expand Down
3 changes: 2 additions & 1 deletion ci/x86_64-windows-debug.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Write-Output "Main test suite..."
-Dstatic-llvm `
-Dskip-non-native `
-Dskip-release `
-Denable-symlinks-windows
-Denable-symlinks-windows `
-Dtest-slow-targets
CheckLastExitCode

Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
Expand Down
3 changes: 2 additions & 1 deletion ci/x86_64-windows-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ Write-Output "Main test suite..."
--search-prefix "$PREFIX_PATH" `
-Dstatic-llvm `
-Dskip-non-native `
-Denable-symlinks-windows
-Denable-symlinks-windows `
-Dtest-slow-targets
CheckLastExitCode

# Ensure that stage3 and stage4 are byte-for-byte identical.
Expand Down
24 changes: 20 additions & 4 deletions lib/std/zig/system.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,37 @@ pub fn getExternalExecutor(
.arm => Executor{ .qemu = "qemu-arm" },
.armeb => Executor{ .qemu = "qemu-armeb" },
.hexagon => Executor{ .qemu = "qemu-hexagon" },
.x86 => Executor{ .qemu = "qemu-i386" },
.m68k => Executor{ .qemu = "qemu-m68k" },
.mips => Executor{ .qemu = "qemu-mips" },
.mipsel => Executor{ .qemu = "qemu-mipsel" },
.mips64 => Executor{ .qemu = "qemu-mips64" },
.mips64el => Executor{ .qemu = "qemu-mips64el" },
.mips64 => Executor{
.qemu = if (candidate.abi == .gnuabin32)
"qemu-mipsn32"
else
"qemu-mips64",
},
.mips64el => Executor{
.qemu = if (candidate.abi == .gnuabin32)
"qemu-mipsn32el"
else
"qemu-mips64el",
},
.powerpc => Executor{ .qemu = "qemu-ppc" },
.powerpc64 => Executor{ .qemu = "qemu-ppc64" },
.powerpc64le => Executor{ .qemu = "qemu-ppc64le" },
.riscv32 => Executor{ .qemu = "qemu-riscv32" },
.riscv64 => Executor{ .qemu = "qemu-riscv64" },
.s390x => Executor{ .qemu = "qemu-s390x" },
.sparc => Executor{ .qemu = "qemu-sparc" },
.sparc => Executor{
.qemu = if (std.Target.sparc.featureSetHas(candidate.cpu.features, .v9))
"qemu-sparc32plus"
else
"qemu-sparc",
},
.sparc64 => Executor{ .qemu = "qemu-sparc64" },
.x86 => Executor{ .qemu = "qemu-i386" },
.x86_64 => Executor{ .qemu = "qemu-x86_64" },
.xtensa => Executor{ .qemu = "qemu-xtensa" },
else => return bad_result,
};
}
Expand Down
15 changes: 13 additions & 2 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11787,7 +11787,9 @@ fn backendSupportsF16(target: std.Target) bool {
.mips64el,
.s390x,
=> false,
.aarch64 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
.aarch64,
.aarch64_be,
=> std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
else => true,
};
}
Expand All @@ -11798,9 +11800,18 @@ fn backendSupportsF16(target: std.Target) bool {
fn backendSupportsF128(target: std.Target) bool {
return switch (target.cpu.arch) {
.amdgcn,
.mips64,
.mips64el,
.sparc,
=> false,
.aarch64 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
.powerpc,
.powerpcle,
.powerpc64,
.powerpc64le,
=> target.os.tag != .aix,
.aarch64,
.aarch64_be,
=> std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
else => true,
};
}
Expand Down
Loading

0 comments on commit 11176d2

Please sign in to comment.