diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 1b0c617598d346dba09599feb5b47649a916b71a..3b982189a861edb7ef30338a74d1dc8388e773ac 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -2180,7 +2180,6 @@ pub fn requiresLibC(target: *const Target) bool { .watchos, .visionos, .dragonfly, - .openbsd, .haiku, .serenity, => true, @@ -2194,6 +2193,7 @@ pub fn requiresLibC(target: *const Target) bool { .windows, .freebsd, .netbsd, + .openbsd, .freestanding, .fuchsia, .managarm, diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index 7f966725371adc0873fe4e0744c34aaf958bad7b..3687db7b8e47e5fd23bfed1fdc4fa98d9e072845 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -239,6 +239,7 @@ pub fn resolve(options: Options) ResolveError!Config { // so we default to linking libc for now. .freebsd, .netbsd, + .openbsd, => break :b true, else => {}, } @@ -266,7 +267,7 @@ pub fn resolve(options: Options) ResolveError!Config { if (explicitly_exe_or_dyn_lib and link_libc and (target.requiresLibC() or // For these libcs, Zig can only provide dynamic libc when cross-compiling. - ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC()) and + ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC() or target.isOpenBSDLibC()) and !options.resolved_target.is_native_abi))) { if (options.link_mode == .static) return error.LibCRequiresDynamicLinking; @@ -286,7 +287,7 @@ pub fn resolve(options: Options) ResolveError!Config { // When targeting systems where the kernel and libc are developed alongside each other, // dynamic linking is the better default; static libc may contain code that requires // the very latest kernel version. - if (target.isFreeBSDLibC() or target.isNetBSDLibC()) { + if (target.isFreeBSDLibC() or target.isNetBSDLibC() or target.isOpenBSDLibC()) { break :b .dynamic; } } diff --git a/test/src/StackTrace.zig b/test/src/StackTrace.zig index ff0b145ff88e1591744b0d6de1fb75e945127d44..ae323c44979c0fb2d4a49120532347b453b0dc9f 100644 --- a/test/src/StackTrace.zig +++ b/test/src/StackTrace.zig @@ -59,7 +59,7 @@ fn addCaseTarget( else => true, }; const both_libc = switch (target.result.os.tag) { - .freebsd, .netbsd => false, + .freebsd, .netbsd, .openbsd => false, else => !target.result.requiresLibC(), }; diff --git a/test/tests.zig b/test/tests.zig index 1531471e95aed8787bf5d19a386d97373891b195..b2cd0334c2d25e8f5aca8bf77fb218030a85f12c 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -2379,7 +2379,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { // 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 (test_target.link_libc == null and (target.os.tag == .freebsd or target.os.tag == .netbsd or target.os.tag == .openbsd)) continue; if (!options.test_extra_targets and test_target.extra_target) continue;