feat(builder): releases need x86-64-v3 (AVX2 and the rest); a build from source is built for any CPU #2833
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2833
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:feat/require-x86-64-v3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Everything we prebuild and ship is x86-64-v3 (AVX2, FMA, BMI2, MOVBE): the release builders' third-party object set and what a stable's or nightly's pack carries. Players on older CPUs kept hitting that (#2723, #2701, #2664). This PR applies that policy:
toolchain::V3: v2's, then AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE and XSAVE), stops early withcpu_too_old. The message names each missing feature, says this version is prebuilt for x86-64-v3 CPUs, says the Longshot Launcher's build-from-source versions (main or a pull request) work on this CPU, and says how to check (lscpu | grep avx2, CPU-Z or Task Manager). A build counts as a release when its tools carry aBUILD_ORIGINfile that saysrelease.longshot-packager release sourceswrites it into every stable and nightly pack.from-source's builder, which writessource. The game is built at-march=native. On a CPU without v3, the third-party code is also built for this CPU, with the CPU's name (LONGSHOT_NATIVE_CPU) in its flags and so in its keys, and the prebuilt set is never taken. When clang cannot name the CPU, both are built for the level /proc/cpuinfo shows (x86-64-v2 or x86-64). On such a CPU,from-sourceno longer compiles or packs a v3 set. CPUs with v3 build as before: native game, v3 third-party code.compile --third-party-objects) is always v3 and never refuses.RX_MARCHstays the developer's override (not checked).game/cloth_cull.cppnow includesimmintrin.hunder__AVX__instead of__AVX2__. Itsge128uses_mm_cmp_pson AVX, so a native build on Sandy or Ivy Bridge (AVX without AVX2) did not compile. On an AVX2 CPU the code is unchanged.I checked the other direct AVX2 users at baseline and AVX-only levels:
host/rx_backend.c,gpu/vk/vk_memory.cpp,gpu/vk/vk_recorder.hand the othergame/cloth_*.cpp. All of them are guarded at compile time with an SSE path. The Rust builder and longshot-rs set notarget-cpu, so they are baseline x86-64. RenHDrum's C sets no-march, so its carried copy is baseline too.Docs:
docs/user/requirements.md(AVX2 required for stable and nightly releases; older CPUs build from source in the launcher; CPU generations as examples, with the exceptions),docs/user/common-issues.md,docs/dev/reference/build.md,builder.mdandbuild-events.md. ReadV3,Buildandchooseinbuilder/crates/build-compile/src/toolchain.rsfirst.Testing
Tested:
cargo test -p build-compile --lib(60 pass; 5 new tests drivechoosewith injected CPU features and origins, and fail when the refusal or the native third-party choice is undone),cargo test -p build-driver sourcesand-p longshot-builder from_sourceandcargo clippyon the three crates (no new warnings) on Linux.game/cloth_*.cppcompile at-march=x86-64,core2,sandybridge,ivybridge,x86-64-v2andx86-64-v3with Linux clang, andcloth_cull.cppwith llvm-mingw atx86-64,sandybridgeandx86-64-v3.host/rx_backend.ccompiles at those levels on Linux. The game was not run: on a v3 CPU, the flags and the code the game is built from are unchanged (__AVX2__implies__AVX__). No test was added for the refusal (asked not to).Still to test: By hand, on a pre-v3 CPU (a tester with one, or Beanstalk if it has one; none here): a release's refusal, and a from-source build and game start, on Windows and Linux.
Measurements
Nothing to measure: on a v3 CPU the flags and the code are unchanged.
Risks
On a pre-v3 CPU, a release's build now refuses (intended) where it used to build for v2 or plain x86-64. A source build on such a CPU compiles its third-party code itself, so its first build takes longer. A PC whose clang cannot name its CPU and has no
/proc/cpuinfo(Windows) is taken to have v3, as before.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (the builder'scargo test -p build-compilepasses; nothing else reads what changed).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
cloth_cull.cppcompiled with both).Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
WIP: feat(builder): require x86-64-v3 (AVX2): an older CPU is refused, not built forto feat(builder): require x86-64-v3 (AVX2): an older CPU is refused, not built forbb00b6823ce7015f39d1feat(builder): require x86-64-v3 (AVX2): an older CPU is refused, not built forto feat(builder): releases need x86-64-v3 (AVX2); a build from source is built for any CPU@review
Recommendation: Request changes. The release check can accept CPUs missing x86-64-v3 features, and source builds can reuse third-party objects compiled for a different CPU. A valid source-build name can also cause an older CPU to be refused as though it were a release.
The change gives older CPUs a source-build path and explains the release requirement, but CPU classification and object caching can still produce builds that fail on those machines. Source builds on older CPUs also compile a v3 object set that they subsequently discard.
Blocking (2): must change before merging.
builder/crates/build-compile/src/toolchain.rs:127: The v3 check omits required x86-64-v3 features, including BMI1, F16C and LZCNT. (more on the line) Do: Check every required x86-64-v3 feature and OS support before accepting the prebuilt objects; report the missing features.builder/crates/build-compile/src/toolchain.rs:379: The new refusal and source fallback have no regression test, despite the repository requiring a game-free test for a fix. (more on the line) Do: Add platform-independent tests with injected CPU features and build origins that exercise the refusal, native fallback and prebuilt-set selection, and fail when those behaviors are undone.Should fix (3): not blocking, but worth doing before merging.
builder/crates/build-compile/src/toolchain.rs:404: Native third-party objects are keyed without the native CPU identity. (more on the line) Do: Include the probed native CPU and feature identity in third-party object keys, and handle an unavailable identity without reusing ambiguous native objects.builder/crates/build-compile/src/toolchain.rs:198: A source build is classified as a release solely from its user-chosen version name. (more on the line) Do: Record and read an unambiguous build-origin marker instead of inferring origin from the displayed version name.builder/crates/build-compile/src/lib.rs:405: On an older CPU, from-source compiles and packs a v3 third-party set that the resulting builder always ignores. (more on the line) Do: Have source-pack creation build a correctly keyed native set for that CPU, or omit the unused set on pre-v3 CPUs.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/build-compile/src/toolchain.rs:379: The older-CPU release and source-build paths have not been exercised end to end. (more on the line) Do: On pre-v3 Windows and Linux systems, check the release refusal and complete a source build and game launch; record the results.@fixcan do L1, L2, L3, L4 and L5.Checks: Failing on this head, which is behind its base, where it passes:
CI / Third-party parts and guide screenshots (pull_request).@rebase(or@fix) brings it up to date and runs it again; not held against it. Still running: 7 checks.More: does it help, other systems, switches, what was read
Does it help: Unproven: the author reports compiler checks and 55 builder library tests on Linux, but no release refusal or complete source build on a pre-v3 CPU. No game run was reported.
Other systems: The CPU policy affects Windows and Linux builds, source-pack creation, third-party object caches and the game and renderer linked from those objects. The reported compile checks cover selected CPU targets, but do not establish that complete builds and launches work on older hardware.
Switches: RX_MARCH remains unset by default and bypasses the CPU check when set to an explicit level. Its behavior is documented; no new switch was added.
Reviewed:
e7015f39d1against450e63b828: Read the repository rules, pull request template, diff, commit, changed toolchain and compile preparation paths, and cloth culling code; traced source-pack creation and object keys. Skimmed the changed documentation and related builder references. Tooling's AGENTS.md was not present locally; the network is closed. No recorded runs, translations or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project, builds or tests were run. CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -398,2 +402,4 @@_ => None,},// (a build from source on a CPU without x86-64-v3 compiles its third-party code for this CPU: never the set)_ if !tc.takes_prebuilt() => None,L4 (should fix): On an older CPU, from-source compiles and packs a v3 third-party set that the resulting builder always ignores.
When: from-source runs compile --third-party-objects before creating its pack; this branch then excludes that set when the player builds on the same pre-v3 CPU. The first source build pays for both the unused v3 compilation and the native compilation.
Do: Have source-pack creation build a correctly keyed native set for that CPU, or omit the unused set on pre-v3 CPUs.
@ -124,2 +125,3 @@/// The CPU levels the game may be built for, by the features they need./// The CPU features of x86-64-v3, what every prebuilt part of a release is built for: a release's build on a CPU without/// them is refused; a build from source is built for the CPU it has.const V3: &[&str] = &["avx2", "fma", "bmi2", "movbe"];L1 (blocking): The v3 check omits required x86-64-v3 features, including BMI1, F16C and LZCNT.
When: A virtual CPU exposing AVX2, FMA, BMI2 and MOVBE but masking BMI1 passes this check. The builder then selects x86-64-v3 third-party objects, which may execute BMI1 instructions and fault on that CPU.
Do: Check every required x86-64-v3 feature and OS support before accepting the prebuilt objects; report the missing features.
@ -169,0 +195,4 @@/// archive do not) names a release (v1.2.3, v1.2.3-rc.4, nightly-<count>-<8 hex>), else [`Build::Source`].pub fn of_tree(root: &Path) -> Build {let v = std::fs::read_to_string(root.join("VERSION")).unwrap_or_default();if is_release_name(v.lines().next().unwrap_or("").trim()) { Build::Release } else { Build::Source }L3 (should fix): A source build is classified as a release solely from its user-chosen version name.
When: from-source accepts --name v3.1.0 and writes that name into the pack's VERSION. On a pre-v3 CPU the resulting source builder reads it as a release and returns cpu_too_old, although its source build should be supported.
Do: Record and read an unambiguous build-origin marker instead of inferring origin from the displayed version name.
@ -343,1 +401,4 @@));with("native")};Ok((cpu, third, name))L2 (should fix): Native third-party objects are keyed without the native CPU identity.
When: On a pre-v3 CPU, third-party units receive only -march=native, so their object keys do not distinguish that CPU from another pre-v3 CPU. Moving or sharing the builder store with an older CPU can reuse objects containing instructions it cannot execute.
Do: Include the probed native CPU and feature identity in third-party object keys, and handle an unavailable identity without reusing ambiguous native objects.
@ -343,0 +376,4 @@}None => (None, missing_v3_of_cpuinfo()),};let v3 = missing.is_empty();L5 (blocking): The new refusal and source fallback have no regression test, despite the repository requiring a game-free test for a fix.
When: Removing the release refusal or allowing the prebuilt set on an older CPU would leave the reported existing tests passing, so the intended behavior can regress unnoticed.
Do: Add platform-independent tests with injected CPU features and build origins that exercise the refusal, native fallback and prebuilt-set selection, and fail when those behaviors are undone.
L6 (should fix): The older-CPU release and source-build paths have not been exercised end to end.
When: The reported checks compile selected files and run builder library tests; they do not show that an older CPU receives the refusal or can build and launch the source version.
Do: On pre-v3 Windows and Linux systems, check the release refusal and complete a source build and game launch; record the results.
e7015f39d1fae312797cBeanBot's points L1-L5 are addressed in
fae31279; L6 needs pre-v3 hardware, which we don't have here. Each inline reply says what changed.@ -127,0 +128,4 @@/// name a player is told). The check ([`missing_v3`]) and the refusal's message ([`cpu_too_old`]) read this one list./// The OS's support (OSXSAVE, the YMM state enabled) is in both sources: clang's `-march=native` drops AVX's features/// where the OS has not enabled them, and Linux takes `avx` out of `/proc/cpuinfo` so.pub const V3: &[(&str, &str, &str)] = &[L1: fixed.
V3now holds every feature of x86-64-v3 as LLVM's X86TargetParser defines it: v2's CX16, LAHF-SAHF, POPCNT, SSE3, SSE4.1, SSE4.2 and SSSE3, then AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE and XSAVE. Each entry gives clang's name, the /proc/cpuinfo flag and the name shown to the player. The check (missing_v3) and thecpu_too_oldmessage read this one list, and the message names every missing feature. OS support: clang's-march=nativedrops the AVX features when XCR0 does not enable YMM, and Linux dropsavxfrom cpuinfo in the same case, so both sources already reflect OSXSAVE.@ -161,0 +216,4 @@/// The file at a tree's root that says where its tools come from: `release` (`longshot-packager release sources`, a/// stable's or a nightly's) or `source` (`from-source`). A checkout has none: a build from source.pub const ORIGIN_FILE: &str = "BUILD_ORIGIN";L3: fixed. The pack now carries a
BUILD_ORIGINfile at the tree's root.tree_entries, which onlylongshot-packager release sourcesuses (it builds every stable and nightly pack), writesrelease.from-sourcewritessource.Build::of_treereads only this marker and ignoresVERSION. A missing marker, as in a checkout or a pack made by an older from-source, means a build from source. The testthe_origin_is_the_trees_marker...covers a source build namedv3.1.0.@ -169,0 +239,4 @@/// Whether the CPU this program runs on has every feature of [`V3`] its OS has enabled (cpuid and XCR0, as Rust's/// `is_x86_feature_detected!` reads them; LAHF-SAHF, which it cannot ask, is taken as there): `from-source` makes no/// x86-64-v3 third-party set for a CPU that could not use it.pub fn this_cpu_has_v3() -> bool {L4: fixed. On a CPU that lacks part of v3 (checked by
this_cpu_has_v3throughis_x86_feature_detected!, which reads cpuid and XCR0 on both Windows and Linux),from-sourceno longer compiles the v3 third-party set and packs none.make_packtakes an optional set. Note that the first source builds use the nightly builder's own from-source code, so this saving starts once a nightly includes this change.@ -344,0 +467,4 @@third-party objects, x86-64-v3, are not taken)",missing.join(", ")));cpu.clone()L2: fixed. When a build from source compiles native third-party code, it uses the game's flags, which include
-DLONGSHOT_NATIVE_CPU=<cpu>_<tune>_<features hash>. The CPU's identity is therefore in those units' keys. When clang cannot name the CPU, the game and the third-party code are both built for the explicit level that /proc/cpuinfo shows (x86-64-v2 or x86-64), never for an unnamed native.@ -350,0 +504,4 @@}#[test]fn a_releases_build_on_a_cpu_without_v3_is_refused_even_unprobed() {L6: agreed, but it needs pre-v3 hardware (Windows and Linux), and there is none here. It stays under Still to test for a tester with such a CPU, or Beanstalk if it has one. The decision logic is now covered by the unit tests above.
@ -350,0 +510,4 @@}#[test]fn a_build_from_source_on_a_cpu_without_v3_is_native_and_named_and_takes_no_prebuilt_set() {L5: fixed.
cpu_flags' decision is split out intochoose, which takes the probed CPU and the cpuinfo answer as injected values. Five tests cover the cases: the full feature list and its missing-feature names, a release refusing on pre-v3 (probed and unprobed), a source build on pre-v3 being native and named with no v3 third-party flags (explicit levels when unprobed; the release set stays v3), v3 unchanged for both origins, and the origin marker. I checked that the tests fail when the behaviour is undone: removing the refusal makes 2 fail, forcing v3 third-party code makes 1 fail.feat(builder): releases need x86-64-v3 (AVX2); a build from source is built for any CPUto feat(builder): releases need x86-64-v3 (AVX2 and the rest); a build from source is built for any CPU