From bf5bf9a193facdd6ea6dc24bf31d89f3e64ed0df Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 13 Oct 2026 19:19:14 +0900 Subject: [PATCH 1/2] json: Use SSE2 on x86-64 without checking at runtime __builtin_cpu_supports refers to __cpu_model in compiler-rt, which clang-cl does not link, so generator.so and parser.so failed with an undefined symbol. SSE2 is part of the x86-64 baseline, as NEON is for AArch64, where no check is made either. Co-Authored-By: Claude Opus 5.5 --- ext/json/ext/simd/simd.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ext/json/ext/simd/simd.h b/ext/json/ext/simd/simd.h index 611b41b06..721972c9e 100644 --- a/ext/json/ext/simd/simd.h +++ b/ext/json/ext/simd/simd.h @@ -187,12 +187,8 @@ ALWAYS_INLINE(static) TARGET_SSE2 int string_scan_simd_sse2(const char **ptr, co static inline SIMD_Implementation find_simd_implementation(void) { - // TODO Revisit. I think the SSE version now only uses SSE2 instructions. - if (__builtin_cpu_supports("sse2")) { - return SIMD_SSE2; - } - - return SIMD_NONE; + // SSE2 is part of the x86-64 baseline. + return SIMD_SSE2; } #endif /* HAVE_X86INTRIN_H */ From 93e68739c0904bb46faba502c4ca3d083d51fe4a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 15 Oct 2026 13:49:51 +0900 Subject: [PATCH 2/2] Drop the leftovers of runtime SSE2 detection Neither the `__builtin_cpu_supports` probe in conf.rb nor `cpuid.h` has a use now that SSE2 is assumed on x86-64. The probe kept SIMD off on GCC older than 4.8, and the `HAVE_CPUID_H` guard broke builds that have `x86intrin.h` but not `cpuid.h` with a redefinition of `find_simd_implementation`. Co-Authored-By: Claude Opus 5.5 --- ext/json/ext/simd/conf.rb | 7 ++----- ext/json/ext/simd/simd.h | 4 ---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/ext/json/ext/simd/conf.rb b/ext/json/ext/simd/conf.rb index 76f774bc9..9b87473d5 100644 --- a/ext/json/ext/simd/conf.rb +++ b/ext/json/ext/simd/conf.rb @@ -1,16 +1,15 @@ case RbConfig::CONFIG['host_cpu'] when /^(arm|aarch64)/ # Try to compile a small program using NEON instructions - header, type, init, extra = 'arm_neon.h', 'uint8x16_t', 'vdupq_n_u8(32)', nil + header, type, init = 'arm_neon.h', 'uint8x16_t', 'vdupq_n_u8(32)' when /^(x86_64|x64)/ - header, type, init, extra = 'x86intrin.h', '__m128i', '_mm_set1_epi8(32)', 'if (__builtin_cpu_supports("sse2")) { printf("OK"); }' + header, type, init = 'x86intrin.h', '__m128i', '_mm_set1_epi8(32)' end if header if have_header(header) && try_compile(<<~SRC, '-Werror=implicit-function-declaration') #{cpp_include(header)} int main(int argc, char **argv) { #{type} test = #{init}; - #{extra} if (argc > 100000) printf("%p", &test); return 0; } @@ -20,5 +19,3 @@ puts "Disable SIMD" end end - -have_header('cpuid.h') diff --git a/ext/json/ext/simd/simd.h b/ext/json/ext/simd/simd.h index 721972c9e..2f3f838a9 100644 --- a/ext/json/ext/simd/simd.h +++ b/ext/json/ext/simd/simd.h @@ -143,7 +143,6 @@ ALWAYS_INLINE(static) int string_scan_simd_neon(const char **ptr, const char *en #define HAVE_SIMD 1 #define HAVE_SIMD_SSE2 1 -#ifdef HAVE_CPUID_H #define FIND_SIMD_IMPLEMENTATION_DEFINED 1 #if defined(__clang__) || defined(__GNUC__) @@ -182,9 +181,6 @@ ALWAYS_INLINE(static) TARGET_SSE2 int string_scan_simd_sse2(const char **ptr, co return 0; } -#include -#endif /* HAVE_CPUID_H */ - static inline SIMD_Implementation find_simd_implementation(void) { // SSE2 is part of the x86-64 baseline.