From 60795ae69daa58c18a70f95c98ee67ba383d5515 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Wed, 1 Jul 2026 18:37:41 -0700 Subject: [PATCH] Keep simdutf westmere and fallback kernels in x86_64 builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building with -march=haswell compiles out simdutf's SSE4.2 and scalar kernels, leaving only haswell and icelake. CPUs that execute AVX but do not advertise it via CPUID (e.g. Rosetta 2) then get the "unsupported" implementation, whose methods return constants instead of computing — validate_ascii() returns false for ASCII input and validate_ascii_with_errors() returns (OTHER, 0), which sends callers into infinite loops. Force the lower-tier kernels back in for x86_64 so runtime dispatch always has a working floor. CPUs with AVX2/AVX-512 still select the haswell/icelake kernels, so this has no effect on machines that advertise those features. --- Source/WTF/wtf/SIMDUTF.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/WTF/wtf/SIMDUTF.cpp b/Source/WTF/wtf/SIMDUTF.cpp index 9222de0506ed5..668ea7a498a21 100644 --- a/Source/WTF/wtf/SIMDUTF.cpp +++ b/Source/WTF/wtf/SIMDUTF.cpp @@ -41,6 +41,23 @@ IGNORE_WARNINGS_BEGIN("unsafe-buffer-usage") #endif #endif +// Building with -march=haswell (or newer) compiles out simdutf's SSE4.2 and +// scalar kernels, so CPUs that don't advertise AVX via CPUID (e.g. Rosetta 2) +// silently get the "unsupported" implementation, which returns constants +// instead of computing. Keep the lower-tier kernels compiled in so runtime +// dispatch always has a working floor; CPUs with AVX2/AVX-512 still select +// the haswell/icelake kernels. Note these kernels are still compiled at the +// TU's -march, so this helps translators that execute AVX without advertising +// it, not CPUs that genuinely cannot execute AVX. +#if CPU(X86_64) +#ifndef SIMDUTF_IMPLEMENTATION_WESTMERE +#define SIMDUTF_IMPLEMENTATION_WESTMERE 1 +#endif +#ifndef SIMDUTF_IMPLEMENTATION_FALLBACK +#define SIMDUTF_IMPLEMENTATION_FALLBACK 1 +#endif +#endif + #include "simdutf/simdutf_impl.cpp.h" #if PLATFORM(PLAYSTATION)