Skip to content

Commit c7deeb4

Browse files
committed
Add Apple visionOS support
1 parent 7bc7672 commit c7deeb4

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ untrusted = { version = "0.9" }
162162
[target.'cfg(any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86",target_arch = "x86_64"))'.dependencies]
163163
spin = { version = "0.9.8", default-features = false, features = ["once"] }
164164

165-
[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]
165+
[target.'cfg(all(any(target_os = "android", target_os = "linux", any(target_os = "ios", target_os = "visionos", target_os = "macos", target_os = "tvos")), any(target_arch = "aarch64", target_arch = "arm")))'.dependencies]
166166
libc = { version = "0.2.148", default-features = false }
167167

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

177177
[build-dependencies]
178-
cc = { version = "1.0.83", default-features = false }
178+
cc = { version = "1.0.94", default-features = false }
179179

180180
[features]
181181
# These features are documented in the top-level module's documentation.

build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ const ASM_TARGETS: &[AsmTarget] = &[
197197
arch: AARCH64,
198198
perlasm_format: "ios64",
199199
},
200+
AsmTarget {
201+
oss: MACOS_ABI,
202+
arch: AARCH64,
203+
perlasm_format: "visionos64",
204+
},
200205
AsmTarget {
201206
oss: MACOS_ABI,
202207
arch: X86_64,
@@ -257,7 +262,7 @@ const NASM: &str = "nasm";
257262

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

262267
const MACOS: &str = "macos";
263268
const WINDOWS: &str = "windows";

crypto/perlasm/arm-xlate.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
else { ""; }
3131
};
3232
my $hidden = sub {
33-
if ($flavour =~ /ios/) { ".private_extern\t".join(',',@_); }
33+
if ($flavour =~ /ios|visionos/) { ".private_extern\t".join(',',@_); }
3434
elsif ($flavour =~ /win64/) { ""; }
3535
else { ".hidden\t".join(',',@_); }
3636
};
@@ -58,7 +58,7 @@
5858
my $ret;
5959

6060
SWITCH: for ($flavour) {
61-
/ios/ && do { $name = "_$name";
61+
/ios|visionos/ && do { $name = "_$name";
6262
last;
6363
};
6464
}
@@ -109,7 +109,7 @@
109109
{ ""; }
110110
};
111111
my $section = sub {
112-
if ($flavour =~ /ios/) {
112+
if ($flavour =~ /ios|visionos/) {
113113
if ($_[0] eq ".rodata") {
114114
return ".section\t__TEXT,__const";
115115
}
@@ -163,7 +163,7 @@ sub expand_line {
163163
# Although the flavour is specified as "linux", it is really used by all
164164
# ELF platforms.
165165
$target_defines = "defined(__ELF__)";
166-
} elsif ($flavour =~ /ios/) {
166+
} elsif ($flavour =~ /ios|visionos/) {
167167
# Although the flavour is specified as "ios", it is really used by all Apple
168168
# platforms.
169169
$target_defines = "defined(__APPLE__)";
@@ -223,7 +223,7 @@ sub expand_line {
223223
$opcode = eval("\$$mnemonic");
224224
}
225225

226-
if ($flavour =~ /ios/) {
226+
if ($flavour =~ /ios|visionos/) {
227227
# Mach-O and ELF use different syntax for these relocations. Note
228228
# that we require :pg_hi21: to be explicitly listed. It is normally
229229
# optional with adrp instructions.

src/cpu/arm.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ fn detect_features() -> u32 {
170170

171171
#[cfg(all(
172172
target_arch = "aarch64",
173-
any(target_os = "ios", target_os = "macos", target_os = "tvos")
173+
any(
174+
target_os = "ios",
175+
target_os = "visionos",
176+
target_os = "macos",
177+
target_os = "tvos"
178+
)
174179
))]
175180
fn detect_features() -> u32 {
176181
// TODO(MSRV 1.64): Use `name: &core::ffi::CStr`.
@@ -225,7 +230,12 @@ fn detect_features() -> u32 {
225230
target_os = "fuchsia",
226231
all(target_os = "linux", not(target_env = "uclibc")),
227232
target_os = "windows",
228-
any(target_os = "ios", target_os = "macos", target_os = "tvos"),
233+
any(
234+
target_os = "ios",
235+
target_os = "visionos",
236+
target_os = "macos",
237+
target_os = "tvos"
238+
),
229239
))
230240
))]
231241
fn detect_features() -> u32 {

src/ec/curve25519/x25519.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ fn x25519_public_from_private(
6363
let private_key: &[u8; SCALAR_LEN] = private_key.bytes_less_safe().try_into()?;
6464
let private_key = ops::MaskedScalar::from_bytes_masked(*private_key);
6565

66-
#[cfg(all(not(target_os = "ios"), target_arch = "arm"))]
66+
#[cfg(all(
67+
not(any(target_os = "ios", target_os = "visionos")),
68+
target_arch = "arm"
69+
))]
6770
{
6871
if cpu::arm::NEON.available(cpu_features) {
6972
static MONTGOMERY_BASE_POINT: [u8; 32] = [
@@ -109,7 +112,10 @@ fn x25519_ecdh(
109112
point: &ops::EncodedPoint,
110113
#[allow(unused_variables)] cpu_features: cpu::Features,
111114
) {
112-
#[cfg(all(not(target_os = "ios"), target_arch = "arm"))]
115+
#[cfg(all(
116+
not(any(target_os = "ios", target_os = "visionos")),
117+
target_arch = "arm"
118+
))]
113119
{
114120
if cpu::arm::NEON.available(cpu_features) {
115121
return x25519_neon(out, scalar, point);
@@ -158,7 +164,10 @@ fn x25519_ecdh(
158164
Ok(())
159165
}
160166

161-
#[cfg(all(not(target_os = "ios"), target_arch = "arm"))]
167+
#[cfg(all(
168+
not(any(target_os = "ios", target_os = "visionos")),
169+
target_arch = "arm"
170+
))]
162171
fn x25519_neon(out: &mut ops::EncodedPoint, scalar: &ops::MaskedScalar, point: &ops::EncodedPoint) {
163172
prefixed_extern! {
164173
fn x25519_NEON(

src/rand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl crate::sealed::Sealed for SystemRandom {}
134134
target_os = "hermit",
135135
target_os = "illumos",
136136
target_os = "ios",
137+
target_os = "visionos",
137138
target_os = "linux",
138139
target_os = "macos",
139140
target_os = "netbsd",

0 commit comments

Comments
 (0)