Skip to content

Commit 612f5b8

Browse files
committed
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 since 3dc2d62 and 792752a 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
1 parent c5bd803 commit 612f5b8

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

configure

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18259,7 +18259,7 @@ $as_echo "#define HAVE_GCC__ATOMIC_INT64_CAS 1" >>confdefs.h
1825918259
fi
1826018260

1826118261

18262-
# Check for x86 cpuid instruction
18262+
# Check for __get_cpuid() and __cpuid()
1826318263
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __get_cpuid" >&5
1826418264
$as_echo_n "checking for __get_cpuid... " >&6; }
1826518265
if ${pgac_cv__get_cpuid+:} false; then :
@@ -18292,9 +18292,9 @@ if test x"$pgac_cv__get_cpuid" = x"yes"; then
1829218292

1829318293
$as_echo "#define HAVE__GET_CPUID 1" >>confdefs.h
1829418294

18295-
fi
18296-
18297-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __cpuid" >&5
18295+
else
18296+
# __cpuid()
18297+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __cpuid" >&5
1829818298
$as_echo_n "checking for __cpuid... " >&6; }
1829918299
if ${pgac_cv__cpuid+:} false; then :
1830018300
$as_echo_n "(cached) " >&6
@@ -18306,7 +18306,7 @@ int
1830618306
main ()
1830718307
{
1830818308
unsigned int exx[4] = {0, 0, 0, 0};
18309-
__get_cpuid(exx[0], 1);
18309+
__cpuid(exx, 1);
1831018310

1831118311
;
1831218312
return 0;
@@ -18322,10 +18322,11 @@ rm -f core conftest.err conftest.$ac_objext \
1832218322
fi
1832318323
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__cpuid" >&5
1832418324
$as_echo "$pgac_cv__cpuid" >&6; }
18325-
if test x"$pgac_cv__cpuid" = x"yes"; then
18325+
if test x"$pgac_cv__cpuid" = x"yes"; then
1832618326

1832718327
$as_echo "#define HAVE__CPUID 1" >>confdefs.h
1832818328

18329+
fi
1832918330
fi
1833018331

1833118332
# Check for Intel SSE 4.2 intrinsics to do CRC calculations.

configure.in

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ PGAC_HAVE_GCC__ATOMIC_INT32_CAS
20872087
PGAC_HAVE_GCC__ATOMIC_INT64_CAS
20882088

20892089

2090-
# Check for x86 cpuid instruction
2090+
# Check for __get_cpuid() and __cpuid()
20912091
AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
20922092
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <cpuid.h>],
20932093
[[unsigned int exx[4] = {0, 0, 0, 0};
@@ -2097,17 +2097,18 @@ AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
20972097
[pgac_cv__get_cpuid="no"])])
20982098
if test x"$pgac_cv__get_cpuid" = x"yes"; then
20992099
AC_DEFINE(HAVE__GET_CPUID, 1, [Define to 1 if you have __get_cpuid.])
2100-
fi
2101-
2102-
AC_CACHE_CHECK([for __cpuid], [pgac_cv__cpuid],
2103-
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <intrin.h>],
2104-
[[unsigned int exx[4] = {0, 0, 0, 0};
2105-
__get_cpuid(exx[0], 1);
2106-
]])],
2107-
[pgac_cv__cpuid="yes"],
2108-
[pgac_cv__cpuid="no"])])
2109-
if test x"$pgac_cv__cpuid" = x"yes"; then
2110-
AC_DEFINE(HAVE__CPUID, 1, [Define to 1 if you have __cpuid.])
2100+
else
2101+
# __cpuid()
2102+
AC_CACHE_CHECK([for __cpuid], [pgac_cv__cpuid],
2103+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <intrin.h>],
2104+
[[unsigned int exx[4] = {0, 0, 0, 0};
2105+
__cpuid(exx, 1);
2106+
]])],
2107+
[pgac_cv__cpuid="yes"],
2108+
[pgac_cv__cpuid="no"])])
2109+
if test x"$pgac_cv__cpuid" = x"yes"; then
2110+
AC_DEFINE(HAVE__CPUID, 1, [Define to 1 if you have __cpuid.])
2111+
fi
21112112
fi
21122113

21132114
# Check for Intel SSE 4.2 intrinsics to do CRC calculations.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy