Skip to content

Comments

MOD-14130 Fix build failures on focal cross-compilation and x86 with old binutils#912

Merged
ofiryanai merged 3 commits intomainfrom
fix-bm-sve2
Feb 22, 2026
Merged

MOD-14130 Fix build failures on focal cross-compilation and x86 with old binutils#912
ofiryanai merged 3 commits intomainfrom
fix-bm-sve2

Conversation

@ofiryanai
Copy link
Collaborator

@ofiryanai ofiryanai commented Feb 19, 2026

Summary

This PR fixes three separate build issues affecting VectorSimilarity on different platforms:

1. SVE benchmark compilation bug (aarch64)

Files: tests/benchmark/spaces_benchmarks/bm_spaces_int8.cpp, bm_spaces_uint8.cpp

Copy-paste bug: #ifdef OPT_SVE blocks incorrectly referenced sve2_supported (only defined in OPT_SVE2 block) instead of sve_supported.

2. Cross-compilation architecture detection

File: src/VecSim/spaces/CMakeLists.txt

Used CMAKE_HOST_SYSTEM_PROCESSOR (the machine running CMake) instead of CMAKE_SYSTEM_PROCESSOR (the target architecture). This caused x86 AVX512 code to be compiled when cross-compiling for ARM.

3. AVX512-FP16/BF16 build failure with old binutils

File: cmake/x86_64InstructionFlags.cmake

On systems with modern GCC (13+) but old binutils (e.g., Ubuntu 20.04 focal with binutils 2.34):

  • CMake's CHECK_CXX_COMPILER_FLAG(-mavx512fp16 ...) passes (GCC accepts the flag)
  • But the assembler fails with Error: no such instruction: 'vfmadd132ph ...'

Fix: Detect binutils version at configure time and disable:

  • CXX_AVX512BF16 if binutils < 2.34
  • CXX_AVX512FP16 if binutils < 2.38

Jira

https://redislabs.atlassian.net/browse/MOD-14130


Pull Request opened by Augment Code with guidance from the PR author


Pull Request opened by Augment Code with guidance from the PR author


Note

Low Risk
Build/benchmark-only changes with straightforward conditional logic; main risk is mis-detecting binutils/CPU and unintentionally enabling/disabling optimized code paths.

Overview
Fixes cross-compilation build breakages by switching VecSim spaces’ architecture gating from CMAKE_HOST_SYSTEM_PROCESSOR to CMAKE_SYSTEM_PROCESSOR, preventing x86-only AVX sources from being compiled when targeting ARM.

Improves x86 AVX512 feature detection on Linux by checking the installed binutils/assembler version and disabling CXX_AVX512BF16 (<2.34) and CXX_AVX512FP16 (<2.38) when assembly support is too old.

Fixes AArch64 benchmark compilation by using sve_supported (not sve2_supported) inside #ifdef OPT_SVE blocks in the INT8/UINT8 space benchmarks.

Written by Cursor Bugbot for commit dcde91f. This will update automatically on new commits. Configure here.

In the OPT_SVE blocks, the code incorrectly referenced sve2_supported
(only defined in OPT_SVE2 block) instead of sve_supported, causing
compilation errors when OPT_SVE is defined but OPT_SVE2 is not.
meiravgri
meiravgri previously approved these changes Feb 19, 2026
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.09%. Comparing base (a68ba7d) to head (dcde91f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #912   +/-   ##
=======================================
  Coverage   97.09%   97.09%           
=======================================
  Files         129      129           
  Lines        7500     7500           
=======================================
  Hits         7282     7282           
  Misses        218      218           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ST_SYSTEM_PROCESSOR

CMAKE_HOST_SYSTEM_PROCESSOR returns the host machine's architecture (where
CMake runs), while CMAKE_SYSTEM_PROCESSOR returns the target architecture
(what we're building for). In cross-compilation scenarios (e.g., building
ARM binaries on an x86 CI runner), these differ.

Using CMAKE_HOST_SYSTEM_PROCESSOR caused x86 AVX512 instructions to be
compiled when cross-compiling for ARM, resulting in assembler errors like:
  Error: no such instruction: 'vfmadd132ph %zmm2,%zmm1,%zmm0{%k1}'
The compiler (GCC 13+) may support -mavx512fp16 flag, but the assembler
(binutils) may be too old to handle the generated AVX512-FP16 instructions.

This caused build failures on Ubuntu 20.04 (focal) which has:
- GCC 13.1.0 (installed via PPA) - supports AVX512-FP16
- binutils 2.34 (system default) - does NOT support AVX512-FP16

AVX512-FP16 instructions (vfmadd132ph, vmovw, vcvtsh2ss, etc.) require
binutils >= 2.38.

Replace the hardcoded Ubuntu 18.04 check with proper binutils version
detection:
- AVX512-BF16: requires binutils >= 2.34
- AVX512-FP16: requires binutils >= 2.38
@ofiryanai ofiryanai changed the title MOD-14130 Fix SVE benchmark compilation bug on aarch64 MOD-14130 Fix build failures on focal cross-compilation and x86 with old binutils Feb 22, 2026
@ofiryanai ofiryanai enabled auto-merge February 22, 2026 18:33
@ofiryanai ofiryanai added this pull request to the merge queue Feb 22, 2026
Merged via the queue into main with commit e5784b1 Feb 22, 2026
17 checks passed
@ofiryanai ofiryanai deleted the fix-bm-sve2 branch February 22, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants