From 7cdb16fd37235ae74710a2390a43949bc04dd497 Mon Sep 17 00:00:00 2001 From: gustav-fff <286169375+gustav-fff@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:48:15 -0700 Subject: [PATCH 1/2] fix(core): restrict AVX2 normalize to x86_64 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. --- .github/workflows/rust.yml | 26 ++++++++++++++++++++++++++ crates/fff-core/src/bigram_filter.rs | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a63411f9..1d60b0f5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -101,6 +101,32 @@ jobs: path: crates/fff-core/tests/fuzz_git_watcher_stress.proptest-regressions if-no-files-found: ignore + build-i686: + name: Build i686-unknown-linux-gnu + runs-on: ubuntu-latest + # Verifies that fff-search compiles on 32-bit x86, where std::arch::x86_64 + # is unavailable. SIMD paths are disabled on this target; only the scalar + # fallback should build. See issue #656. + timeout-minutes: 15 + steps: + - uses: actions/checkout@v5 + + - name: Install cross toolchain + run: | + sudo apt-get update + sudo apt-get install -y gcc-multilib g++-multilib + + - name: Install Rust (i686 target) + uses: actions-rust-lang/setup-rust-toolchain@v1.15.4 + with: + target: i686-unknown-linux-gnu + cache: true + cache-on-failure: true + cache-key: "v1-rust-i686" + + - name: Build fff-search for i686 + run: cargo build -p fff-search --target i686-unknown-linux-gnu + fmt: name: cargo fmt runs-on: ubuntu-latest diff --git a/crates/fff-core/src/bigram_filter.rs b/crates/fff-core/src/bigram_filter.rs index b2dd18bb..6ce2a319 100644 --- a/crates/fff-core/src/bigram_filter.rs +++ b/crates/fff-core/src/bigram_filter.rs @@ -593,7 +593,7 @@ fn normalize_byte_scalar(b: u8) -> u8 { #[inline(always)] fn normalize_bytes(src: &[u8], dst: &mut [u8]) { debug_assert!(dst.len() >= src.len()); - #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] + #[cfg(target_arch = "x86_64")] { if std::is_x86_feature_detected!("avx2") { unsafe { normalize_bytes_avx2(src, dst) }; @@ -620,7 +620,7 @@ fn normalize_bytes_scalar(src: &[u8], dst: &mut [u8]) { /// AVX2 normalize: 32 bytes/iter. AVX2 only has signed cmp, so unsigned /// range checks use `min(max(v, lo), hi) == v`. -#[cfg(any(target_arch = "x86_64", target_arch = "x86"))] +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "avx2")] unsafe fn normalize_bytes_avx2(src: &[u8], dst: &mut [u8]) { use std::arch::x86_64::*; From afc23c4df6f08168fe6d2b8afbdc04e4838495aa Mon Sep 17 00:00:00 2001 From: gustav-fff <286169375+gustav-fff@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:57:28 -0700 Subject: [PATCH 2/2] fix(core): silence unused i1/i2 on non-SIMD targets `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. --- crates/fff-core/src/case_insensitive_memmem.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/fff-core/src/case_insensitive_memmem.rs b/crates/fff-core/src/case_insensitive_memmem.rs index e0d93a8a..bdbb8b84 100644 --- a/crates/fff-core/src/case_insensitive_memmem.rs +++ b/crates/fff-core/src/case_insensitive_memmem.rs @@ -496,6 +496,10 @@ pub fn search_packed_pair(haystack: &[u8], needle_lower: &[u8]) -> bool { return false; } + #[cfg_attr( + not(any(target_arch = "x86_64", target_arch = "aarch64")), + allow(unused_variables) + )] let (i1, i2) = select_rare_pair(needle_lower); #[cfg(target_arch = "x86_64")]