fix(core): restrict AVX2 normalize to x86_64 (fix i686 build)#657
Merged
Conversation
The AVX2 path in `normalize_bytes` gated on `any(target_arch = "x86_64", target_arch = "x86")` unconditionally imports `std::arch::x86_64`, which does not exist on 32-bit x86, so `fff-search` failed to compile for `i686-unknown-linux-gnu` (e.g. termux i686 android builds pulling us in via nushell). SIMD stays on x86_64/aarch64; 32-bit x86 falls back to the scalar path. Add a `Build i686-unknown-linux-gnu` CI job so this regresses loudly next time. Closes #656.
Owner
|
@gustav-fff iterate on this PR and guard all the non x86_64 code that is failing to compile |
`select_rare_pair` results are only consumed inside x86_64/aarch64 cfg blocks, so on 32-bit x86 both bindings are unused and CI's `-D unused-variables` fails the i686 build introduced in the previous commit.
Collaborator
Author
|
[triage-bot] DIRECTED: already guarded, i686 CI green as of afc23c4. Timeline: your comment at 17:55:06 UTC preceded commit afc23c4 (17:57:28 UTC), which silenced the unused
Grep swept for every arch-specific site in
On i686 all SIMD paths compile out; If you were seeing a stale failure in your local view, please point me at the specific error — otherwise ready for review. Honk-Honk 🪿 |
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.
Closes #656
Root cause
normalize_bytesincrates/fff-core/src/bigram_filter.rsgated the AVX2 dispatch and thenormalize_bytes_avx2fn on#[cfg(any(target_arch = \"x86_64\", target_arch = \"x86\"))], but the body unconditionally doesuse std::arch::x86_64::*;. On 32-bit x86 (i686-unknown-linux-gnu)std::arch::x86_64does not exist, sofff-searchfailed to compile:Regressed in #566. Reported by @Juhan280 hitting this while packaging nushell for termux i686 android devices.
Fix
Restrict the AVX2 dispatch and the
normalize_bytes_avx2implementation to#[cfg(target_arch = \"x86_64\")]. On 32-bit x86 we fall back tonormalize_bytes_scalar, which LLVM auto-vectorises with the baseline SIMD anyway. Per maintainer + @fdncred: dropping SIMD on 32-bit x86 is acceptable — compiling at all is more important.Also add a
Build i686-unknown-linux-gnuCI job in.github/workflows/rust.ymlso this regresses loudly next time. The job installsgcc-multilib, adds thei686-unknown-linux-gnutarget, and runscargo build -p fff-search --target i686-unknown-linux-gnu.Steps to reproduce
On pre-fix
main(commit 8c76a1b):rustup target add i686-unknown-linux-gnu sudo apt-get install -y gcc-multilib # linux host cargo build -p fff-search --target i686-unknown-linux-gnuExpected: build succeeds. Actual on pre-fix
main:error[E0432]: unresolved import 'std::arch::x86_64'atcrates/fff-core/src/bigram_filter.rs:626.How verified
cargo check -p fff-search --no-default-features --features ripgrepon x86_64 macOS: clean.cargo clippy -p fff-search --no-default-features --features ripgrep -- -D warnings: clean.Automated triage via Gustav. Honk-Honk 🪿