Improve check for Apple M1 silicon under Rosetta
This commit is contained in:
parent
9255ae334d
commit
59641623d1
|
@ -1438,6 +1438,25 @@ fn wait_for_supermajority(
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_rosetta_emulated() -> bool {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use std::str::FromStr;
|
||||||
|
std::process::Command::new("sysctl")
|
||||||
|
.args(&["-in", "sysctl.proc_translated"])
|
||||||
|
.output()
|
||||||
|
.map_err(|_| ())
|
||||||
|
.and_then(|output| String::from_utf8(output.stdout).map_err(|_| ()))
|
||||||
|
.and_then(|stdout| u8::from_str(stdout.trim()).map_err(|_| ()))
|
||||||
|
.map(|enabled| enabled == 1)
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn report_target_features() {
|
fn report_target_features() {
|
||||||
warn!(
|
warn!(
|
||||||
"CUDA is {}abled",
|
"CUDA is {}abled",
|
||||||
|
@ -1448,21 +1467,7 @@ fn report_target_features() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// We exclude Mac OS here to be compatible with computers that have Mac M1 chips.
|
if !is_rosetta_emulated() {
|
||||||
// For these computers, one must install rust/cargo/brew etc. using Rosetta 2,
|
|
||||||
// which allows them to run software targeted for x86_64 on an aarch64.
|
|
||||||
// Hence the code below will run on these machines (target_arch="x86_64")
|
|
||||||
// if we don't exclude with target_os="macos".
|
|
||||||
//
|
|
||||||
// It's going to require more more work to get Solana building
|
|
||||||
// on Mac M1's without Rosetta,
|
|
||||||
// and when that happens we should remove this
|
|
||||||
// (the feature flag for code targeting that is target_arch="aarch64")
|
|
||||||
#[cfg(all(
|
|
||||||
any(target_arch = "x86", target_arch = "x86_64"),
|
|
||||||
not(target_os = "macos")
|
|
||||||
))]
|
|
||||||
{
|
|
||||||
unsafe { check_avx() };
|
unsafe { check_avx() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1470,7 +1475,7 @@ fn report_target_features() {
|
||||||
// Validator binaries built on a machine with AVX support will generate invalid opcodes
|
// Validator binaries built on a machine with AVX support will generate invalid opcodes
|
||||||
// when run on machines without AVX causing a non-obvious process abort. Instead detect
|
// when run on machines without AVX causing a non-obvious process abort. Instead detect
|
||||||
// the mismatch and error cleanly.
|
// the mismatch and error cleanly.
|
||||||
#[allow(dead_code)]
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
#[target_feature(enable = "avx")]
|
#[target_feature(enable = "avx")]
|
||||||
unsafe fn check_avx() {
|
unsafe fn check_avx() {
|
||||||
if is_x86_feature_detected!("avx") {
|
if is_x86_feature_detected!("avx") {
|
||||||
|
@ -1483,6 +1488,9 @@ unsafe fn check_avx() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
|
||||||
|
unsafe fn check_avx() {}
|
||||||
|
|
||||||
// Get the activated stake percentage (based on the provided bank) that is visible in gossip
|
// Get the activated stake percentage (based on the provided bank) that is visible in gossip
|
||||||
fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: bool) -> u64 {
|
fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: bool) -> u64 {
|
||||||
let mut online_stake = 0;
|
let mut online_stake = 0;
|
||||||
|
|
Loading…
Reference in New Issue