Fix crash on 32-bit x86 CPUs that support AVX-512

The AVX-512 implementations in simd-string-512.c are built only for
x86-64, on other platforms they are stubs that call fatal(). However,
init_simd() enables them whenever the CPU reports AVX-512 support, which
it also does when running a 32-bit x86 build. That build then exits as
soon as it decodes any UTF-8 or draws any text.

Never select the AVX-512 implementations on platforms for which they are
not built, whether detected at runtime or requested via KITTY_SIMD=512.
This commit is contained in:
Egor Ignatov 2026-09-21 13:04:19 +05:00
parent 42ec0f62ca
commit ead3ff5ea4

View file

@ -388,6 +388,10 @@ init_simd(void *x) {
has_avx2 = strcmp(simd_env, "256") == 0;
has_avx512 = strcmp(simd_env, "512") == 0;
}
#if !(defined(__x86_64__) || defined(__amd64__)) || defined(KITTY_NO_SIMD)
// The AVX-512 implementations are x86-64 only, elsewhere they are stubs that call fatal()
has_avx512 = false;
#endif
#undef do_check
if (has_avx512) {