Skip to content

Commit aea4116

Browse files
committed
Change the way JIT availability is checked
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.
1 parent d92f763 commit aea4116

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

ext/pcre/config0.m4

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,35 @@ PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality
4747
fi
4848
fi
4949

50+
PHP_EVAL_INCLINE($PCRE2_INC)
51+
PHP_EVAL_LIBLINE($PCRE2_LIB)
52+
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
53+
AC_DEFINE(HAVE_PCRE, 1, [ ])
54+
5055
if test "$PHP_PCRE_JIT" != "no"; then
51-
PHP_CHECK_LIBRARY(pcre2-8, pcre2_jit_compile_8,
56+
AC_MSG_CHECKING([for JIT support in PCRE2])
57+
AC_RUN_IFELSE([
58+
AC_LANG_SOURCE([[
59+
#include <pcre2.h>
60+
#include <stdlib.h>
61+
int main(void) {
62+
uint32_t have_jit;
63+
pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit);
64+
return !have_jit;
65+
}
66+
]])], [
67+
AC_MSG_RESULT([yes])
68+
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
69+
],
5270
[
53-
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
54-
],[
55-
],[
56-
$PCRE2_LIB
71+
AC_MSG_RESULT([no])
72+
],
73+
[
74+
dnl cross compilation might want to rely on arch names
75+
AC_MSG_RESULT([no])
5776
])
5877
fi
5978

60-
PHP_EVAL_INCLINE($PCRE2_INC)
61-
PHP_EVAL_LIBLINE($PCRE2_LIB)
62-
AC_DEFINE(HAVE_PCRE, 1, [ ])
63-
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
6479
PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
6580
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
6681
else

0 commit comments

Comments
 (0)