postgres/config
Tom Lane fdb5dd6331 Be more paranoid in configure's checks for CRC and POPCNT intrinsics.
In these tests, we need to verify not only that the compiler has heard
of these intrinsics, but that lower-level tools cope with them too.
(For example, the assembler must also know the instructions, and on
some platforms there might be library support involved.)  The hazard
is that the compiler might optimize away the calls altogether,
allowing the configure check to succeed only to have the build fail
later if lower-level support is missing.  The existing code tried to
prevent that by ensuring that the result of the intrinsic is used
for something, but that's really insufficient because we were feeding
constant input to it.  So the compiler would be perfectly entitled to
optimize away the calls anyway.  Fix by making the inputs into global
variables.  (Hypothetically, LTO optimization could still remove the
code --- but that's well past where we'd be likely to hit trouble.)

It is not known that any current compiler would actually optimize
away these calls, and even if that happened it would be unlikely
that any problem would manifest.  Our concern for this stems from
largely-bygone days when it was common to install gcc on platforms
with some other native compiler, so that a compiler-vs-library
support discrepancy was more probable.  Still, there's little
point in defending against such cases in a way that is visibly
incomplete.

I'm content to fix this in master for now; we can back-patch if
any indication appears that it's a live problem for someone.

Discussion: https://postgr.es/m/3368102.1741993462@sss.pgh.pa.us
2025-03-20 16:23:09 -04:00
..
ax_pthread.m4 Update config/ax_pthread.m4 to latest upstream version. 2018-11-19 15:05:33 -05:00
c-compiler.m4 Be more paranoid in configure's checks for CRC and POPCNT intrinsics. 2025-03-20 16:23:09 -04:00
c-library.m4 Simplify checking for xlocale.h 2024-10-01 07:23:45 -04:00
check_decls.m4 Fix configure's AC_CHECK_DECLS tests to work correctly with clang. 2018-11-19 12:01:47 -05:00
check_modules.pl Update copyright for 2025 2025-01-01 11:21:55 -05:00
config.guess Update config.guess and config.sub 2024-04-09 14:21:57 +02:00
config.sub Update config.guess and config.sub 2024-04-09 14:21:57 +02:00
general.m4 Rename configure.in to configure.ac 2020-07-24 10:42:08 +02:00
install-sh Fix install-strip on Mac OS X 2012-08-21 23:42:43 -04:00
llvm.m4 jit: Require at least LLVM 14, if enabled. 2024-10-01 04:49:11 -04:00
Makefile Install our "missing" script where PGXS builds can find it. 2015-12-11 16:15:05 -05:00
meson.build meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
missing
perl.m4 Remove MSVC scripts 2023-12-20 09:44:37 +09:00
pkg.m4 Fix collection of typos in the code and the documentation 2022-03-15 11:29:35 +09:00
prep_buildtree Fix vpath build 2019-03-27 23:36:00 +01:00
programs.m4 oauth: Disallow synchronous DNS in libcurl 2025-03-19 16:56:19 +13:00
python.m4 Unify DLSUFFIX on Darwin 2022-07-06 07:41:33 +02:00
tcl.m4 configure: More use of AC_ARG_VAR 2019-01-18 08:38:34 +01:00