Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lore-base/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.includes(Some(native_dir.join("thirdparty")));

if platform == "linux" && arch == "aarch64" {
cc_builder.flag("-mcpu=neoverse-512tvb");
if env::var("LORE_CPU_NEOVERSE_512TVB").is_ok() {
let cpuinfo = std::fs::read_to_string("/proc/cpuinfo").unwrap_or_default();
if cpuinfo.contains("sve2") {
cc_builder.flag("-mcpu=neoverse-512tvb");
} else {
println!(
"cargo:warning=LORE_CPU_NEOVERSE_512TVB is set but SVE2 not detected in /proc/cpuinfo; skipping -mcpu=neoverse-512tvb and building for generic aarch64 to avoid illegal hardware instruction. Disable the `neoverse-512tvb` feature to suppress this warning"
);
}
Comment on lines +31 to +37

@subhramit subhramit Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also force respecting the flag setting irrespective of cpu info:

Suggested change
if cpuinfo.contains("sve2") {
cc_builder.flag("-mcpu=neoverse-512tvb");
} else {
println!(
"cargo:warning=LORE_CPU_NEOVERSE_512TVB is set but SVE2 not detected in /proc/cpuinfo; skipping -mcpu=neoverse-512tvb and building for generic aarch64 to avoid illegal hardware instruction. Disable the `neoverse-512tvb` feature to suppress this warning"
);
}
if !cpuinfo.contains("sve2") {
println!(
"cargo:warning=LORE_CPU_NEOVERSE_512TVB is set but SVE2 not detected in /proc/cpuinfo; binary may crash with illegal hardware instruction. Unset the `neoverse-512tvb` feature to build for generic aarch64"
);
cc_builder.flag("-mcpu=neoverse-512tvb");
}

in case we are looking forward to cross-compilation cases, so I leave it upto your decision @mjansson @valentina2509

} else {
println!(
"cargo:warning=Building rpmalloc without -mcpu=neoverse-512tvb; binary may be slower on Graviton3+. Set LORE_CPU_NEOVERSE_512TVB=1 to opt in"
);
}
}

if cc_builder.get_compiler().is_like_msvc() {
Expand Down