Skip to content

Commit 63033e7

Browse files
Rollup merge of rust-lang#121419 - agg23:xrOS-pr, r=davidtwco
Add aarch64-apple-visionos and aarch64-apple-visionos-sim tier 3 targets Introduces `aarch64-apple-visionos` and `aarch64-apple-visionos-sim` as tier 3 targets. This allows native development for the Apple Vision Pro's visionOS platform. This work has been tracked in rust-lang/compiler-team#642. There is a corresponding `libc` change rust-lang/libc#3568 that is not required for merge. Ideally we would be able to incorporate [this change](gimli-rs/object#626) to the `object` crate, but the author has stated that a release will not be cut for quite a while. Therefore, the two locations that would reference the xrOS constant from `object` are hardcoded to their MachO values of 11 and 12, accompanied by TODOs to mark the code as needing change. I am open to suggestions on what to do here to get this checked in. # Tier 3 Target Policy At this tier, the Rust project provides no official support for a target, so we place minimal requirements on the introduction of targets. > A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.) See [src/doc/rustc/src/platform-support/apple-visionos.md](https://github.com/rust-lang/rust/blob/e88379034a0fe7d90a8f305bbaf4ad66dd2ce8dc/src/doc/rustc/src/platform-support/apple-visionos.md) > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target. > * Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it. > * If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo. This naming scheme matches `$ARCH-$VENDOR-$OS-$ABI` which is matches the iOS Apple Silicon simulator (`aarch64-apple-ios-sim`) and other Apple targets. > Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. > - The target must not introduce license incompatibilities. > - Anything added to the Rust repository must be under the standard Rust license (`MIT OR Apache-2.0`). > - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the `tidy` tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to besubject to any new license requirements. > - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, `rustc` built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. > - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are *not* limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users. This contribution is fully available under the standard Rust license with no additional legal restrictions whatsoever. This PR does not introduce any new dependency less permissive than the Rust license policy. The new targets do not depend on proprietary libraries. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. This new target mirrors the standard library for watchOS and iOS, with minor divergences. > The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary. Documentation is provided in [src/doc/rustc/src/platform-support/apple-visionos.md](https://github.com/rust-lang/rust/blob/e88379034a0fe7d90a8f305bbaf4ad66dd2ce8dc/src/doc/rustc/src/platform-support/apple-visionos.md) > Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. > * This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements. > Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages. > * Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications. > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. > * In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. I acknowledge these requirements and intend to ensure that they are met. This target does not touch any existing tier 2 or tier 1 targets and should not break any other targets.
2 parents b1080b2 + 342da67 commit 63033e7

File tree

29 files changed

+394
-21
lines changed

29 files changed

+394
-21
lines changed

std/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn main() {
2222
|| target_os == "ios"
2323
|| target_os == "tvos"
2424
|| target_os == "watchos"
25+
|| target_os == "visionos"
2526
|| target_os == "windows"
2627
|| target_os == "fuchsia"
2728
|| (target_vendor == "fortanix" && target_env == "sgx")

std/src/fs/tests.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,8 +1644,8 @@ fn test_file_times() {
16441644
use crate::os::macos::fs::FileTimesExt;
16451645
#[cfg(target_os = "tvos")]
16461646
use crate::os::tvos::fs::FileTimesExt;
1647-
#[cfg(target_os = "tvos")]
1648-
use crate::os::tvos::fs::FileTimesExt;
1647+
#[cfg(target_os = "visionos")]
1648+
use crate::os::visionos::fs::FileTimesExt;
16491649
#[cfg(target_os = "watchos")]
16501650
use crate::os::watchos::fs::FileTimesExt;
16511651
#[cfg(windows)]
@@ -1662,6 +1662,7 @@ fn test_file_times() {
16621662
target_os = "macos",
16631663
target_os = "ios",
16641664
target_os = "watchos",
1665+
target_os = "visionos",
16651666
target_os = "tvos",
16661667
))]
16671668
let created = SystemTime::UNIX_EPOCH + Duration::from_secs(32123);
@@ -1670,6 +1671,7 @@ fn test_file_times() {
16701671
target_os = "macos",
16711672
target_os = "ios",
16721673
target_os = "watchos",
1674+
target_os = "visionos",
16731675
target_os = "tvos",
16741676
))]
16751677
{
@@ -1701,6 +1703,7 @@ fn test_file_times() {
17011703
target_os = "macos",
17021704
target_os = "ios",
17031705
target_os = "watchos",
1706+
target_os = "visionos",
17041707
target_os = "tvos",
17051708
))]
17061709
{
@@ -1709,14 +1712,22 @@ fn test_file_times() {
17091712
}
17101713

17111714
#[test]
1712-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
1715+
#[cfg(any(
1716+
target_os = "macos",
1717+
target_os = "ios",
1718+
target_os = "tvos",
1719+
target_os = "watchos",
1720+
target_os = "visionos"
1721+
))]
17131722
fn test_file_times_pre_epoch_with_nanos() {
17141723
#[cfg(target_os = "ios")]
17151724
use crate::os::ios::fs::FileTimesExt;
17161725
#[cfg(target_os = "macos")]
17171726
use crate::os::macos::fs::FileTimesExt;
17181727
#[cfg(target_os = "tvos")]
17191728
use crate::os::tvos::fs::FileTimesExt;
1729+
#[cfg(target_os = "visionos")]
1730+
use crate::os::visionos::fs::FileTimesExt;
17201731
#[cfg(target_os = "watchos")]
17211732
use crate::os::watchos::fs::FileTimesExt;
17221733

std/src/os/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ pub mod solid;
149149
pub(crate) mod tvos;
150150
#[cfg(target_os = "uefi")]
151151
pub mod uefi;
152+
#[cfg(target_os = "visionos")]
153+
pub(crate) mod visionos;
152154
#[cfg(target_os = "vita")]
153155
pub mod vita;
154156
#[cfg(target_os = "vxworks")]

std/src/os/unix/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ mod platform {
7979
pub use crate::os::solaris::*;
8080
#[cfg(target_os = "tvos")]
8181
pub use crate::os::tvos::*;
82+
#[cfg(target_os = "visionos")]
83+
pub use crate::os::visionos::*;
8284
#[cfg(target_os = "vita")]
8385
pub use crate::os::vita::*;
8486
#[cfg(target_os = "vxworks")]

std/src/os/unix/net/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod tests;
2020
target_os = "ios",
2121
target_os = "tvos",
2222
target_os = "watchos",
23+
target_os = "visionos",
2324
target_os = "macos",
2425
target_os = "netbsd",
2526
target_os = "openbsd",
@@ -46,6 +47,7 @@ pub use self::stream::*;
4647
target_os = "ios",
4748
target_os = "tvos",
4849
target_os = "watchos",
50+
target_os = "visionos",
4951
target_os = "macos",
5052
target_os = "netbsd",
5153
target_os = "openbsd",

std/src/os/unix/net/stream.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
target_os = "tvos",
88
target_os = "macos",
99
target_os = "watchos",
10+
target_os = "visionos",
1011
target_os = "netbsd",
1112
target_os = "openbsd",
1213
target_os = "nto"
@@ -234,6 +235,7 @@ impl UnixStream {
234235
target_os = "tvos",
235236
target_os = "macos",
236237
target_os = "watchos",
238+
target_os = "visionos",
237239
target_os = "netbsd",
238240
target_os = "openbsd",
239241
target_os = "nto"

std/src/os/unix/net/ucred.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ pub(super) use self::impl_linux::peer_cred;
3535
))]
3636
pub(super) use self::impl_bsd::peer_cred;
3737

38-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
38+
#[cfg(any(
39+
target_os = "macos",
40+
target_os = "ios",
41+
target_os = "tvos",
42+
target_os = "watchos",
43+
target_os = "visionos"
44+
))]
3945
pub(super) use self::impl_mac::peer_cred;
4046

4147
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -97,7 +103,13 @@ mod impl_bsd {
97103
}
98104
}
99105

100-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
106+
#[cfg(any(
107+
target_os = "macos",
108+
target_os = "ios",
109+
target_os = "tvos",
110+
target_os = "watchos",
111+
target_os = "visionos"
112+
))]
101113
mod impl_mac {
102114
use super::UCred;
103115
use crate::os::unix::io::AsRawFd;

std/src/os/unix/net/ucred/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use libc::{getegid, geteuid, getpid};
1111
target_os = "tvos",
1212
target_os = "macos",
1313
target_os = "watchos",
14+
target_os = "visionos",
1415
target_os = "openbsd"
1516
))]
1617
fn test_socket_pair() {
@@ -32,6 +33,7 @@ fn test_socket_pair() {
3233
target_os = "ios",
3334
target_os = "macos",
3435
target_os = "watchos",
36+
target_os = "visionos",
3537
target_os = "tvos",
3638
))]
3739
fn test_socket_pair_pids(arg: Type) -> RetType {

std/src/os/visionos/fs.rs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#![stable(feature = "metadata_ext", since = "1.1.0")]
2+
3+
use crate::fs::{self, Metadata};
4+
use crate::sealed::Sealed;
5+
use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
6+
use crate::time::SystemTime;
7+
8+
#[allow(deprecated)]
9+
use super::raw;
10+
11+
/// OS-specific extensions to [`fs::Metadata`].
12+
///
13+
/// [`fs::Metadata`]: crate::fs::Metadata
14+
#[stable(feature = "metadata_ext", since = "1.1.0")]
15+
pub trait MetadataExt {
16+
/// Gain a reference to the underlying `stat` structure which contains
17+
/// the raw information returned by the OS.
18+
///
19+
/// The contents of the returned `stat` are **not** consistent across
20+
/// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
21+
/// cross-Unix abstractions contained within the raw stat.
22+
#[stable(feature = "metadata_ext", since = "1.1.0")]
23+
#[deprecated(
24+
since = "1.8.0",
25+
note = "deprecated in favor of the accessor \
26+
methods of this trait"
27+
)]
28+
#[allow(deprecated)]
29+
fn as_raw_stat(&self) -> &raw::stat;
30+
31+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
32+
fn st_dev(&self) -> u64;
33+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
34+
fn st_ino(&self) -> u64;
35+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
36+
fn st_mode(&self) -> u32;
37+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
38+
fn st_nlink(&self) -> u64;
39+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
40+
fn st_uid(&self) -> u32;
41+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
42+
fn st_gid(&self) -> u32;
43+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
44+
fn st_rdev(&self) -> u64;
45+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
46+
fn st_size(&self) -> u64;
47+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
48+
fn st_atime(&self) -> i64;
49+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
50+
fn st_atime_nsec(&self) -> i64;
51+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
52+
fn st_mtime(&self) -> i64;
53+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
54+
fn st_mtime_nsec(&self) -> i64;
55+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
56+
fn st_ctime(&self) -> i64;
57+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
58+
fn st_ctime_nsec(&self) -> i64;
59+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
60+
fn st_birthtime(&self) -> i64;
61+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
62+
fn st_birthtime_nsec(&self) -> i64;
63+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
64+
fn st_blksize(&self) -> u64;
65+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
66+
fn st_blocks(&self) -> u64;
67+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
68+
fn st_flags(&self) -> u32;
69+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
70+
fn st_gen(&self) -> u32;
71+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
72+
fn st_lspare(&self) -> u32;
73+
}
74+
75+
#[stable(feature = "metadata_ext", since = "1.1.0")]
76+
impl MetadataExt for Metadata {
77+
#[allow(deprecated)]
78+
fn as_raw_stat(&self) -> &raw::stat {
79+
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
80+
}
81+
fn st_dev(&self) -> u64 {
82+
self.as_inner().as_inner().st_dev as u64
83+
}
84+
fn st_ino(&self) -> u64 {
85+
self.as_inner().as_inner().st_ino as u64
86+
}
87+
fn st_mode(&self) -> u32 {
88+
self.as_inner().as_inner().st_mode as u32
89+
}
90+
fn st_nlink(&self) -> u64 {
91+
self.as_inner().as_inner().st_nlink as u64
92+
}
93+
fn st_uid(&self) -> u32 {
94+
self.as_inner().as_inner().st_uid as u32
95+
}
96+
fn st_gid(&self) -> u32 {
97+
self.as_inner().as_inner().st_gid as u32
98+
}
99+
fn st_rdev(&self) -> u64 {
100+
self.as_inner().as_inner().st_rdev as u64
101+
}
102+
fn st_size(&self) -> u64 {
103+
self.as_inner().as_inner().st_size as u64
104+
}
105+
fn st_atime(&self) -> i64 {
106+
self.as_inner().as_inner().st_atime as i64
107+
}
108+
fn st_atime_nsec(&self) -> i64 {
109+
self.as_inner().as_inner().st_atime_nsec as i64
110+
}
111+
fn st_mtime(&self) -> i64 {
112+
self.as_inner().as_inner().st_mtime as i64
113+
}
114+
fn st_mtime_nsec(&self) -> i64 {
115+
self.as_inner().as_inner().st_mtime_nsec as i64
116+
}
117+
fn st_ctime(&self) -> i64 {
118+
self.as_inner().as_inner().st_ctime as i64
119+
}
120+
fn st_ctime_nsec(&self) -> i64 {
121+
self.as_inner().as_inner().st_ctime_nsec as i64
122+
}
123+
fn st_birthtime(&self) -> i64 {
124+
self.as_inner().as_inner().st_birthtime as i64
125+
}
126+
fn st_birthtime_nsec(&self) -> i64 {
127+
self.as_inner().as_inner().st_birthtime_nsec as i64
128+
}
129+
fn st_blksize(&self) -> u64 {
130+
self.as_inner().as_inner().st_blksize as u64
131+
}
132+
fn st_blocks(&self) -> u64 {
133+
self.as_inner().as_inner().st_blocks as u64
134+
}
135+
fn st_gen(&self) -> u32 {
136+
self.as_inner().as_inner().st_gen as u32
137+
}
138+
fn st_flags(&self) -> u32 {
139+
self.as_inner().as_inner().st_flags as u32
140+
}
141+
fn st_lspare(&self) -> u32 {
142+
self.as_inner().as_inner().st_lspare as u32
143+
}
144+
}
145+
146+
/// OS-specific extensions to [`fs::FileTimes`].
147+
#[stable(feature = "file_set_times", since = "1.75.0")]
148+
pub trait FileTimesExt: Sealed {
149+
/// Set the creation time of a file.
150+
#[stable(feature = "file_set_times", since = "1.75.0")]
151+
fn set_created(self, t: SystemTime) -> Self;
152+
}
153+
154+
#[stable(feature = "file_set_times", since = "1.75.0")]
155+
impl FileTimesExt for fs::FileTimes {
156+
fn set_created(mut self, t: SystemTime) -> Self {
157+
self.as_inner_mut().set_created(t.into_inner());
158+
self
159+
}
160+
}

std/src/os/visionos/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! visionos-specific definitions
2+
3+
#![stable(feature = "raw_ext", since = "1.1.0")]
4+
5+
pub mod fs;
6+
pub mod raw;

0 commit comments

Comments
 (0)