Browse Source

MDEV-23585: Fix the 32-bit build on GCC 4

GCC before version 5 would fail to emit the CPUID instruction
when targeting IA-32 in -fPIC mode. Therefore, we must add the
CPUID instruction to the HAVE_CLMUL_INSTRUCTION check.

This means that the PCLMUL accelerated crc32() function will
not be available on i686 executables that are compiled with
GCC 4. The limitation does not impact AMD64 builds or non-PIC
x86 builds, or other compilers (clang, or GCC 5 or newer).
pull/1663/head
Marko Mäkelä 5 years ago
parent
commit
fe5dbfe723
  1. 4
      mysys/CMakeLists.txt

4
mysys/CMakeLists.txt

@ -59,10 +59,12 @@ IF (WIN32)
ENDIF()
IF(NOT MSVC AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|i[36]86")
#Check for PCLMUL instruction (x86)
#Check for CPUID and PCLMUL. GCC before version 5 would refuse to emit the
#CPUID instruction for -m32 -fPIC because it would clobber the EBX register.
CHECK_C_SOURCE_COMPILES("
int main()
{
asm volatile (\"cpuid\" : : \"a\"(1) : \"ebx\");
asm volatile (\"pclmulqdq \\$0x00, %%xmm1, %%xmm0\":::\"cc\");
return 0;
}" HAVE_CLMUL_INSTRUCTION)

Loading…
Cancel
Save