fix: simplify cpu arch detection
This commit is contained in:
parent
2398c0ab33
commit
973a8dd8cc
@ -24,38 +24,11 @@ impl CpuStaticInfo {
|
||||
CpuStaticInfo {
|
||||
name,
|
||||
core_count: System::physical_core_count().unwrap_or(0),
|
||||
arch: CpuStaticInfo::get_runtime_arch(),
|
||||
arch: System::cpu_arch(),
|
||||
extensions: CpuStaticInfo::get_extensions(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_runtime_arch() -> String {
|
||||
// Use sysinfo to get the actual CPU architecture at runtime
|
||||
let mut system = System::new();
|
||||
system.refresh_cpu_all();
|
||||
|
||||
if let Some(cpu) = system.cpus().first() {
|
||||
let brand = cpu.brand().to_lowercase();
|
||||
|
||||
// Detect architecture based on CPU brand/model
|
||||
if brand.contains("aarch64") || brand.contains("arm64") || brand.contains("apple m") {
|
||||
"aarch64".to_string()
|
||||
} else if brand.contains("x86")
|
||||
|| brand.contains("amd64")
|
||||
|| brand.contains("i386")
|
||||
|| brand.contains("i686")
|
||||
{
|
||||
"x86_64".to_string()
|
||||
} else {
|
||||
// Fallback to compile-time architecture if we can't detect
|
||||
std::env::consts::ARCH.to_string()
|
||||
}
|
||||
} else {
|
||||
// Fallback to compile-time architecture if no CPU info available
|
||||
std::env::consts::ARCH.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: see if we need to check for all CPU extensions
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
fn get_extensions() -> Vec<String> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user