test: Add dynamic musl targets to the module test matrix.

Most of these are gated by -Dtest-extra-targets because:

* We don't really have CI resources to spare at the moment.
* They're relatively niche if you're not on a musl distro.
    * And the few musl distros that exist don't support all these targets.
* Quite a few of them are broken and need investigating.

x86_64-linux-musl and aarch64-linux-musl are not gated as they're the most
common targets that people will be running dynamic musl on, so we'll want to
have some bare minimum coverage of those.
This commit is contained in:
Alex Rønne Petersen 2025-05-06 04:52:48 +02:00
parent c272ddc070
commit 473f36d70f
No known key found for this signature in database

View file

@ -20,6 +20,7 @@ pub const StackTracesContext = @import("src/StackTrace.zig");
pub const DebuggerContext = @import("src/Debugger.zig"); pub const DebuggerContext = @import("src/Debugger.zig");
const TestTarget = struct { const TestTarget = struct {
linkage: ?std.builtin.LinkMode = null,
target: std.Target.Query = .{}, target: std.Target.Query = .{},
optimize_mode: std.builtin.OptimizeMode = .Debug, optimize_mode: std.builtin.OptimizeMode = .Debug,
link_libc: ?bool = null, link_libc: ?bool = null,
@ -30,8 +31,9 @@ const TestTarget = struct {
strip: ?bool = null, strip: ?bool = null,
skip_modules: []const []const u8 = &.{}, skip_modules: []const []const u8 = &.{},
// This is intended for targets that are known to be slow to compile, or require a newer LLVM // This is intended for targets that, for any reason, shouldn't be run as part of a normal test
// version than is present on the CI machines, etc. // invocation. This could be because of a slow backend, requiring a newer LLVM version, being
// too niche, etc.
extra_target: bool = false, extra_target: bool = false,
}; };
@ -240,6 +242,15 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .x86_64,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
@ -248,6 +259,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .x86_64,
.os_tag = .linux,
.abi = .muslx32,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
@ -273,6 +294,17 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
// https://github.com/ziglang/zig/issues/7935
// .{
// .target = .{
// .cpu_arch = .x86,
// .os_tag = .linux,
// .abi = .musl,
// },
// .linkage = .dynamic,
// .link_libc = true,
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
.cpu_arch = .x86, .cpu_arch = .x86,
@ -297,6 +329,15 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .aarch64,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .aarch64, .cpu_arch = .aarch64,
@ -329,6 +370,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .aarch64_be,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .aarch64_be, .cpu_arch = .aarch64_be,
@ -360,6 +411,17 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
// Crashes in weird ways when applying relocations.
// .{
// .target = .{
// .cpu_arch = .arm,
// .os_tag = .linux,
// .abi = .musleabi,
// },
// .linkage = .dynamic,
// .link_libc = true,
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
.cpu_arch = .arm, .cpu_arch = .arm,
@ -368,6 +430,17 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
// Crashes in weird ways when applying relocations.
// .{
// .target = .{
// .cpu_arch = .arm,
// .os_tag = .linux,
// .abi = .musleabihf,
// },
// .linkage = .dynamic,
// .link_libc = true,
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
.cpu_arch = .arm, .cpu_arch = .arm,
@ -407,6 +480,17 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
// Crashes in weird ways when applying relocations.
// .{
// .target = .{
// .cpu_arch = .armeb,
// .os_tag = .linux,
// .abi = .musleabi,
// },
// .linkage = .dynamic,
// .link_libc = true,
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
.cpu_arch = .armeb, .cpu_arch = .armeb,
@ -415,6 +499,17 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
// Crashes in weird ways when applying relocations.
// .{
// .target = .{
// .cpu_arch = .armeb,
// .os_tag = .linux,
// .abi = .musleabihf,
// },
// .linkage = .dynamic,
// .link_libc = true,
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
.cpu_arch = .armeb, .cpu_arch = .armeb,
@ -516,6 +611,19 @@ const test_targets = blk: {
// https://github.com/llvm/llvm-project/pull/111217 // https://github.com/llvm/llvm-project/pull/111217
.skip_modules = &.{"std"}, .skip_modules = &.{"std"},
}, },
// Currently crashes in qemu-hexagon.
// .{
// .target = .{
// .cpu_arch = .hexagon,
// .os_tag = .linux,
// .abi = .musl,
// },
// .linkage = .dynamic,
// .link_libc = true,
// // https://github.com/llvm/llvm-project/pull/111217
// .skip_modules = &.{"std"},
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
@ -534,6 +642,17 @@ const test_targets = blk: {
.link_libc = true, .link_libc = true,
.skip_modules = &.{"std"}, .skip_modules = &.{"std"},
}, },
.{
.target = .{
.cpu_arch = .loongarch64,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
.skip_modules = &.{"std"},
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .loongarch64, .cpu_arch = .loongarch64,
@ -566,6 +685,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .mips,
.os_tag = .linux,
.abi = .musleabi,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .mips, .cpu_arch = .mips,
@ -574,6 +703,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .mips,
.os_tag = .linux,
.abi = .musleabihf,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .mips, .cpu_arch = .mips,
@ -613,6 +752,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .mipsel,
.os_tag = .linux,
.abi = .musleabi,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .mipsel, .cpu_arch = .mipsel,
@ -621,6 +770,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .mipsel,
.os_tag = .linux,
.abi = .musleabihf,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .mipsel, .cpu_arch = .mipsel,
@ -653,6 +812,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .mips64,
.os_tag = .linux,
.abi = .muslabi64,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .mips64, .cpu_arch = .mips64,
@ -677,6 +846,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .mips64el,
.os_tag = .linux,
.abi = .muslabi64,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .mips64el, .cpu_arch = .mips64el,
@ -708,6 +887,18 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .powerpc,
.os_tag = .linux,
.abi = .musleabi,
},
.linkage = .dynamic,
.link_libc = true,
// https://github.com/ziglang/zig/issues/2256
.skip_modules = &.{"std"},
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .powerpc, .cpu_arch = .powerpc,
@ -716,6 +907,18 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .powerpc,
.os_tag = .linux,
.abi = .musleabihf,
},
.linkage = .dynamic,
.link_libc = true,
// https://github.com/ziglang/zig/issues/2256
.skip_modules = &.{"std"},
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .powerpc, .cpu_arch = .powerpc,
@ -752,6 +955,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .powerpc64,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
// Requires ELFv1 linker support. // Requires ELFv1 linker support.
// .{ // .{
// .target = .{ // .target = .{
@ -776,6 +989,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .powerpc64le,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .powerpc64le, .cpu_arch = .powerpc64le,
@ -814,6 +1037,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .riscv32,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .riscv32, .cpu_arch = .riscv32,
@ -852,6 +1085,16 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
.{
.target = .{
.cpu_arch = .riscv64,
.os_tag = .linux,
.abi = .musl,
},
.linkage = .dynamic,
.link_libc = true,
.extra_target = true,
},
.{ .{
.target = .{ .target = .{
.cpu_arch = .riscv64, .cpu_arch = .riscv64,
@ -885,6 +1128,17 @@ const test_targets = blk: {
}, },
.link_libc = true, .link_libc = true,
}, },
// Currently hangs in qemu-s390x.
// .{
// .target = .{
// .cpu_arch = .s390x,
// .os_tag = .linux,
// .abi = .musl,
// },
// .linkage = .dynamic,
// .link_libc = true,
// .extra_target = true,
// },
.{ .{
.target = .{ .target = .{
.cpu_arch = .s390x, .cpu_arch = .s390x,
@ -1518,6 +1772,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
.use_lld = test_target.use_lld, .use_lld = test_target.use_lld,
.zig_lib_dir = b.path("lib"), .zig_lib_dir = b.path("lib"),
}); });
these_tests.linkage = test_target.linkage;
if (options.no_builtin) these_tests.no_builtin = true; if (options.no_builtin) these_tests.no_builtin = true;
if (options.build_options) |build_options| { if (options.build_options) |build_options| {
these_tests.root_module.addOptions("build_options", build_options); these_tests.root_module.addOptions("build_options", build_options);
@ -1532,11 +1787,14 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
else else
""; "";
const use_lld = if (test_target.use_lld == false) "-no-lld" else ""; const use_lld = if (test_target.use_lld == false) "-no-lld" else "";
const linkage_name = if (test_target.linkage) |linkage| switch (linkage) {
inline else => |t| "-" ++ @tagName(t),
} else "";
const use_pic = if (test_target.pic == true) "-pic" else ""; const use_pic = if (test_target.pic == true) "-pic" else "";
for (options.include_paths) |include_path| these_tests.addIncludePath(b.path(include_path)); for (options.include_paths) |include_path| these_tests.addIncludePath(b.path(include_path));
const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}", .{ const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{
options.name, options.name,
triple_txt, triple_txt,
model_txt, model_txt,
@ -1545,6 +1803,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
single_threaded_suffix, single_threaded_suffix,
backend_suffix, backend_suffix,
use_lld, use_lld,
linkage_name,
use_pic, use_pic,
}); });