]> granicus.if.org Git - php/commitdiff
Change the way JIT availability is checked
authorAnatol Belski <ab@php.net>
Sat, 3 Nov 2018 19:29:51 +0000 (20:29 +0100)
committerAnatol Belski <ab@php.net>
Sat, 3 Nov 2018 19:50:05 +0000 (20:50 +0100)
The pcre2_jit_compile_8 sysmbol is always available, even JIT might be
not. If JIT is not enabled explicitly and is enabled in the PHP runtime,
this will lead to a malfunction. This approach ensures JIT is indeed
available on the given platform. For cross compilation this might get
complicated, as it would require an explicit processor architecture and
PCRE2 version check.

Another solution for this case is to run pcre2_config at runtime. That
however would require more condition checks that would impact
architectures where JIT is available.

ext/pcre/config0.m4

index 753071340da9c70e95b9777efb69baf52da693a5..6b94bac3c9291743c582ce9c26ef5335126fefb6 100644 (file)
@@ -47,20 +47,35 @@ PHP_ARG_WITH(pcre-jit,,[  --with-pcre-jit         Enable PCRE JIT functionality
       fi
     fi
 
+    PHP_EVAL_INCLINE($PCRE2_INC)
+    PHP_EVAL_LIBLINE($PCRE2_LIB)
+    AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
+    AC_DEFINE(HAVE_PCRE, 1, [ ])
+
     if test "$PHP_PCRE_JIT" != "no"; then
-      PHP_CHECK_LIBRARY(pcre2-8, pcre2_jit_compile_8,
+      AC_MSG_CHECKING([for JIT support in PCRE2])
+      AC_RUN_IFELSE([
+        AC_LANG_SOURCE([[
+            #include <pcre2.h>
+            #include <stdlib.h>
+            int main(void) {
+              uint32_t have_jit;
+              pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit);
+              return !have_jit;
+            }
+        ]])], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
+      ],
       [
-        AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
-      ],[
-      ],[
-        $PCRE2_LIB
+        AC_MSG_RESULT([no])
+      ],
+      [
+        dnl cross compilation might want to rely on arch names
+        AC_MSG_RESULT([no])
       ])
     fi
 
-    PHP_EVAL_INCLINE($PCRE2_INC)
-    PHP_EVAL_LIBLINE($PCRE2_LIB)
-    AC_DEFINE(HAVE_PCRE, 1, [ ])
-    AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
     PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
     PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
   else