Skip to content

Commit 54d8053

Browse files
committed
Fix bug #73121 Bundled PCRE doesn't compile because JIT isn't supported on s390
1 parent a95caa2 commit 54d8053

File tree

5 files changed

+39
-11
lines changed

5 files changed

+39
-11
lines changed

ext/pcre/config.w32

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ AC_DEFINE('HAVE_PCRE', 1, 'Have PCRE library');
1111
PHP_PCRE="yes";
1212
PHP_INSTALL_HEADERS("ext/pcre", "php_pcre.h pcrelib/");
1313
ADD_FLAG("CFLAGS_PCRE", " /D HAVE_CONFIG_H");
14+
15+
ARG_WITH("pcre-jit", "Enable PCRE JIT support", "yes");
16+
if (PHP_PCRE_JIT != "no") {
17+
AC_DEFINE('HAVE_PCRE_JIT_SUPPORT', 1, 'PCRE library');
18+
}
19+

ext/pcre/config0.m4

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,15 @@ PHP_ARG_WITH(pcre-regex,,
6666
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcrelib/])
6767
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
6868
fi
69+
70+
PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality], yes, no)
71+
if test "$PHP_PCRE_REGEX" != "no"; then
72+
AC_MSG_CHECKING([whether to enable PCRE JIT functionality])
73+
if test "$PHP_PCRE_JIT" != "no"; then
74+
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
75+
AC_MSG_RESULT([yes])
76+
else
77+
AC_MSG_RESULT([no])
78+
fi
79+
fi
80+

ext/pcre/pcrelib/config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
#include <php_compat.h>
33

4-
#ifndef PHP_WIN32
4+
#ifdef PHP_WIN32
5+
# include <config.w32.h>
6+
#else
57
# include <php_config.h>
68
#endif
79

@@ -397,7 +399,9 @@ them both to 0; an emulation function will be used. */
397399
#undef SUPPORT_GCOV
398400

399401
/* Define to any value to enable support for Just-In-Time compiling. */
402+
#if HAVE_PCRE_JIT_SUPPORT
400403
#define SUPPORT_JIT
404+
#endif
401405

402406
/* Define to any value to allow pcregrep to be linked with libbz2, so that it
403407
is able to handle .bz2 files. */

ext/pcre/php_pcre.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum {
6262

6363
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(pcre)
6464

65-
#ifdef PCRE_STUDY_JIT_COMPILE
65+
#ifdef HAVE_PCRE_JIT_SUPPORT
6666
#define PCRE_JIT_STACK_MIN_SIZE (32 * 1024)
6767
#define PCRE_JIT_STACK_MAX_SIZE (64 * 1024)
6868
ZEND_TLS pcre_jit_stack *jit_stack = NULL;
@@ -89,7 +89,7 @@ static void pcre_handle_exec_error(int pcre_code) /* {{{ */
8989
preg_code = PHP_PCRE_BAD_UTF8_OFFSET_ERROR;
9090
break;
9191

92-
#ifdef PCRE_STUDY_JIT_COMPILE
92+
#ifdef HAVE_PCRE_JIT_SUPPORT
9393
case PCRE_ERROR_JIT_STACKLIMIT:
9494
preg_code = PHP_PCRE_JIT_STACKLIMIT_ERROR;
9595
break;
@@ -135,7 +135,7 @@ static PHP_GSHUTDOWN_FUNCTION(pcre) /* {{{ */
135135
{
136136
zend_hash_destroy(&pcre_globals->pcre_cache);
137137

138-
#ifdef PCRE_STUDY_JIT_COMPILE
138+
#ifdef HAVE_PCRE_JIT_SUPPORT
139139
/* Stack may only be destroyed when no cached patterns
140140
possibly associated with it do exist. */
141141
if (jit_stack) {
@@ -150,7 +150,7 @@ static PHP_GSHUTDOWN_FUNCTION(pcre) /* {{{ */
150150
PHP_INI_BEGIN()
151151
STD_PHP_INI_ENTRY("pcre.backtrack_limit", "1000000", PHP_INI_ALL, OnUpdateLong, backtrack_limit, zend_pcre_globals, pcre_globals)
152152
STD_PHP_INI_ENTRY("pcre.recursion_limit", "100000", PHP_INI_ALL, OnUpdateLong, recursion_limit, zend_pcre_globals, pcre_globals)
153-
#ifdef PCRE_STUDY_JIT_COMPILE
153+
#ifdef HAVE_PCRE_JIT_SUPPORT
154154
STD_PHP_INI_ENTRY("pcre.jit", "1", PHP_INI_ALL, OnUpdateBool, jit, zend_pcre_globals, pcre_globals)
155155
#endif
156156
PHP_INI_END()
@@ -159,17 +159,23 @@ PHP_INI_END()
159159
/* {{{ PHP_MINFO_FUNCTION(pcre) */
160160
static PHP_MINFO_FUNCTION(pcre)
161161
{
162+
#ifdef HAVE_PCRE_JIT_SUPPORT
162163
int jit_yes = 0;
164+
#endif
163165

164166
php_info_print_table_start();
165167
php_info_print_table_row(2, "PCRE (Perl Compatible Regular Expressions) Support", "enabled" );
166168
php_info_print_table_row(2, "PCRE Library Version", pcre_version() );
167169

170+
#ifdef HAVE_PCRE_JIT_SUPPORT
168171
if (!pcre_config(PCRE_CONFIG_JIT, &jit_yes)) {
169172
php_info_print_table_row(2, "PCRE JIT Support", jit_yes ? "enabled" : "disabled");
170173
} else {
171174
php_info_print_table_row(2, "PCRE JIT Support", "unknown" );
172175
}
176+
#else
177+
php_info_print_table_row(2, "PCRE JIT Support", "not compiled in" );
178+
#endif
173179

174180
php_info_print_table_end();
175181

@@ -212,7 +218,7 @@ static PHP_MSHUTDOWN_FUNCTION(pcre)
212218
}
213219
/* }}} */
214220

215-
#ifdef PCRE_STUDY_JIT_COMPILE
221+
#ifdef HAVE_PCRE_JIT_SUPPORT
216222
/* {{{ PHP_RINIT_FUNCTION(pcre) */
217223
static PHP_RINIT_FUNCTION(pcre)
218224
{
@@ -474,7 +480,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
474480
return NULL;
475481
}
476482

477-
#ifdef PCRE_STUDY_JIT_COMPILE
483+
#ifdef HAVE_PCRE_JIT_SUPPORT
478484
if (PCRE_G(jit)) {
479485
/* Enable PCRE JIT compiler */
480486
do_study = 1;
@@ -490,7 +496,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
490496
extra->flags |= PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION;
491497
extra->match_limit = (unsigned long)PCRE_G(backtrack_limit);
492498
extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit);
493-
#ifdef PCRE_STUDY_JIT_COMPILE
499+
#ifdef HAVE_PCRE_JIT_SUPPORT
494500
if (PCRE_G(jit) && jit_stack) {
495501
pcre_assign_jit_stack(extra, NULL, jit_stack);
496502
}
@@ -2180,10 +2186,10 @@ zend_module_entry pcre_module_entry = {
21802186
pcre_functions,
21812187
PHP_MINIT(pcre),
21822188
PHP_MSHUTDOWN(pcre),
2183-
#ifdef PCRE_STUDY_JIT_COMPILE
2189+
#ifdef HAVE_PCRE_JIT_SUPPORT
21842190
PHP_RINIT(pcre),
21852191
#else
2186-
NULL
2192+
NULL,
21872193
#endif
21882194
NULL,
21892195
PHP_MINFO(pcre),

ext/pcre/php_pcre.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcre)
7575
HashTable pcre_cache;
7676
zend_long backtrack_limit;
7777
zend_long recursion_limit;
78-
#ifdef PCRE_STUDY_JIT_COMPILE
78+
#ifdef HAVE_PCRE_JIT_SUPPORT
7979
zend_bool jit;
8080
#endif
8181
int error_code;

0 commit comments

Comments
 (0)