Add neoverse-512tvb optimization build flag and gate it behind CPU detection#82
Open
subhramit wants to merge 1 commit into
Open
Add neoverse-512tvb optimization build flag and gate it behind CPU detection#82subhramit wants to merge 1 commit into
subhramit wants to merge 1 commit into
Conversation
…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>
cac12bb to
9776d06
Compare
subhramit
commented
Jun 27, 2026
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" | ||
| ); | ||
| } |
Author
There was a problem hiding this comment.
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of cross-platform build portability.
Fixes #42
lore-base/build.rspassed-mcpu=neoverse-512tvbunconditionally to the C compiler for all linux/aarch64 targets, causing binaries to crash withillegal hardware instructionon 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/cpuinfoSVE2 check, falling back to a generic aarch64 build with a warning if it is not detected.