authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-03-26 01:05:12+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-03-26 05:50:51+01:00
logcef16b5130eae56a77262df532aae5a458736670
tree014e21edc6f9aaea20e30c5c925c238c3a2effd7
parente4a977f9e41165168fed7628134c701e9060a741
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: don't claim that OpenBSD requires libc

https://codeberg.org/ziglang/zig/issues/30982

4 files changed, 6 insertions(+), 5 deletions(-)

lib/std/Target.zig+1-1
......@@ -2180,7 +2180,6 @@ pub fn requiresLibC(target: *const Target) bool {
21802180 .watchos,
21812181 .visionos,
21822182 .dragonfly,
2183 .openbsd,
21842183 .haiku,
21852184 .serenity,
21862185 => true,
......@@ -2194,6 +2193,7 @@ pub fn requiresLibC(target: *const Target) bool {
21942193 .windows,
21952194 .freebsd,
21962195 .netbsd,
2196 .openbsd,
21972197 .freestanding,
21982198 .fuchsia,
21992199 .managarm,
src/Compilation/Config.zig+3-2
......@@ -239,6 +239,7 @@ pub fn resolve(options: Options) ResolveError!Config {
239239 // so we default to linking libc for now.
240240 .freebsd,
241241 .netbsd,
242 .openbsd,
242243 => break :b true,
243244 else => {},
244245 }
......@@ -266,7 +267,7 @@ pub fn resolve(options: Options) ResolveError!Config {
266267 if (explicitly_exe_or_dyn_lib and link_libc and
267268 (target.requiresLibC() or
268269 // For these libcs, Zig can only provide dynamic libc when cross-compiling.
269 ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC()) and
270 ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC() or target.isOpenBSDLibC()) and
270271 !options.resolved_target.is_native_abi)))
271272 {
272273 if (options.link_mode == .static) return error.LibCRequiresDynamicLinking;
......@@ -286,7 +287,7 @@ pub fn resolve(options: Options) ResolveError!Config {
286287 // When targeting systems where the kernel and libc are developed alongside each other,
287288 // dynamic linking is the better default; static libc may contain code that requires
288289 // the very latest kernel version.
289 if (target.isFreeBSDLibC() or target.isNetBSDLibC()) {
290 if (target.isFreeBSDLibC() or target.isNetBSDLibC() or target.isOpenBSDLibC()) {
290291 break :b .dynamic;
291292 }
292293 }
test/src/StackTrace.zig+1-1
......@@ -59,7 +59,7 @@ fn addCaseTarget(
5959 else => true,
6060 };
6161 const both_libc = switch (target.result.os.tag) {
62 .freebsd, .netbsd => false,
62 .freebsd, .netbsd, .openbsd => false,
6363 else => !target.result.requiresLibC(),
6464 };
6565
test/tests.zig+1-1
......@@ -2379,7 +2379,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
23792379 // These targets don't strictly require libc, but we don't yet have a
23802380 // syscall layer for them, so the compiler links libc by default. They
23812381 // therefore get the same treatment here.
2382 if (test_target.link_libc == null and (target.os.tag == .freebsd or target.os.tag == .netbsd)) continue;
2382 if (test_target.link_libc == null and (target.os.tag == .freebsd or target.os.tag == .netbsd or target.os.tag == .openbsd)) continue;
23832383
23842384 if (!options.test_extra_targets and test_target.extra_target) continue;
23852385