diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-01-24 03:45:38 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-02-17 19:18:19 +0100 |
| commit | 481b7bf3f095488a89e20d88ada092529bc6e6f8 (patch) | |
| tree | 9e4dde982be4327fb18d156d7b3540c8d03ce658 /lib/std | |
| parent | e62352611faf3056b989cc1edaa4aedaa74f326e (diff) | |
| download | zig-481b7bf3f095488a89e20d88ada092529bc6e6f8.tar.gz zig-481b7bf3f095488a89e20d88ada092529bc6e6f8.zip | |
std.Target: Remove functions that just wrap component functions.
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look
at multiple components of the target. But functions like isWasm(), isDarwin(),
isGnu(), etc only exist to save 4-8 characters. I don't think this is a good
enough reason to keep them, especially given that:
* It's not immediately obvious to a reader whether target.isDarwin() means the
same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar
functions *do* look at multiple components.
* It's not clear where we would draw the line. The logical conclusion before
this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(),
Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand.
* It's nice to just have a single correct way of doing something.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Build/Step/Compile.zig | 6 | ||||
| -rw-r--r-- | lib/std/Target.zig | 66 | ||||
| -rw-r--r-- | lib/std/Target/Query.zig | 5 | ||||
| -rw-r--r-- | lib/std/Thread.zig | 2 | ||||
| -rw-r--r-- | lib/std/Thread/Futex.zig | 2 | ||||
| -rw-r--r-- | lib/std/builtin.zig | 2 | ||||
| -rw-r--r-- | lib/std/c.zig | 12 | ||||
| -rw-r--r-- | lib/std/c/darwin.zig | 2 | ||||
| -rw-r--r-- | lib/std/debug.zig | 8 | ||||
| -rw-r--r-- | lib/std/debug/SelfInfo.zig | 8 | ||||
| -rw-r--r-- | lib/std/fs/Dir.zig | 2 | ||||
| -rw-r--r-- | lib/std/heap.zig | 6 | ||||
| -rw-r--r-- | lib/std/heap/WasmAllocator.zig | 2 | ||||
| -rw-r--r-- | lib/std/heap/debug_allocator.zig | 4 | ||||
| -rw-r--r-- | lib/std/math/big/int_test.zig | 2 | ||||
| -rw-r--r-- | lib/std/math/gamma.zig | 2 | ||||
| -rw-r--r-- | lib/std/math/log10.zig | 2 | ||||
| -rw-r--r-- | lib/std/posix.zig | 4 | ||||
| -rw-r--r-- | lib/std/zig/LibCDirs.zig | 4 | ||||
| -rw-r--r-- | lib/std/zig/LibCInstallation.zig | 10 | ||||
| -rw-r--r-- | lib/std/zig/system.zig | 2 | ||||
| -rw-r--r-- | lib/std/zig/system/NativePaths.zig | 2 |
22 files changed, 68 insertions, 87 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index 25061917fa..c2c91ad447 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -465,7 +465,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { if (compile.linkage != null and compile.linkage.? == .static) { compile.out_lib_filename = compile.out_filename; } else if (compile.version) |version| { - if (target.isDarwin()) { + if (target.os.tag.isDarwin()) { compile.major_only_filename = owner.fmt("lib{s}.{d}.dylib", .{ compile.name, version.major, @@ -480,7 +480,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { compile.out_lib_filename = compile.out_filename; } } else { - if (target.isDarwin()) { + if (target.os.tag.isDarwin()) { compile.out_lib_filename = compile.out_filename; } else if (target.os.tag == .windows) { compile.out_lib_filename = owner.fmt("{s}.lib", .{compile.name}); @@ -1524,7 +1524,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { try zig_args.append(b.fmt("{}", .{version})); } - if (compile.rootModuleTarget().isDarwin()) { + if (compile.rootModuleTarget().os.tag.isDarwin()) { const install_name = compile.install_name orelse b.fmt("@rpath/{s}{s}{s}", .{ compile.rootModuleTarget().libPrefix(), compile.name, diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 05bd2a3673..740949858f 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -144,10 +144,6 @@ pub const Os = struct { }; } - pub inline fn isGnuLibC(tag: Os.Tag, abi: Abi) bool { - return (tag == .hurd or tag == .linux) and abi.isGnu(); - } - pub fn defaultVersionRange(tag: Tag, arch: Cpu.Arch, abi: Abi) Os { return .{ .tag = tag, @@ -973,7 +969,12 @@ pub const Abi = enum { }; } - pub inline fn floatAbi(abi: Abi) FloatAbi { + pub const Float = enum { + hard, + soft, + }; + + pub inline fn float(abi: Abi) Float { return switch (abi) { .androideabi, .eabi, @@ -2022,48 +2023,29 @@ pub fn libPrefix(target: Target) [:0]const u8 { } pub inline fn isMinGW(target: Target) bool { - return target.os.tag == .windows and target.isGnu(); -} - -pub inline fn isGnu(target: Target) bool { - return target.abi.isGnu(); -} - -pub inline fn isMusl(target: Target) bool { - return target.abi.isMusl(); -} - -pub inline fn isAndroid(target: Target) bool { - return target.abi.isAndroid(); -} - -pub inline fn isWasm(target: Target) bool { - return target.cpu.arch.isWasm(); -} - -pub inline fn isDarwin(target: Target) bool { - return target.os.tag.isDarwin(); -} - -pub inline fn isBSD(target: Target) bool { - return target.os.tag.isBSD(); + return target.os.tag == .windows and target.abi.isGnu(); } pub inline fn isGnuLibC(target: Target) bool { - return target.os.tag.isGnuLibC(target.abi); + return switch (target.os.tag) { + .hurd, .linux => target.abi.isGnu(), + else => false, + }; } -pub inline fn isSpirV(target: Target) bool { - return target.cpu.arch.isSpirV(); +pub inline fn isMuslLibC(target: Target) bool { + return target.os.tag == .linux and target.abi.isMusl(); } -pub const FloatAbi = enum { - hard, - soft, -}; +pub inline fn isDarwinLibC(target: Target) bool { + return switch (target.abi) { + .none, .macabi, .simulator => target.os.tag.isDarwin(), + else => false, + }; +} -pub inline fn floatAbi(target: Target) FloatAbi { - return target.abi.floatAbi(); +pub inline fn isWasiLibC(target: Target) bool { + return target.os.tag == .wasi and target.abi.isMusl(); } pub const DynamicLinker = struct { @@ -2699,7 +2681,7 @@ pub fn stackAlignment(target: Target) u16 { /// Note that char signedness is implementation-defined and many compilers provide /// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char pub fn charSignedness(target: Target) std.builtin.Signedness { - if (target.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed; + if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed; return switch (target.cpu.arch) { .arm, @@ -3292,7 +3274,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention { .windows => .{ .aarch64_aapcs_win = .{} }, else => .{ .aarch64_aapcs = .{} }, }, - .arm, .armeb, .thumb, .thumbeb => switch (target.abi.floatAbi()) { + .arm, .armeb, .thumb, .thumbeb => switch (target.abi.float()) { .soft => .{ .arm_aapcs = .{} }, .hard => .{ .arm_aapcs_vfp = .{} }, }, @@ -3305,7 +3287,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention { .riscv32 => .{ .riscv32_ilp32 = .{} }, .sparc64 => .{ .sparc64_sysv = .{} }, .sparc => .{ .sparc_sysv = .{} }, - .powerpc64 => if (target.isMusl()) + .powerpc64 => if (target.abi.isMusl()) .{ .powerpc64_elf_v2 = .{} } else .{ .powerpc64_elf = .{} }, diff --git a/lib/std/Target/Query.zig b/lib/std/Target/Query.zig index 56387c27b3..2d5c734108 100644 --- a/lib/std/Target/Query.zig +++ b/lib/std/Target/Query.zig @@ -26,7 +26,7 @@ os_version_min: ?OsVersion = null, os_version_max: ?OsVersion = null, /// `null` means default when cross compiling, or native when `os_tag` is native. -/// If `isGnuLibC()` is `false`, this must be `null` and is ignored. +/// If `isGnu()` is `false`, this must be `null` and is ignored. glibc_version: ?SemanticVersion = null, /// `null` means default when cross compiling, or native when `os_tag` is native. @@ -235,8 +235,7 @@ pub fn parse(args: ParseOptions) !Query { const abi_ver_text = abi_it.rest(); if (abi_it.next() != null) { - const tag = result.os_tag orelse builtin.os.tag; - if (tag.isGnuLibC(abi)) { + if (abi.isGnu()) { result.glibc_version = parseVersion(abi_ver_text) catch |err| switch (err) { error.Overflow => return error.InvalidAbiVersion, error.InvalidVersion => return error.InvalidAbiVersion, diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 6dcb956184..eaf136d0eb 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -734,7 +734,7 @@ const PosixThreadImpl = struct { else => { var count: c_int = undefined; var count_len: usize = @sizeOf(c_int); - const name = if (comptime target.isDarwin()) "hw.logicalcpu" else "hw.ncpu"; + const name = if (comptime target.os.tag.isDarwin()) "hw.logicalcpu" else "hw.ncpu"; posix.sysctlbynameZ(name, &count, &count_len, null, 0) catch |err| switch (err) { error.NameTooLong, error.UnknownName => unreachable, else => |e| return e, diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index c18caec7a6..69ed57a908 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -80,7 +80,7 @@ else if (builtin.os.tag == .openbsd) OpenbsdImpl else if (builtin.os.tag == .dragonfly) DragonflyImpl -else if (builtin.target.isWasm()) +else if (builtin.target.cpu.arch.isWasm()) WasmImpl else if (std.Thread.use_pthreads) PosixImpl diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 19570c28b6..3a8764eed9 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -957,7 +957,7 @@ pub const VaList = switch (builtin.cpu.arch) { .amdgcn => *u8, .avr => *anyopaque, .bpfel, .bpfeb => *anyopaque, - .hexagon => if (builtin.target.isMusl()) VaListHexagon else *u8, + .hexagon => if (builtin.target.abi.isMusl()) VaListHexagon else *u8, .loongarch32, .loongarch64 => *anyopaque, .mips, .mipsel, .mips64, .mips64el => *anyopaque, .riscv32, .riscv64 => *anyopaque, diff --git a/lib/std/c.zig b/lib/std/c.zig index fea9bbe177..32579c04d0 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -2808,7 +2808,7 @@ pub const Sigaction = switch (native_os) { .mipsel, .mips64, .mips64el, - => if (builtin.target.isMusl()) + => if (builtin.target.abi.isMusl()) linux.Sigaction else if (builtin.target.ptrBitWidth() == 64) extern struct { pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; @@ -6701,7 +6701,7 @@ pub const Stat = switch (native_os) { return self.ctim; } }, - .mips, .mipsel => if (builtin.target.isMusl()) extern struct { + .mips, .mipsel => if (builtin.target.abi.isMusl()) extern struct { dev: dev_t, __pad0: [2]i32, ino: ino_t, @@ -6762,7 +6762,7 @@ pub const Stat = switch (native_os) { return self.ctim; } }, - .mips64, .mips64el => if (builtin.target.isMusl()) extern struct { + .mips64, .mips64el => if (builtin.target.abi.isMusl()) extern struct { dev: dev_t, __pad0: [3]i32, ino: ino_t, @@ -9863,16 +9863,16 @@ pub const LC = enum(c_int) { pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8; -pub const getcontext = if (builtin.target.isAndroid() or builtin.target.os.tag == .openbsd) +pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd) {} // android bionic and openbsd libc does not implement getcontext -else if (native_os == .linux and builtin.target.isMusl()) +else if (native_os == .linux and builtin.target.abi.isMusl()) linux.getcontext else private.getcontext; pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium) f64 -else if (builtin.target.isDarwin()) +else if (native_os.isDarwin()) c_longdouble else extern struct { diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index 89aa792566..561a4e7ce4 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -979,7 +979,7 @@ pub const kevent64_s = extern struct { // to make sure the struct is laid out the same. These values were // produced from C code using the offsetof macro. comptime { - if (builtin.target.isDarwin()) { + if (builtin.target.os.tag.isDarwin()) { assert(@offsetOf(kevent64_s, "ident") == 0); assert(@offsetOf(kevent64_s, "filter") == 8); assert(@offsetOf(kevent64_s, "flags") == 10); diff --git a/lib/std/debug.zig b/lib/std/debug.zig index c36c89b206..56d978626a 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -292,7 +292,7 @@ pub fn dumpHexFallible(bytes: []const u8) !void { /// TODO multithreaded awareness pub fn dumpCurrentStackTrace(start_addr: ?usize) void { nosuspend { - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { if (native_os == .wasi) { const stderr = io.getStdErr().writer(); stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; @@ -380,7 +380,7 @@ pub inline fn getContext(context: *ThreadContext) bool { /// TODO multithreaded awareness pub fn dumpStackTraceFromBase(context: *ThreadContext) void { nosuspend { - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { if (native_os == .wasi) { const stderr = io.getStdErr().writer(); stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; @@ -478,7 +478,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackT /// TODO multithreaded awareness pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { nosuspend { - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { if (native_os == .wasi) { const stderr = io.getStdErr().writer(); stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; @@ -759,7 +759,7 @@ pub const StackIterator = struct { pub fn initWithContext(first_address: ?usize, debug_info: *SelfInfo, context: *posix.ucontext_t) !StackIterator { // The implementation of DWARF unwinding on aarch64-macos is not complete. However, Apple mandates that // the frame pointer register is always used, so on this platform we can safely use the FP-based unwinder. - if (builtin.target.isDarwin() and native_arch == .aarch64) + if (builtin.target.os.tag.isDarwin() and native_arch == .aarch64) return init(first_address, @truncate(context.mcontext.ss.fp)); if (SelfInfo.supports_unwinding) { diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index 3c4260b212..0bd3f2d41b 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -121,13 +121,13 @@ pub fn deinit(self: *SelfInfo) void { } pub fn getModuleForAddress(self: *SelfInfo, address: usize) !*Module { - if (builtin.target.isDarwin()) { + if (builtin.target.os.tag.isDarwin()) { return self.lookupModuleDyld(address); } else if (native_os == .windows) { return self.lookupModuleWin32(address); } else if (native_os == .haiku) { return self.lookupModuleHaiku(address); - } else if (builtin.target.isWasm()) { + } else if (builtin.target.cpu.arch.isWasm()) { return self.lookupModuleWasm(address); } else { return self.lookupModuleDl(address); @@ -138,13 +138,13 @@ pub fn getModuleForAddress(self: *SelfInfo, address: usize) !*Module { // This can be called when getModuleForAddress fails, so implementations should provide // a path that doesn't rely on any side-effects of a prior successful module lookup. pub fn getModuleNameForAddress(self: *SelfInfo, address: usize) ?[]const u8 { - if (builtin.target.isDarwin()) { + if (builtin.target.os.tag.isDarwin()) { return self.lookupModuleNameDyld(address); } else if (native_os == .windows) { return self.lookupModuleNameWin32(address); } else if (native_os == .haiku) { return null; - } else if (builtin.target.isWasm()) { + } else if (builtin.target.cpu.arch.isWasm()) { return null; } else { return self.lookupModuleNameDl(address); diff --git a/lib/std/fs/Dir.zig b/lib/std/fs/Dir.zig index 39aad8d42d..4ebec1ce14 100644 --- a/lib/std/fs/Dir.zig +++ b/lib/std/fs/Dir.zig @@ -2587,7 +2587,7 @@ const CopyFileRawError = error{SystemResources} || posix.CopyFileRangeError || p // The copy starts at offset 0, the initial offsets are preserved. // No metadata is transferred over. fn copy_file(fd_in: posix.fd_t, fd_out: posix.fd_t, maybe_size: ?u64) CopyFileRawError!void { - if (builtin.target.isDarwin()) { + if (builtin.target.os.tag.isDarwin()) { const rc = posix.system.fcopyfile(fd_in, fd_out, null, .{ .DATA = true }); switch (posix.errno(rc)) { .SUCCESS => return, diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 51f434743d..6fbc3d8b75 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -348,7 +348,7 @@ pub const page_allocator: Allocator = if (@hasDecl(root, "os") and @hasDecl(root.os, "heap") and @hasDecl(root.os.heap, "page_allocator")) root.os.heap.page_allocator -else if (builtin.target.isWasm()) .{ +else if (builtin.target.cpu.arch.isWasm()) .{ .ptr = undefined, .vtable = &WasmAllocator.vtable, } else if (builtin.target.os.tag == .plan9) .{ @@ -508,7 +508,7 @@ test PageAllocator { const allocator = page_allocator; try testAllocator(allocator); try testAllocatorAligned(allocator); - if (!builtin.target.isWasm()) { + if (!builtin.target.cpu.arch.isWasm()) { try testAllocatorLargeAlignment(allocator); try testAllocatorAlignedShrink(allocator); } @@ -990,7 +990,7 @@ test { _ = FixedBufferAllocator; _ = ThreadSafeAllocator; _ = SbrkAllocator; - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { _ = WasmAllocator; } if (!builtin.single_threaded) _ = smp_allocator; diff --git a/lib/std/heap/WasmAllocator.zig b/lib/std/heap/WasmAllocator.zig index 0a9003f245..b511a216f7 100644 --- a/lib/std/heap/WasmAllocator.zig +++ b/lib/std/heap/WasmAllocator.zig @@ -7,7 +7,7 @@ const wasm = std.wasm; const math = std.math; comptime { - if (!builtin.target.isWasm()) { + if (!builtin.target.cpu.arch.isWasm()) { @compileError("only available for wasm32 arch"); } if (!builtin.single_threaded) { diff --git a/lib/std/heap/debug_allocator.zig b/lib/std/heap/debug_allocator.zig index 44e7a4c943..3e5163cd6c 100644 --- a/lib/std/heap/debug_allocator.zig +++ b/lib/std/heap/debug_allocator.zig @@ -1140,7 +1140,7 @@ test "shrink" { } test "large object - grow" { - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { // Not expected to pass on targets that do not have memory mapping. return error.SkipZigTest; } @@ -1319,7 +1319,7 @@ test "realloc large object to larger alignment" { } test "large object rejects shrinking to small" { - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { // Not expected to pass on targets that do not have memory mapping. return error.SkipZigTest; } diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig index 701dddf0c9..811cf98d73 100644 --- a/lib/std/math/big/int_test.zig +++ b/lib/std/math/big/int_test.zig @@ -2262,7 +2262,7 @@ test "bitNotWrap more than two limbs" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO // LLVM: unexpected runtime library name: __umodei4 - if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.isWasm()) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.cpu.arch.isWasm()) return error.SkipZigTest; // TODO var a = try Managed.initSet(testing.allocator, maxInt(Limb)); defer a.deinit(); diff --git a/lib/std/math/gamma.zig b/lib/std/math/gamma.zig index aad2a104cc..5577f71461 100644 --- a/lib/std/math/gamma.zig +++ b/lib/std/math/gamma.zig @@ -263,7 +263,7 @@ test gamma { } test "gamma.special" { - if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234 + if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234 inline for (&.{ f32, f64 }) |T| { try expect(std.math.isNan(gamma(T, -std.math.nan(T)))); diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig index 6f3d9a47f6..655a42215e 100644 --- a/lib/std/math/log10.zig +++ b/lib/std/math/log10.zig @@ -135,7 +135,7 @@ test log10_int { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.isWasm()) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.cpu.arch.isWasm()) return error.SkipZigTest; // TODO inline for ( .{ u8, u16, u32, u64, u128, u256, u512 }, diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 011a6723d1..0a640bf62a 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -3583,7 +3583,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t return rc; } - const have_sock_flags = !builtin.target.isDarwin() and native_os != .haiku; + const have_sock_flags = !builtin.target.os.tag.isDarwin() and native_os != .haiku; const filtered_sock_type = if (!have_sock_flags) socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC) else @@ -3879,7 +3879,7 @@ pub fn accept( /// description of the `CLOEXEC` flag in `open` for reasons why this may be useful. flags: u32, ) AcceptError!socket_t { - const have_accept4 = !(builtin.target.isDarwin() or native_os == .windows or native_os == .haiku); + const have_accept4 = !(builtin.target.os.tag.isDarwin() or native_os == .windows or native_os == .haiku); assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s) const accepted_sock: socket_t = while (true) { diff --git a/lib/std/zig/LibCDirs.zig b/lib/std/zig/LibCDirs.zig index 2ca3f406b9..cda21fbb37 100644 --- a/lib/std/zig/LibCDirs.zig +++ b/lib/std/zig/LibCDirs.zig @@ -127,7 +127,7 @@ fn detectFromInstallation(arena: Allocator, target: std.Target, lci: *const LibC var sysroot: ?[]const u8 = null; - if (target.isDarwin()) d: { + if (target.os.tag.isDarwin()) d: { const down1 = std.fs.path.dirname(lci.sys_include_dir.?) orelse break :d; const down2 = std.fs.path.dirname(down1) orelse break :d; try framework_list.append(try std.fs.path.join(arena, &.{ down2, "System", "Library", "Frameworks" })); @@ -150,7 +150,7 @@ pub fn detectFromBuilding( ) !LibCDirs { const s = std.fs.path.sep_str; - if (target.isDarwin()) { + if (target.os.tag.isDarwin()) { const list = try arena.alloc([]const u8, 1); list[0] = try std.fmt.allocPrint( arena, diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig index 56bc388f5d..b52c009313 100644 --- a/lib/std/zig/LibCInstallation.zig +++ b/lib/std/zig/LibCInstallation.zig @@ -81,7 +81,7 @@ pub fn parse( } const os_tag = target.os.tag; - if (self.crt_dir == null and !target.isDarwin()) { + if (self.crt_dir == null and !target.os.tag.isDarwin()) { log.err("crt_dir may not be empty for {s}", .{@tagName(os_tag)}); return error.ParseError; } @@ -167,7 +167,7 @@ pub const FindNativeOptions = struct { pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { var self: LibCInstallation = .{}; - if (is_darwin and args.target.isDarwin()) { + if (is_darwin and args.target.os.tag.isDarwin()) { if (!std.zig.system.darwin.isSdkInstalled(args.allocator)) return error.DarwinSdkNotFound; const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse @@ -444,7 +444,7 @@ fn findNativeCrtDirPosix(self: *LibCInstallation, args: FindNativeOptions) FindE self.crt_dir = try ccPrintFileName(.{ .allocator = args.allocator, .search_basename = switch (args.target.os.tag) { - .linux => if (args.target.isAndroid()) "crtbegin_dynamic.o" else "crt1.o", + .linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o", else => "crt1.o", }, .want_dirname = .only_dir, @@ -734,7 +734,7 @@ pub const CrtBasenames = struct { const target = args.target; - if (target.isAndroid()) return switch (mode) { + if (target.abi.isAndroid()) return switch (mode) { .dynamic_lib => .{ .crtbegin = "crtbegin_so.o", .crtend = "crtend_so.o", @@ -1025,7 +1025,7 @@ const fs = std.fs; const Allocator = std.mem.Allocator; const Path = std.Build.Cache.Path; -const is_darwin = builtin.target.isDarwin(); +const is_darwin = builtin.target.os.tag.isDarwin(); const is_windows = builtin.target.os.tag == .windows; const is_haiku = builtin.target.os.tag == .haiku; diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 68182366e8..84f9cf7330 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -415,7 +415,7 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target { } // https://github.com/llvm/llvm-project/issues/105978 - if (result.cpu.arch.isArm() and result.abi.floatAbi() == .soft) { + if (result.cpu.arch.isArm() and result.abi.float() == .soft) { result.cpu.features.removeFeature(@intFromEnum(Target.arm.Feature.vfp2)); } } diff --git a/lib/std/zig/system/NativePaths.zig b/lib/std/zig/system/NativePaths.zig index be8e7b05dd..d7bc9dfad7 100644 --- a/lib/std/zig/system/NativePaths.zig +++ b/lib/std/zig/system/NativePaths.zig @@ -83,7 +83,7 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths { // TODO: consider also adding homebrew paths // TODO: consider also adding macports paths - if (builtin.target.isDarwin()) { + if (builtin.target.os.tag.isDarwin()) { if (std.zig.system.darwin.isSdkInstalled(arena)) sdk: { const sdk = std.zig.system.darwin.getSdk(arena, native_target) orelse break :sdk; try self.addLibDir(try std.fs.path.join(arena, &.{ sdk, "usr/lib" })); |
