From 2c8c7214f03dee7d998e5f9c175adeb529673e4b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 29 Apr 2026 16:52:20 +0800 Subject: [PATCH] Forward-port #1115 --- src/Package/Target/php/unix.php | 4 + .../spc_fix_avx512_cache_before_80400.patch‎ | 91 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 src/globals/patch/spc_fix_avx512_cache_before_80400.patch‎ diff --git a/src/Package/Target/php/unix.php b/src/Package/Target/php/unix.php index 8bcefa1f..092bb8f4 100644 --- a/src/Package/Target/php/unix.php +++ b/src/Package/Target/php/unix.php @@ -55,6 +55,10 @@ trait unix foreach (glob("{$package->getSourceDir()}/ext/*/*.m4") as $m4file) { FileSystem::replaceFileStr($m4file, 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC('); } + + if (self::getPHPVersionID() >= 80300 && self::getPHPVersionID() < 80400) { + SourcePatcher::patchFile('spc_fix_avx512_cache_before_80400.patch', $this->getSourceDir()); + } } #[Stage] diff --git a/src/globals/patch/spc_fix_avx512_cache_before_80400.patch‎ b/src/globals/patch/spc_fix_avx512_cache_before_80400.patch‎ new file mode 100644 index 00000000..79393c01 --- /dev/null +++ b/src/globals/patch/spc_fix_avx512_cache_before_80400.patch‎ @@ -0,0 +1,91 @@ +--- a/build/php.m4 ++++ b/build/php.m4 +@@ -2812,27 +2812,26 @@ + dnl PHP_CHECK_AVX512_SUPPORTS + dnl + AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [ +- AC_MSG_CHECKING([for avx512 supports in compiler]) +- save_CFLAGS="$CFLAGS" +- CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS" +- +- AC_LINK_IFELSE([AC_LANG_SOURCE([[ +- #include +- int main(void) { +- __m512i mask = _mm512_set1_epi32(0x1); +- char out[32]; +- _mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask)); +- return 0; +- }]])], [ ++ AC_CACHE_CHECK([whether compiler supports AVX-512], [php_cv_have_avx512], [ ++ save_CFLAGS="$CFLAGS" ++ CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS" ++ AC_LINK_IFELSE([AC_LANG_SOURCE([[ ++ #include ++ int main(void) { ++ __m512i mask = _mm512_set1_epi32(0x1); ++ char out[32]; ++ _mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask)); ++ return 0; ++ }]])], ++ [php_cv_have_avx512=yes], ++ [php_cv_have_avx512=no]) ++ CFLAGS="$save_CFLAGS" ++ ]) ++ if test "$php_cv_have_avx512" = "yes"; then + have_avx512_supports=1 +- AC_MSG_RESULT([yes]) +- ], [ ++ else + have_avx512_supports=0 +- AC_MSG_RESULT([no]) +- ]) +- +- CFLAGS="$save_CFLAGS" +- ++ fi + AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_SUPPORTS], + [$have_avx512_supports], [Whether the compiler supports AVX512]) + ]) +@@ -2841,24 +2840,26 @@ + dnl PHP_CHECK_AVX512_VBMI_SUPPORTS + dnl + AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [ +- AC_MSG_CHECKING([for avx512 vbmi supports in compiler]) +- save_CFLAGS="$CFLAGS" +- CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS" +- AC_LINK_IFELSE([AC_LANG_SOURCE([[ +- #include +- int main(void) { +- __m512i mask = _mm512_set1_epi32(0x1); +- char out[32]; +- _mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask)); +- return 0; +- }]])], [ ++ AC_CACHE_CHECK([whether compiler supports AVX-512 VBMI], [php_cv_have_avx512vbmi], [ ++ save_CFLAGS="$CFLAGS" ++ CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS" ++ AC_LINK_IFELSE([AC_LANG_SOURCE([[ ++ #include ++ int main(void) { ++ __m512i mask = _mm512_set1_epi32(0x1); ++ char out[32]; ++ _mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask)); ++ return 0; ++ }]])], ++ [php_cv_have_avx512vbmi=yes], ++ [php_cv_have_avx512vbmi=no]) ++ CFLAGS="$save_CFLAGS" ++ ]) ++ if test "$php_cv_have_avx512vbmi" = "yes"; then + have_avx512_vbmi_supports=1 +- AC_MSG_RESULT([yes]) +- ], [ ++ else + have_avx512_vbmi_supports=0 +- AC_MSG_RESULT([no]) +- ]) +- CFLAGS="$save_CFLAGS" ++ fi + AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS], + [$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI]) + ])