[MDEV-23618] InnoDB lacks IA-32 non-PIC CRC-32C acceleration on GCC 4 Created: 2020-08-28  Updated: 2020-10-06  Resolved: 2020-08-28

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5.4
Fix Version/s: 10.5.7

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: performance, portability
Environment:

GCC 4, IA-32, non-PIC


Issue Links:
Problem/Incident
is caused by MDEV-22669 InnoDB lacks CRC-32C acceleration on ... Closed

 Description   

When MDEV-22669 introduced CRC-32C acceleration to IA-32, it worked around a bug of GCC 4 by disabling the acceleration for IA-32. The bug only affects the generating of position independent code (-fPIC):

/home/buildbot/buildbot/build/storage/innobase/ut/ut0crc32.cc: In function 'void ut_crc32_init()':
/home/buildbot/buildbot/build/storage/innobase/ut/ut0crc32.cc:120:50: error: PIC register clobbered by 'ebx' in 'asm'
   asm("cpuid" : "=c"(i) : "ax"(1) : "ebx", "edx");

In MDEV-23585 I found a more elegant solution to this problem: implement a CMake check for that the cpuid instruction.
We can extend this check so that the source code can simply refer to HAVE_CPUID_INSTRUCTION. In that way, only those platforms that are affected by the compiler bug will avoid using any instruction set extensions.

Clarification: We always generated the CPUID instruction for AMD64. We only unnecessarily disabled it on IA-32 in some cases. I do not know whether and how the code could be compiled without -fPIC.


Generated at Thu Feb 08 09:23:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.