From b66fe565db650bbac17c7fd6559734f7d658f36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 23 Aug 2026 19:49:26 +0200 Subject: [PATCH] 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. --- lib/compiler/aro/aro/Target.zig | 5 ++++- lib/std/Target.zig | 1 + src/target.zig | 11 ++++++++--- test/tests.zig | 10 +++++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/compiler/aro/aro/Target.zig b/lib/compiler/aro/aro/Target.zig index a0c9f3be3943810313dfcd94b94f6bea0794ff2d..88f7cbe9c3080bd040e61d0abfc48eb46b7c4dcc 100644 --- a/lib/compiler/aro/aro/Target.zig +++ b/lib/compiler/aro/aro/Target.zig @@ -523,7 +523,10 @@ pub fn systemCompiler(target: *const Target) LangOpts.Compiler { // the rest for documentation as fn returns .clang if (target.os.tag.isDarwin() or target.abi.isAndroid() or - target.os.tag.isBSD() or + target.os.tag == .dragonfly or + target.os.tag == .freebsd or + target.os.tag == .netbsd or + target.os.tag == .openbsd or target.os.tag == .fuchsia or target.os.tag == .illumos or target.os.tag == .haiku or diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 55b70bba3707c25dd043e8350118630dd2419492..6ab58d3b52369a8c1f64598fb450dd54697a5370 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -89,6 +89,7 @@ pub const Os = struct { }; } + /// Deprecated; to be removed in 0.18.0. Check for relevant tags instead. pub inline fn isBSD(tag: Tag) bool { return tag.isDarwin() or switch (tag) { .freebsd, .openbsd, .netbsd, .dragonfly => true, diff --git a/src/target.zig b/src/target.zig index ed7a854fa796f2ffd188011b7c80aa950674285e..6b57484254ce1e2fc697e3e0b1baea1f71ab6ba9 100644 --- a/src/target.zig +++ b/src/target.zig @@ -303,9 +303,14 @@ pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool { // https://github.com/ziglang/zig/issues/25699 return false; } - if (target.os.tag.isBSD()) { - // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341 - return false; + // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341 + switch (target.os.tag) { + .dragonfly, + .freebsd, + .netbsd, + .openbsd, + => return false, + else => {}, } return switch (target.ofmt) { .elf, .macho => true, diff --git a/test/tests.zig b/test/tests.zig index caedd5452a157fe1df63cab1ef42e40a4e07f156..81f778dcb15a29941c9163c86627dbaa79ac7444 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -3041,7 +3041,15 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt switch (cpu_arch) { .x86_64 => { if (std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true; - if (os_tag.isBSD() or os_tag == .illumos) return true; + if (os_tag == .illumos) return true; + switch (os_tag) { + .dragonfly, + .freebsd, + .netbsd, + .openbsd, + => return true, + else => {}, + } return switch (ofmt) { .elf, .macho => return false, else => return true, -- 2.54.0