Skip to content

Commit

Permalink
Fix --enable-re2c-cgoto check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petk committed Jun 24, 2024
1 parent df6d85a commit 54c0c7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 15 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 54c0c7f

Please sign in to comment.