Commit 2e1fc0dd14

Jakub Konka <kubkon@jakubkonka.com>
2024-05-09 15:04:13
handle visionos target OS tag in the compiler
* rename .xros to .visionos as agreed in the tracking issue * add support for VisionOS platform in the MachO linker
1 parent 8f202ba
lib/compiler/aro/aro/Compilation.zig
@@ -912,12 +912,12 @@ fn generateVaListType(comp: *Compilation) !Type {
     const kind: Kind = switch (comp.target.cpu.arch) {
         .aarch64 => switch (comp.target.os.tag) {
             .windows => @as(Kind, .char_ptr),
-            .ios, .macos, .tvos, .watchos => .char_ptr,
+            .ios, .macos, .tvos, .watchos, .visionos => .char_ptr,
             else => .aarch64_va_list,
         },
         .sparc, .wasm32, .wasm64, .bpfel, .bpfeb, .riscv32, .riscv64, .avr, .spirv32, .spirv64 => .void_ptr,
         .powerpc => switch (comp.target.os.tag) {
-            .ios, .macos, .tvos, .watchos, .aix => @as(Kind, .char_ptr),
+            .ios, .macos, .tvos, .watchos, .visionos, .aix => @as(Kind, .char_ptr),
             else => return Type{ .specifier = .void }, // unknown
         },
         .x86, .msp430 => .char_ptr,
lib/compiler/aro/aro/target.zig
@@ -706,6 +706,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
         .ios => "ios",
         .tvos => "tvos",
         .watchos => "watchos",
+        .visionos => "xros",
         .driverkit => "driverkit",
         .shadermodel => "shadermodel",
         .liteos => "liteos",
lib/compiler_rt/clear_cache.zig
@@ -45,7 +45,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
         else => false,
     };
     const apple = switch (os) {
-        .ios, .macos, .watchos, .tvos => true,
+        .ios, .macos, .watchos, .tvos, .visionos => true,
         else => false,
     };
     if (x86) {
lib/std/crypto/tlcsprng.zig
@@ -29,6 +29,7 @@ const os_has_fork = switch (native_os) {
     .illumos,
     .tvos,
     .watchos,
+    .visionos,
     .haiku,
     => true,
 
lib/std/zig/system/darwin.zig
@@ -45,6 +45,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 {
         },
         .watchos => if (is_simulator_abi) "watchsimulator" else "watchos",
         .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos",
+        .visionos => if (is_simulator_abi) "xrsimulator" else "xros",
         else => return null,
     };
     const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" };
lib/std/zig/LibCDirs.zig
@@ -222,7 +222,7 @@ pub fn detectFromBuilding(
 fn libCGenericName(target: std.Target) [:0]const u8 {
     switch (target.os.tag) {
         .windows => return "mingw",
-        .macos, .ios, .tvos, .watchos => return "darwin",
+        .macos, .ios, .tvos, .watchos, .visionos => return "darwin",
         else => {},
     }
     switch (target.abi) {
lib/std/builtin.zig
@@ -597,11 +597,11 @@ pub const VaListX86_64 = extern struct {
 pub const VaList = switch (builtin.cpu.arch) {
     .aarch64, .aarch64_be => switch (builtin.os.tag) {
         .windows => *u8,
-        .ios, .macos, .tvos, .watchos => *u8,
+        .ios, .macos, .tvos, .watchos, .visionos => *u8,
         else => @compileError("disabled due to miscompilations"), // VaListAarch64,
     },
     .arm => switch (builtin.os.tag) {
-        .ios, .macos, .tvos, .watchos => *u8,
+        .ios, .macos, .tvos, .watchos, .visionos => *u8,
         else => *anyopaque,
     },
     .amdgcn => *u8,
@@ -611,7 +611,7 @@ pub const VaList = switch (builtin.cpu.arch) {
     .mips, .mipsel, .mips64, .mips64el => *anyopaque,
     .riscv32, .riscv64 => *anyopaque,
     .powerpc, .powerpcle => switch (builtin.os.tag) {
-        .ios, .macos, .tvos, .watchos, .aix => *u8,
+        .ios, .macos, .tvos, .watchos, .visionos, .aix => *u8,
         else => VaListPowerPc,
     },
     .powerpc64, .powerpc64le => *u8,
lib/std/c.zig
@@ -35,7 +35,7 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool {
 pub usingnamespace switch (native_os) {
     .linux => @import("c/linux.zig"),
     .windows => @import("c/windows.zig"),
-    .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
+    .macos, .ios, .tvos, .watchos, .visionos => @import("c/darwin.zig"),
     .freebsd, .kfreebsd => @import("c/freebsd.zig"),
     .netbsd => @import("c/netbsd.zig"),
     .dragonfly => @import("c/dragonfly.zig"),
@@ -63,7 +63,7 @@ pub const pthread_mutex_t = switch (native_os) {
             else => @compileError("unsupported ABI"),
         };
     },
-    .macos, .ios, .tvos, .watchos => extern struct {
+    .macos, .ios, .tvos, .watchos, .visionos => extern struct {
         sig: c_long = 0x32AAABA7,
         data: [data_len]u8 = [_]u8{0} ** data_len,
 
@@ -113,7 +113,7 @@ pub const pthread_cond_t = switch (native_os) {
     .linux => extern struct {
         data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
     },
-    .macos, .ios, .tvos, .watchos => extern struct {
+    .macos, .ios, .tvos, .watchos, .visionos => extern struct {
         sig: c_long = 0x3CB0B1BB,
         data: [data_len]u8 = [_]u8{0} ** data_len,
         const data_len = if (@sizeOf(usize) == 8) 40 else 24;
@@ -166,7 +166,7 @@ pub const pthread_rwlock_t = switch (native_os) {
             data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
         },
     },
-    .macos, .ios, .tvos, .watchos => extern struct {
+    .macos, .ios, .tvos, .watchos, .visionos => extern struct {
         sig: c_long = 0x2DA8B3B4,
         data: [192]u8 = [_]u8{0} ** 192,
     },
@@ -214,7 +214,7 @@ pub const AT = switch (native_os) {
         /// Remove directory instead of unlinking file
         pub const REMOVEDIR = 0x200;
     },
-    .macos, .ios, .tvos, .watchos => struct {
+    .macos, .ios, .tvos, .watchos, .visionos => struct {
         pub const FDCWD = -2;
         /// Use effective ids in access check
         pub const EACCESS = 0x0010;
@@ -458,7 +458,7 @@ pub const O = switch (native_os) {
         DIRECTORY: bool = false,
         _: u10 = 0,
     },
-    .macos, .ios, .tvos, .watchos => packed struct(u32) {
+    .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
         ACCMODE: std.posix.ACCMODE = .RDONLY,
         NONBLOCK: bool = false,
         APPEND: bool = false,
@@ -620,7 +620,7 @@ pub const MAP = switch (native_os) {
         NORESERVE: bool = false,
         _: u27 = 0,
     },
-    .macos, .ios, .tvos, .watchos => packed struct(u32) {
+    .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
         TYPE: enum(u4) {
             SHARED = 0x01,
             PRIVATE = 0x02,
@@ -685,7 +685,7 @@ pub const cc_t = u8;
 /// Indices into the `cc` array in the `termios` struct.
 pub const V = switch (native_os) {
     .linux => linux.V,
-    .macos, .ios, .tvos, .watchos, .netbsd, .openbsd => enum {
+    .macos, .ios, .tvos, .watchos, .visionos, .netbsd, .openbsd => enum {
         EOF,
         EOL,
         EOL2,
@@ -784,7 +784,7 @@ pub const V = switch (native_os) {
 
 pub const NCCS = switch (native_os) {
     .linux => linux.NCCS,
-    .macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
+    .macos, .ios, .tvos, .watchos, .visionos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
     .haiku => 11,
     .solaris, .illumos => 19,
     .emscripten, .wasi => 32,
@@ -793,7 +793,7 @@ pub const NCCS = switch (native_os) {
 
 pub const termios = switch (native_os) {
     .linux => linux.termios,
-    .macos, .ios, .tvos, .watchos => extern struct {
+    .macos, .ios, .tvos, .watchos, .visionos => extern struct {
         iflag: tc_iflag_t,
         oflag: tc_oflag_t,
         cflag: tc_cflag_t,
@@ -843,7 +843,7 @@ pub const termios = switch (native_os) {
 
 pub const tc_iflag_t = switch (native_os) {
     .linux => linux.tc_iflag_t,
-    .macos, .ios, .tvos, .watchos => packed struct(u64) {
+    .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
         IGNBRK: bool = false,
         BRKINT: bool = false,
         IGNPAR: bool = false,
@@ -953,7 +953,7 @@ pub const tc_iflag_t = switch (native_os) {
 
 pub const tc_oflag_t = switch (native_os) {
     .linux => linux.tc_oflag_t,
-    .macos, .ios, .tvos, .watchos => packed struct(u64) {
+    .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
         OPOST: bool = false,
         ONLCR: bool = false,
         OXTABS: bool = false,
@@ -1050,7 +1050,7 @@ pub const CSIZE = switch (native_os) {
 
 pub const tc_cflag_t = switch (native_os) {
     .linux => linux.tc_cflag_t,
-    .macos, .ios, .tvos, .watchos => packed struct(u64) {
+    .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
         CIGNORE: bool = false,
         _1: u5 = 0,
         CSTOPB: bool = false,
@@ -1186,7 +1186,7 @@ pub const tc_cflag_t = switch (native_os) {
 
 pub const tc_lflag_t = switch (native_os) {
     .linux => linux.tc_lflag_t,
-    .macos, .ios, .tvos, .watchos => packed struct(u64) {
+    .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
         ECHOKE: bool = false,
         ECHOE: bool = false,
         ECHOK: bool = false,
@@ -1312,7 +1312,7 @@ pub const tc_lflag_t = switch (native_os) {
 
 pub const speed_t = switch (native_os) {
     .linux => linux.speed_t,
-    .macos, .ios, .tvos, .watchos, .openbsd => enum(u64) {
+    .macos, .ios, .tvos, .watchos, .visionos, .openbsd => enum(u64) {
         B0 = 0,
         B50 = 50,
         B75 = 75,
@@ -1535,7 +1535,7 @@ pub const fstatat = switch (native_os) {
 };
 
 pub const getdirentries = switch (native_os) {
-    .macos, .ios, .tvos, .watchos => private.__getdirentries64,
+    .macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64,
     else => private.getdirentries,
 };
 
@@ -1569,7 +1569,7 @@ pub const readdir = switch (native_os) {
 };
 
 pub const realpath = switch (native_os) {
-    .macos, .ios, .tvos, .watchos => private.@"realpath$DARWIN_EXTSN",
+    .macos, .ios, .tvos, .watchos, .visionos => private.@"realpath$DARWIN_EXTSN",
     else => private.realpath,
 };
 
lib/std/debug.zig
@@ -706,7 +706,7 @@ pub const StackIterator = struct {
         const unwind_state = &self.unwind_state.?;
         const module = try unwind_state.debug_info.getModuleForAddress(unwind_state.dwarf_context.pc);
         switch (native_os) {
-            .macos, .ios, .watchos, .tvos => {
+            .macos, .ios, .watchos, .tvos, .visionos => {
                 // __unwind_info is a requirement for unwinding on Darwin. It may fall back to DWARF, but unwinding
                 // via DWARF before attempting to use the compact unwind info will produce incorrect results.
                 if (module.unwind_info) |unwind_info| {
@@ -2132,7 +2132,7 @@ pub const DebugInfo = struct {
 };
 
 pub const ModuleDebugInfo = switch (native_os) {
-    .macos, .ios, .watchos, .tvos => struct {
+    .macos, .ios, .watchos, .tvos, .visionos => struct {
         base_address: usize,
         vmaddr_slide: usize,
         mapped_memory: []align(mem.page_size) const u8,
lib/std/dynamic_library.zig
@@ -16,7 +16,7 @@ pub const DynLib = struct {
         else
             DlDynLib,
         .windows => WindowsDynLib,
-        .macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
+        .macos, .tvos, .watchos, .ios, .visionos, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
         else => @compileError("unsupported platform"),
     };
 
@@ -461,7 +461,7 @@ test "dynamic_library" {
     const libname = switch (native_os) {
         .linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",
         .windows => "invalid_dll.dll",
-        .macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",
+        .macos, .tvos, .watchos, .ios, .visionos => "invalid_dylib.dylib",
         else => return error.SkipZigTest,
     };
 
lib/std/mem.zig
@@ -13,7 +13,7 @@ const native_endian = builtin.cpu.arch.endian();
 pub const page_size = switch (builtin.cpu.arch) {
     .wasm32, .wasm64 => 64 * 1024,
     .aarch64 => switch (builtin.os.tag) {
-        .macos, .ios, .watchos, .tvos => 16 * 1024,
+        .macos, .ios, .watchos, .tvos, .visionos => 16 * 1024,
         else => 4 * 1024,
     },
     .sparc64 => 8 * 1024,
lib/std/os.zig
@@ -76,6 +76,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
         .ios,
         .watchos,
         .tvos,
+        .visionos,
         .linux,
         .solaris,
         .illumos,
@@ -110,7 +111,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
             const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice);
             return out_buffer[0..end_index];
         },
-        .macos, .ios, .watchos, .tvos => {
+        .macos, .ios, .watchos, .tvos, .visionos => {
             // On macOS, we can use F.GETPATH fcntl command to query the OS for
             // the path to the file descriptor.
             @memset(out_buffer[0..MAX_PATH_BYTES], 0);
lib/std/posix.zig
@@ -604,7 +604,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
         }
     }
     switch (native_os) {
-        .netbsd, .openbsd, .macos, .ios, .tvos, .watchos => {
+        .netbsd, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => {
             system.arc4random_buf(buffer.ptr, buffer.len);
             return;
         },
@@ -823,7 +823,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
     // Prevents EINVAL.
     const max_count = switch (native_os) {
         .linux => 0x7ffff000,
-        .macos, .ios, .watchos, .tvos => maxInt(i32),
+        .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
         else => maxInt(isize),
     };
     while (true) {
@@ -962,7 +962,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
     // Prevent EINVAL.
     const max_count = switch (native_os) {
         .linux => 0x7ffff000,
-        .macos, .ios, .watchos, .tvos => maxInt(i32),
+        .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
         else => maxInt(isize),
     };
 
@@ -1069,7 +1069,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
 /// On these systems, the read races with concurrent writes to the same file descriptor.
 pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
     const have_pread_but_not_preadv = switch (native_os) {
-        .windows, .macos, .ios, .watchos, .tvos, .haiku => true,
+        .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
         else => false,
     };
     if (have_pread_but_not_preadv) {
@@ -1211,7 +1211,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
 
     const max_count = switch (native_os) {
         .linux => 0x7ffff000,
-        .macos, .ios, .watchos, .tvos => maxInt(i32),
+        .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
         else => maxInt(isize),
     };
     while (true) {
@@ -1370,7 +1370,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
     // Prevent EINVAL.
     const max_count = switch (native_os) {
         .linux => 0x7ffff000,
-        .macos, .ios, .watchos, .tvos => maxInt(i32),
+        .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
         else => maxInt(isize),
     };
 
@@ -1423,7 +1423,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
 /// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.
 pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize {
     const have_pwrite_but_not_pwritev = switch (native_os) {
-        .windows, .macos, .ios, .watchos, .tvos, .haiku => true,
+        .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
         else => false,
     };
 
@@ -1846,7 +1846,7 @@ pub fn execveZ(
         .NOTDIR => return error.NotDir,
         .TXTBSY => return error.FileBusy,
         else => |err| switch (native_os) {
-            .macos, .ios, .tvos, .watchos => switch (err) {
+            .macos, .ios, .tvos, .watchos, .visionos => switch (err) {
                 .BADEXEC => return error.InvalidExe,
                 .BADARCH => return error.InvalidExe,
                 else => return unexpectedErrno(err),
@@ -6123,7 +6123,7 @@ pub fn sendfile(
     const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);
     const max_count = switch (native_os) {
         .linux => 0x7ffff000,
-        .macos, .ios, .watchos, .tvos => maxInt(i32),
+        .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
         else => maxInt(size_t),
     };
 
@@ -6268,7 +6268,7 @@ pub fn sendfile(
                 }
             }
         },
-        .macos, .ios, .tvos, .watchos => sf: {
+        .macos, .ios, .tvos, .watchos, .visionos => sf: {
             var hdtr_data: std.c.sf_hdtr = undefined;
             var hdtr: ?*std.c.sf_hdtr = null;
             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!
             else => |err| return unexpectedErrno(err),
         },
 
-        .macos, .ios, .tvos, .watchos => switch (errno(std.c.ptrace(
+        .macos, .ios, .tvos, .watchos, .visionos => switch (errno(std.c.ptrace(
             @intCast(request),
             pid,
             @ptrFromInt(addr),
lib/std/process.zig
@@ -1456,6 +1456,7 @@ pub fn getUserInfo(name: []const u8) !UserInfo {
         .linux,
         .macos,
         .watchos,
+        .visionos,
         .tvos,
         .ios,
         .freebsd,
@@ -1599,7 +1600,7 @@ pub const can_execv = switch (native_os) {
 
 /// Tells whether spawning child processes is supported (e.g. via ChildProcess)
 pub const can_spawn = switch (native_os) {
-    .wasi, .watchos, .tvos => false,
+    .wasi, .watchos, .tvos, .visionos => false,
     else => true,
 };
 
lib/std/start.zig
@@ -576,6 +576,7 @@ fn maybeIgnoreSigpipe() void {
         .ios,
         .watchos,
         .tvos,
+        .visionos,
         .dragonfly,
         .freebsd,
         => true,
lib/std/Target.zig
@@ -47,7 +47,7 @@ pub const Os = struct {
         tvos,
         watchos,
         driverkit,
-        xros,
+        visionos,
         mesa3d,
         contiki,
         amdpal,
@@ -67,7 +67,7 @@ pub const Os = struct {
 
         pub inline fn isDarwin(tag: Tag) bool {
             return switch (tag) {
-                .ios, .macos, .watchos, .tvos => true,
+                .ios, .macos, .watchos, .tvos, .visionos => true,
                 else => false,
             };
         }
@@ -108,7 +108,7 @@ pub const Os = struct {
         pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {
             return switch (tag) {
                 .windows, .uefi => ".dll",
-                .ios, .macos, .watchos, .tvos => ".dylib",
+                .ios, .macos, .watchos, .tvos, .visionos => ".dylib",
                 else => ".so",
             };
         }
@@ -178,7 +178,7 @@ pub const Os = struct {
                 .ios,
                 .tvos,
                 .watchos,
-                .xros,
+                .visionos,
                 .netbsd,
                 .openbsd,
                 .dragonfly,
@@ -434,7 +434,12 @@ pub const Os = struct {
                         .max = .{ .major = 17, .minor = 1, .patch = 0 },
                     },
                 },
-                .xros => @panic("TODO what version is xros on right now?"),
+                .visionos => .{
+                    .semver = .{
+                        .min = .{ .major = 1, .minor = 0, .patch = 0 },
+                        .max = .{ .major = 1, .minor = 0, .patch = 0 },
+                    },
+                },
                 .netbsd => .{
                     .semver = .{
                         .min = .{ .major = 8, .minor = 0, .patch = 0 },
@@ -531,7 +536,7 @@ pub const Os = struct {
             .ios,
             .tvos,
             .watchos,
-            .xros,
+            .visionos,
             .dragonfly,
             .openbsd,
             .haiku,
@@ -691,7 +696,7 @@ pub const Abi = enum {
             .ios,
             .tvos,
             .watchos,
-            .xros,
+            .visionos,
             .driverkit,
             .shadermodel,
             .liteos, // TODO: audit this
@@ -768,7 +773,7 @@ pub const ObjectFormat = enum {
     pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {
         return switch (os_tag) {
             .windows, .uefi => .coff,
-            .ios, .macos, .watchos, .tvos => .macho,
+            .ios, .macos, .watchos, .tvos, .visionos => .macho,
             .plan9 => .plan9,
             else => switch (arch) {
                 .wasm32, .wasm64 => .wasm,
@@ -1633,6 +1638,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {
         .tvos,
         .watchos,
         .macos,
+        .visionos,
         .uefi,
         .windows,
         .emscripten,
@@ -1807,7 +1813,7 @@ pub const DynamicLinker = struct {
             .tvos,
             .watchos,
             .macos,
-            .xros,
+            .visionos,
             => init("/usr/lib/dyld"),
 
             // 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 {
             },
         },
 
-        .macos, .ios, .tvos, .watchos, .xros => switch (c_type) {
+        .macos, .ios, .tvos, .watchos, .visionos => switch (c_type) {
             .char => return 8,
             .short, .ushort => return 16,
             .int, .uint, .float => return 32,
@@ -2407,7 +2413,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
 
                     else => 4,
                 },
-                .ios, .tvos, .watchos => 4,
+                .ios, .tvos, .watchos, .visionos => 4,
                 else => 8,
             },
 
@@ -2500,7 +2506,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
                     else => {},
                 },
             },
-            .ios, .tvos, .watchos => switch (c_type) {
+            .ios, .tvos, .watchos, .visionos => switch (c_type) {
                 .longdouble => return 4,
                 else => {},
             },
lib/std/Thread.zig
@@ -39,7 +39,7 @@ impl: Impl,
 pub const max_name_len = switch (native_os) {
     .linux => 15,
     .windows => 31,
-    .macos, .ios, .watchos, .tvos => 63,
+    .macos, .ios, .watchos, .tvos, .visionos => 63,
     .netbsd => 31,
     .freebsd => 15,
     .openbsd => 23,
@@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
                 else => |err| return windows.unexpectedStatus(err),
             }
         },
-        .macos, .ios, .watchos, .tvos => if (use_pthreads) {
+        .macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
             // There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.
             if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
 
@@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
                 else => |err| return windows.unexpectedStatus(err),
             }
         },
-        .macos, .ios, .watchos, .tvos => if (use_pthreads) {
+        .macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
             const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
             switch (err) {
                 .SUCCESS => return std.mem.sliceTo(buffer, 0),
@@ -266,7 +266,7 @@ pub const Id = switch (native_os) {
     .haiku,
     .wasi,
     => u32,
-    .macos, .ios, .watchos, .tvos => u64,
+    .macos, .ios, .watchos, .tvos, .visionos => u64,
     .windows => windows.DWORD,
     else => usize,
 };
@@ -588,7 +588,7 @@ const PosixThreadImpl = struct {
             .linux => {
                 return LinuxThreadImpl.getCurrentId();
             },
-            .macos, .ios, .watchos, .tvos => {
+            .macos, .ios, .watchos, .tvos, .visionos => {
                 var thread_id: u64 = undefined;
                 // Pass thread=null to get the current thread ID.
                 assert(c.pthread_threadid_np(null, &thread_id) == 0);
@@ -1434,7 +1434,7 @@ test "setName, getName" {
     context.test_done_event.wait();
 
     switch (native_os) {
-        .macos, .ios, .watchos, .tvos => {
+        .macos, .ios, .watchos, .tvos, .visionos => {
             const res = thread.setName("foobar");
             try std.testing.expectError(error.Unsupported, res);
         },
lib/std/time.zig
@@ -205,7 +205,7 @@ pub const Instant = struct {
             },
             // On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while
             // suspended.
-            .macos, .ios, .tvos, .watchos => posix.CLOCK.UPTIME_RAW,
+            .macos, .ios, .tvos, .watchos, .visionos => posix.CLOCK.UPTIME_RAW,
             // On freebsd derivatives, use MONOTONIC_FAST as currently there's
             // no precision tradeoff.
             .freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,
src/codegen/llvm.zig
@@ -145,7 +145,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
         .driverkit => "driverkit",
         .shadermodel => "shadermodel",
         .liteos => "liteos",
-        .xros => "xros",
+        .visionos => "xros",
         .serenity => "serenity",
         .vulkan => "vulkan",
 
@@ -256,7 +256,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
         .elfiamcu => .ELFIAMCU,
         .tvos => .TvOS,
         .watchos => .WatchOS,
-        .xros => .XROS,
+        .visionos => .XROS,
         .mesa3d => .Mesa3D,
         .amdpal => .AMDPAL,
         .hermit => .HermitCore,
src/link/MachO.zig
@@ -3676,7 +3676,8 @@ pub inline fn getPageSize(self: MachO) u16 {
 
 pub fn requiresCodeSig(self: MachO) bool {
     if (self.entitlements) |_| return true;
-    if (self.options.adhoc_codesign) |cs| return cs;
+    // TODO: enable once we support this linker option
+    // if (self.options.adhoc_codesign) |cs| return cs;
     const target = self.getTarget();
     return switch (target.cpu.arch) {
         .aarch64 => switch (target.os.tag) {
src/Compilation.zig
@@ -5280,7 +5280,7 @@ pub fn addCCArgs(
                     // doesn't matter which one gets overridden.
                     argv.appendAssumeCapacity("-Wno-overriding-option");
                 },
-                .ios, .tvos, .watchos => switch (target.cpu.arch) {
+                .ios => switch (target.cpu.arch) {
                     // Pass the proper -m<os>-version-min argument for darwin.
                     .x86, .x86_64 => {
                         const ver = target.os.version_range.semver.min;
src/libtsan.zig
@@ -125,7 +125,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v
     }
 
     const platform_tsan_sources = switch (target.os.tag) {
-        .ios, .macos, .watchos, .tvos => &darwin_tsan_sources,
+        .ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
         .windows => &windows_tsan_sources,
         else => &unix_tsan_sources,
     };
src/main.zig
@@ -4432,7 +4432,7 @@ fn runOrTestHotSwap(
     }
 
     switch (builtin.target.os.tag) {
-        .macos, .ios, .tvos, .watchos => {
+        .macos, .ios, .tvos, .watchos, .visionos => {
             const PosixSpawn = @import("DarwinPosixSpawn.zig");
 
             var attr = try PosixSpawn.Attr.init();
src/target.zig
@@ -26,6 +26,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
         .ios,
         .watchos,
         .tvos,
+        .visionos,
         .freestanding,
         .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.
         => false,
build.zig
@@ -705,7 +705,7 @@ fn addCmakeCfgOptionsToExe(
                 };
                 exe.linkSystemLibrary("unwind");
             },
-            .ios, .macos, .watchos, .tvos => {
+            .ios, .macos, .watchos, .tvos, .visionos => {
                 exe.linkLibCpp();
             },
             .windows => {