pgsql: Use auxv to check for CRC32 instructions on ARM. - Mailing list pgsql-committers

From Thomas Munro
Subject pgsql: Use auxv to check for CRC32 instructions on ARM.
Date
Msg-id E1tEPKW-00309I-V1@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Use auxv to check for CRC32 instructions on ARM.

Previously we probed for CRC32 instructions by testing if they caused
SIGILL.  Some have expressed doubts about that technique, the Linux
documentation advises not to use it, and it's not exactly beautiful.
Now that more operating systems expose CPU features to userspace via the
ELF loader in approximately the same way, let's use that instead.

This is expected to work on Linux, FreeBSD and recent OpenBSD.
OpenBSD/ARM has not been tested and is not present in our build farm,
but the API matches FreeBSD.

On macOS, compilers use a more recent baseline ISA so the runtime test
mechanism isn't reached.  (A similar situation is expected for
Windows/ARM when that port lands.)

On NetBSD, runtime feature probing is lost for armv8-a builds.  It looks
potentially doable with sysctl following the example of the cpuctl
program; patches are welcome.

No back-patch for now, since we don't have any evidence of actual
breakage from the previous technique.

Suggested-by: Bastien Roucariès <rouca@debian.org>
Discussion: https://postgr.es/m/4496616.iHFcN1HehY%40portable-bastien

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/aac831cafa6f3106dfcbd3298757801c299351fc

Modified Files
--------------
configure                         |  2 +-
configure.ac                      |  2 ++
meson.build                       |  2 ++
src/include/pg_config.h.in        |  6 ++++
src/port/pg_crc32c_armv8_choose.c | 66 ++++++++++++++-------------------------
5 files changed, 34 insertions(+), 44 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: psql: Fix category of \parse in output of --help=commands and \?
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix data loss when restarting the bulk_write facility