Commit b47d61d0 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-23585: Fix HAVE_CLMUL_INSTRUCTION

MDEV-22641 in commit dec3f8ca
refactored a SIMD implementation of CRC-32 for the ISO 3309 polynomial
that uses the IA-32/AMD64 carry-less multiplication (pclmul)
instructions. The code was previously only available in Mariabackup;
it was changed to be a general replacement of the zlib crc32().

There exist AMD64 systems where CMAKE_SYSTEM_PROCESSOR matches
the pattern i[36]86 but not x86_64 or amd64. This would cause a
link failure, because mysys/checksum.c would basically assume that
the compiler support for instruction is always available on GCC-compatible
compilers on AMD64.

Furthermore, we were unnecessarily disabling the SIMD acceleration
for 32-bit executables.

Note: Until MDEV-22749 has been implemented, the PCLMUL instruction
will not be used on Microsoft Windows.

Closes: #1660
parent bb284e3f
...@@ -102,6 +102,8 @@ ...@@ -102,6 +102,8 @@
/* Libraries */ /* Libraries */
#cmakedefine HAVE_LIBWRAP 1 #cmakedefine HAVE_LIBWRAP 1
#cmakedefine HAVE_SYSTEMD 1 #cmakedefine HAVE_SYSTEMD 1
#cmakedefine HAVE_CLMUL_INSTRUCTION 1
#cmakedefine HAVE_CRC32_VPMSUM 1 #cmakedefine HAVE_CRC32_VPMSUM 1
/* Support ARMv8 crc + crypto */ /* Support ARMv8 crc + crypto */
......
...@@ -58,7 +58,7 @@ IF (WIN32) ...@@ -58,7 +58,7 @@ IF (WIN32)
my_win_popen.cc) my_win_popen.cc)
ENDIF() ENDIF()
IF(NOT MSVC AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64") IF(NOT MSVC AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|i[36]86")
#Check for PCLMUL instruction (x86) #Check for PCLMUL instruction (x86)
CHECK_C_SOURCE_COMPILES(" CHECK_C_SOURCE_COMPILES("
int main() int main()
......
...@@ -30,8 +30,7 @@ static unsigned int my_crc32_zlib(unsigned int crc, const void *data, ...@@ -30,8 +30,7 @@ static unsigned int my_crc32_zlib(unsigned int crc, const void *data,
my_crc32_t my_checksum= my_crc32_zlib; my_crc32_t my_checksum= my_crc32_zlib;
#endif #endif
#if __GNUC__ >= 4 && defined(__x86_64__) #ifdef HAVE_CLMUL_INSTRUCTION
extern int crc32_pclmul_enabled(); extern int crc32_pclmul_enabled();
extern unsigned int crc32_pclmul(unsigned int, const void *, size_t); extern unsigned int crc32_pclmul(unsigned int, const void *, size_t);
......
...@@ -57,8 +57,6 @@ typedef uint8_t byte; ...@@ -57,8 +57,6 @@ typedef uint8_t byte;
# define _gcry_bswap32 __builtin_bswap32 # define _gcry_bswap32 __builtin_bswap32
#if __GNUC__ >= 4 && defined(__x86_64__)
#if defined(_GCRY_GCC_VERSION) && _GCRY_GCC_VERSION >= 40400 /* 4.4 */ #if defined(_GCRY_GCC_VERSION) && _GCRY_GCC_VERSION >= 40400 /* 4.4 */
/* Prevent compiler from issuing SSE instructions between asm blocks. */ /* Prevent compiler from issuing SSE instructions between asm blocks. */
# pragma GCC target("no-sse") # pragma GCC target("no-sse")
...@@ -542,4 +540,3 @@ unsigned int crc32_pclmul(unsigned int crc32, const void *buf, size_t len) ...@@ -542,4 +540,3 @@ unsigned int crc32_pclmul(unsigned int crc32, const void *buf, size_t len)
crc32_intel_pclmul(&crc32, buf, len); crc32_intel_pclmul(&crc32, buf, len);
return ~crc32; return ~crc32;
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment