mirror of
https://github.com/postgres/postgres.git
synced 2025-08-06 18:42:54 +03:00
Fix ./configure checks with __cpuidex() and __cpuid()
The configure checks used two incorrect functions when checking the presence of some routines in an environment: - __get_cpuidex() for the check of __cpuidex(). - __get_cpuid() for the check of __cpuid(). This means that Postgres has never been able to detect the presence of these functions, impacting environments where these exist, like Windows. Simply fixing the function name does not work. For example, using configure with MinGW on Windows causes the checks to detect all four of __get_cpuid(), __get_cpuid_count(), __cpuidex() and __cpuid() to be available, causing a compilation failure as this messes up with the MinGW headers as we would include both <intrin.h> and <cpuid.h>. The Postgres code expects only one in { __get_cpuid() , __cpuid() } and one in { __get_cpuid_count() , __cpuidex() } to exist. This commit reshapes the configure checks to do exactly what meson is doing, which has been working well for us: check one, then the other, but never allow both to be detected in a given build. The logic is wrong since3dc2d62d04
and792752af4e
where these checks have been introduced (the second case is most likely a copy-pasto coming from the first case), with meson documenting that the configure checks were broken. As far as I can see, they are not once applied consistently with what the code expects, but let's see if the buildfarm has different something to say. The comment in meson.build is adjusted as well, to reflect the new reality. Author: Lukas Fittl <lukas@fittl.com> Co-authored-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/aIgwNYGVt5aRAqTJ@paquier.xyz Backpatch-through: 13
This commit is contained in:
13
configure
vendored
13
configure
vendored
@@ -18828,7 +18828,7 @@ $as_echo "#define HAVE_GCC__ATOMIC_INT64_CAS 1" >>confdefs.h
|
||||
fi
|
||||
|
||||
|
||||
# Check for x86 cpuid instruction
|
||||
# Check for __get_cpuid() and __cpuid()
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __get_cpuid" >&5
|
||||
$as_echo_n "checking for __get_cpuid... " >&6; }
|
||||
if ${pgac_cv__get_cpuid+:} false; then :
|
||||
@@ -18861,9 +18861,9 @@ if test x"$pgac_cv__get_cpuid" = x"yes"; then
|
||||
|
||||
$as_echo "#define HAVE__GET_CPUID 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __cpuid" >&5
|
||||
else
|
||||
# __cpuid()
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __cpuid" >&5
|
||||
$as_echo_n "checking for __cpuid... " >&6; }
|
||||
if ${pgac_cv__cpuid+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
@@ -18875,7 +18875,7 @@ int
|
||||
main ()
|
||||
{
|
||||
unsigned int exx[4] = {0, 0, 0, 0};
|
||||
__get_cpuid(exx[0], 1);
|
||||
__cpuid(exx, 1);
|
||||
|
||||
;
|
||||
return 0;
|
||||
@@ -18891,10 +18891,11 @@ rm -f core conftest.err conftest.$ac_objext \
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__cpuid" >&5
|
||||
$as_echo "$pgac_cv__cpuid" >&6; }
|
||||
if test x"$pgac_cv__cpuid" = x"yes"; then
|
||||
if test x"$pgac_cv__cpuid" = x"yes"; then
|
||||
|
||||
$as_echo "#define HAVE__CPUID 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for Intel SSE 4.2 intrinsics to do CRC calculations.
|
||||
|
25
configure.ac
25
configure.ac
@@ -2221,7 +2221,7 @@ PGAC_HAVE_GCC__ATOMIC_INT32_CAS
|
||||
PGAC_HAVE_GCC__ATOMIC_INT64_CAS
|
||||
|
||||
|
||||
# Check for x86 cpuid instruction
|
||||
# Check for __get_cpuid() and __cpuid()
|
||||
AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <cpuid.h>],
|
||||
[[unsigned int exx[4] = {0, 0, 0, 0};
|
||||
@@ -2231,17 +2231,18 @@ AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
|
||||
[pgac_cv__get_cpuid="no"])])
|
||||
if test x"$pgac_cv__get_cpuid" = x"yes"; then
|
||||
AC_DEFINE(HAVE__GET_CPUID, 1, [Define to 1 if you have __get_cpuid.])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for __cpuid], [pgac_cv__cpuid],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <intrin.h>],
|
||||
[[unsigned int exx[4] = {0, 0, 0, 0};
|
||||
__get_cpuid(exx[0], 1);
|
||||
]])],
|
||||
[pgac_cv__cpuid="yes"],
|
||||
[pgac_cv__cpuid="no"])])
|
||||
if test x"$pgac_cv__cpuid" = x"yes"; then
|
||||
AC_DEFINE(HAVE__CPUID, 1, [Define to 1 if you have __cpuid.])
|
||||
else
|
||||
# __cpuid()
|
||||
AC_CACHE_CHECK([for __cpuid], [pgac_cv__cpuid],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <intrin.h>],
|
||||
[[unsigned int exx[4] = {0, 0, 0, 0};
|
||||
__cpuid(exx, 1);
|
||||
]])],
|
||||
[pgac_cv__cpuid="yes"],
|
||||
[pgac_cv__cpuid="no"])])
|
||||
if test x"$pgac_cv__cpuid" = x"yes"; then
|
||||
AC_DEFINE(HAVE__CPUID, 1, [Define to 1 if you have __cpuid.])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for Intel SSE 4.2 intrinsics to do CRC calculations.
|
||||
|
Reference in New Issue
Block a user