From 5e96f6e102607aa5d014f1737fdbfe6ce7156475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 16 Sep 2026 10:45:31 +0200 Subject: [PATCH] test: refactor compatible32bitArch() -> supportedCompatArch() Also fix some inaccuracies in it. --- test/tests.zig | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index 7fa149519bf04daf725d6707f59630e9e40e6dd5..00bfd3f685cdeddf76c243e060d2a6231b0f3678 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -2323,38 +2323,38 @@ pub const debugger_matrix: []const RunnerTarget = &.{ }, }; -fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch { +fn supportedCompatArch(host: *const std.Target, arch: std.Target.Cpu.Arch) bool { return switch (host.os.tag) { .freebsd => switch (host.cpu.arch) { - .aarch64 => .arm, - .powerpc64 => .powerpc, - else => null, + .aarch64 => arch == .arm, + else => false, }, .illumos => switch (host.cpu.arch) { - .x86_64 => .x86, - else => null, + .x86_64 => arch == .x86, + else => false, }, .linux => switch (host.cpu.arch) { - .aarch64 => .arm, - .aarch64_be => .armeb, - .mips64 => .mips, - .mips64el => .mipsel, - .powerpc64 => .powerpc, - .sparc64 => .sparc, - .x86_64 => .x86, - else => null, + .aarch64 => arch == .arm or arch == .thumb, + .aarch64_be => arch == .armeb or arch == .thumbeb, + .mips64 => arch == .mips, + .mips64el => arch == .mipsel, + .powerpc64 => arch == .powerpc, + .riscv64 => arch == .riscv32, + .sparc64 => arch == .sparc, + .x86_64 => arch == .x86, + else => false, }, .netbsd => switch (host.cpu.arch) { - .riscv64 => .riscv32, - .sparc64 => .sparc, - .x86_64 => .x86, - else => null, + .riscv64 => arch == .riscv32, + .sparc64 => arch == .sparc, + .x86_64 => arch == .x86, + else => false, }, .windows => switch (host.cpu.arch) { - .x86_64 => .x86, - else => null, + .x86_64 => arch == .x86, + else => false, }, - else => null, + else => false, }; } @@ -2362,11 +2362,8 @@ pub fn isNative(actual_target: *const std.Build.ResolvedTarget, host: *const std if (actual_target.query.isNative()) return true; const actual = &actual_target.result; - if (actual.cpu.arch != host.cpu.arch and - actual.cpu.arch != compatible32bitArch(host)) - { + if (actual.cpu.arch != host.cpu.arch and !supportedCompatArch(host, actual.cpu.arch)) return false; - } if (actual.os.tag != host.os.tag) return false; -- 2.54.0