From e2349f3cbbe183a6a864e46b34def7d86e93a14f Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 30 Oct 2026 02:47:33 -0400 Subject: [PATCH 1/3] cpu: compile out other architectures' cpuinfo fallbacks Signed-off-by: Amaan Qureshi Change-Id: I5b3d1fcf3eb7391f59935c9bc5261c226a6a6964 --- crates/lib/src/cpu.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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)) }, }; From 6eff0154f59c62fb93a9ae40ae7346f41df1d3b5 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 30 Oct 2026 02:51:29 -0400 Subject: [PATCH 2/3] build: drop the eh_frame_hdr lookup table Signed-off-by: Amaan Qureshi Change-Id: Ifecc153827cb5366a436401aa00259dc6a6a6964 --- build.rs | 2 ++ 1 file changed, 2 insertions(+) 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) From 3423e4622cc9de18a7b2e3472316b1c53f9aa25d Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 30 Oct 2026 02:55:14 -0400 Subject: [PATCH 3/3] cargo: bump to 1.2.2 Signed-off-by: Amaan Qureshi Change-Id: I4b504f25b9f86f1cbf63938987bf1e3f6a6a6964 --- Cargo.lock | 8 ++++---- Cargo.toml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) 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" }