1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix --enable-re2c-cgoto check (#11928)

When the computed goto extension is available to optimize conditional
jumps, option --enable-re2c-cgoto adds the -g flag to re2c.

In this case the AC_LANG_SOURCE is used instead of the AC_LANG_PROG to
not wrap the compilation check program in another main() function. Code
is also simplified and help messages updated. This is a
compiler-agnostic extension, not only available with GCC.

When the check is successful, the -g is added, otherwise not.
This commit is contained in:
Peter Kokot
2024-06-25 16:10:10 +02:00
committed by GitHub
parent f7df238971
commit 5db847e313
2 changed files with 17 additions and 16 deletions

2
NEWS
View File

@@ -30,6 +30,8 @@ PHP NEWS
(Florian Engelhardt)
. Fixed bug GH-14650 (Compute the size of pages before allocating memory).
(Julien Voisin)
. Fixed bug GH-11928 (The --enable-re2c-cgoto doesn't add the -g flag).
(Peter Kokot)
- Curl:
. Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76)

View File

@@ -170,31 +170,30 @@ PHP_PROG_RE2C([1.0.3], [--no-generation-date])
PHP_PROG_PHP()
PHP_ARG_ENABLE([re2c-cgoto],
[whether to enable computed goto gcc extension with re2c],
[whether to enable computed goto extension with re2c],
[AS_HELP_STRING([--enable-re2c-cgoto],
[Enable -g flag to re2c to use computed goto gcc extension])],
[Enable re2c -g flag to optimize conditional jumps using computed goto
extension, if supported by the compiler])],
[no],
[no])
AS_VAR_IF([PHP_RE2C_CGOTO], [no],, [
AC_MSG_CHECKING([whether re2c -g works])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
int main(int argc, const char **argv)
AS_VAR_IF([PHP_RE2C_CGOTO], [no],,
[AC_CACHE_CHECK([whether re2c -g works], [php_cv_have_re2c_cgoto],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
int main(void)
{
argc = argc;
argv = argv;
label1:
;
label2:
static void *adr[] = { &&label1, &&label2};
;
static void *adr[] = { &&label1, &&label2 };
goto *adr[0];
return 0;
}
]])],[
AC_MSG_RESULT([no])
],[
AS_VAR_APPEND([RE2C_FLAGS], [" -g"])
AC_MSG_RESULT([yes])
])
}]])],
[php_cv_have_re2c_cgoto=yes],
[php_cv_have_re2c_cgoto=no])])
AS_VAR_IF([php_cv_have_re2c_cgoto], [yes],
[AS_VAR_APPEND([RE2C_FLAGS], [" -g"])])
])
dnl Platform-specific compile settings.