From 39a2722837816f6242dae23a158f35803772072d 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 f0d3de2cdf38af1a9b5638e760102f1f6c11a243..e394eea5c7e510ac7a8cd0a68fb1b226fb4b7a14 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -2350,38 +2350,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, }; } @@ -2389,11 +2389,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