Skip to content

Add neoverse-512tvb optimization build flag and gate it behind CPU detection#82

Open
subhramit wants to merge 1 commit into
EpicGames:mainfrom
subhramit:fix-aarch64-crash
Open

Add neoverse-512tvb optimization build flag and gate it behind CPU detection#82
subhramit wants to merge 1 commit into
EpicGames:mainfrom
subhramit:fix-aarch64-crash

Conversation

@subhramit

@subhramit subhramit commented Jun 27, 2026

Copy link
Copy Markdown

Part of cross-platform build portability.

Fixes #42

lore-base/build.rs passed -mcpu=neoverse-512tvb unconditionally to the C compiler for all linux/aarch64 targets, causing binaries to crash with illegal hardware instruction on hardware that does not implement SVE2 and other Neoverse 512TVB extensions. This introduces a neoverse-512tvb build flag to opt-in to the optimization, and gates it behind a /proc/cpuinfo SVE2 check, falling back to a generic aarch64 build with a warning if it is not detected.

…ehind CPU detection

`lore-base/build.rs` passed `-mcpu=neoverse-512tvb` unconditionally to the C compiler for all `linux/aarch64` targets, causing binaries to crash with `illegal hardware instruction` on hardware that does not implement SVE2 and other Neoverse 512TVB extensions. Introduce a `neoverse-512tvb` Cargo feature to opt in to the optimization, and gate it behind a `/proc/cpuinfo` SVE2 check so the flag is only applied when the hardware supports it.

Fixes EpicGames#42

Signed-off-by: subhramit <subhramit.bb@live.in>
@subhramit subhramit force-pushed the fix-aarch64-crash branch from cac12bb to 9776d06 Compare June 27, 2026 23:12
Comment thread lore-base/build.rs
Comment on lines +31 to +37
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"
);
}

@subhramit subhramit Jun 27, 2026

Copy link
Copy Markdown
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

@dev-Kanade dev-Kanade left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i think good.

@mjansson mjansson requested a review from ragnarula July 7, 2026 14:00
@mjansson

mjansson commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

I think we are restructuring the compilation for various platforms and CPU tuning a bit to handle building both vanilla arm64 and tuned for Gravitons. That work should be done soon and supersede this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: aarch64-unknown-linux-gnu generic prebuilt binaries

3 participants