diff --git a/Cargo.lock b/Cargo.lock index edd7a72..6e20010 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -580,7 +580,7 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "microfetch" -version = "1.2.1" +version = "1.2.2" dependencies = [ "microfetch-asm", "microfetch-lib", @@ -588,11 +588,11 @@ dependencies = [ [[package]] name = "microfetch-asm" -version = "1.2.1" +version = "1.2.2" [[package]] name = "microfetch-bench" -version = "1.2.1" +version = "1.2.2" dependencies = [ "criterion", "hotpath", @@ -601,7 +601,7 @@ dependencies = [ [[package]] name = "microfetch-lib" -version = "1.2.1" +version = "1.2.2" dependencies = [ "hotpath", "microfetch-asm", diff --git a/Cargo.toml b/Cargo.toml index cdcdb1d..b8c3e27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,11 @@ edition = "2024" license = "GPL-3.0" repository = "https://github.com/notashelf/microfetch" rust-version = "1.95.0" -version = "1.2.1" +version = "1.2.2" [workspace.dependencies] -microfetch-asm = { path = "./crates/asm", version = "1.2.1" } -microfetch-lib = { path = "./crates/lib", version = "1.2.1" } +microfetch-asm = { path = "./crates/asm", version = "1.2.2" } +microfetch-lib = { path = "./crates/lib", version = "1.2.2" } criterion = { default-features = false, features = [ "cargo_bench_support" ], version = "0.8.2" } diff --git a/build.rs b/build.rs index 132d06c..b329cd1 100644 --- a/build.rs +++ b/build.rs @@ -37,6 +37,8 @@ fn main() -> io::Result<()> { if env::var("DEBUG").as_deref() != Ok("true") { println!("cargo:rustc-link-arg-bin=microfetch=-Wl,--strip-all"); } + // Nothing unwinds with panic=abort, so skip the unwinder's lookup table + println!("cargo:rustc-link-arg-bin=microfetch=-Wl,--no-eh-frame-hdr"); // Omit the .note.gnu.build-id section println!("cargo:rustc-link-arg-bin=microfetch=-Wl,--build-id=none"); // Disable RELRO (removes relro_padding) diff --git a/crates/lib/src/cpu.rs b/crates/lib/src/cpu.rs index 97d057e..2fec5b3 100644 --- a/crates/lib/src/cpu.rs +++ b/crates/lib/src/cpu.rs @@ -132,6 +132,10 @@ fn get_core_count(threads: u32) -> u32 { /// by reading `/sys/devices/cpu_core/cpus` and `/sys/devices/cpu_atom/cpus`. #[cfg(target_os = "linux")] fn get_pe_cores() -> Option<(u32, u32)> { + if !cfg!(any(target_arch = "x86", target_arch = "x86_64")) { + return None; + } + let perf = count_pmu_cores("/sys/devices/cpu_core/cpus")?; let eff = count_pmu_cores("/sys/devices/cpu_atom/cpus").unwrap_or(0); (perf > 0 && eff > 0).then_some((perf, eff)) @@ -327,7 +331,8 @@ fn get_cpu_freq_mhz(cpuinfo: &[u8]) -> Option { // Octeon presets loops_per_jiffy to clock_rate/HZ, so its BogoMIPS is // exactly 2x the core clock, unlike the 1:1 of other MIPS. // https://github.com/torvalds/linux/blob/v6.19/arch/mips/cavium-octeon/csrc-octeon.c#L40 - if *key == b"BogoMIPS" + if cfg!(any(target_arch = "mips", target_arch = "mips64")) + && *key == b"BogoMIPS" && cpuinfo.windows(6).any(|window| window == b"Octeon") { mhz /= 2; @@ -340,7 +345,9 @@ fn get_cpu_freq_mhz(cpuinfo: &[u8]) -> Option { } // SPARC exposes its clock as `Cpu0ClkTck : `, // which signifies ticks per second in hex. - if let Some(val) = extract_field(cpuinfo, b"Cpu0ClkTck") { + if cfg!(any(target_arch = "sparc64", target_arch = "sparc")) + && let Some(val) = extract_field(cpuinfo, b"Cpu0ClkTck") + { let mut hz = 0_u64; let mut seen = false; for &byte in val.as_bytes() { @@ -389,7 +396,8 @@ fn write_model_name(writer: &mut StackWriter) { true }, None => { - write_dt_compatible(writer) + (cfg!(not(any(target_arch = "x86", target_arch = "x86_64"))) + && write_dt_compatible(writer)) || (cfg!(target_arch = "aarch64") && write_arm_part(writer, data)) }, };