fix: add preprocessor guards in SIMD test files to fix ARM build#1847
Draft
fix: add preprocessor guards in SIMD test files to fix ARM build#1847
Conversation
…nc_test.cpp Wrap x86-specific (sse::, avx::, avx2::, avx512::) and ARM-specific (neon::, sve::) function references with compile-time guards to prevent linker errors when building on non-matching architectures. - Inside TEST_ACCURACY macro: use SIMD_TEST_SSE/AVX/AVX2/AVX512/NEON/SVE wrapper macros - In PQ Calculation test: use #ifdef ENABLE_SSE/AVX/AVX2/AVX512/SVE/NEON guards - Add #include "simd_test_macro.h" for the wrapper macros - generic:: calls remain unconditional Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
…d_test.cpp Wrap architecture-specific SIMD test code with conditional compilation guards to prevent linker errors on ARM: - Inside TEST_ACCURACY macro: use SIMD_TEST_XXX() wrapper macros - Inside BF16 Benchmark test: use #ifdef ENABLE_XXX / #endif guards - generic:: calls left unchanged (always available) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
…ibility Wrap architecture-specific SIMD test code with conditional compilation guards to prevent linker errors when building on ARM platforms where x86 SIMD namespaces (sse, avx, avx2, avx512) are not available, and vice versa. - Inside macro definitions: use SIMD_TEST_XXX() wrapper macros from simd_test_macro.h (since #ifdef cannot be used inside #define) - Outside macro definitions: use #ifdef ENABLE_XXX / #endif directly - generic:: calls left unguarded as they are always available Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
…fp16_simd_test.cpp Wrap architecture-specific SIMD test code with conditional compilation guards to prevent linker errors when building on ARM (or other non-x86 platforms). - Include simd_test_macro.h for SIMD_TEST_XXX wrapper macros - Use SIMD_TEST_XXX() wrappers inside the TEST_ACCURACY macro definition - Use #ifdef ENABLE_XXX / #endif guards in the FP16 Benchmark test case This matches the pattern already used in bf16_simd_test.cpp. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
…_simd_test.cpp Wrap architecture-specific SIMD blocks with conditional compilation guards to prevent linker errors when building on platforms that don't support certain instruction sets (e.g., x86 instructions on ARM). - Inside macro definitions: use SIMD_TEST_XXX() wrapper macros - Outside macro definitions: use #ifdef ENABLE_XXX / #endif directly - generic:: calls remain unchanged (always compiled) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
Wrap architecture-specific SIMD calls in int8_simd_test.cpp and sq8_uniform_simd_test.cpp with preprocessor guards to prevent linker errors on ARM. Inside macro definitions, use SIMD_TEST_XXX() wrapper macros from simd_test_macro.h. Outside macros, use #ifdef ENABLE_XXX directly. Generic calls are left unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
Wrap architecture-specific SIMD function calls in test files with compile-time preprocessor guards (SIMD_TEST_SSE, SIMD_TEST_AVX, etc.) so that x86-specific symbols are not referenced on ARM, and vice versa. This prevents linker errors like "undefined reference to vsag::sse::L2Sqr" when building on ARM where x86 SIMD implementations are not available. Changes: - Create src/simd/simd_test_macro.h with conditional wrapper macros - Add missing ENABLE_SVE definition for simd_test in CMakeLists.txt - Update basic_func_test.cpp, bf16_simd_test.cpp, bit_simd_test.cpp, fp16_simd_test.cpp, fp32_simd_test.cpp, int8_simd_test.cpp, normalize_test.cpp, pqfs_simd_test.cpp, sq4_simd_test.cpp, sq8_uniform_simd_test.cpp with preprocessor guards Agent-Logs-Url: https://github.com/antgroup/vsag/sessions/5ad71904-f717-4218-980d-c2a1c7df79b7 Co-authored-by: wxyucs <12595343+wxyucs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix build failure issue on ARM architecture
fix: add preprocessor guards in SIMD test files to fix ARM build
Apr 16, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 Require kind labelWaiting for:
This rule is failing.
🔴 Require version labelWaiting for:
This rule is failing.
|
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.
Change Type
Linked Issue
What Changed
SIMD test files unconditionally reference x86-specific symbols (
sse::L2Sqr,avx::FP32ComputeIP, etc.) which don't exist invsag.soon ARM, causing mass linker failures. The runtime checks (SimdStatus::SupportSSE()) don't help — the linker still needs the symbols.New
src/simd/simd_test_macro.h: Variadic wrapper macros (SIMD_TEST_SSE(...),SIMD_TEST_AVX(...), etc.) that conditionally expand based onENABLE_XXXdefines. These work inside#definebodies where#ifdefis illegal.src/simd/CMakeLists.txt: Added missingENABLE_SVEcompile definition forsimd_testtarget (was already defined forsimdbut notsimd_test).10 of 13 test files updated:
basic_func_test,bf16_simd_test,bit_simd_test,fp16_simd_test,fp32_simd_test,int8_simd_test,normalize_test,pqfs_simd_test,sq4_simd_test,sq8_uniform_simd_test.3 files still need the same treatment:
sq4_uniform_simd_test.cpp,sq8_simd_test.cpp,rabitq_simd_test.cpp. Pattern is identical.Test Evidence
make fmtmake lintmake testmake cov, run tests, and collect coverageTest details:
Compatibility Impact
Performance and Concurrency Impact
Documentation Impact
README.mdDEVELOPMENT.mdCONTRIBUTING.mdRisk and Rollback
Checklist
[skip ci]prefix)