Use auxv to check for CRC32 instructions on ARM.
authorThomas Munro <[email protected]>
Fri, 22 Nov 2024 03:45:19 +0000 (16:45 +1300)
committerThomas Munro <[email protected]>
Fri, 22 Nov 2024 08:45:25 +0000 (21:45 +1300)
commitaac831cafa6f3106dfcbd3298757801c299351fc
treee0747ab30623bb19294c2f7cb41836c5c02cf5aa
parentea15816928c1bbcab749205a263d82daea28a3e0
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; es are welcome.

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

Suggested-by: Bastien Roucariès <[email protected]>
Discussion: https://postgr.es/m/4496616.iHFcN1HehY%40portable-bastien
configure
configure.ac
meson.build
src/include/pg_config.h.in
src/port/pg_crc32c_armv8_choose.c