authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-23 19:49:26+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-23 20:05:28+02:00
logb66fe565db650bbac17c7fd6559734f7d658f36d
tree0e6c76948382f513ddbb26dbaf720c7292c38277
parentc606ad4ce342fc8c69f94810b6d30b3d0fcc266f
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: deprecate Os.Tag.isBSD()

These operating systems share a lineage but it almost never makes sense to consider them together. Current-day Darwin being included is also likely to be a surprise to many.

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

lib/compiler/aro/aro/Target.zig+4-1
...@@ -523,7 +523,10 @@ pub fn systemCompiler(target: *const Target) LangOpts.Compiler {...@@ -523,7 +523,10 @@ pub fn systemCompiler(target: *const Target) LangOpts.Compiler {
523 // the rest for documentation as fn returns .clang523 // the rest for documentation as fn returns .clang
524 if (target.os.tag.isDarwin() or524 if (target.os.tag.isDarwin() or
525 target.abi.isAndroid() or525 target.abi.isAndroid() or
526 target.os.tag.isBSD() or526 target.os.tag == .dragonfly or
527 target.os.tag == .freebsd or
528 target.os.tag == .netbsd or
529 target.os.tag == .openbsd or
527 target.os.tag == .fuchsia or530 target.os.tag == .fuchsia or
528 target.os.tag == .illumos or531 target.os.tag == .illumos or
529 target.os.tag == .haiku or532 target.os.tag == .haiku or
lib/std/Target.zig+1
...@@ -89,6 +89,7 @@ pub const Os = struct {...@@ -89,6 +89,7 @@ pub const Os = struct {
89 };89 };
90 }90 }
9191
92 /// Deprecated; to be removed in 0.18.0. Check for relevant tags instead.
92 pub inline fn isBSD(tag: Tag) bool {93 pub inline fn isBSD(tag: Tag) bool {
93 return tag.isDarwin() or switch (tag) {94 return tag.isDarwin() or switch (tag) {
94 .freebsd, .openbsd, .netbsd, .dragonfly => true,95 .freebsd, .openbsd, .netbsd, .dragonfly => true,
src/target.zig+8-3
...@@ -303,9 +303,14 @@ pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {...@@ -303,9 +303,14 @@ pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
303 // https://github.com/ziglang/zig/issues/25699303 // https://github.com/ziglang/zig/issues/25699
304 return false;304 return false;
305 }305 }
306 if (target.os.tag.isBSD()) {306 // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341
307 // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341307 switch (target.os.tag) {
308 return false;308 .dragonfly,
309 .freebsd,
310 .netbsd,
311 .openbsd,
312 => return false,
313 else => {},
309 }314 }
310 return switch (target.ofmt) {315 return switch (target.ofmt) {
311 .elf, .macho => true,316 .elf, .macho => true,
test/tests.zig+9-1
...@@ -3041,7 +3041,15 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt...@@ -3041,7 +3041,15 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
3041 switch (cpu_arch) {3041 switch (cpu_arch) {
3042 .x86_64 => {3042 .x86_64 => {
3043 if (std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true;3043 if (std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true;
3044 if (os_tag.isBSD() or os_tag == .illumos) return true;3044 if (os_tag == .illumos) return true;
3045 switch (os_tag) {
3046 .dragonfly,
3047 .freebsd,
3048 .netbsd,
3049 .openbsd,
3050 => return true,
3051 else => {},
3052 }
3045 return switch (ofmt) {3053 return switch (ofmt) {
3046 .elf, .macho => return false,3054 .elf, .macho => return false,
3047 else => return true,3055 else => return true,