From ac793232eeeca87378b6b6cf4bec6e610859b5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 15 Jan 2026 07:55:47 +0100 Subject: [PATCH] test: skip non-libc module tests for targets that require or default to libc We were just creating duplicate work and breaking -Dskip-libc. --- test/tests.zig | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index 52b2fe6621..7873774c2a 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -2345,27 +2345,39 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { } } + const resolved_target = b.resolveTargetQuery(test_target.target); + const target = &resolved_target.result; + + if (test_target.link_libc == false and target.requiresLibC()) continue; + // If the target requires libc, there's no point building the cases that + // don't explicitly link libc as they'll just end up actually linking + // libc anyway, thus creating duplicate work and making -Dskip-libc not + // work as expected. + if (test_target.link_libc == null and target.requiresLibC()) continue; + // These targets don't strictly require libc, but we don't yet have a + // syscall layer for them, so the compiler links libc by default. They + // therefore get the same treatment here. + if (test_target.link_libc == null and (target.os.tag == .freebsd or target.os.tag == .netbsd)) continue; + if (!options.test_extra_targets and test_target.extra_target) continue; if (options.skip_non_native and !test_target.target.isNative()) continue; - if (options.skip_spirv and test_target.target.cpu_arch != null and test_target.target.cpu_arch.?.isSpirV()) continue; - if (options.skip_wasm and test_target.target.cpu_arch != null and test_target.target.cpu_arch.?.isWasm()) continue; + if (options.skip_spirv and target.cpu.arch.isSpirV()) continue; + if (options.skip_wasm and target.cpu.arch.isWasm()) continue; - if (options.skip_freebsd and test_target.target.os_tag == .freebsd) continue; - if (options.skip_netbsd and test_target.target.os_tag == .netbsd) continue; - if (options.skip_openbsd and test_target.target.os_tag == .openbsd) continue; - if (options.skip_windows and test_target.target.os_tag == .windows) continue; - if (options.skip_darwin and test_target.target.os_tag != null and test_target.target.os_tag.?.isDarwin()) continue; - if (options.skip_linux and test_target.target.os_tag == .linux) continue; + if (options.skip_freebsd and target.os.tag == .freebsd) continue; + if (options.skip_netbsd and target.os.tag == .netbsd) continue; + if (options.skip_openbsd and target.os.tag == .openbsd) continue; + if (options.skip_windows and target.os.tag == .windows) continue; + if (options.skip_darwin and target.os.tag.isDarwin()) continue; + if (options.skip_linux and target.os.tag == .linux) continue; const would_use_llvm = wouldUseLlvm(test_target.use_llvm, test_target.target, test_target.optimize_mode); if (options.skip_llvm and would_use_llvm) continue; - const resolved_target = b.resolveTargetQuery(test_target.target); const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); - const target = &resolved_target.result; if (options.test_target_filters.len > 0) { for (options.test_target_filters) |filter| {