]> granicus.if.org Git - php/commitdiff
Fix bundled libpcre2 build regarding the `-fcf-protection` gcc flag
authorChristoph M. Becker <cmbecker69@gmx.de>
Thu, 17 Sep 2020 14:16:44 +0000 (16:16 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Thu, 17 Sep 2020 14:21:01 +0000 (16:21 +0200)
Cf. <https://bugs.exim.org/show_bug.cgi?id=2578>.

ext/pcre/config0.m4

index 714a8d57e8a86609d96e71d81974e0d1653a206f..7e572019548857d89a49b99b0db14fb9e460cbec 100644 (file)
@@ -68,9 +68,6 @@ else
   pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \
   pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c pcre2lib/pcre2_script_run.c"
   PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
-  PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
-  PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
-  PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
   AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
   AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
 
@@ -78,10 +75,31 @@ else
   if test "$PHP_PCRE_JIT" != "no"; then
     AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
     AC_MSG_RESULT([yes])
+
+    AC_CACHE_CHECK([whether Intel CET is enabled], ac_cv_have_pcre2_intel_cet, [
+      AC_COMPILE_IFELSE([
+        AC_LANG_SOURCE([[
+          #ifndef __CET__
+          # error CET is not enabled
+          #endif
+        ]])], [
+          ac_cv_have_pcre2_intel_cet=yes
+        ], [
+          ac_cv_have_pcre2_intel_cet=no
+        ])
+      if test "$ac_cv_have_pcre2_intel_cet" = yes; then
+        PHP_PCRE_CFLAGS="-mshstk $PHP_PCRE_CFLAGS"
+      fi
+    ])
+
   else
     AC_MSG_RESULT([no])
   fi
 
+  PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
+  PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
+  PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
+
   if test "$PHP_VALGRIND" != "no" && test "$have_valgrind" = "yes"; then
       dnl Enable pcre valgrind support only in DEBUG build (it affects performance)
       if test "$ZEND_DEBUG" = "yes"; then