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 {
523523 // the rest for documentation as fn returns .clang
524524 if (target.os.tag.isDarwin() or
525525 target.abi.isAndroid() or
526 target.os.tag.isBSD() or
526 target.os.tag == .dragonfly or
527 target.os.tag == .freebsd or
528 target.os.tag == .netbsd or
529 target.os.tag == .openbsd or
527530 target.os.tag == .fuchsia or
528531 target.os.tag == .illumos or
529532 target.os.tag == .haiku or
lib/std/Target.zig+1
......@@ -89,6 +89,7 @@ pub const Os = struct {
8989 };
9090 }
9191
92 /// Deprecated; to be removed in 0.18.0. Check for relevant tags instead.
9293 pub inline fn isBSD(tag: Tag) bool {
9394 return tag.isDarwin() or switch (tag) {
9495 .freebsd, .openbsd, .netbsd, .dragonfly => true,
src/target.zig+8-3
......@@ -303,9 +303,14 @@ pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
303303 // https://github.com/ziglang/zig/issues/25699
304304 return false;
305305 }
306 if (target.os.tag.isBSD()) {
307 // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341
308 return false;
306 // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341
307 switch (target.os.tag) {
308 .dragonfly,
309 .freebsd,
310 .netbsd,
311 .openbsd,
312 => return false,
313 else => {},
309314 }
310315 return switch (target.ofmt) {
311316 .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
30413041 switch (cpu_arch) {
30423042 .x86_64 => {
30433043 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 }
30453053 return switch (ofmt) {
30463054 .elf, .macho => return false,
30473055 else => return true,