Skip to content

Commit 12e7cbc

Browse files
committed
std_detect: Workaround Exynos 9810 bug on aarch64 Android
Samsung Exynos 9810 has a bug that big and little cores have different ISAs. And on older Android (pre-9), the kernel incorrectly reports that features available only on some cores are available on all cores. https://reviews.llvm.org/D114523
1 parent 7fbf697 commit 12e7cbc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crates/std_detect/src/detect/os/linux/aarch64.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ use crate::detect::{bit, cache, Feature};
66
/// Try to read the features from the auxiliary vector, and if that fails, try
77
/// to read them from /proc/cpuinfo.
88
pub(crate) fn detect_features() -> cache::Initializer {
9+
#[cfg(all(target_arch = "aarch64", target_os = "android"))]
10+
{
11+
// Samsung Exynos 9810 has a bug that big and little cores have different
12+
// ISAs. And on older Android (pre-9), the kernel incorrectly reports
13+
// that features available only on some cores are available on all cores.
14+
// https://reviews.llvm.org/D114523
15+
let mut arch = [0_u8; libc::PROP_VALUE_MAX as usize];
16+
let len = unsafe {
17+
libc::__system_property_get(
18+
b"ro.arch\0".as_ptr() as *const libc::c_char,
19+
arch.as_mut_ptr() as *mut libc::c_char,
20+
)
21+
};
22+
if len > 0 && arch.starts_with(b"exynos9810\0") {
23+
return cache::Initializer::default();
24+
}
25+
}
926
if let Ok(auxv) = auxvec::auxv() {
1027
let hwcap: AtHwcap = auxv.into();
1128
return hwcap.cache();

0 commit comments

Comments
 (0)