From 4f6f433745077c9a0179d582ffa3851baf4d5c5f Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Mon, 18 Mar 2024 20:45:45 -0700 Subject: [PATCH 01/12] Support for visionOS --- compiler/rustc_codegen_llvm/src/back/write.rs | 1 + compiler/rustc_codegen_ssa/src/back/link.rs | 10 +- .../rustc_target/src/spec/base/apple/mod.rs | 24 +++ .../rustc_target/src/spec/base/apple/tests.rs | 6 +- compiler/rustc_target/src/spec/mod.rs | 3 + .../spec/targets/aarch64_apple_visionos.rs | 22 +++ .../targets/aarch64_apple_visionos_sim.rs | 22 +++ library/std/build.rs | 1 + library/std/src/fs/tests.rs | 17 +- library/std/src/os/mod.rs | 2 + library/std/src/os/unix/mod.rs | 2 + library/std/src/os/unix/net/stream.rs | 1 + library/std/src/os/unix/net/ucred.rs | 16 +- library/std/src/os/unix/net/ucred/tests.rs | 2 + library/std/src/os/xros/fs.rs | 160 ++++++++++++++++++ library/std/src/os/xros/mod.rs | 6 + library/std/src/os/xros/raw.rs | 83 +++++++++ library/std/src/sys/pal/unix/args.rs | 15 +- library/std/src/sys/pal/unix/env.rs | 11 ++ library/std/src/sys/pal/unix/fd.rs | 2 + library/std/src/sys/pal/unix/fs.rs | 38 ++++- library/std/src/sys/pal/unix/mod.rs | 3 +- library/std/src/sys/pal/unix/os.rs | 13 +- .../src/sys/pal/unix/process/process_unix.rs | 1 + library/std/src/sys/pal/unix/rand.rs | 1 + library/std/src/sys/pal/unix/thread.rs | 9 +- .../std/src/sys/pal/unix/thread_local_dtor.rs | 8 +- .../src/sys/pal/unix/thread_parking/mod.rs | 1 + .../sys/pal/unix/thread_parking/pthread.rs | 3 + library/std/src/sys/pal/unix/time.rs | 5 +- library/std/src/sys/personality/gcc.rs | 2 +- library/std/src/sys/sync/condvar/pthread.rs | 3 + library/std/src/sys_common/net.rs | 2 +- library/std/src/thread/tests.rs | 3 +- library/unwind/src/libunwind.rs | 2 +- src/bootstrap/src/core/build_steps/llvm.rs | 3 +- src/bootstrap/src/lib.rs | 3 +- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 2 + .../src/platform-support/apple-visionos.md | 52 ++++++ src/librustdoc/clean/cfg.rs | 1 + src/tools/compiletest/src/raise_fd_limit.rs | 2 +- tests/assembly/targets/targets-macho.rs | 6 + tests/ui/check-cfg/well-known-values.stderr | 4 +- triagebot.toml | 5 + 45 files changed, 550 insertions(+), 29 deletions(-) create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs create mode 100644 library/std/src/os/xros/fs.rs create mode 100644 library/std/src/os/xros/mod.rs create mode 100644 library/std/src/os/xros/raw.rs create mode 100644 src/doc/rustc/src/platform-support/apple-visionos.md diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 031bbd6336116..2357e98f1b1d4 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -912,6 +912,7 @@ fn target_is_apple(cgcx: &CodegenContext) -> bool { || cgcx.opts.target_triple.triple().contains("-darwin") || cgcx.opts.target_triple.triple().contains("-tvos") || cgcx.opts.target_triple.triple().contains("-watchos") + || cgcx.opts.target_triple.triple().contains("-visionos") } fn target_is_aix(cgcx: &CodegenContext) -> bool { diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index f5e8d5fc92a91..9b1cbe8f58991 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2941,7 +2941,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { let os = &sess.target.os; let llvm_target = &sess.target.llvm_target; if sess.target.vendor != "apple" - || !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "macos") + || !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "visionos" | "macos") || !matches!(flavor, LinkerFlavor::Darwin(..)) { return; @@ -2966,6 +2966,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { ("arm64_32", "watchos") => "watchos", ("aarch64", "watchos") if llvm_target.ends_with("-simulator") => "watchsimulator", ("aarch64", "watchos") => "watchos", + ("aarch64", "visionos") if llvm_target.ends_with("-simulator") => "xrsimulator", + ("aarch64", "visionos") => "visionos", ("arm", "watchos") => "watchos", (_, "macos") => "macosx", _ => { @@ -3022,6 +3024,12 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result {} "watchsimulator" if sdkroot.contains("WatchOS.platform") || sdkroot.contains("MacOSX.platform") => {} + "visionos" + if sdkroot.contains("visionos.platform") || sdkroot.contains("MacOSX.platform") => { + } + "visionossimulator" + if sdkroot.contains("visionos.platform") || sdkroot.contains("MacOSX.platform") => { + } // Ignore `SDKROOT` if it's not a valid path. _ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {} _ => return Ok(sdkroot), diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index dd75377ead2a7..33691be718286 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -102,6 +102,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs { "ios" => ios_deployment_target(arch, abi), "tvos" => tvos_deployment_target(), "watchos" => watchos_deployment_target(), + "visionos" => visionos_deployment_target(), "macos" => macos_deployment_target(arch), _ => unreachable!(), }; @@ -202,6 +203,8 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> { | object::macho::PLATFORM_TVOSSIMULATOR | object::macho::PLATFORM_MACCATALYST => Some((16, 2)), object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)), + // FIXME: Upgrade to yet unreleased `object-rs` implementation with visionos platform definition + 11 | 12 => Some((1, 0)), _ => None, } } @@ -216,6 +219,9 @@ pub fn platform(target: &Target) -> Option { ("watchos", _) => object::macho::PLATFORM_WATCHOS, ("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR, ("tvos", _) => object::macho::PLATFORM_TVOS, + // FIXME: Upgrade to yet unreleased `object-rs` implementation with visionos platform definition + ("visionos", "sim") => 12, + ("visionos", _) => 11, _ => return None, }) } @@ -240,6 +246,7 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> { } "watchos" => watchos_deployment_target(), "tvos" => tvos_deployment_target(), + "visionos" => visionos_deployment_target(), _ => return None, }; @@ -290,6 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow]> { || sdkroot.contains("AppleTVSimulator.platform") || sdkroot.contains("WatchOS.platform") || sdkroot.contains("WatchSimulator.platform") + || sdkroot.contains("visionos.platform") { env_remove.push("SDKROOT".into()) } @@ -299,6 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow]> { // although this is apparently ignored when using the linker at "/usr/bin/ld". env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); env_remove.push("TVOS_DEPLOYMENT_TARGET".into()); + env_remove.push("visionos_DEPLOYMENT_TARGET".into()); env_remove.into() } else { // Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part @@ -363,3 +372,18 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String { let (major, minor) = watchos_deployment_target(); format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor) } + +fn visionos_deployment_target() -> (u32, u32) { + // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. + from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0)) +} + +pub fn visionos_llvm_target(arch: Arch) -> String { + let (major, minor) = visionos_deployment_target(); + format!("{}-apple-visionos{}.{}.0", arch.target_name(), major, minor) +} + +pub fn visionos_sim_llvm_target(arch: Arch) -> String { + let (major, minor) = visionos_deployment_target(); + format!("{}-apple-visionos{}.{}.0-simulator", arch.target_name(), major, minor) +} diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs index 097039d6c7382..18347037eb77d 100644 --- a/compiler/rustc_target/src/spec/base/apple/tests.rs +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -1,6 +1,7 @@ use crate::spec::targets::{ - aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin, - x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim, + aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_visionos_sim, + aarch64_apple_watchos_sim, i686_apple_darwin, x86_64_apple_darwin, x86_64_apple_ios, + x86_64_apple_tvos, x86_64_apple_watchos_sim, }; #[test] @@ -12,6 +13,7 @@ fn simulator_targets_set_abi() { aarch64_apple_ios_sim::target(), // Note: There is currently no ARM64 tvOS simulator target aarch64_apple_watchos_sim::target(), + aarch64_apple_visionos_sim::target(), ]; for target in &all_sim_targets { diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 941d767b850dc..65881c4c41daf 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1557,6 +1557,9 @@ supported_targets! { ("aarch64-apple-watchos", aarch64_apple_watchos), ("aarch64-apple-watchos-sim", aarch64_apple_watchos_sim), + ("aarch64-apple-visionos", aarch64_apple_visionos), + ("aarch64-apple-visionos-sim", aarch64_apple_visionos_sim), + ("armebv7r-none-eabi", armebv7r_none_eabi), ("armebv7r-none-eabihf", armebv7r_none_eabihf), ("armv7r-none-eabi", armv7r_none_eabi), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs new file mode 100644 index 0000000000000..5ccfb6e85712e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs @@ -0,0 +1,22 @@ +use crate::spec::base::apple::{opts, visionos_llvm_target, Arch}; +use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64; + let mut base = opts("visionos", arch); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; + + Target { + llvm_target: visionos_llvm_target(arch).into(), + description: None, + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a12".into(), + max_atomic_width: Some(128), + frame_pointer: FramePointer::NonLeaf, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs new file mode 100644 index 0000000000000..10fea85eb4709 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs @@ -0,0 +1,22 @@ +use crate::spec::base::apple::{opts, visionos_sim_llvm_target, Arch}; +use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64_sim; + let mut base = opts("visionos", arch); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; + + Target { + llvm_target: visionos_sim_llvm_target(arch).into(), + description: None, + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-m1".into(), + max_atomic_width: Some(128), + frame_pointer: FramePointer::NonLeaf, + ..base + }, + } +} diff --git a/library/std/build.rs b/library/std/build.rs index ee3f3612d2e0f..7a47b52e8e4eb 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -22,6 +22,7 @@ fn main() { || target_os == "ios" || target_os == "tvos" || target_os == "watchos" + || target_os == "visionos" || target_os == "windows" || target_os == "fuchsia" || (target_vendor == "fortanix" && target_env == "sgx") diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 65dec3863cc69..6a92832fcdbdd 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1644,8 +1644,8 @@ fn test_file_times() { use crate::os::macos::fs::FileTimesExt; #[cfg(target_os = "tvos")] use crate::os::tvos::fs::FileTimesExt; - #[cfg(target_os = "tvos")] - use crate::os::tvos::fs::FileTimesExt; + #[cfg(target_os = "visionos")] + use crate::os::visionos::fs::FileTimesExt; #[cfg(target_os = "watchos")] use crate::os::watchos::fs::FileTimesExt; #[cfg(windows)] @@ -1662,6 +1662,7 @@ fn test_file_times() { target_os = "macos", target_os = "ios", target_os = "watchos", + target_os = "visionos", target_os = "tvos", ))] let created = SystemTime::UNIX_EPOCH + Duration::from_secs(32123); @@ -1670,6 +1671,7 @@ fn test_file_times() { target_os = "macos", target_os = "ios", target_os = "watchos", + target_os = "visionos", target_os = "tvos", ))] { @@ -1701,6 +1703,7 @@ fn test_file_times() { target_os = "macos", target_os = "ios", target_os = "watchos", + target_os = "visionos", target_os = "tvos", ))] { @@ -1709,7 +1712,13 @@ fn test_file_times() { } #[test] -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" +))] fn test_file_times_pre_epoch_with_nanos() { #[cfg(target_os = "ios")] use crate::os::ios::fs::FileTimesExt; @@ -1717,6 +1726,8 @@ fn test_file_times_pre_epoch_with_nanos() { use crate::os::macos::fs::FileTimesExt; #[cfg(target_os = "tvos")] use crate::os::tvos::fs::FileTimesExt; + #[cfg(target_os = "visionos")] + use crate::os::visionos::fs::FileTimesExt; #[cfg(target_os = "watchos")] use crate::os::watchos::fs::FileTimesExt; diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs index bebf3a797d813..ca3584e82f918 100644 --- a/library/std/src/os/mod.rs +++ b/library/std/src/os/mod.rs @@ -149,6 +149,8 @@ pub mod solid; pub(crate) mod tvos; #[cfg(target_os = "uefi")] pub mod uefi; +#[cfg(target_os = "visionos")] +pub(crate) mod visionos; #[cfg(target_os = "vita")] pub mod vita; #[cfg(target_os = "vxworks")] diff --git a/library/std/src/os/unix/mod.rs b/library/std/src/os/unix/mod.rs index b0633fd7bfccb..d7a622012a5ac 100644 --- a/library/std/src/os/unix/mod.rs +++ b/library/std/src/os/unix/mod.rs @@ -79,6 +79,8 @@ mod platform { pub use crate::os::solaris::*; #[cfg(target_os = "tvos")] pub use crate::os::tvos::*; + #[cfg(target_os = "visionos")] + pub use crate::os::visionos::*; #[cfg(target_os = "vita")] pub use crate::os::vita::*; #[cfg(target_os = "vxworks")] diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index d2e23bdee6c88..79a797ccbf6b5 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -233,6 +233,7 @@ impl UnixStream { target_os = "tvos", target_os = "macos", target_os = "watchos", + target_os = "visionos", target_os = "netbsd", target_os = "openbsd" ))] diff --git a/library/std/src/os/unix/net/ucred.rs b/library/std/src/os/unix/net/ucred.rs index de09c93840a54..f94d8f06c316d 100644 --- a/library/std/src/os/unix/net/ucred.rs +++ b/library/std/src/os/unix/net/ucred.rs @@ -34,7 +34,13 @@ pub(super) use self::impl_linux::peer_cred; ))] pub(super) use self::impl_bsd::peer_cred; -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" +))] pub(super) use self::impl_mac::peer_cred; #[cfg(any(target_os = "linux", target_os = "android"))] @@ -96,7 +102,13 @@ mod impl_bsd { } } -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" +))] mod impl_mac { use super::UCred; use crate::os::unix::io::AsRawFd; diff --git a/library/std/src/os/unix/net/ucred/tests.rs b/library/std/src/os/unix/net/ucred/tests.rs index dd99ecdd819a7..2a0797877c6fc 100644 --- a/library/std/src/os/unix/net/ucred/tests.rs +++ b/library/std/src/os/unix/net/ucred/tests.rs @@ -11,6 +11,7 @@ use libc::{getegid, geteuid, getpid}; target_os = "tvos", target_os = "macos", target_os = "watchos", + target_os = "visionos", target_os = "openbsd" ))] fn test_socket_pair() { @@ -32,6 +33,7 @@ fn test_socket_pair() { target_os = "ios", target_os = "macos", target_os = "watchos", + target_os = "visionos", target_os = "tvos", ))] fn test_socket_pair_pids(arg: Type) -> RetType { diff --git a/library/std/src/os/xros/fs.rs b/library/std/src/os/xros/fs.rs new file mode 100644 index 0000000000000..e5df4de0b7f71 --- /dev/null +++ b/library/std/src/os/xros/fs.rs @@ -0,0 +1,160 @@ +#![stable(feature = "metadata_ext", since = "1.1.0")] + +use crate::fs::{self, Metadata}; +use crate::sealed::Sealed; +use crate::sys_common::{AsInner, AsInnerMut, IntoInner}; +use crate::time::SystemTime; + +#[allow(deprecated)] +use super::raw; + +/// OS-specific extensions to [`fs::Metadata`]. +/// +/// [`fs::Metadata`]: crate::fs::Metadata +#[stable(feature = "metadata_ext", since = "1.1.0")] +pub trait MetadataExt { + /// Gain a reference to the underlying `stat` structure which contains + /// the raw information returned by the OS. + /// + /// The contents of the returned `stat` are **not** consistent across + /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the + /// cross-Unix abstractions contained within the raw stat. + #[stable(feature = "metadata_ext", since = "1.1.0")] + #[deprecated( + since = "1.8.0", + note = "deprecated in favor of the accessor \ + methods of this trait" + )] + #[allow(deprecated)] + fn as_raw_stat(&self) -> &raw::stat; + + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_dev(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ino(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mode(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_nlink(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_uid(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_gid(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_rdev(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_size(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_atime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_atime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mtime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mtime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ctime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ctime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_birthtime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_birthtime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_blksize(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_blocks(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_flags(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_gen(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_lspare(&self) -> u32; +} + +#[stable(feature = "metadata_ext", since = "1.1.0")] +impl MetadataExt for Metadata { + #[allow(deprecated)] + fn as_raw_stat(&self) -> &raw::stat { + unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } + } + fn st_dev(&self) -> u64 { + self.as_inner().as_inner().st_dev as u64 + } + fn st_ino(&self) -> u64 { + self.as_inner().as_inner().st_ino as u64 + } + fn st_mode(&self) -> u32 { + self.as_inner().as_inner().st_mode as u32 + } + fn st_nlink(&self) -> u64 { + self.as_inner().as_inner().st_nlink as u64 + } + fn st_uid(&self) -> u32 { + self.as_inner().as_inner().st_uid as u32 + } + fn st_gid(&self) -> u32 { + self.as_inner().as_inner().st_gid as u32 + } + fn st_rdev(&self) -> u64 { + self.as_inner().as_inner().st_rdev as u64 + } + fn st_size(&self) -> u64 { + self.as_inner().as_inner().st_size as u64 + } + fn st_atime(&self) -> i64 { + self.as_inner().as_inner().st_atime as i64 + } + fn st_atime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_atime_nsec as i64 + } + fn st_mtime(&self) -> i64 { + self.as_inner().as_inner().st_mtime as i64 + } + fn st_mtime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_mtime_nsec as i64 + } + fn st_ctime(&self) -> i64 { + self.as_inner().as_inner().st_ctime as i64 + } + fn st_ctime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_ctime_nsec as i64 + } + fn st_birthtime(&self) -> i64 { + self.as_inner().as_inner().st_birthtime as i64 + } + fn st_birthtime_nsec(&self) -> i64 { + self.as_inner().as_inner().st_birthtime_nsec as i64 + } + fn st_blksize(&self) -> u64 { + self.as_inner().as_inner().st_blksize as u64 + } + fn st_blocks(&self) -> u64 { + self.as_inner().as_inner().st_blocks as u64 + } + fn st_gen(&self) -> u32 { + self.as_inner().as_inner().st_gen as u32 + } + fn st_flags(&self) -> u32 { + self.as_inner().as_inner().st_flags as u32 + } + fn st_lspare(&self) -> u32 { + self.as_inner().as_inner().st_lspare as u32 + } +} + +/// OS-specific extensions to [`fs::FileTimes`]. +#[stable(feature = "file_set_times", since = "1.75.0")] +pub trait FileTimesExt: Sealed { + /// Set the creation time of a file. + #[stable(feature = "file_set_times", since = "1.75.0")] + fn set_created(self, t: SystemTime) -> Self; +} + +#[stable(feature = "file_set_times", since = "1.75.0")] +impl FileTimesExt for fs::FileTimes { + fn set_created(mut self, t: SystemTime) -> Self { + self.as_inner_mut().set_created(t.into_inner()); + self + } +} diff --git a/library/std/src/os/xros/mod.rs b/library/std/src/os/xros/mod.rs new file mode 100644 index 0000000000000..f4b061ffda898 --- /dev/null +++ b/library/std/src/os/xros/mod.rs @@ -0,0 +1,6 @@ +//! visionos-specific definitions + +#![stable(feature = "raw_ext", since = "1.1.0")] + +pub mod fs; +pub mod raw; diff --git a/library/std/src/os/xros/raw.rs b/library/std/src/os/xros/raw.rs new file mode 100644 index 0000000000000..2b3eca6f493df --- /dev/null +++ b/library/std/src/os/xros/raw.rs @@ -0,0 +1,83 @@ +//! visionos-specific raw type definitions + +#![stable(feature = "raw_ext", since = "1.1.0")] +#![deprecated( + since = "1.8.0", + note = "these type aliases are no longer supported by \ + the standard library, the `libc` crate on \ + crates.io should be used instead for the correct \ + definitions" +)] +#![allow(deprecated)] + +use crate::os::raw::c_long; + +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type blkcnt_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type blksize_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type dev_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type ino_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type mode_t = u32; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type nlink_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type off_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type time_t = i64; + +#[stable(feature = "pthread_t", since = "1.8.0")] +pub type pthread_t = usize; + +#[repr(C)] +#[derive(Clone)] +#[stable(feature = "raw_ext", since = "1.1.0")] +pub struct stat { + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_dev: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: u16, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: u16, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ino: u64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_birthtime: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_birthtime_nsec: c_long, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_flags: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gen: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_lspare: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_qspare: [i64; 2], +} diff --git a/library/std/src/sys/pal/unix/args.rs b/library/std/src/sys/pal/unix/args.rs index 78e82d9c194c4..acf8100d47f23 100644 --- a/library/std/src/sys/pal/unix/args.rs +++ b/library/std/src/sys/pal/unix/args.rs @@ -170,7 +170,13 @@ mod imp { } } -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" +))] mod imp { use super::Args; use crate::ffi::CStr; @@ -211,7 +217,12 @@ mod imp { // for i in (0..[args count]) // res.push([args objectAtIndex:i]) // res - #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))] + #[cfg(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ))] pub fn args() -> Args { use crate::ffi::{c_char, c_void, OsString}; use crate::mem; diff --git a/library/std/src/sys/pal/unix/env.rs b/library/std/src/sys/pal/unix/env.rs index 3d4ba509829d3..fb1f868644d48 100644 --- a/library/std/src/sys/pal/unix/env.rs +++ b/library/std/src/sys/pal/unix/env.rs @@ -53,6 +53,17 @@ pub mod os { pub const EXE_EXTENSION: &str = ""; } +#[cfg(target_os = "visionos")] +pub mod os { + pub const FAMILY: &str = "unix"; + pub const OS: &str = "visionos"; + pub const DLL_PREFIX: &str = "lib"; + pub const DLL_SUFFIX: &str = ".dylib"; + pub const DLL_EXTENSION: &str = "dylib"; + pub const EXE_SUFFIX: &str = ""; + pub const EXE_EXTENSION: &str = ""; +} + #[cfg(target_os = "freebsd")] pub mod os { pub const FAMILY: &str = "unix"; diff --git a/library/std/src/sys/pal/unix/fd.rs b/library/std/src/sys/pal/unix/fd.rs index a1c0321876fa8..d6a57f179e5b5 100644 --- a/library/std/src/sys/pal/unix/fd.rs +++ b/library/std/src/sys/pal/unix/fd.rs @@ -51,6 +51,7 @@ const READ_LIMIT: usize = libc::ssize_t::MAX as usize; target_os = "netbsd", target_os = "openbsd", target_os = "watchos", + target_os = "visionos", ))] const fn max_iov() -> usize { libc::IOV_MAX as usize @@ -81,6 +82,7 @@ const fn max_iov() -> usize { target_os = "horizon", target_os = "vita", target_os = "watchos", + target_os = "visionos", )))] const fn max_iov() -> usize { 16 // The minimum value required by POSIX. diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index b968f8df34c23..4d93a9b3933cf 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -23,6 +23,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", ))] use crate::sys::weak::syscall; #[cfg(any(target_os = "android", target_os = "macos", target_os = "solaris"))] @@ -35,6 +36,7 @@ use libc::{c_int, mode_t}; target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "solaris", all(target_os = "linux", target_env = "gnu") ))] @@ -377,7 +379,13 @@ pub struct FilePermissions { pub struct FileTimes { accessed: Option, modified: Option, - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))] + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" + ))] created: Option, } @@ -555,6 +563,7 @@ impl FileAttr { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", ))] pub fn created(&self) -> io::Result { SystemTime::new(self.stat.st_birthtime as i64, self.stat.st_birthtime_nsec as i64) @@ -567,6 +576,7 @@ impl FileAttr { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "vita", )))] pub fn created(&self) -> io::Result { @@ -647,7 +657,13 @@ impl FileTimes { self.modified = Some(t); } - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))] + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" + ))] pub fn set_created(&mut self, t: SystemTime) { self.created = Some(t); } @@ -938,6 +954,7 @@ impl DirEntry { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "linux", target_os = "emscripten", target_os = "android", @@ -974,6 +991,7 @@ impl DirEntry { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "netbsd", target_os = "openbsd", target_os = "freebsd", @@ -993,6 +1011,7 @@ impl DirEntry { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "netbsd", target_os = "openbsd", target_os = "freebsd", @@ -1162,6 +1181,7 @@ impl File { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", ))] unsafe fn os_fsync(fd: c_int) -> c_int { libc::fcntl(fd, libc::F_FULLFSYNC) @@ -1171,6 +1191,7 @@ impl File { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", )))] unsafe fn os_fsync(fd: c_int) -> c_int { libc::fsync(fd) @@ -1186,6 +1207,7 @@ impl File { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", ))] unsafe fn os_datasync(fd: c_int) -> c_int { libc::fcntl(fd, libc::F_FULLFSYNC) @@ -1212,6 +1234,7 @@ impl File { target_os = "netbsd", target_os = "openbsd", target_os = "watchos", + target_os = "visionos", target_os = "nto", target_os = "hurd", )))] @@ -1322,7 +1345,7 @@ impl File { io::ErrorKind::Unsupported, "setting file times not supported", )) - } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] { + } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] { let mut buf = [mem::MaybeUninit::::uninit(); 3]; let mut num_times = 0; let mut attrlist: libc::attrlist = unsafe { mem::zeroed() }; @@ -1787,6 +1810,7 @@ fn open_to_and_set_permissions( target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", )))] pub fn copy(from: &Path, to: &Path) -> io::Result { let (mut reader, reader_metadata) = open_from(from)?; @@ -1813,7 +1837,13 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { } } -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" +))] pub fn copy(from: &Path, to: &Path) -> io::Result { use crate::sync::atomic::{AtomicBool, Ordering}; diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index f608ae47a21fb..4ae76518c4f62 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -83,6 +83,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "redox", target_os = "l4re", target_os = "horizon", @@ -405,7 +406,7 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "macos")] { #[link(name = "System")] extern "C" {} - } else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))] { + } else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] { #[link(name = "System")] #[link(name = "objc")] #[link(name = "Foundation", kind = "framework")] diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs index 0b9c8027e6fc3..96492fedece78 100644 --- a/library/std/src/sys/pal/unix/os.rs +++ b/library/std/src/sys/pal/unix/os.rs @@ -69,7 +69,8 @@ extern "C" { target_os = "ios", target_os = "tvos", target_os = "freebsd", - target_os = "watchos" + target_os = "watchos", + target_os = "visionos", ), link_name = "__error" )] @@ -430,7 +431,13 @@ pub fn current_exe() -> io::Result { Ok(PathBuf::from(OsString::from_vec(e))) } -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" +))] pub fn current_exe() -> io::Result { unsafe { let mut sz: u32 = 0; @@ -699,6 +706,7 @@ pub fn home_dir() -> Option { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "emscripten", target_os = "redox", target_os = "vxworks", @@ -714,6 +722,7 @@ pub fn home_dir() -> Option { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "emscripten", target_os = "redox", target_os = "vxworks", diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs index f017d39d804aa..e798510f9e64c 100644 --- a/library/std/src/sys/pal/unix/process/process_unix.rs +++ b/library/std/src/sys/pal/unix/process/process_unix.rs @@ -14,6 +14,7 @@ use crate::os::unix::io::AsRawFd; #[cfg(any( target_os = "macos", target_os = "watchos", + target_os = "visionos", target_os = "tvos", target_os = "freebsd", all(target_os = "linux", target_env = "gnu"), diff --git a/library/std/src/sys/pal/unix/rand.rs b/library/std/src/sys/pal/unix/rand.rs index c9ed6825f6c21..d88acf065b0ff 100644 --- a/library/std/src/sys/pal/unix/rand.rs +++ b/library/std/src/sys/pal/unix/rand.rs @@ -16,6 +16,7 @@ pub fn hashmap_random_keys() -> (u64, u64) { not(target_os = "ios"), not(target_os = "tvos"), not(target_os = "watchos"), + not(target_os = "visionos"), not(target_os = "openbsd"), not(target_os = "netbsd"), not(target_os = "fuchsia"), diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 6520ca9fc48ef..77b54a4a40f49 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -150,7 +150,13 @@ impl Thread { } } - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" + ))] pub fn set_name(name: &CStr) { unsafe { let name = truncate_cstr::<{ libc::MAXTHREADNAMESIZE }>(name); @@ -334,6 +340,7 @@ impl Drop for Thread { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "nto", ))] fn truncate_cstr(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] { diff --git a/library/std/src/sys/pal/unix/thread_local_dtor.rs b/library/std/src/sys/pal/unix/thread_local_dtor.rs index 79b152cece945..1c0b39e652ff0 100644 --- a/library/std/src/sys/pal/unix/thread_local_dtor.rs +++ b/library/std/src/sys/pal/unix/thread_local_dtor.rs @@ -76,7 +76,13 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { // workaround below is to register, via _tlv_atexit, a custom DTOR list once per // thread. thread_local dtors are pushed to the DTOR list without calling // _tlv_atexit. -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))] +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "watchos", + target_os = "visionos", + target_os = "tvos" +))] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { use crate::cell::{Cell, RefCell}; use crate::ptr; diff --git a/library/std/src/sys/pal/unix/thread_parking/mod.rs b/library/std/src/sys/pal/unix/thread_parking/mod.rs index 185333c072f49..3348d4b366d22 100644 --- a/library/std/src/sys/pal/unix/thread_parking/mod.rs +++ b/library/std/src/sys/pal/unix/thread_parking/mod.rs @@ -16,6 +16,7 @@ cfg_if::cfg_if! { target_os = "macos", target_os = "ios", target_os = "watchos", + target_os = "visionos", target_os = "tvos", ), not(miri), diff --git a/library/std/src/sys/pal/unix/thread_parking/pthread.rs b/library/std/src/sys/pal/unix/thread_parking/pthread.rs index ae805d8439945..ba19b53e8080b 100644 --- a/library/std/src/sys/pal/unix/thread_parking/pthread.rs +++ b/library/std/src/sys/pal/unix/thread_parking/pthread.rs @@ -48,6 +48,7 @@ unsafe fn wait_timeout( target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "espidf", target_os = "horizon", ))] @@ -76,6 +77,7 @@ unsafe fn wait_timeout( target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "espidf", target_os = "horizon", )))] @@ -124,6 +126,7 @@ impl Parker { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "l4re", target_os = "android", target_os = "redox", diff --git a/library/std/src/sys/pal/unix/time.rs b/library/std/src/sys/pal/unix/time.rs index 0440f33ded139..e69775be8cf8e 100644 --- a/library/std/src/sys/pal/unix/time.rs +++ b/library/std/src/sys/pal/unix/time.rs @@ -90,7 +90,8 @@ impl Timespec { target_os = "macos", target_os = "ios", target_os = "tvos", - target_os = "watchos" + target_os = "watchos", + target_os = "visionos", ))] let (tv_sec, tv_nsec) = if (tv_sec <= 0 && tv_sec > i64::MIN) && (tv_nsec < 0 && tv_nsec > -1_000_000_000) { @@ -278,6 +279,7 @@ impl Instant { target_os = "macos", target_os = "ios", target_os = "watchos", + target_os = "visionos", target_os = "tvos" ))] const clock_id: libc::clockid_t = libc::CLOCK_UPTIME_RAW; @@ -285,6 +287,7 @@ impl Instant { target_os = "macos", target_os = "ios", target_os = "watchos", + target_os = "visionos", target_os = "tvos" )))] const clock_id: libc::clockid_t = libc::CLOCK_MONOTONIC; diff --git a/library/std/src/sys/personality/gcc.rs b/library/std/src/sys/personality/gcc.rs index 6f317131145ae..b0f744dd96605 100644 --- a/library/std/src/sys/personality/gcc.rs +++ b/library/std/src/sys/personality/gcc.rs @@ -92,7 +92,7 @@ const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1 // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c cfg_if::cfg_if! { - if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "tvos"), not(target_os = "watchos"), not(target_os = "netbsd")))] { + if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "tvos"), not(target_os = "watchos"), not(target_os = "visionos"), not(target_os = "netbsd")))] { // ARM EHABI personality routine. // https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf // diff --git a/library/std/src/sys/sync/condvar/pthread.rs b/library/std/src/sys/sync/condvar/pthread.rs index 728371685eeee..0475f9850786f 100644 --- a/library/std/src/sys/sync/condvar/pthread.rs +++ b/library/std/src/sys/sync/condvar/pthread.rs @@ -34,6 +34,7 @@ impl LazyInit for AllocatedCondvar { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "l4re", target_os = "android", target_os = "redox" @@ -127,6 +128,7 @@ impl Condvar { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "android", target_os = "espidf", target_os = "horizon" @@ -162,6 +164,7 @@ impl Condvar { target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "android", target_os = "espidf", target_os = "horizon" diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index 581c46af0eacf..b353ce2b09039 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -18,7 +18,7 @@ use crate::ffi::{c_int, c_void}; cfg_if::cfg_if! { if #[cfg(any( target_os = "dragonfly", target_os = "freebsd", - target_os = "ios", target_os = "tvos", target_os = "macos", target_os = "watchos", + target_os = "ios", target_os = "tvos", target_os = "macos", target_os = "watchos", target_os = "visionos", target_os = "openbsd", target_os = "netbsd", target_os = "illumos", target_os = "solaris", target_os = "haiku", target_os = "l4re", target_os = "nto"))] { use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 589a5fdad1d7e..d33fe27b9c3d8 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -43,7 +43,8 @@ fn test_named_thread() { target_os = "macos", target_os = "ios", target_os = "tvos", - target_os = "watchos" + target_os = "watchos", + target_os = "visionos", ))] #[test] fn test_named_thread_truncation() { diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 0a0dc9438b305..57ce3d0fa5c3e 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -123,7 +123,7 @@ extern "C" { } cfg_if::cfg_if! { -if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "netbsd", not(target_arch = "arm")))] { +if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos", target_os = "netbsd", not(target_arch = "arm")))] { // Not ARM EHABI #[repr(C)] #[derive(Copy, Clone, PartialEq)] diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 3da927b5fa0fa..31209391d1455 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -364,10 +364,11 @@ impl Step for Llvm { cfg.define("LLVM_ENABLE_ZLIB", "OFF"); } - // Are we compiling for iOS/tvOS/watchOS? + // Are we compiling for iOS/tvOS/watchOS/visionos? if target.contains("apple-ios") || target.contains("apple-tvos") || target.contains("apple-watchos") + || target.contains("apple-visionos") { // These two defines prevent CMake from automatically trying to add a MacOSX sysroot, which leads to a compiler error. cfg.define("CMAKE_OSX_SYSROOT", "/"); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 64bb7bf01f796..eaf70059b8264 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -92,8 +92,9 @@ const EXTRA_CHECK_CFGS: &[(Option, &str, Option<&[&'static str]>)] = &[ (Some(Mode::Std), "backtrace_in_libstd", None), /* Extra values not defined in the built-in targets yet, but used in std */ (Some(Mode::Std), "target_env", Some(&["libnx", "p2"])), - // (Some(Mode::Std), "target_os", Some(&[])), + (Some(Mode::Std), "target_os", Some(&["visionos"])), (Some(Mode::Std), "target_arch", Some(&["arm64ec", "spirv", "nvptx", "xtensa"])), + (Some(Mode::ToolStd), "target_os", Some(&["visionos"])), /* Extra names used by dependencies */ // FIXME: Used by serde_json, but we should not be triggering on external dependencies. (Some(Mode::Rustc), "no_btreemap_remove_entry", None), diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 83acce80f969d..db85753145d45 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -21,6 +21,7 @@ - [arm64ec-pc-windows-msvc](platform-support/arm64ec-pc-windows-msvc.md) - [\*-apple-tvos](platform-support/apple-tvos.md) - [\*-apple-watchos\*](platform-support/apple-watchos.md) + - [aarch64-apple-visionos\*](platform-support/apple-visionos.md) - [aarch64-nintendo-switch-freestanding](platform-support/aarch64-nintendo-switch-freestanding.md) - [armeb-unknown-linux-gnueabi](platform-support/armeb-unknown-linux-gnueabi.md) - [arm-none-eabi](platform-support/arm-none-eabi.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 274745b908294..903509060e261 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -242,6 +242,8 @@ target | std | host | notes [`aarch64-apple-tvos-sim`](platform-support/apple-tvos.md) | ? | | ARM64 tvOS Simulator [`aarch64-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS [`aarch64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS Simulator +[`aarch64-apple-visionos`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS +[`aarch64-apple-vision-sim`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS Simulator [`aarch64-kmc-solid_asp3`](platform-support/kmc-solid.md) | ✓ | | ARM64 SOLID with TOPPERS/ASP3 [`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon [`aarch64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ | diff --git a/src/doc/rustc/src/platform-support/apple-visionos.md b/src/doc/rustc/src/platform-support/apple-visionos.md new file mode 100644 index 0000000000000..95d3bdd5c270b --- /dev/null +++ b/src/doc/rustc/src/platform-support/apple-visionos.md @@ -0,0 +1,52 @@ +# aarch64-apple-visionos\* + +- aarch64-apple-visionos +- aarch64-apple-visionos-sim + +**Tier: 3** + +Apple visionOS targets: + +- Apple visionOS on arm64 +- Apple visionOS Simulator on arm64 + +## Target maintainers + +- [@agg23](https://github.com/agg23) + +## Requirements + +These targets are cross-compiled. +To build these targets Xcode 15 or higher on macOS is required. + +## Building the target + +The targets can be built by enabling them for a `rustc` build, for example: + +```toml +[build] +build-stage = 1 +target = ["aarch64-apple-visionos-sim"] +``` + +## Building Rust programs + +_Note: Building for this target requires the corresponding visionOS SDK, as provided by Xcode 15+._ + +Rust programs can be built for these targets, if `rustc` has been built with support for them, for example: + +```text +rustc --target aarch64-apple-visionos-sim your-code.rs +``` + +## Testing + +There is no support for running the Rust testsuite on visionOS or the simulators. + +There is no easy way to run simple programs on visionOS or the visionOS simulators. Static library builds can be embedded into visionOS applications. + +## Cross-compilation toolchains and C code + +This target can be cross-compiled from x86_64 or aarch64 macOS hosts. + +Other hosts are not supported for cross-compilation, but might work when also providing the required Xcode SDK. diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 277db90df9aaa..8e4e2830a0435 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -511,6 +511,7 @@ impl<'a> fmt::Display for Display<'a> { "wasi" => "WASI", "watchos" => "watchOS", "windows" => "Windows", + "visionos" => "visionos", _ => "", }, (sym::target_arch, Some(arch)) => match arch.as_str() { diff --git a/src/tools/compiletest/src/raise_fd_limit.rs b/src/tools/compiletest/src/raise_fd_limit.rs index bc2946e2c1354..a4235381beb6f 100644 --- a/src/tools/compiletest/src/raise_fd_limit.rs +++ b/src/tools/compiletest/src/raise_fd_limit.rs @@ -4,7 +4,7 @@ /// on the number of cores available. /// /// This fixes issue #7772. -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] +#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "visionos"))] #[allow(non_camel_case_types)] pub unsafe fn raise_fd_limit() { use std::cmp; diff --git a/tests/assembly/targets/targets-macho.rs b/tests/assembly/targets/targets-macho.rs index bbdafb76e5a9f..36145a82bda72 100644 --- a/tests/assembly/targets/targets-macho.rs +++ b/tests/assembly/targets/targets-macho.rs @@ -27,6 +27,12 @@ //@ revisions: arm64_32_apple_watchos //@ [arm64_32_apple_watchos] compile-flags: --target arm64_32-apple-watchos //@ [arm64_32_apple_watchos] needs-llvm-components: aarch64 +//@ revisions: aarch64_apple_visionos +//@ [aarch64_apple_visionos] compile-flags: --target aarch64-apple-visionos +//@ [aarch64_apple_visionos] needs-llvm-components: aarch64 +//@ revisions: aarch64_apple_visionos_sim +//@ [aarch64_apple_visionos_sim] compile-flags: --target aarch64-apple-visionos-sim +//@ [aarch64_apple_visionos_sim] needs-llvm-components: aarch64 //@ revisions: arm64e_apple_darwin //@ [arm64e_apple_darwin] compile-flags: --target arm64e-apple-darwin //@ [arm64e_apple_darwin] needs-llvm-components: aarch64 diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index cf18503b74bb9..31553371101f9 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -190,7 +190,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm` + = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -263,7 +263,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm` + = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm` = note: see for more information about checking conditional configuration warning: 27 warnings emitted diff --git a/triagebot.toml b/triagebot.toml index 0a36eab7b8738..de1399ecc9f4b 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -286,6 +286,11 @@ trigger_files = [ "library/std/src/os/windows" ] +[autolabel."O-visionos"] +trigger_files = [ + "library/std/src/os/visionos" +] + [autolabel."T-bootstrap"] trigger_files = [ "x.py", From 11ea14e9b94520aaad94f6adeda2064d6231fa7a Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Mon, 18 Mar 2024 20:51:37 -0700 Subject: [PATCH 02/12] Update visionOS MachO tests to require LLVM 18 --- tests/assembly/targets/targets-macho.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/assembly/targets/targets-macho.rs b/tests/assembly/targets/targets-macho.rs index 36145a82bda72..713129b692cdd 100644 --- a/tests/assembly/targets/targets-macho.rs +++ b/tests/assembly/targets/targets-macho.rs @@ -28,9 +28,11 @@ //@ [arm64_32_apple_watchos] compile-flags: --target arm64_32-apple-watchos //@ [arm64_32_apple_watchos] needs-llvm-components: aarch64 //@ revisions: aarch64_apple_visionos +//@ [aarch64_apple_visionos] min-llvm-version: 18 //@ [aarch64_apple_visionos] compile-flags: --target aarch64-apple-visionos //@ [aarch64_apple_visionos] needs-llvm-components: aarch64 //@ revisions: aarch64_apple_visionos_sim +//@ [aarch64_apple_visionos_sim] min-llvm-version: 18 //@ [aarch64_apple_visionos_sim] compile-flags: --target aarch64-apple-visionos-sim //@ [aarch64_apple_visionos_sim] needs-llvm-components: aarch64 //@ revisions: arm64e_apple_darwin From 51777dc81240f97869b99370dc59dcd541b90b70 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 19 Mar 2024 05:27:54 -0700 Subject: [PATCH 03/12] Add missing visionOS target metadata --- .../src/spec/targets/aarch64_apple_visionos.rs | 7 ++++++- .../src/spec/targets/aarch64_apple_visionos_sim.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs index 5ccfb6e85712e..9982855017721 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs @@ -8,7 +8,12 @@ pub fn target() -> Target { Target { llvm_target: visionos_llvm_target(arch).into(), - description: None, + metadata: crate::spec::TargetMetadata { + description: None, + tier: None, + host_tools: None, + std: None, + }, pointer_width: 64, data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), arch: arch.target_arch(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs index 10fea85eb4709..73cd8e9d66d42 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs @@ -8,7 +8,12 @@ pub fn target() -> Target { Target { llvm_target: visionos_sim_llvm_target(arch).into(), - description: None, + metadata: crate::spec::TargetMetadata { + description: None, + tier: None, + host_tools: None, + std: None, + }, pointer_width: 64, data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), arch: arch.target_arch(), From f32ad2baf47e03effcded82f5f2e17b9cc85e50f Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 19 Mar 2024 06:44:35 -0700 Subject: [PATCH 04/12] Fixed VISIONOS_DEPLOYMENT_TARGET envar test --- compiler/rustc_target/src/spec/base/apple/mod.rs | 4 ++-- compiler/rustc_target/src/spec/base/apple/tests.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index 33691be718286..9c0bda43c1377 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -307,7 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow]> { // although this is apparently ignored when using the linker at "/usr/bin/ld". env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); env_remove.push("TVOS_DEPLOYMENT_TARGET".into()); - env_remove.push("visionos_DEPLOYMENT_TARGET".into()); + env_remove.push("VISIONOS_DEPLOYMENT_TARGET".into()); env_remove.into() } else { // Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part @@ -375,7 +375,7 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String { fn visionos_deployment_target() -> (u32, u32) { // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0)) + from_set_deployment_target("VISIONOS_DEPLOYMENT_TARGET").unwrap_or((1, 0)) } pub fn visionos_llvm_target(arch: Arch) -> String { diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs index 18347037eb77d..91da60abb9232 100644 --- a/compiler/rustc_target/src/spec/base/apple/tests.rs +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -34,7 +34,7 @@ fn macos_link_environment_unmodified() { // for the host. assert_eq!( target.link_env_remove, - crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET"], + crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET", "VISIONOS_DEPLOYMENT_TARGET"], ); } } From f7870a38d98126c01134ba37ca49cf9ce24d0662 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 19 Mar 2024 06:53:27 -0700 Subject: [PATCH 05/12] Fix test formatting --- compiler/rustc_target/src/spec/base/apple/tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs index 91da60abb9232..59eee2638fb87 100644 --- a/compiler/rustc_target/src/spec/base/apple/tests.rs +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -34,7 +34,11 @@ fn macos_link_environment_unmodified() { // for the host. assert_eq!( target.link_env_remove, - crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET", "VISIONOS_DEPLOYMENT_TARGET"], + crate::spec::cvs![ + "IPHONEOS_DEPLOYMENT_TARGET", + "TVOS_DEPLOYMENT_TARGET", + "VISIONOS_DEPLOYMENT_TARGET" + ], ); } } From 4f7ac51372cfcb14454433de52fed6321f5378ca Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 19 Mar 2024 07:34:03 -0700 Subject: [PATCH 06/12] Fixed incorrectly named sim target in platform-support.md --- src/doc/rustc/src/platform-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 903509060e261..37417888003b2 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -243,7 +243,7 @@ target | std | host | notes [`aarch64-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS [`aarch64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS Simulator [`aarch64-apple-visionos`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS -[`aarch64-apple-vision-sim`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS Simulator +[`aarch64-apple-visionos-sim`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS Simulator [`aarch64-kmc-solid_asp3`](platform-support/kmc-solid.md) | ✓ | | ARM64 SOLID with TOPPERS/ASP3 [`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon [`aarch64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ | From 572d6cd322e96963e3e056fadc352e4d7471203f Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 19 Mar 2024 13:06:10 -0700 Subject: [PATCH 07/12] Added note about LLVM 18 requirement --- src/doc/rustc/src/platform-support/apple-visionos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/apple-visionos.md b/src/doc/rustc/src/platform-support/apple-visionos.md index 95d3bdd5c270b..24bb94d3cf035 100644 --- a/src/doc/rustc/src/platform-support/apple-visionos.md +++ b/src/doc/rustc/src/platform-support/apple-visionos.md @@ -17,7 +17,7 @@ Apple visionOS targets: ## Requirements These targets are cross-compiled. -To build these targets Xcode 15 or higher on macOS is required. +To build these targets Xcode 15 or higher on macOS is required, along with LLVM 18. ## Building the target From 52960d499e76990526c694838ffc27428566f905 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Sat, 23 Mar 2024 16:42:06 -0700 Subject: [PATCH 08/12] Fixed builds with modified libc --- compiler/rustc_codegen_ssa/src/back/link.rs | 6 +++--- compiler/rustc_target/src/spec/base/apple/mod.rs | 6 +++--- compiler/rustc_target/src/spec/base/apple/tests.rs | 2 +- .../rustc_target/src/spec/targets/aarch64_apple_visionos.rs | 4 ++-- .../src/spec/targets/aarch64_apple_visionos_sim.rs | 4 ++-- library/std/src/os/unix/net/mod.rs | 2 ++ library/std/src/os/unix/net/stream.rs | 1 + library/std/src/os/{xros => visionos}/fs.rs | 0 library/std/src/os/{xros => visionos}/mod.rs | 0 library/std/src/os/{xros => visionos}/raw.rs | 0 src/librustdoc/clean/cfg.rs | 2 +- 11 files changed, 15 insertions(+), 12 deletions(-) rename library/std/src/os/{xros => visionos}/fs.rs (100%) rename library/std/src/os/{xros => visionos}/mod.rs (100%) rename library/std/src/os/{xros => visionos}/raw.rs (100%) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 9b1cbe8f58991..f2bc083f0f55c 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2967,7 +2967,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { ("aarch64", "watchos") if llvm_target.ends_with("-simulator") => "watchsimulator", ("aarch64", "watchos") => "watchos", ("aarch64", "visionos") if llvm_target.ends_with("-simulator") => "xrsimulator", - ("aarch64", "visionos") => "visionos", + ("aarch64", "visionos") => "xros", ("arm", "watchos") => "watchos", (_, "macos") => "macosx", _ => { @@ -3025,10 +3025,10 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result {} "visionos" - if sdkroot.contains("visionos.platform") || sdkroot.contains("MacOSX.platform") => { + if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => { } "visionossimulator" - if sdkroot.contains("visionos.platform") || sdkroot.contains("MacOSX.platform") => { + if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => { } // Ignore `SDKROOT` if it's not a valid path. _ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {} diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index 9c0bda43c1377..04e1ebb4acda1 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -297,7 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow]> { || sdkroot.contains("AppleTVSimulator.platform") || sdkroot.contains("WatchOS.platform") || sdkroot.contains("WatchSimulator.platform") - || sdkroot.contains("visionos.platform") + || sdkroot.contains("XROS.platform") { env_remove.push("SDKROOT".into()) } @@ -307,7 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow]> { // although this is apparently ignored when using the linker at "/usr/bin/ld". env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); env_remove.push("TVOS_DEPLOYMENT_TARGET".into()); - env_remove.push("VISIONOS_DEPLOYMENT_TARGET".into()); + env_remove.push("XROS_DEPLOYMENT_TARGET".into()); env_remove.into() } else { // Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part @@ -375,7 +375,7 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String { fn visionos_deployment_target() -> (u32, u32) { // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("VISIONOS_DEPLOYMENT_TARGET").unwrap_or((1, 0)) + from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0)) } pub fn visionos_llvm_target(arch: Arch) -> String { diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs index 59eee2638fb87..7a985ad4dc056 100644 --- a/compiler/rustc_target/src/spec/base/apple/tests.rs +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -37,7 +37,7 @@ fn macos_link_environment_unmodified() { crate::spec::cvs![ "IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET", - "VISIONOS_DEPLOYMENT_TARGET" + "XROS_DEPLOYMENT_TARGET" ], ); } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs index 9982855017721..8625f87acd451 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs @@ -15,10 +15,10 @@ pub fn target() -> Target { std: None, }, pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), arch: arch.target_arch(), options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a12".into(), + features: "+neon,+fp-armv8,+apple-a16".into(), max_atomic_width: Some(128), frame_pointer: FramePointer::NonLeaf, ..base diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs index 73cd8e9d66d42..0f709001263c9 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs @@ -15,10 +15,10 @@ pub fn target() -> Target { std: None, }, pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), arch: arch.target_arch(), options: TargetOptions { - features: "+neon,+fp-armv8,+apple-m1".into(), + features: "+neon,+fp-armv8,+apple-a16".into(), max_atomic_width: Some(128), frame_pointer: FramePointer::NonLeaf, ..base diff --git a/library/std/src/os/unix/net/mod.rs b/library/std/src/os/unix/net/mod.rs index 28c1188677b6e..16d9cd915acc1 100644 --- a/library/std/src/os/unix/net/mod.rs +++ b/library/std/src/os/unix/net/mod.rs @@ -20,6 +20,7 @@ mod tests; target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "openbsd", @@ -46,6 +47,7 @@ pub use self::stream::*; target_os = "ios", target_os = "tvos", target_os = "watchos", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "openbsd", diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index 79a797ccbf6b5..092273a930b2a 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -7,6 +7,7 @@ target_os = "tvos", target_os = "macos", target_os = "watchos", + target_os = "visionos", target_os = "netbsd", target_os = "openbsd" ))] diff --git a/library/std/src/os/xros/fs.rs b/library/std/src/os/visionos/fs.rs similarity index 100% rename from library/std/src/os/xros/fs.rs rename to library/std/src/os/visionos/fs.rs diff --git a/library/std/src/os/xros/mod.rs b/library/std/src/os/visionos/mod.rs similarity index 100% rename from library/std/src/os/xros/mod.rs rename to library/std/src/os/visionos/mod.rs diff --git a/library/std/src/os/xros/raw.rs b/library/std/src/os/visionos/raw.rs similarity index 100% rename from library/std/src/os/xros/raw.rs rename to library/std/src/os/visionos/raw.rs diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 8e4e2830a0435..2814e83dcd757 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -511,7 +511,7 @@ impl<'a> fmt::Display for Display<'a> { "wasi" => "WASI", "watchos" => "watchOS", "windows" => "Windows", - "visionos" => "visionos", + "visionos" => "visionOS", _ => "", }, (sym::target_arch, Some(arch)) => match arch.as_str() { From 61fd74f48657b9c123e57815c3a0c09b2f2304d1 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Sat, 23 Mar 2024 16:51:01 -0700 Subject: [PATCH 09/12] Fixed bad formatting --- compiler/rustc_codegen_ssa/src/back/link.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index f2bc083f0f55c..bb68cdf293938 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -3025,11 +3025,9 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result {} "visionos" - if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => { - } + if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {} "visionossimulator" - if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => { - } + if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {} // Ignore `SDKROOT` if it's not a valid path. _ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {} _ => return Ok(sdkroot), From fb09ddb1eaa7ab4ca5db7fa6842a8fc19253e2bc Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Sun, 24 Mar 2024 07:01:39 -0700 Subject: [PATCH 10/12] Added madsmtm as second maintainer --- src/doc/rustc/src/platform-support/apple-visionos.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/rustc/src/platform-support/apple-visionos.md b/src/doc/rustc/src/platform-support/apple-visionos.md index 24bb94d3cf035..9874126e42fe1 100644 --- a/src/doc/rustc/src/platform-support/apple-visionos.md +++ b/src/doc/rustc/src/platform-support/apple-visionos.md @@ -13,6 +13,7 @@ Apple visionOS targets: ## Target maintainers - [@agg23](https://github.com/agg23) +- [@madsmtm](https://github.com/madsmtm) ## Requirements From 72aeeaf4800b498ffba9540c4e1d1da10d565af1 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 2 Apr 2024 08:11:58 -0700 Subject: [PATCH 11/12] Updated comments --- compiler/rustc_target/src/spec/base/apple/mod.rs | 4 ++-- src/bootstrap/src/core/build_steps/llvm.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index 04e1ebb4acda1..96da0b6fd1f58 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -203,7 +203,7 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> { | object::macho::PLATFORM_TVOSSIMULATOR | object::macho::PLATFORM_MACCATALYST => Some((16, 2)), object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)), - // FIXME: Upgrade to yet unreleased `object-rs` implementation with visionos platform definition + // FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition 11 | 12 => Some((1, 0)), _ => None, } @@ -219,7 +219,7 @@ pub fn platform(target: &Target) -> Option { ("watchos", _) => object::macho::PLATFORM_WATCHOS, ("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR, ("tvos", _) => object::macho::PLATFORM_TVOS, - // FIXME: Upgrade to yet unreleased `object-rs` implementation with visionos platform definition + // FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition ("visionos", "sim") => 12, ("visionos", _) => 11, _ => return None, diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 31209391d1455..2726566546875 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -364,7 +364,7 @@ impl Step for Llvm { cfg.define("LLVM_ENABLE_ZLIB", "OFF"); } - // Are we compiling for iOS/tvOS/watchOS/visionos? + // Are we compiling for iOS/tvOS/watchOS/visionOS? if target.contains("apple-ios") || target.contains("apple-tvos") || target.contains("apple-watchos") From 288a615ab79ca336af0643eec0d08cc53e1ea142 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Wed, 3 Apr 2024 07:08:28 -0700 Subject: [PATCH 12/12] Added target metadata --- .../src/spec/targets/aarch64_apple_visionos.rs | 8 ++++---- .../src/spec/targets/aarch64_apple_visionos_sim.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs index 8625f87acd451..7afe224163bcc 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs @@ -9,10 +9,10 @@ pub fn target() -> Target { Target { llvm_target: visionos_llvm_target(arch).into(), metadata: crate::spec::TargetMetadata { - description: None, - tier: None, - host_tools: None, - std: None, + description: Some("ARM64 Apple visionOS".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(false), }, pointer_width: 64, data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs index 0f709001263c9..422b2d7b922fc 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs @@ -9,10 +9,10 @@ pub fn target() -> Target { Target { llvm_target: visionos_sim_llvm_target(arch).into(), metadata: crate::spec::TargetMetadata { - description: None, - tier: None, - host_tools: None, - std: None, + description: Some("ARM64 Apple visionOS simulator".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(false), }, pointer_width: 64, data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),