diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 1b0c617598..3b982189a8 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 7f96672537..3687db7b8e 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 ff0b145ff8..ae323c4497 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 1531471e95..b2cd0334c2 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;