summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-27 11:42:35 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-27 11:47:28 +0300
commitfe5dbfe723427a3606c41409626dc853f997e679 (patch)
tree73d60d0b5a4d3dc8e63e90eac8f215482d5d3e28
parent05aa7ae7ba667ae9f35ad762ea435a67dcc58c0d (diff)
downloadmariadb-git-fe5dbfe723427a3606c41409626dc853f997e679.tar.gz
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).
-rw-r--r--mysys/CMakeLists.txt4
1 files changed, 3 insertions, 1 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 3122decfde1..f72608aa1a9 100644
--- a/mysys/CMakeLists.txt
+++ b/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)