authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-09 15:45:42-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-05-09 15:45:42-07:00
log68629fedefd46bad4feed7f9244a3208199d6a0e
tree0d483126b4222796eea87349b79330bb76fc733e
parentc9ad1b51993e45942e38079325dcb7b5ce41e877
parent47e840a9b99c6ca371c89a73350617ba0cad877c
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #19918 from ziglang/xros

Add support for VisionOS

27 files changed, 120 insertions(+), 80 deletions(-)

build.zig+1-1
...@@ -705,7 +705,7 @@ fn addCmakeCfgOptionsToExe(...@@ -705,7 +705,7 @@ fn addCmakeCfgOptionsToExe(
705 };705 };
706 exe.linkSystemLibrary("unwind");706 exe.linkSystemLibrary("unwind");
707 },707 },
708 .ios, .macos, .watchos, .tvos => {708 .ios, .macos, .watchos, .tvos, .visionos => {
709 exe.linkLibCpp();709 exe.linkLibCpp();
710 },710 },
711 .windows => {711 .windows => {
lib/compiler/aro/aro/Compilation.zig+2-2
...@@ -912,12 +912,12 @@ fn generateVaListType(comp: *Compilation) !Type {...@@ -912,12 +912,12 @@ fn generateVaListType(comp: *Compilation) !Type {
912 const kind: Kind = switch (comp.target.cpu.arch) {912 const kind: Kind = switch (comp.target.cpu.arch) {
913 .aarch64 => switch (comp.target.os.tag) {913 .aarch64 => switch (comp.target.os.tag) {
914 .windows => @as(Kind, .char_ptr),914 .windows => @as(Kind, .char_ptr),
915 .ios, .macos, .tvos, .watchos => .char_ptr,915 .ios, .macos, .tvos, .watchos, .visionos => .char_ptr,
916 else => .aarch64_va_list,916 else => .aarch64_va_list,
917 },917 },
918 .sparc, .wasm32, .wasm64, .bpfel, .bpfeb, .riscv32, .riscv64, .avr, .spirv32, .spirv64 => .void_ptr,918 .sparc, .wasm32, .wasm64, .bpfel, .bpfeb, .riscv32, .riscv64, .avr, .spirv32, .spirv64 => .void_ptr,
919 .powerpc => switch (comp.target.os.tag) {919 .powerpc => switch (comp.target.os.tag) {
920 .ios, .macos, .tvos, .watchos, .aix => @as(Kind, .char_ptr),920 .ios, .macos, .tvos, .watchos, .visionos, .aix => @as(Kind, .char_ptr),
921 else => return Type{ .specifier = .void }, // unknown921 else => return Type{ .specifier = .void }, // unknown
922 },922 },
923 .x86, .msp430 => .char_ptr,923 .x86, .msp430 => .char_ptr,
lib/compiler/aro/aro/target.zig+1
...@@ -706,6 +706,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {...@@ -706,6 +706,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
706 .ios => "ios",706 .ios => "ios",
707 .tvos => "tvos",707 .tvos => "tvos",
708 .watchos => "watchos",708 .watchos => "watchos",
709 .visionos => "xros",
709 .driverkit => "driverkit",710 .driverkit => "driverkit",
710 .shadermodel => "shadermodel",711 .shadermodel => "shadermodel",
711 .liteos => "liteos",712 .liteos => "liteos",
lib/compiler_rt/clear_cache.zig+1-1
...@@ -45,7 +45,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {...@@ -45,7 +45,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
45 else => false,45 else => false,
46 };46 };
47 const apple = switch (os) {47 const apple = switch (os) {
48 .ios, .macos, .watchos, .tvos => true,48 .ios, .macos, .watchos, .tvos, .visionos => true,
49 else => false,49 else => false,
50 };50 };
51 if (x86) {51 if (x86) {
lib/std/Target.zig+18-12
...@@ -47,7 +47,7 @@ pub const Os = struct {...@@ -47,7 +47,7 @@ pub const Os = struct {
47 tvos,47 tvos,
48 watchos,48 watchos,
49 driverkit,49 driverkit,
50 xros,50 visionos,
51 mesa3d,51 mesa3d,
52 contiki,52 contiki,
53 amdpal,53 amdpal,
...@@ -67,7 +67,7 @@ pub const Os = struct {...@@ -67,7 +67,7 @@ pub const Os = struct {
6767
68 pub inline fn isDarwin(tag: Tag) bool {68 pub inline fn isDarwin(tag: Tag) bool {
69 return switch (tag) {69 return switch (tag) {
70 .ios, .macos, .watchos, .tvos => true,70 .ios, .macos, .watchos, .tvos, .visionos => true,
71 else => false,71 else => false,
72 };72 };
73 }73 }
...@@ -108,7 +108,7 @@ pub const Os = struct {...@@ -108,7 +108,7 @@ pub const Os = struct {
108 pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {108 pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {
109 return switch (tag) {109 return switch (tag) {
110 .windows, .uefi => ".dll",110 .windows, .uefi => ".dll",
111 .ios, .macos, .watchos, .tvos => ".dylib",111 .ios, .macos, .watchos, .tvos, .visionos => ".dylib",
112 else => ".so",112 else => ".so",
113 };113 };
114 }114 }
...@@ -178,7 +178,7 @@ pub const Os = struct {...@@ -178,7 +178,7 @@ pub const Os = struct {
178 .ios,178 .ios,
179 .tvos,179 .tvos,
180 .watchos,180 .watchos,
181 .xros,181 .visionos,
182 .netbsd,182 .netbsd,
183 .openbsd,183 .openbsd,
184 .dragonfly,184 .dragonfly,
...@@ -434,7 +434,12 @@ pub const Os = struct {...@@ -434,7 +434,12 @@ pub const Os = struct {
434 .max = .{ .major = 17, .minor = 1, .patch = 0 },434 .max = .{ .major = 17, .minor = 1, .patch = 0 },
435 },435 },
436 },436 },
437 .xros => @panic("TODO what version is xros on right now?"),437 .visionos => .{
438 .semver = .{
439 .min = .{ .major = 1, .minor = 0, .patch = 0 },
440 .max = .{ .major = 1, .minor = 0, .patch = 0 },
441 },
442 },
438 .netbsd => .{443 .netbsd => .{
439 .semver = .{444 .semver = .{
440 .min = .{ .major = 8, .minor = 0, .patch = 0 },445 .min = .{ .major = 8, .minor = 0, .patch = 0 },
...@@ -531,7 +536,7 @@ pub const Os = struct {...@@ -531,7 +536,7 @@ pub const Os = struct {
531 .ios,536 .ios,
532 .tvos,537 .tvos,
533 .watchos,538 .watchos,
534 .xros,539 .visionos,
535 .dragonfly,540 .dragonfly,
536 .openbsd,541 .openbsd,
537 .haiku,542 .haiku,
...@@ -691,7 +696,7 @@ pub const Abi = enum {...@@ -691,7 +696,7 @@ pub const Abi = enum {
691 .ios,696 .ios,
692 .tvos,697 .tvos,
693 .watchos,698 .watchos,
694 .xros,699 .visionos,
695 .driverkit,700 .driverkit,
696 .shadermodel,701 .shadermodel,
697 .liteos, // TODO: audit this702 .liteos, // TODO: audit this
...@@ -768,7 +773,7 @@ pub const ObjectFormat = enum {...@@ -768,7 +773,7 @@ pub const ObjectFormat = enum {
768 pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {773 pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {
769 return switch (os_tag) {774 return switch (os_tag) {
770 .windows, .uefi => .coff,775 .windows, .uefi => .coff,
771 .ios, .macos, .watchos, .tvos => .macho,776 .ios, .macos, .watchos, .tvos, .visionos => .macho,
772 .plan9 => .plan9,777 .plan9 => .plan9,
773 else => switch (arch) {778 else => switch (arch) {
774 .wasm32, .wasm64 => .wasm,779 .wasm32, .wasm64 => .wasm,
...@@ -1633,6 +1638,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {...@@ -1633,6 +1638,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {
1633 .tvos,1638 .tvos,
1634 .watchos,1639 .watchos,
1635 .macos,1640 .macos,
1641 .visionos,
1636 .uefi,1642 .uefi,
1637 .windows,1643 .windows,
1638 .emscripten,1644 .emscripten,
...@@ -1807,7 +1813,7 @@ pub const DynamicLinker = struct {...@@ -1807,7 +1813,7 @@ pub const DynamicLinker = struct {
1807 .tvos,1813 .tvos,
1808 .watchos,1814 .watchos,
1809 .macos,1815 .macos,
1810 .xros,1816 .visionos,
1811 => init("/usr/lib/dyld"),1817 => init("/usr/lib/dyld"),
18121818
1813 // Operating systems in this list have been verified as not having a standard1819 // Operating systems in this list have been verified as not having a standard
...@@ -2287,7 +2293,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {...@@ -2287,7 +2293,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
2287 },2293 },
2288 },2294 },
22892295
2290 .macos, .ios, .tvos, .watchos, .xros => switch (c_type) {2296 .macos, .ios, .tvos, .watchos, .visionos => switch (c_type) {
2291 .char => return 8,2297 .char => return 8,
2292 .short, .ushort => return 16,2298 .short, .ushort => return 16,
2293 .int, .uint, .float => return 32,2299 .int, .uint, .float => return 32,
...@@ -2407,7 +2413,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {...@@ -2407,7 +2413,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
24072413
2408 else => 4,2414 else => 4,
2409 },2415 },
2410 .ios, .tvos, .watchos => 4,2416 .ios, .tvos, .watchos, .visionos => 4,
2411 else => 8,2417 else => 8,
2412 },2418 },
24132419
...@@ -2500,7 +2506,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {...@@ -2500,7 +2506,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
2500 else => {},2506 else => {},
2501 },2507 },
2502 },2508 },
2503 .ios, .tvos, .watchos => switch (c_type) {2509 .ios, .tvos, .watchos, .visionos => switch (c_type) {
2504 .longdouble => return 4,2510 .longdouble => return 4,
2505 else => {},2511 else => {},
2506 },2512 },
lib/std/Thread.zig+6-6
...@@ -39,7 +39,7 @@ impl: Impl,...@@ -39,7 +39,7 @@ impl: Impl,
39pub const max_name_len = switch (native_os) {39pub const max_name_len = switch (native_os) {
40 .linux => 15,40 .linux => 15,
41 .windows => 31,41 .windows => 31,
42 .macos, .ios, .watchos, .tvos => 63,42 .macos, .ios, .watchos, .tvos, .visionos => 63,
43 .netbsd => 31,43 .netbsd => 31,
44 .freebsd => 15,44 .freebsd => 15,
45 .openbsd => 23,45 .openbsd => 23,
...@@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {...@@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
114 else => |err| return windows.unexpectedStatus(err),114 else => |err| return windows.unexpectedStatus(err),
115 }115 }
116 },116 },
117 .macos, .ios, .watchos, .tvos => if (use_pthreads) {117 .macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
118 // There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.118 // There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.
119 if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;119 if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
120120
...@@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co...@@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
217 else => |err| return windows.unexpectedStatus(err),217 else => |err| return windows.unexpectedStatus(err),
218 }218 }
219 },219 },
220 .macos, .ios, .watchos, .tvos => if (use_pthreads) {220 .macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
221 const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);221 const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
222 switch (err) {222 switch (err) {
223 .SUCCESS => return std.mem.sliceTo(buffer, 0),223 .SUCCESS => return std.mem.sliceTo(buffer, 0),
...@@ -266,7 +266,7 @@ pub const Id = switch (native_os) {...@@ -266,7 +266,7 @@ pub const Id = switch (native_os) {
266 .haiku,266 .haiku,
267 .wasi,267 .wasi,
268 => u32,268 => u32,
269 .macos, .ios, .watchos, .tvos => u64,269 .macos, .ios, .watchos, .tvos, .visionos => u64,
270 .windows => windows.DWORD,270 .windows => windows.DWORD,
271 else => usize,271 else => usize,
272};272};
...@@ -588,7 +588,7 @@ const PosixThreadImpl = struct {...@@ -588,7 +588,7 @@ const PosixThreadImpl = struct {
588 .linux => {588 .linux => {
589 return LinuxThreadImpl.getCurrentId();589 return LinuxThreadImpl.getCurrentId();
590 },590 },
591 .macos, .ios, .watchos, .tvos => {591 .macos, .ios, .watchos, .tvos, .visionos => {
592 var thread_id: u64 = undefined;592 var thread_id: u64 = undefined;
593 // Pass thread=null to get the current thread ID.593 // Pass thread=null to get the current thread ID.
594 assert(c.pthread_threadid_np(null, &thread_id) == 0);594 assert(c.pthread_threadid_np(null, &thread_id) == 0);
...@@ -1434,7 +1434,7 @@ test "setName, getName" {...@@ -1434,7 +1434,7 @@ test "setName, getName" {
1434 context.test_done_event.wait();1434 context.test_done_event.wait();
14351435
1436 switch (native_os) {1436 switch (native_os) {
1437 .macos, .ios, .watchos, .tvos => {1437 .macos, .ios, .watchos, .tvos, .visionos => {
1438 const res = thread.setName("foobar");1438 const res = thread.setName("foobar");
1439 try std.testing.expectError(error.Unsupported, res);1439 try std.testing.expectError(error.Unsupported, res);
1440 },1440 },
lib/std/builtin.zig+3-3
...@@ -597,11 +597,11 @@ pub const VaListX86_64 = extern struct {...@@ -597,11 +597,11 @@ pub const VaListX86_64 = extern struct {
597pub const VaList = switch (builtin.cpu.arch) {597pub const VaList = switch (builtin.cpu.arch) {
598 .aarch64, .aarch64_be => switch (builtin.os.tag) {598 .aarch64, .aarch64_be => switch (builtin.os.tag) {
599 .windows => *u8,599 .windows => *u8,
600 .ios, .macos, .tvos, .watchos => *u8,600 .ios, .macos, .tvos, .watchos, .visionos => *u8,
601 else => @compileError("disabled due to miscompilations"), // VaListAarch64,601 else => @compileError("disabled due to miscompilations"), // VaListAarch64,
602 },602 },
603 .arm => switch (builtin.os.tag) {603 .arm => switch (builtin.os.tag) {
604 .ios, .macos, .tvos, .watchos => *u8,604 .ios, .macos, .tvos, .watchos, .visionos => *u8,
605 else => *anyopaque,605 else => *anyopaque,
606 },606 },
607 .amdgcn => *u8,607 .amdgcn => *u8,
...@@ -611,7 +611,7 @@ pub const VaList = switch (builtin.cpu.arch) {...@@ -611,7 +611,7 @@ pub const VaList = switch (builtin.cpu.arch) {
611 .mips, .mipsel, .mips64, .mips64el => *anyopaque,611 .mips, .mipsel, .mips64, .mips64el => *anyopaque,
612 .riscv32, .riscv64 => *anyopaque,612 .riscv32, .riscv64 => *anyopaque,
613 .powerpc, .powerpcle => switch (builtin.os.tag) {613 .powerpc, .powerpcle => switch (builtin.os.tag) {
614 .ios, .macos, .tvos, .watchos, .aix => *u8,614 .ios, .macos, .tvos, .watchos, .visionos, .aix => *u8,
615 else => VaListPowerPc,615 else => VaListPowerPc,
616 },616 },
617 .powerpc64, .powerpc64le => *u8,617 .powerpc64, .powerpc64le => *u8,
lib/std/c.zig+17-17
...@@ -35,7 +35,7 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool {...@@ -35,7 +35,7 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool {
35pub usingnamespace switch (native_os) {35pub usingnamespace switch (native_os) {
36 .linux => @import("c/linux.zig"),36 .linux => @import("c/linux.zig"),
37 .windows => @import("c/windows.zig"),37 .windows => @import("c/windows.zig"),
38 .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),38 .macos, .ios, .tvos, .watchos, .visionos => @import("c/darwin.zig"),
39 .freebsd, .kfreebsd => @import("c/freebsd.zig"),39 .freebsd, .kfreebsd => @import("c/freebsd.zig"),
40 .netbsd => @import("c/netbsd.zig"),40 .netbsd => @import("c/netbsd.zig"),
41 .dragonfly => @import("c/dragonfly.zig"),41 .dragonfly => @import("c/dragonfly.zig"),
...@@ -63,7 +63,7 @@ pub const pthread_mutex_t = switch (native_os) {...@@ -63,7 +63,7 @@ pub const pthread_mutex_t = switch (native_os) {
63 else => @compileError("unsupported ABI"),63 else => @compileError("unsupported ABI"),
64 };64 };
65 },65 },
66 .macos, .ios, .tvos, .watchos => extern struct {66 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
67 sig: c_long = 0x32AAABA7,67 sig: c_long = 0x32AAABA7,
68 data: [data_len]u8 = [_]u8{0} ** data_len,68 data: [data_len]u8 = [_]u8{0} ** data_len,
6969
...@@ -113,7 +113,7 @@ pub const pthread_cond_t = switch (native_os) {...@@ -113,7 +113,7 @@ pub const pthread_cond_t = switch (native_os) {
113 .linux => extern struct {113 .linux => extern struct {
114 data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,114 data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
115 },115 },
116 .macos, .ios, .tvos, .watchos => extern struct {116 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
117 sig: c_long = 0x3CB0B1BB,117 sig: c_long = 0x3CB0B1BB,
118 data: [data_len]u8 = [_]u8{0} ** data_len,118 data: [data_len]u8 = [_]u8{0} ** data_len,
119 const data_len = if (@sizeOf(usize) == 8) 40 else 24;119 const data_len = if (@sizeOf(usize) == 8) 40 else 24;
...@@ -166,7 +166,7 @@ pub const pthread_rwlock_t = switch (native_os) {...@@ -166,7 +166,7 @@ pub const pthread_rwlock_t = switch (native_os) {
166 data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,166 data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
167 },167 },
168 },168 },
169 .macos, .ios, .tvos, .watchos => extern struct {169 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
170 sig: c_long = 0x2DA8B3B4,170 sig: c_long = 0x2DA8B3B4,
171 data: [192]u8 = [_]u8{0} ** 192,171 data: [192]u8 = [_]u8{0} ** 192,
172 },172 },
...@@ -214,7 +214,7 @@ pub const AT = switch (native_os) {...@@ -214,7 +214,7 @@ pub const AT = switch (native_os) {
214 /// Remove directory instead of unlinking file214 /// Remove directory instead of unlinking file
215 pub const REMOVEDIR = 0x200;215 pub const REMOVEDIR = 0x200;
216 },216 },
217 .macos, .ios, .tvos, .watchos => struct {217 .macos, .ios, .tvos, .watchos, .visionos => struct {
218 pub const FDCWD = -2;218 pub const FDCWD = -2;
219 /// Use effective ids in access check219 /// Use effective ids in access check
220 pub const EACCESS = 0x0010;220 pub const EACCESS = 0x0010;
...@@ -458,7 +458,7 @@ pub const O = switch (native_os) {...@@ -458,7 +458,7 @@ pub const O = switch (native_os) {
458 DIRECTORY: bool = false,458 DIRECTORY: bool = false,
459 _: u10 = 0,459 _: u10 = 0,
460 },460 },
461 .macos, .ios, .tvos, .watchos => packed struct(u32) {461 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
462 ACCMODE: std.posix.ACCMODE = .RDONLY,462 ACCMODE: std.posix.ACCMODE = .RDONLY,
463 NONBLOCK: bool = false,463 NONBLOCK: bool = false,
464 APPEND: bool = false,464 APPEND: bool = false,
...@@ -620,7 +620,7 @@ pub const MAP = switch (native_os) {...@@ -620,7 +620,7 @@ pub const MAP = switch (native_os) {
620 NORESERVE: bool = false,620 NORESERVE: bool = false,
621 _: u27 = 0,621 _: u27 = 0,
622 },622 },
623 .macos, .ios, .tvos, .watchos => packed struct(u32) {623 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
624 TYPE: enum(u4) {624 TYPE: enum(u4) {
625 SHARED = 0x01,625 SHARED = 0x01,
626 PRIVATE = 0x02,626 PRIVATE = 0x02,
...@@ -685,7 +685,7 @@ pub const cc_t = u8;...@@ -685,7 +685,7 @@ pub const cc_t = u8;
685/// Indices into the `cc` array in the `termios` struct.685/// Indices into the `cc` array in the `termios` struct.
686pub const V = switch (native_os) {686pub const V = switch (native_os) {
687 .linux => linux.V,687 .linux => linux.V,
688 .macos, .ios, .tvos, .watchos, .netbsd, .openbsd => enum {688 .macos, .ios, .tvos, .watchos, .visionos, .netbsd, .openbsd => enum {
689 EOF,689 EOF,
690 EOL,690 EOL,
691 EOL2,691 EOL2,
...@@ -784,7 +784,7 @@ pub const V = switch (native_os) {...@@ -784,7 +784,7 @@ pub const V = switch (native_os) {
784784
785pub const NCCS = switch (native_os) {785pub const NCCS = switch (native_os) {
786 .linux => linux.NCCS,786 .linux => linux.NCCS,
787 .macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,787 .macos, .ios, .tvos, .watchos, .visionos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
788 .haiku => 11,788 .haiku => 11,
789 .solaris, .illumos => 19,789 .solaris, .illumos => 19,
790 .emscripten, .wasi => 32,790 .emscripten, .wasi => 32,
...@@ -793,7 +793,7 @@ pub const NCCS = switch (native_os) {...@@ -793,7 +793,7 @@ pub const NCCS = switch (native_os) {
793793
794pub const termios = switch (native_os) {794pub const termios = switch (native_os) {
795 .linux => linux.termios,795 .linux => linux.termios,
796 .macos, .ios, .tvos, .watchos => extern struct {796 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
797 iflag: tc_iflag_t,797 iflag: tc_iflag_t,
798 oflag: tc_oflag_t,798 oflag: tc_oflag_t,
799 cflag: tc_cflag_t,799 cflag: tc_cflag_t,
...@@ -843,7 +843,7 @@ pub const termios = switch (native_os) {...@@ -843,7 +843,7 @@ pub const termios = switch (native_os) {
843843
844pub const tc_iflag_t = switch (native_os) {844pub const tc_iflag_t = switch (native_os) {
845 .linux => linux.tc_iflag_t,845 .linux => linux.tc_iflag_t,
846 .macos, .ios, .tvos, .watchos => packed struct(u64) {846 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
847 IGNBRK: bool = false,847 IGNBRK: bool = false,
848 BRKINT: bool = false,848 BRKINT: bool = false,
849 IGNPAR: bool = false,849 IGNPAR: bool = false,
...@@ -953,7 +953,7 @@ pub const tc_iflag_t = switch (native_os) {...@@ -953,7 +953,7 @@ pub const tc_iflag_t = switch (native_os) {
953953
954pub const tc_oflag_t = switch (native_os) {954pub const tc_oflag_t = switch (native_os) {
955 .linux => linux.tc_oflag_t,955 .linux => linux.tc_oflag_t,
956 .macos, .ios, .tvos, .watchos => packed struct(u64) {956 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
957 OPOST: bool = false,957 OPOST: bool = false,
958 ONLCR: bool = false,958 ONLCR: bool = false,
959 OXTABS: bool = false,959 OXTABS: bool = false,
...@@ -1050,7 +1050,7 @@ pub const CSIZE = switch (native_os) {...@@ -1050,7 +1050,7 @@ pub const CSIZE = switch (native_os) {
10501050
1051pub const tc_cflag_t = switch (native_os) {1051pub const tc_cflag_t = switch (native_os) {
1052 .linux => linux.tc_cflag_t,1052 .linux => linux.tc_cflag_t,
1053 .macos, .ios, .tvos, .watchos => packed struct(u64) {1053 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
1054 CIGNORE: bool = false,1054 CIGNORE: bool = false,
1055 _1: u5 = 0,1055 _1: u5 = 0,
1056 CSTOPB: bool = false,1056 CSTOPB: bool = false,
...@@ -1186,7 +1186,7 @@ pub const tc_cflag_t = switch (native_os) {...@@ -1186,7 +1186,7 @@ pub const tc_cflag_t = switch (native_os) {
11861186
1187pub const tc_lflag_t = switch (native_os) {1187pub const tc_lflag_t = switch (native_os) {
1188 .linux => linux.tc_lflag_t,1188 .linux => linux.tc_lflag_t,
1189 .macos, .ios, .tvos, .watchos => packed struct(u64) {1189 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
1190 ECHOKE: bool = false,1190 ECHOKE: bool = false,
1191 ECHOE: bool = false,1191 ECHOE: bool = false,
1192 ECHOK: bool = false,1192 ECHOK: bool = false,
...@@ -1312,7 +1312,7 @@ pub const tc_lflag_t = switch (native_os) {...@@ -1312,7 +1312,7 @@ pub const tc_lflag_t = switch (native_os) {
13121312
1313pub const speed_t = switch (native_os) {1313pub const speed_t = switch (native_os) {
1314 .linux => linux.speed_t,1314 .linux => linux.speed_t,
1315 .macos, .ios, .tvos, .watchos, .openbsd => enum(u64) {1315 .macos, .ios, .tvos, .watchos, .visionos, .openbsd => enum(u64) {
1316 B0 = 0,1316 B0 = 0,
1317 B50 = 50,1317 B50 = 50,
1318 B75 = 75,1318 B75 = 75,
...@@ -1535,7 +1535,7 @@ pub const fstatat = switch (native_os) {...@@ -1535,7 +1535,7 @@ pub const fstatat = switch (native_os) {
1535};1535};
15361536
1537pub const getdirentries = switch (native_os) {1537pub const getdirentries = switch (native_os) {
1538 .macos, .ios, .tvos, .watchos => private.__getdirentries64,1538 .macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64,
1539 else => private.getdirentries,1539 else => private.getdirentries,
1540};1540};
15411541
...@@ -1569,7 +1569,7 @@ pub const readdir = switch (native_os) {...@@ -1569,7 +1569,7 @@ pub const readdir = switch (native_os) {
1569};1569};
15701570
1571pub const realpath = switch (native_os) {1571pub const realpath = switch (native_os) {
1572 .macos, .ios, .tvos, .watchos => private.@"realpath$DARWIN_EXTSN",1572 .macos, .ios, .tvos, .watchos, .visionos => private.@"realpath$DARWIN_EXTSN",
1573 else => private.realpath,1573 else => private.realpath,
1574};1574};
15751575
lib/std/crypto/tlcsprng.zig+1
...@@ -29,6 +29,7 @@ const os_has_fork = switch (native_os) {...@@ -29,6 +29,7 @@ const os_has_fork = switch (native_os) {
29 .illumos,29 .illumos,
30 .tvos,30 .tvos,
31 .watchos,31 .watchos,
32 .visionos,
32 .haiku,33 .haiku,
33 => true,34 => true,
3435
lib/std/debug.zig+2-2
...@@ -706,7 +706,7 @@ pub const StackIterator = struct {...@@ -706,7 +706,7 @@ pub const StackIterator = struct {
706 const unwind_state = &self.unwind_state.?;706 const unwind_state = &self.unwind_state.?;
707 const module = try unwind_state.debug_info.getModuleForAddress(unwind_state.dwarf_context.pc);707 const module = try unwind_state.debug_info.getModuleForAddress(unwind_state.dwarf_context.pc);
708 switch (native_os) {708 switch (native_os) {
709 .macos, .ios, .watchos, .tvos => {709 .macos, .ios, .watchos, .tvos, .visionos => {
710 // __unwind_info is a requirement for unwinding on Darwin. It may fall back to DWARF, but unwinding710 // __unwind_info is a requirement for unwinding on Darwin. It may fall back to DWARF, but unwinding
711 // via DWARF before attempting to use the compact unwind info will produce incorrect results.711 // via DWARF before attempting to use the compact unwind info will produce incorrect results.
712 if (module.unwind_info) |unwind_info| {712 if (module.unwind_info) |unwind_info| {
...@@ -2132,7 +2132,7 @@ pub const DebugInfo = struct {...@@ -2132,7 +2132,7 @@ pub const DebugInfo = struct {
2132};2132};
21332133
2134pub const ModuleDebugInfo = switch (native_os) {2134pub const ModuleDebugInfo = switch (native_os) {
2135 .macos, .ios, .watchos, .tvos => struct {2135 .macos, .ios, .watchos, .tvos, .visionos => struct {
2136 base_address: usize,2136 base_address: usize,
2137 vmaddr_slide: usize,2137 vmaddr_slide: usize,
2138 mapped_memory: []align(mem.page_size) const u8,2138 mapped_memory: []align(mem.page_size) const u8,
lib/std/dynamic_library.zig+2-2
...@@ -16,7 +16,7 @@ pub const DynLib = struct {...@@ -16,7 +16,7 @@ pub const DynLib = struct {
16 else16 else
17 DlDynLib,17 DlDynLib,
18 .windows => WindowsDynLib,18 .windows => WindowsDynLib,
19 .macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,19 .macos, .tvos, .watchos, .ios, .visionos, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
20 else => @compileError("unsupported platform"),20 else => @compileError("unsupported platform"),
21 };21 };
2222
...@@ -461,7 +461,7 @@ test "dynamic_library" {...@@ -461,7 +461,7 @@ test "dynamic_library" {
461 const libname = switch (native_os) {461 const libname = switch (native_os) {
462 .linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",462 .linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",
463 .windows => "invalid_dll.dll",463 .windows => "invalid_dll.dll",
464 .macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",464 .macos, .tvos, .watchos, .ios, .visionos => "invalid_dylib.dylib",
465 else => return error.SkipZigTest,465 else => return error.SkipZigTest,
466 };466 };
467467
lib/std/mem.zig+1-1
...@@ -13,7 +13,7 @@ const native_endian = builtin.cpu.arch.endian();...@@ -13,7 +13,7 @@ const native_endian = builtin.cpu.arch.endian();
13pub const page_size = switch (builtin.cpu.arch) {13pub const page_size = switch (builtin.cpu.arch) {
14 .wasm32, .wasm64 => 64 * 1024,14 .wasm32, .wasm64 => 64 * 1024,
15 .aarch64 => switch (builtin.os.tag) {15 .aarch64 => switch (builtin.os.tag) {
16 .macos, .ios, .watchos, .tvos => 16 * 1024,16 .macos, .ios, .watchos, .tvos, .visionos => 16 * 1024,
17 else => 4 * 1024,17 else => 4 * 1024,
18 },18 },
19 .sparc64 => 8 * 1024,19 .sparc64 => 8 * 1024,
lib/std/os.zig+2-1
...@@ -76,6 +76,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {...@@ -76,6 +76,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
76 .ios,76 .ios,
77 .watchos,77 .watchos,
78 .tvos,78 .tvos,
79 .visionos,
79 .linux,80 .linux,
80 .solaris,81 .solaris,
81 .illumos,82 .illumos,
...@@ -110,7 +111,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -110,7 +111,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
110 const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice);111 const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice);
111 return out_buffer[0..end_index];112 return out_buffer[0..end_index];
112 },113 },
113 .macos, .ios, .watchos, .tvos => {114 .macos, .ios, .watchos, .tvos, .visionos => {
114 // On macOS, we can use F.GETPATH fcntl command to query the OS for115 // On macOS, we can use F.GETPATH fcntl command to query the OS for
115 // the path to the file descriptor.116 // the path to the file descriptor.
116 @memset(out_buffer[0..MAX_PATH_BYTES], 0);117 @memset(out_buffer[0..MAX_PATH_BYTES], 0);
lib/std/posix.zig+11-11
...@@ -604,7 +604,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {...@@ -604,7 +604,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
604 }604 }
605 }605 }
606 switch (native_os) {606 switch (native_os) {
607 .netbsd, .openbsd, .macos, .ios, .tvos, .watchos => {607 .netbsd, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => {
608 system.arc4random_buf(buffer.ptr, buffer.len);608 system.arc4random_buf(buffer.ptr, buffer.len);
609 return;609 return;
610 },610 },
...@@ -823,7 +823,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {...@@ -823,7 +823,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
823 // Prevents EINVAL.823 // Prevents EINVAL.
824 const max_count = switch (native_os) {824 const max_count = switch (native_os) {
825 .linux => 0x7ffff000,825 .linux => 0x7ffff000,
826 .macos, .ios, .watchos, .tvos => maxInt(i32),826 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
827 else => maxInt(isize),827 else => maxInt(isize),
828 };828 };
829 while (true) {829 while (true) {
...@@ -962,7 +962,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {...@@ -962,7 +962,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
962 // Prevent EINVAL.962 // Prevent EINVAL.
963 const max_count = switch (native_os) {963 const max_count = switch (native_os) {
964 .linux => 0x7ffff000,964 .linux => 0x7ffff000,
965 .macos, .ios, .watchos, .tvos => maxInt(i32),965 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
966 else => maxInt(isize),966 else => maxInt(isize),
967 };967 };
968968
...@@ -1069,7 +1069,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {...@@ -1069,7 +1069,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
1069/// On these systems, the read races with concurrent writes to the same file descriptor.1069/// On these systems, the read races with concurrent writes to the same file descriptor.
1070pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {1070pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
1071 const have_pread_but_not_preadv = switch (native_os) {1071 const have_pread_but_not_preadv = switch (native_os) {
1072 .windows, .macos, .ios, .watchos, .tvos, .haiku => true,1072 .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
1073 else => false,1073 else => false,
1074 };1074 };
1075 if (have_pread_but_not_preadv) {1075 if (have_pread_but_not_preadv) {
...@@ -1211,7 +1211,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {...@@ -1211,7 +1211,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
12111211
1212 const max_count = switch (native_os) {1212 const max_count = switch (native_os) {
1213 .linux => 0x7ffff000,1213 .linux => 0x7ffff000,
1214 .macos, .ios, .watchos, .tvos => maxInt(i32),1214 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
1215 else => maxInt(isize),1215 else => maxInt(isize),
1216 };1216 };
1217 while (true) {1217 while (true) {
...@@ -1370,7 +1370,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {...@@ -1370,7 +1370,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
1370 // Prevent EINVAL.1370 // Prevent EINVAL.
1371 const max_count = switch (native_os) {1371 const max_count = switch (native_os) {
1372 .linux => 0x7ffff000,1372 .linux => 0x7ffff000,
1373 .macos, .ios, .watchos, .tvos => maxInt(i32),1373 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
1374 else => maxInt(isize),1374 else => maxInt(isize),
1375 };1375 };
13761376
...@@ -1423,7 +1423,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {...@@ -1423,7 +1423,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
1423/// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.1423/// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.
1424pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize {1424pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize {
1425 const have_pwrite_but_not_pwritev = switch (native_os) {1425 const have_pwrite_but_not_pwritev = switch (native_os) {
1426 .windows, .macos, .ios, .watchos, .tvos, .haiku => true,1426 .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
1427 else => false,1427 else => false,
1428 };1428 };
14291429
...@@ -1846,7 +1846,7 @@ pub fn execveZ(...@@ -1846,7 +1846,7 @@ pub fn execveZ(
1846 .NOTDIR => return error.NotDir,1846 .NOTDIR => return error.NotDir,
1847 .TXTBSY => return error.FileBusy,1847 .TXTBSY => return error.FileBusy,
1848 else => |err| switch (native_os) {1848 else => |err| switch (native_os) {
1849 .macos, .ios, .tvos, .watchos => switch (err) {1849 .macos, .ios, .tvos, .watchos, .visionos => switch (err) {
1850 .BADEXEC => return error.InvalidExe,1850 .BADEXEC => return error.InvalidExe,
1851 .BADARCH => return error.InvalidExe,1851 .BADARCH => return error.InvalidExe,
1852 else => return unexpectedErrno(err),1852 else => return unexpectedErrno(err),
...@@ -6123,7 +6123,7 @@ pub fn sendfile(...@@ -6123,7 +6123,7 @@ pub fn sendfile(
6123 const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);6123 const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);
6124 const max_count = switch (native_os) {6124 const max_count = switch (native_os) {
6125 .linux => 0x7ffff000,6125 .linux => 0x7ffff000,
6126 .macos, .ios, .watchos, .tvos => maxInt(i32),6126 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
6127 else => maxInt(size_t),6127 else => maxInt(size_t),
6128 };6128 };
61296129
...@@ -6268,7 +6268,7 @@ pub fn sendfile(...@@ -6268,7 +6268,7 @@ pub fn sendfile(
6268 }6268 }
6269 }6269 }
6270 },6270 },
6271 .macos, .ios, .tvos, .watchos => sf: {6271 .macos, .ios, .tvos, .watchos, .visionos => sf: {
6272 var hdtr_data: std.c.sf_hdtr = undefined;6272 var hdtr_data: std.c.sf_hdtr = undefined;
6273 var hdtr: ?*std.c.sf_hdtr = null;6273 var hdtr: ?*std.c.sf_hdtr = null;
6274 if (headers.len != 0 or trailers.len != 0) {6274 if (headers.len != 0 or trailers.len != 0) {
...@@ -7244,7 +7244,7 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!...@@ -7244,7 +7244,7 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!
7244 else => |err| return unexpectedErrno(err),7244 else => |err| return unexpectedErrno(err),
7245 },7245 },
72467246
7247 .macos, .ios, .tvos, .watchos => switch (errno(std.c.ptrace(7247 .macos, .ios, .tvos, .watchos, .visionos => switch (errno(std.c.ptrace(
7248 @intCast(request),7248 @intCast(request),
7249 pid,7249 pid,
7250 @ptrFromInt(addr),7250 @ptrFromInt(addr),
lib/std/process.zig+2-1
...@@ -1456,6 +1456,7 @@ pub fn getUserInfo(name: []const u8) !UserInfo {...@@ -1456,6 +1456,7 @@ pub fn getUserInfo(name: []const u8) !UserInfo {
1456 .linux,1456 .linux,
1457 .macos,1457 .macos,
1458 .watchos,1458 .watchos,
1459 .visionos,
1459 .tvos,1460 .tvos,
1460 .ios,1461 .ios,
1461 .freebsd,1462 .freebsd,
...@@ -1599,7 +1600,7 @@ pub const can_execv = switch (native_os) {...@@ -1599,7 +1600,7 @@ pub const can_execv = switch (native_os) {
15991600
1600/// Tells whether spawning child processes is supported (e.g. via ChildProcess)1601/// Tells whether spawning child processes is supported (e.g. via ChildProcess)
1601pub const can_spawn = switch (native_os) {1602pub const can_spawn = switch (native_os) {
1602 .wasi, .watchos, .tvos => false,1603 .wasi, .watchos, .tvos, .visionos => false,
1603 else => true,1604 else => true,
1604};1605};
16051606
lib/std/start.zig+1
...@@ -576,6 +576,7 @@ fn maybeIgnoreSigpipe() void {...@@ -576,6 +576,7 @@ fn maybeIgnoreSigpipe() void {
576 .ios,576 .ios,
577 .watchos,577 .watchos,
578 .tvos,578 .tvos,
579 .visionos,
579 .dragonfly,580 .dragonfly,
580 .freebsd,581 .freebsd,
581 => true,582 => true,
lib/std/time.zig+1-1
...@@ -205,7 +205,7 @@ pub const Instant = struct {...@@ -205,7 +205,7 @@ pub const Instant = struct {
205 },205 },
206 // On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while206 // On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while
207 // suspended.207 // suspended.
208 .macos, .ios, .tvos, .watchos => posix.CLOCK.UPTIME_RAW,208 .macos, .ios, .tvos, .watchos, .visionos => posix.CLOCK.UPTIME_RAW,
209 // On freebsd derivatives, use MONOTONIC_FAST as currently there's209 // On freebsd derivatives, use MONOTONIC_FAST as currently there's
210 // no precision tradeoff.210 // no precision tradeoff.
211 .freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,211 .freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,
lib/std/zig/LibCDirs.zig+1-1
...@@ -222,7 +222,7 @@ pub fn detectFromBuilding(...@@ -222,7 +222,7 @@ pub fn detectFromBuilding(
222fn libCGenericName(target: std.Target) [:0]const u8 {222fn libCGenericName(target: std.Target) [:0]const u8 {
223 switch (target.os.tag) {223 switch (target.os.tag) {
224 .windows => return "mingw",224 .windows => return "mingw",
225 .macos, .ios, .tvos, .watchos => return "darwin",225 .macos, .ios, .tvos, .watchos, .visionos => return "darwin",
226 else => {},226 else => {},
227 }227 }
228 switch (target.abi) {228 switch (target.abi) {
lib/std/zig/system/darwin.zig+1
...@@ -45,6 +45,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 {...@@ -45,6 +45,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 {
45 },45 },
46 .watchos => if (is_simulator_abi) "watchsimulator" else "watchos",46 .watchos => if (is_simulator_abi) "watchsimulator" else "watchos",
47 .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos",47 .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos",
48 .visionos => if (is_simulator_abi) "xrsimulator" else "xros",
48 else => return null,49 else => return null,
49 };50 };
50 const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" };51 const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" };
src/Compilation.zig+1-1
...@@ -5280,7 +5280,7 @@ pub fn addCCArgs(...@@ -5280,7 +5280,7 @@ pub fn addCCArgs(
5280 // doesn't matter which one gets overridden.5280 // doesn't matter which one gets overridden.
5281 argv.appendAssumeCapacity("-Wno-overriding-option");5281 argv.appendAssumeCapacity("-Wno-overriding-option");
5282 },5282 },
5283 .ios, .tvos, .watchos => switch (target.cpu.arch) {5283 .ios => switch (target.cpu.arch) {
5284 // Pass the proper -m<os>-version-min argument for darwin.5284 // Pass the proper -m<os>-version-min argument for darwin.
5285 .x86, .x86_64 => {5285 .x86, .x86_64 => {
5286 const ver = target.os.version_range.semver.min;5286 const ver = target.os.version_range.semver.min;
src/codegen/llvm.zig+4-4
...@@ -145,7 +145,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -145,7 +145,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
145 .driverkit => "driverkit",145 .driverkit => "driverkit",
146 .shadermodel => "shadermodel",146 .shadermodel => "shadermodel",
147 .liteos => "liteos",147 .liteos => "liteos",
148 .xros => "xros",148 .visionos => "xros",
149 .serenity => "serenity",149 .serenity => "serenity",
150 .vulkan => "vulkan",150 .vulkan => "vulkan",
151151
...@@ -256,7 +256,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {...@@ -256,7 +256,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
256 .elfiamcu => .ELFIAMCU,256 .elfiamcu => .ELFIAMCU,
257 .tvos => .TvOS,257 .tvos => .TvOS,
258 .watchos => .WatchOS,258 .watchos => .WatchOS,
259 .xros => .XROS,259 .visionos => .XROS,
260 .mesa3d => .Mesa3D,260 .mesa3d => .Mesa3D,
261 .amdpal => .AMDPAL,261 .amdpal => .AMDPAL,
262 .hermit => .HermitCore,262 .hermit => .HermitCore,
...@@ -618,7 +618,7 @@ const DataLayoutBuilder = struct {...@@ -618,7 +618,7 @@ const DataLayoutBuilder = struct {
618 abi = size;618 abi = size;
619 pref = size;619 pref = size;
620 } else switch (self.target.os.tag) {620 } else switch (self.target.os.tag) {
621 .macos, .ios => {},621 .macos, .ios, .watchos, .tvos, .visionos => {},
622 .uefi, .windows => {622 .uefi, .windows => {
623 pref = size;623 pref = size;
624 force_abi = size >= 32;624 force_abi = size >= 32;
...@@ -11578,7 +11578,7 @@ fn ccAbiPromoteInt(...@@ -11578,7 +11578,7 @@ fn ccAbiPromoteInt(
11578 else => return null,11578 else => return null,
11579 };11579 };
11580 return switch (target.os.tag) {11580 return switch (target.os.tag) {
11581 .macos => switch (int_info.bits) {11581 .macos, .ios, .watchos, .tvos, .visionos => switch (int_info.bits) {
11582 0...16 => int_info.signedness,11582 0...16 => int_info.signedness,
11583 else => null,11583 else => null,
11584 },11584 },
src/libtsan.zig+1-1
...@@ -125,7 +125,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v...@@ -125,7 +125,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v
125 }125 }
126126
127 const platform_tsan_sources = switch (target.os.tag) {127 const platform_tsan_sources = switch (target.os.tag) {
128 .ios, .macos, .watchos, .tvos => &darwin_tsan_sources,128 .ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
129 .windows => &windows_tsan_sources,129 .windows => &windows_tsan_sources,
130 else => &unix_tsan_sources,130 else => &unix_tsan_sources,
131 };131 };
src/link/MachO.zig+26-10
...@@ -891,6 +891,10 @@ pub fn resolveLibSystem(...@@ -891,6 +891,10 @@ pub fn resolveLibSystem(
891 },891 },
892 };892 };
893893
894 for (self.lib_dirs) |dir| {
895 if (try accessLibPath(arena, &test_path, &checked_paths, dir, "System")) break :success;
896 }
897
894 try self.reportMissingLibraryError(checked_paths.items, "unable to find libSystem system library", .{});898 try self.reportMissingLibraryError(checked_paths.items, "unable to find libSystem system library", .{});
895 return error.MissingLibSystem;899 return error.MissingLibSystem;
896 }900 }
...@@ -3676,10 +3680,17 @@ pub inline fn getPageSize(self: MachO) u16 {...@@ -3676,10 +3680,17 @@ pub inline fn getPageSize(self: MachO) u16 {
36763680
3677pub fn requiresCodeSig(self: MachO) bool {3681pub fn requiresCodeSig(self: MachO) bool {
3678 if (self.entitlements) |_| return true;3682 if (self.entitlements) |_| return true;
3683 // TODO: enable once we support this linker option
3679 // if (self.options.adhoc_codesign) |cs| return cs;3684 // if (self.options.adhoc_codesign) |cs| return cs;
3680 return switch (self.getTarget().cpu.arch) {3685 const target = self.getTarget();
3681 .aarch64 => true,3686 return switch (target.cpu.arch) {
3682 else => false,3687 .aarch64 => switch (target.os.tag) {
3688 .macos => true,
3689 .watchos, .tvos, .ios, .visionos => target.abi == .simulator,
3690 else => false,
3691 },
3692 .x86_64 => false,
3693 else => unreachable,
3683 };3694 };
3684}3695}
36853696
...@@ -4424,6 +4435,7 @@ pub const Platform = struct {...@@ -4424,6 +4435,7 @@ pub const Platform = struct {
4424 .TVOS, .TVOSSIMULATOR => .tvos,4435 .TVOS, .TVOSSIMULATOR => .tvos,
4425 .WATCHOS, .WATCHOSSIMULATOR => .watchos,4436 .WATCHOS, .WATCHOSSIMULATOR => .watchos,
4426 .MACCATALYST => .ios,4437 .MACCATALYST => .ios,
4438 .VISIONOS, .VISIONOSSIMULATOR => .visionos,
4427 else => @panic("TODO"),4439 else => @panic("TODO"),
4428 },4440 },
4429 .abi = switch (cmd.platform) {4441 .abi = switch (cmd.platform) {
...@@ -4431,6 +4443,7 @@ pub const Platform = struct {...@@ -4431,6 +4443,7 @@ pub const Platform = struct {
4431 .IOSSIMULATOR,4443 .IOSSIMULATOR,
4432 .TVOSSIMULATOR,4444 .TVOSSIMULATOR,
4433 .WATCHOSSIMULATOR,4445 .WATCHOSSIMULATOR,
4446 .VISIONOSSIMULATOR,
4434 => .simulator,4447 => .simulator,
4435 else => .none,4448 else => .none,
4436 },4449 },
...@@ -4481,6 +4494,7 @@ pub const Platform = struct {...@@ -4481,6 +4494,7 @@ pub const Platform = struct {
4481 },4494 },
4482 .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS,4495 .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS,
4483 .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,4496 .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,
4497 .visionos => if (plat.abi == .simulator) .VISIONOSSIMULATOR else .VISIONOS,
4484 else => unreachable,4498 else => unreachable,
4485 };4499 };
4486 }4500 }
...@@ -4549,13 +4563,15 @@ const SupportedPlatforms = struct {...@@ -4549,13 +4563,15 @@ const SupportedPlatforms = struct {
4549// Source: https://github.com/apple-oss-distributions/ld64/blob/59a99ab60399c5e6c49e6945a9e1049c42b71135/src/ld/PlatformSupport.cpp#L524563// Source: https://github.com/apple-oss-distributions/ld64/blob/59a99ab60399c5e6c49e6945a9e1049c42b71135/src/ld/PlatformSupport.cpp#L52
4550// zig fmt: off4564// zig fmt: off
4551const supported_platforms = [_]SupportedPlatforms{4565const supported_platforms = [_]SupportedPlatforms{
4552 .{ .macos, .none, 0xA0E00, 0xA0800 },4566 .{ .macos, .none, 0xA0E00, 0xA0800 },
4553 .{ .ios, .none, 0xC0000, 0x70000 },4567 .{ .ios, .none, 0xC0000, 0x70000 },
4554 .{ .tvos, .none, 0xC0000, 0x70000 },4568 .{ .tvos, .none, 0xC0000, 0x70000 },
4555 .{ .watchos, .none, 0x50000, 0x20000 },4569 .{ .watchos, .none, 0x50000, 0x20000 },
4556 .{ .ios, .simulator, 0xD0000, 0x80000 },4570 .{ .visionos, .none, 0x10000, 0x10000 },
4557 .{ .tvos, .simulator, 0xD0000, 0x80000 },4571 .{ .ios, .simulator, 0xD0000, 0x80000 },
4558 .{ .watchos, .simulator, 0x60000, 0x20000 },4572 .{ .tvos, .simulator, 0xD0000, 0x80000 },
4573 .{ .watchos, .simulator, 0x60000, 0x20000 },
4574 .{ .visionos, .simulator, 0x10000, 0x10000 },
4559};4575};
4560// zig fmt: on4576// zig fmt: on
45614577
src/link/MachO/Dylib.zig+3-1
...@@ -671,7 +671,7 @@ pub const TargetMatcher = struct {...@@ -671,7 +671,7 @@ pub const TargetMatcher = struct {
671 try self.target_strings.append(allocator, apple_string);671 try self.target_strings.append(allocator, apple_string);
672672
673 switch (platform) {673 switch (platform) {
674 .IOSSIMULATOR, .TVOSSIMULATOR, .WATCHOSSIMULATOR => {674 .IOSSIMULATOR, .TVOSSIMULATOR, .WATCHOSSIMULATOR, .VISIONOSSIMULATOR => {
675 // For Apple simulator targets, linking gets tricky as we need to link against the simulator675 // For Apple simulator targets, linking gets tricky as we need to link against the simulator
676 // hosts dylibs too.676 // hosts dylibs too.
677 const host_target = try targetToAppleString(allocator, cpu_arch, .MACOS);677 const host_target = try targetToAppleString(allocator, cpu_arch, .MACOS);
...@@ -714,9 +714,11 @@ pub const TargetMatcher = struct {...@@ -714,9 +714,11 @@ pub const TargetMatcher = struct {
714 .IOS => "ios",714 .IOS => "ios",
715 .TVOS => "tvos",715 .TVOS => "tvos",
716 .WATCHOS => "watchos",716 .WATCHOS => "watchos",
717 .VISIONOS => "xros",
717 .IOSSIMULATOR => "ios-simulator",718 .IOSSIMULATOR => "ios-simulator",
718 .TVOSSIMULATOR => "tvos-simulator",719 .TVOSSIMULATOR => "tvos-simulator",
719 .WATCHOSSIMULATOR => "watchos-simulator",720 .WATCHOSSIMULATOR => "watchos-simulator",
721 .VISIONOSSIMULATOR => "xros-simulator",
720 .BRIDGEOS => "bridgeos",722 .BRIDGEOS => "bridgeos",
721 .MACCATALYST => "maccatalyst",723 .MACCATALYST => "maccatalyst",
722 .DRIVERKIT => "driverkit",724 .DRIVERKIT => "driverkit",
src/main.zig+1-1
...@@ -4432,7 +4432,7 @@ fn runOrTestHotSwap(...@@ -4432,7 +4432,7 @@ fn runOrTestHotSwap(
4432 }4432 }
44334433
4434 switch (builtin.target.os.tag) {4434 switch (builtin.target.os.tag) {
4435 .macos, .ios, .tvos, .watchos => {4435 .macos, .ios, .tvos, .watchos, .visionos => {
4436 const PosixSpawn = @import("DarwinPosixSpawn.zig");4436 const PosixSpawn = @import("DarwinPosixSpawn.zig");
44374437
4438 var attr = try PosixSpawn.Attr.init();4438 var attr = try PosixSpawn.Attr.init();
src/target.zig+1
...@@ -26,6 +26,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {...@@ -26,6 +26,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
26 .ios,26 .ios,
27 .watchos,27 .watchos,
28 .tvos,28 .tvos,
29 .visionos,
29 .freestanding,30 .freestanding,
30 .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.31 .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.
31 => false,32 => false,
test/llvm_targets.zig+9
...@@ -7,6 +7,12 @@ const targets = [_]std.Target.Query{...@@ -7,6 +7,12 @@ const targets = [_]std.Target.Query{
7 .{ .cpu_arch = .aarch64, .os_tag = .ios, .abi = .simulator },7 .{ .cpu_arch = .aarch64, .os_tag = .ios, .abi = .simulator },
8 .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .none },8 .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .none },
9 .{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = .none },9 .{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = .none },
10 .{ .cpu_arch = .aarch64, .os_tag = .watchos, .abi = .none },
11 .{ .cpu_arch = .aarch64, .os_tag = .watchos, .abi = .simulator },
12 .{ .cpu_arch = .aarch64, .os_tag = .tvos, .abi = .none },
13 .{ .cpu_arch = .aarch64, .os_tag = .tvos, .abi = .simulator },
14 .{ .cpu_arch = .aarch64, .os_tag = .visionos, .abi = .none },
15 .{ .cpu_arch = .aarch64, .os_tag = .visionos, .abi = .simulator },
10 .{ .cpu_arch = .aarch64, .os_tag = .uefi, .abi = .none },16 .{ .cpu_arch = .aarch64, .os_tag = .uefi, .abi = .none },
11 .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu },17 .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu },
12 .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .msvc },18 .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .msvc },
...@@ -118,6 +124,9 @@ const targets = [_]std.Target.Query{...@@ -118,6 +124,9 @@ const targets = [_]std.Target.Query{
118 .cpu_features_sub = std.Target.x86.featureSet(&.{ .mmx, .sse, .sse2, .avx, .avx2 }),124 .cpu_features_sub = std.Target.x86.featureSet(&.{ .mmx, .sse, .sse2, .avx, .avx2 }),
119 },125 },
120 .{ .cpu_arch = .x86_64, .os_tag = .ios, .abi = .simulator },126 .{ .cpu_arch = .x86_64, .os_tag = .ios, .abi = .simulator },
127 .{ .cpu_arch = .x86_64, .os_tag = .watchos, .abi = .simulator },
128 .{ .cpu_arch = .x86_64, .os_tag = .tvos, .abi = .simulator },
129 .{ .cpu_arch = .x86_64, .os_tag = .visionos, .abi = .simulator },
121 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none },130 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none },
122 .{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .none },131 .{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .none },
123 .{ .cpu_arch = .x86_64, .os_tag = .uefi, .abi = .none },132 .{ .cpu_arch = .x86_64, .os_tag = .uefi, .abi = .none },