Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apple visionOS support #2032

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ untrusted = { version = "0.9" }
[target.'cfg(any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86",target_arch = "x86_64"))'.dependencies]
spin = { version = "0.9.8", default-features = false, features = ["once"] }

[target.'cfg(all(any(target_os = "android", target_os = "linux", any(target_os = "ios", target_os = "macos", target_os = "tvos")), any(target_arch = "aarch64", target_arch = "arm")))'.dependencies]
[target.'cfg(all(any(target_os = "android", target_os = "linux", target_vendor = "apple"), any(target_arch = "aarch64", target_arch = "arm")))'.dependencies]
libc = { version = "0.2.148", default-features = false }

[target.'cfg(all(target_arch = "aarch64", target_os = "windows"))'.dependencies]
Expand All @@ -174,7 +174,7 @@ wasm-bindgen-test = { version = "0.3.37", default-features = false }
libc = { version = "0.2.148", default-features = false }

[build-dependencies]
cc = { version = "1.0.83", default-features = false }
cc = { version = "1.0.94", default-features = false }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the oldest cc-rs that is known to work for this? Because of issues like rust-lang/cc-rs#984 I'm weary of forcing users to update to too-new version of cc-rs right now, if we can avoid it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VisionOS support was added in 1.0.93, but 1.0.94 includes a fix to how it integrates with xcrun that may be necessary. I don't see anything in the changelog after 1.0.94 related to visionos.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think we need to go through the release notes of cc-rs 1.0.94 and higher, and recent issues in that crate, to verify that requiring such a new release is not going to be problematic, given recent instability regarding Apple targets in that crate.

Copy link

@eugenehp eugenehp Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what would be the best course of action here? seems like rust-lang/cc-rs#984 is still a blocker.

original PR was merged on April 12, and release followed on April 13
https://github.com/rust-lang/cc-rs/releases/tag/1.0.93

ps: we did run tests on cc = { version = "1.0.98", default-features = false } and it worked fine for all devices with the host systems on Apple Silicon (M1, M2, M3). Haven't tested on older X86_64.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could leave the cc-rs dependency as-is but add a comment above it saying cc-rs 1.0.94 or later is required for visionos support, but we're waiting to increase our dependency until rust-lang/cc-rs#984 and maybe other issues are addressed, and also add a note to that same effect to BUILDING.md. Then we can merge this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, a conditional dependency in Cargo.toml sounds like a feasible option.

@QuentinPerez wanna do it?


[features]
# These features are documented in the top-level module's documentation.
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const NASM: &str = "nasm";

/// Operating systems that have the same ABI as macOS on every architecture
/// mentioned in `ASM_TARGETS`.
const MACOS_ABI: &[&str] = &["ios", MACOS, "tvos"];
const MACOS_ABI: &[&str] = &["ios", MACOS, "tvos", "visionos"];

const MACOS: &str = "macos";
const WINDOWS: &str = "windows";
Expand Down
3 changes: 1 addition & 2 deletions src/cpu/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ mod abi_assumptions {
// detection.

cfg_if::cfg_if! {
if #[cfg(all(target_arch = "aarch64",
any(target_os = "ios", target_os = "macos", target_os = "tvos")))] {
if #[cfg(all(target_arch = "aarch64", target_vendor = "apple"))] {
mod darwin;
use darwin as detect;
} else if #[cfg(all(target_arch = "aarch64", target_os = "fuchsia"))] {
Expand Down
4 changes: 1 addition & 3 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,14 @@ impl crate::sealed::Sealed for SystemRandom {}
target_os = "haiku",
target_os = "hermit",
target_os = "illumos",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "tvos",
target_os = "vita",
target_os = "windows",
target_vendor = "apple",
all(
target_arch = "wasm32",
any(
Expand Down
Loading