summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2018-11-05 18:24:39 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2018-11-05 18:24:39 +0100
commit7625f972db10fe1a69757b97c6dec57ea049129b (patch)
treebaa5ce59b12b4aafa1bb13e4262c1106bf3817cf
parentd78479737c8a078fccf57c3f1f21ef3104430cba (diff)
downloadphp-git-7625f972db10fe1a69757b97c6dec57ea049129b.tar.gz
Fix #76825: Undefined symbols ___cpuid_count
Apparently, the presence of `cpuid.h` is not necessarily sufficient to guarantee the availability of `__cpuid_count()`. We therefore test for the latter explicitly.
-rw-r--r--NEWS2
-rw-r--r--Zend/Zend.m418
-rw-r--r--Zend/zend_cpuinfo.c2
3 files changed, 20 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 49c8cd9e29..a0949e94be 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP NEWS
?? ??? ????, PHP 7.3.0RC5
- Core:
+ . Fixed bug #76825 (Undefined symbols ___cpuid_count). (Laruence, cmb)
. Fixed bug #77110 (undefined symbol zend_string_equal_val in C++ build).
(Remi)
@@ -139,7 +140,6 @@ PHP NEWS
13 Sep 2018, PHP 7.3.0RC1
- Core:
- . Fixed bug #76825 (Undefined symbols ___cpuid_count). (Laruence)
. Fixed bug #76820 (Z_COPYABLE invalid definition). (mvdwerve, cmb)
. Fixed bug #76510 (file_exists() stopped working for phar://). (cmb)
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 20dd0f9a39..67cea95a91 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -596,3 +596,21 @@ dnl This is the most probable fallback so we assume yes in case of cross compile
if test "$ac_cv_huge_val_nan" = "yes"; then
AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
fi
+
+dnl
+dnl Check whether __cpuid_count is available
+dnl
+AC_CACHE_CHECK(whether __cpuid_count is available, ac_cv_cpuid_count_available, [
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ #include <cpuid.h>
+]], [[
+ unsigned eax, ebx, ecx, edx;
+ __cpuid_count(0, 0, eax, ebx, ecx, edx);
+]])], [
+ ac_cv_cpuid_count_available=yes
+], [
+ ac_cv_cpuid_count_available=no
+])])
+if test "$ac_cv_cpuid_count_available" = "yes"; then
+ AC_DEFINE([HAVE_CPUID_COUNT], 1, [whether __cpuid_count is available])
+fi
diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c
index ffa370416d..5791a11c62 100644
--- a/Zend/zend_cpuinfo.c
+++ b/Zend/zend_cpuinfo.c
@@ -29,7 +29,7 @@ typedef struct _zend_cpu_info {
static zend_cpu_info cpuinfo = {0};
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-# ifdef HAVE_CPUID_H
+# if defined(HAVE_CPUID_H) && defined(HAVE_CPUID_COUNT)
# include <cpuid.h>
static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) {
__cpuid_count(func, subfunc, cpuinfo->eax, cpuinfo->ebx, cpuinfo->ecx, cpuinfo->edx);