Skip to content

Commit f3feef8

Browse files
authored
Define default RE2C_FLAGS (#14615)
The --no-generation-date flag is a common re2c flag used in all re2c invocations. This adds the 2nd optional argument to PHP_PROG_RE2C M4 macro in BC manner to set the default re2c command-line options and sets the default RE2C_FLAGS similarly on Windows.
1 parent e4250ce commit f3feef8

22 files changed

+42
-39
lines changed

UPGRADING.INTERNALS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
142142
AC_CHECK_MEMBERS).
143143
- M4 macro PHP_CHECK_GCC_ARG has been removed since PHP 8.0 (use
144144
AX_CHECK_COMPILE_FLAG).
145+
- M4 macro PHP_PROG_RE2C got a new 2nd argument to define common default re2c
146+
command-line options substituted to the Makefile RE2C_FLAGS variable.
145147
- Added php-config --lib-dir and --lib-embed options for PHP embed SAPI.
146148
- PDO extensions in php-src don't have the include flag -I$pdo_cv_inc_path
147149
directory anymore.

Zend/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $(builddir)/zend_language_scanner.lo: $(srcdir)/zend_language_parser.h
66
$(builddir)/zend_ini_scanner.lo: $(srcdir)/zend_ini_parser.h
77

88
$(srcdir)/zend_language_scanner.c $(srcdir)/zend_language_scanner_defs.h: $(srcdir)/zend_language_scanner.l
9-
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l)
9+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l)
1010

1111
$(srcdir)/zend_language_parser.h: $(srcdir)/zend_language_parser.c
1212
$(srcdir)/zend_language_parser.c: $(srcdir)/zend_language_parser.y
@@ -26,7 +26,7 @@ $(srcdir)/zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
2626
@$(YACC) $(YFLAGS) -v -d $(srcdir)/zend_ini_parser.y -o $@
2727

2828
$(srcdir)/zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
29-
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l)
29+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l)
3030

3131
# Use an intermediate target to indicate that zend_vm_gen.php produces both files
3232
# at the same time, rather than the same recipe applying for two different targets.

build/php.m4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,10 +1690,12 @@ AC_DEFUN([PHP_PROG_BISON], [
16901690
])
16911691

16921692
dnl
1693-
dnl PHP_PROG_RE2C([MIN-VERSION])
1693+
dnl PHP_PROG_RE2C([min-version], [options])
16941694
dnl
16951695
dnl Search for the re2c and optionally check if version is at least the minimum
1696-
dnl required version MIN-VERSION.
1696+
dnl required version "min-version". The blank-or-newline-separated "options" are
1697+
dnl the re2c command-line flags substituted into a Makefile variable RE2C_FLAGS
1698+
dnl which can be added to all re2c invocations.
16971699
dnl
16981700
AC_DEFUN([PHP_PROG_RE2C],[
16991701
AC_CHECK_PROG(RE2C, re2c, re2c)
@@ -1745,6 +1747,8 @@ AC_DEFUN([PHP_PROG_RE2C],[
17451747
esac
17461748
17471749
PHP_SUBST(RE2C)
1750+
AS_VAR_SET([RE2C_FLAGS], [m4_normalize([$2])])
1751+
PHP_SUBST([RE2C_FLAGS])
17481752
])
17491753

17501754
AC_DEFUN([PHP_PROG_PHP],[

configure.ac

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ PHP_RUNPATH_SWITCH
166166
dnl Checks for some support/generator progs.
167167
PHP_PROG_AWK
168168
PHP_PROG_BISON([3.0.0])
169-
PHP_PROG_RE2C([1.0.3])
169+
PHP_PROG_RE2C([1.0.3], [--no-generation-date])
170170
PHP_PROG_PHP()
171171

172172
PHP_ARG_ENABLE([re2c-cgoto],
@@ -176,9 +176,7 @@ PHP_ARG_ENABLE([re2c-cgoto],
176176
[no],
177177
[no])
178178

179-
if test "$PHP_RE2C_CGOTO" = "no"; then
180-
RE2C_FLAGS=""
181-
else
179+
AS_VAR_IF([PHP_RE2C_CGOTO], [no],, [
182180
AC_MSG_CHECKING([whether re2c -g works])
183181
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
184182
int main(int argc, const char **argv)
@@ -192,14 +190,12 @@ label2:
192190
return 0;
193191
}
194192
]])],[
195-
RE2C_FLAGS=""
196193
AC_MSG_RESULT([no])
197194
],[
198-
RE2C_FLAGS="-g"
195+
AS_VAR_APPEND([RE2C_FLAGS], [" -g"])
199196
AC_MSG_RESULT([yes])
200197
])
201-
fi
202-
PHP_SUBST(RE2C_FLAGS)
198+
])
203199

204200
dnl Platform-specific compile settings.
205201
dnl ----------------------------------------------------------------------------

ext/json/Makefile.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$(srcdir)/json_scanner.c $(srcdir)/php_json_scanner_defs.h: $(srcdir)/json_scanner.re $(srcdir)/json_parser.tab.h
2-
@$(RE2C) $(RE2C_FLAGS) -t $(srcdir)/php_json_scanner_defs.h --no-generation-date -bci -o $(srcdir)/json_scanner.c $(srcdir)/json_scanner.re
2+
@$(RE2C) $(RE2C_FLAGS) -t $(srcdir)/php_json_scanner_defs.h -bci -o $(srcdir)/json_scanner.c $(srcdir)/json_scanner.re
33

44
$(srcdir)/json_parser.tab.c $(srcdir)/json_parser.tab.h: $(srcdir)/json_parser.y
55
@$(YACC) $(YFLAGS) --defines -l $(srcdir)/json_parser.y -o $(srcdir)/json_parser.tab.c

ext/json/Makefile.frag.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ext\json\json_scanner.c ext\json\php_json_scanner_defs.h: ext\json\json_scanner.re ext\json\json_parser.tab.h
2-
$(RE2C) $(RE2C_FLAGS) -t ext/json/php_json_scanner_defs.h --no-generation-date -bci -o ext/json/json_scanner.c ext/json/json_scanner.re
2+
$(RE2C) $(RE2C_FLAGS) -t ext/json/php_json_scanner_defs.h -bci -o ext/json/json_scanner.c ext/json/json_scanner.re
33

44
ext\json\json_parser.tab.c ext\json\json_parser.tab.h: ext\json\json_parser.y
55
$(BISON) $(BISON_FLAGS) --defines -l ext/json/json_parser.y -o ext/json/json_parser.tab.c

ext/pdo/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(srcdir)/pdo_sql_parser.c: $(srcdir)/pdo_sql_parser.re
22
@(cd $(top_srcdir); \
33
if test -f ./pdo_sql_parser.re; then \
4-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o pdo_sql_parser.c pdo_sql_parser.re; \
4+
$(RE2C) $(RE2C_FLAGS) -o pdo_sql_parser.c pdo_sql_parser.re; \
55
else \
6-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re; \
6+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re; \
77
fi)

ext/pdo/Makefile.frag.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ext\pdo\pdo_sql_parser.c: ext\pdo\pdo_sql_parser.re
22
cd $(PHP_SRC_DIR)
3-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re
3+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re

ext/pdo_mysql/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(srcdir)/mysql_sql_parser.c: $(srcdir)/mysql_sql_parser.re
22
@(cd $(top_srcdir); \
33
if test -f ./mysql_sql_parser.re; then \
4-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o mysql_sql_parser.c mysql_sql_parser.re; \
4+
$(RE2C) $(RE2C_FLAGS) -o mysql_sql_parser.c mysql_sql_parser.re; \
55
else \
6-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re; \
6+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re; \
77
fi)

ext/pdo_mysql/Makefile.frag.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ext\pdo_mysql\mysql_sql_parser.c: ext\pdo_mysql\mysql_sql_parser.re
22
cd $(PHP_SRC_DIR)
3-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re
3+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re

ext/pdo_pgsql/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(srcdir)/pgsql_sql_parser.c: $(srcdir)/pgsql_sql_parser.re
22
@(cd $(top_srcdir); \
33
if test -f ./pgsql_sql_parser.re; then \
4-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o pgsql_sql_parser.c pgsql_sql_parser.re; \
4+
$(RE2C) $(RE2C_FLAGS) -o pgsql_sql_parser.c pgsql_sql_parser.re; \
55
else \
6-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re; \
6+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re; \
77
fi)

ext/pdo_pgsql/Makefile.frag.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ext\pdo_pgsql\pgsql_sql_parser.c: ext\pdo_pgsql\pgsql_sql_parser.re
22
cd $(PHP_SRC_DIR)
3-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re
3+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re

ext/pdo_sqlite/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(srcdir)/sqlite_sql_parser.c: $(srcdir)/sqlite_sql_parser.re
22
@(cd $(top_srcdir); \
33
if test -f ./sqlite_sql_parser.re; then \
4-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o sqlite_sql_parser.c sqlite_sql_parser.re; \
4+
$(RE2C) $(RE2C_FLAGS) -o sqlite_sql_parser.c sqlite_sql_parser.re; \
55
else \
6-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re; \
6+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re; \
77
fi)

ext/pdo_sqlite/Makefile.frag.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ext\pdo_sqlite\sqlite_sql_parser.c: ext\pdo_sqlite\sqlite_sql_parser.re
22
cd $(PHP_SRC_DIR)
3-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re
3+
$(RE2C) $(RE2C_FLAGS) -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re

ext/phar/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
$(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
22
@(cd $(top_srcdir); \
33
if test -f ./php_phar.h; then \
4-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o phar_path_check.c phar_path_check.re; \
4+
$(RE2C) $(RE2C_FLAGS) -b -o phar_path_check.c phar_path_check.re; \
55
else \
6-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re; \
6+
$(RE2C) $(RE2C_FLAGS) -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re; \
77
fi)
88

99
pharcmd: $(builddir)/phar.php $(builddir)/phar.phar

ext/phar/Makefile.frag.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ext\phar\phar_path_check.c: ext\phar\phar_path_check.re
22
cd $(PHP_SRC_DIR)
3-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re
3+
$(RE2C) $(RE2C_FLAGS) -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re

ext/standard/Makefile.frag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
$(srcdir)/var_unserializer.c: $(srcdir)/var_unserializer.re
2-
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re)
2+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re)
33

44
$(srcdir)/url_scanner_ex.c: $(srcdir)/url_scanner_ex.re
5-
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re)
5+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re)
66

77
$(builddir)/info.lo: $(builddir)/../../main/build-defs.h
88

ext/standard/Makefile.frag.w32

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ext\standard\var_unserializer.c: ext\standard\var_unserializer.re
22
cd $(PHP_SRC_DIR)
3-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re
3+
$(RE2C) $(RE2C_FLAGS) -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re
44

55
ext\standard\url_scanner_ex.c: ext\standard\url_scanner_ex.re
66
cd $(PHP_SRC_DIR)
7-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re
7+
$(RE2C) $(RE2C_FLAGS) -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re
88

99
$(BUILD_DIR)\ext\standard\basic_functions.obj: $(PHP_SRC_DIR)\Zend\zend_language_parser.h

sapi/phpdbg/Makefile.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
1414
$(builddir)/phpdbg_lexer.lo: $(srcdir)/phpdbg_parser.h
1515

1616
$(srcdir)/phpdbg_lexer.c: $(srcdir)/phpdbg_lexer.l
17-
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l)
17+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l)
1818

1919
$(srcdir)/phpdbg_parser.h: $(srcdir)/phpdbg_parser.c
2020
$(srcdir)/phpdbg_parser.c: $(srcdir)/phpdbg_parser.y

scripts/dev/genfiles

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ YACC=${YACC:-bison}
3737
YACC="$YACC -l"
3838
YFLAGS="-Wall"
3939
RE2C=${RE2C:-re2c}
40-
RE2C_FLAGS="-i"
40+
RE2C_FLAGS="--no-generation-date -i"
4141
SED=${SED:-sed}
4242
MAKE=${MAKE:-make}
4343

@@ -70,7 +70,7 @@ else
7070
fi
7171

7272
# Check required re2c version from the configure.ac file.
73-
required_re2c_version=$($SED -n 's/PHP_PROG_RE2C(\[\(.*\)\])/\1/p' configure.ac)
73+
required_re2c_version=$($SED -n 's/PHP_PROG_RE2C(\[\([0-9.]*\)\][^)]*)*/\1/p' configure.ac)
7474
set -f; IFS='.'; set -- $required_re2c_version; set +f; IFS=' '
7575
required_re2c_num="$(expr ${1:-0} \* 10000 + ${2:-0} \* 100 + ${3:-0})"
7676

win32/build/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ sapi\phpdbg\phpdbg_parser.c sapi\phpdbg\phpdbg_parser.h: sapi\phpdbg\phpdbg_pars
9090

9191
!if $(RE2C) != ""
9292
Zend\zend_ini_scanner.c Zend\zend_ini_scanner_defs.h: Zend\zend_ini_scanner.l
93-
$(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
93+
$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
9494

9595
Zend\zend_language_scanner.c Zend\zend_language_scanner_defs.h: Zend\zend_language_scanner.l
96-
$(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
96+
$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
9797

9898
sapi\phpdbg\phpdbg_lexer.c: sapi\phpdbg\phpdbg_lexer.l
99-
$(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l
99+
$(RE2C) $(RE2C_FLAGS) -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l
100100
!endif
101101

102102
!if "$(ZTS)" == "1"

win32/build/confutils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,6 +3006,7 @@ function toolset_setup_project_tools()
30063006
}
30073007

30083008
var RE2C = PATH_PROG('re2c');
3009+
DEFINE('RE2C_FLAGS', '--no-generation-date');
30093010
if (RE2C) {
30103011
var RE2CVERS = probe_binary(RE2C, "version");
30113012
STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);

0 commit comments

Comments
 (0)