Refactor CPU feature detection to use an explicit x86 whitelist (#258)
* fix(cpu_features): refactor architecture detection to explicit x86 whitelist Currently, `cpu_features.cc` assumes any non-ARM architecture is x86/x64, which leads to a fatal missing `<cpuid.h>` error on architectures like RISC-V. This commit refactors the preprocessor macros to explicitly whitelist x86 architectures (`__x86_64__`, `__i386__`, `_M_X64`, `_M_IX86`). All other architectures (RISC-V, ARM, etc.) will now safely fall back to the default zero-initialization, allowing cross-compilation to succeed. Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: Add RISE RISC-V runner Introduce the RISC-V CI runner provided by the RISE project. This enables automated testing and building for the RISC-V architecture. Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: use python 3.12 for RISC-V64 Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: add RISC-V numpy dependencies Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: add RISC-V wheel cache Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: use pre-built RISE numpy wheel to speed up riscv builds Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: use pre-built RISE cmake wheel to speed up riscv builds Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: split RISC-V build and test into separate jobs Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: fix Signed-off-by: ihb2032 <hebome@foxmail.com> * ci: fix Signed-off-by: ihb2032 <hebome@foxmail.com> * Update hnsw_streamer_test.cc * ci: add cache Signed-off-by: ihb2032 <hebome@foxmail.com> * Update hnsw_streamer_test.cc * Update test_gil_release.py * ci: schedule workflow to run overnight --------- Signed-off-by: ihb2032 <hebome@foxmail.com> Co-authored-by: ZeFeng Yin <yinzefeng.yzf@alibaba-inc.com>
This commit is contained in:
@@ -17,7 +17,9 @@
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
#elif !defined(__ARM_ARCH)
|
||||
#endif
|
||||
|
||||
#if (defined(__x86_64__) || defined(__i386__)) && !defined(_MSC_VER)
|
||||
#include <cpuid.h>
|
||||
#endif
|
||||
|
||||
@@ -34,7 +36,7 @@ namespace internal {
|
||||
|
||||
CpuFeatures::CpuFlags CpuFeatures::flags_;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
|
||||
CpuFeatures::CpuFlags::CpuFlags(void)
|
||||
: L1_ECX(0), L1_EDX(0), L7_EBX(0), L7_ECX(0), L7_EDX(0) {
|
||||
int l1[4] = {0, 0, 0, 0};
|
||||
@@ -48,7 +50,7 @@ CpuFeatures::CpuFlags::CpuFlags(void)
|
||||
L7_ECX = l7[2];
|
||||
L7_EDX = l7[3];
|
||||
}
|
||||
#elif !defined(__ARM_ARCH)
|
||||
#elif defined(__x86_64__) || defined(__i386__)
|
||||
CpuFeatures::CpuFlags::CpuFlags(void)
|
||||
: L1_ECX(0), L1_EDX(0), L7_EBX(0), L7_ECX(0), L7_EDX(0) {
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
|
||||
Reference in New Issue
Block a user