From 266495b93ef550210cd598f1d7eff6031b34a7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 21 May 2024 16:45:07 +0300 Subject: [PATCH] MDEV-33817 fixup: Disable for macOS According to https://discussions.apple.com/thread/8256853 an attempt to use AVX512 registers on macOS will result in #UD (crash at runtime). Also, starting with clang-18 and GCC 14, we must add "evex512" to the target flags so that AVX and SSE instructions can use AVX512 specific encodings. This flag was introduced together with the avx10.1-512 target. Older compiler versions do not recognize "evex512". We do not want to write "avx10.1-512" because it could enable some AVX512 subfeatures that we do not have any CPUID check for. Reviewed by: Vladislav Vaintroub Tested on macOS by: Valerii Kravchuk --- mysys/crc32/crc32c_x86.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mysys/crc32/crc32c_x86.cc b/mysys/crc32/crc32c_x86.cc index 317b3545c0c..1ea0689a14b 100644 --- a/mysys/crc32/crc32c_x86.cc +++ b/mysys/crc32/crc32c_x86.cc @@ -24,7 +24,11 @@ # endif #else # include -# if __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 8) +# ifdef __APPLE__ /* AVX512 states are not enabled in XCR0 */ +# elif __GNUC__ >= 14 || (defined __clang_major__ && __clang_major__ >= 18) +# define TARGET "pclmul,evex512,avx512f,avx512dq,avx512bw,avx512vl,vpclmulqdq" +# define USE_VPCLMULQDQ __attribute__((target(TARGET))) +# elif __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 8) # define TARGET "pclmul,avx512f,avx512dq,avx512bw,avx512vl,vpclmulqdq" # define USE_VPCLMULQDQ __attribute__((target(TARGET))) # endif