Skip to content

Commit b1edbf9

Browse files
madsmtmAmanieu
authored andcommitted
Enable feature detection on all Apple/Darwin targets
Tested in the simulator and on the device I had lying around, a 1st generation iPad Mini (which isn't Aarch64, but shows that the `sysctlbyname` calls still work even there, even if they return false). `sysctlbyname` _should_ be safe to use without causing rejections from the app store, as its usage is documented in: https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics Also, the standard library will use these soon anyhow, so this shouldn't affect the situation: rust-lang/rust#129019
1 parent 57a3375 commit b1edbf9

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

crates/std_detect/src/detect/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ cfg_if! {
6666
} else if #[cfg(all(target_os = "windows", any(target_arch = "aarch64", target_arch = "arm64ec")))] {
6767
#[path = "os/windows/aarch64.rs"]
6868
mod os;
69-
} else if #[cfg(all(target_os = "macos", target_arch = "aarch64", feature = "libc"))] {
70-
#[path = "os/macos/aarch64.rs"]
69+
} else if #[cfg(all(target_vendor = "apple", target_arch = "aarch64", feature = "libc"))] {
70+
#[path = "os/darwin/aarch64.rs"]
7171
mod os;
7272
} else {
7373
#[path = "os/other.rs"]

crates/std_detect/src/detect/os/macos/aarch64.rs crates/std_detect/src/detect/os/darwin/aarch64.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//! Run-time feature detection for aarch64 on macOS.
1+
//! Run-time feature detection for aarch64 on Darwin (macOS/iOS/tvOS/watchOS/visionOS).
2+
//!
3+
//! <https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics>
24
35
use crate::detect::{cache, Feature};
46

crates/std_detect/tests/cpu-detection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ fn aarch64_bsd() {
188188
}
189189

190190
#[test]
191-
#[cfg(all(target_arch = "aarch64", target_os = "macos"))]
192-
fn aarch64_macos() {
191+
#[cfg(all(target_arch = "aarch64", target_vendor = "apple"))]
192+
fn aarch64_darwin() {
193193
println!("asimd: {:?}", is_aarch64_feature_detected!("asimd"));
194194
println!("fp: {:?}", is_aarch64_feature_detected!("fp"));
195195
println!("fp16: {:?}", is_aarch64_feature_detected!("fp16"));

crates/stdarch-test/src/disassembly.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
7474
let me = env::current_exe().expect("failed to get current exe");
7575

7676
let objdump = env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string());
77-
let add_args = if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
78-
// Target features need to be enabled for LLVM objdump on Macos ARM64
77+
let add_args = if cfg!(target_vendor = "apple") && cfg!(target_arch = "aarch64") {
78+
// Target features need to be enabled for LLVM objdump on Darwin ARM64
7979
vec!["--mattr=+v8.6a,+crypto,+tme"]
8080
} else if cfg!(target_arch = "riscv64") {
8181
vec!["--mattr=+zk,+zks,+zbc,+zbb"]

triagebot.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ resolved/implemented on Fuchsia. Could one of you weigh in please?
4343
Thanks!
4444
"""
4545

46-
[ping.macos]
46+
[ping.apple]
47+
alias = ["macos", "ios", "tvos", "watchos", "visionos"]
4748
message = """\
48-
Hey MacOS Group! This issue or PR could use some MacOS-specific guidance. Could
49+
Hey Apple Group! This issue or PR could use some Darwin-specific guidance. Could
4950
one of you weigh in please?
5051
Thanks!
5152
"""
52-

0 commit comments

Comments
 (0)