Re: centralize CPU feature detection

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Naylor <johncnaylorls@gmail.com>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, root <tenistarkim@gmail.com>, Nathan Bossart <nathandbossart@gmail.com>
Date: 2026-02-24T19:59:47Z
Lists: pgsql-hackers
John Naylor <johncnaylorls@gmail.com> writes:
> I've committed 0001.

BF animal rhinoceros isn't happy.  I can reproduce that locally by
doing

$ ./configure ... USE_SLICING_BY_8_CRC32C=1
$ make
...
pg_cpu_x86.c: In function 'pg_comp_crc32c_choose':
pg_cpu_x86.c:85:3: error: 'pg_comp_crc32c' undeclared (first use in this function); did you mean 'pg_comp_crc32c_sb8'?
   pg_comp_crc32c = pg_comp_crc32c_sse42;
   ^~~~~~~~~~~~~~
   pg_comp_crc32c_sb8
pg_cpu_x86.c:85:3: note: each undeclared identifier is reported only once for each function it appears in
pg_cpu_x86.c:85:20: error: 'pg_comp_crc32c_sse42' undeclared (first use in this function); did you mean 'pg_comp_crc32c_sb8'?
   pg_comp_crc32c = pg_comp_crc32c_sse42;
                    ^~~~~~~~~~~~~~~~~~~~
                    pg_comp_crc32c_sb8
pg_cpu_x86.c:108:9: warning: implicit declaration of function 'pg_comp_crc32c'; did you mean 'pg_comp_crc32c_sb8'? [-Wimplicit-function-declaration]
  return pg_comp_crc32c(crc, data, len);
         ^~~~~~~~~~~~~~
         pg_comp_crc32c_sb8


It appears that if you want to build pg_cpu_x86.o unconditionally,
you need to make it more proof against the cases it wasn't getting
built in before.

			regards, tom lane



Commits

  1. Remove extraneous PGDLLIMPORT

  2. Refactor detection of x86 ZMM registers

  3. Centralize detection of x86 CPU features

  4. Fix USE_SLICING_BY_8_CRC32C builds on x86

  5. Rename pg_crc32c_sse42_choose.c for general purpose