mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix the aligned variable attribute check (#14211)
By default compilers may not treat attribute warnings as errors when encountering an unknown __attribute__, unless some error option is provided (-Werror=attributes, -Werror=unknown-attributes, -Werror...). This fixes the check and wraps it into a separate M4 macro to be extendable in the future if needed. It checks if conftest.err file was generated by the compilation check when warnings appear. Also, PHP check is a bit customized by using __alignof__ keyword, so it is left in there for now to not break existing checks.
This commit is contained in:
parent
52767343b2
commit
bc09cd2bc8
3 changed files with 33 additions and 16 deletions
30
build/php.m4
30
build/php.m4
|
@ -2743,3 +2743,33 @@ AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [
|
|||
AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS],
|
||||
[$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl PHP_CHECK_VARIABLE_ATTRIBUTE(attribute)
|
||||
dnl
|
||||
dnl Check whether the compiler supports the GNU C variable attribute.
|
||||
dnl
|
||||
AC_DEFUN([PHP_CHECK_VARIABLE_ATTRIBUTE],
|
||||
[AS_VAR_PUSHDEF([php_var], [php_cv_have_variable_attribute_$1])
|
||||
AC_CACHE_CHECK([for variable __attribute__(($1))], [php_var],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([m4_case([$1],
|
||||
[aligned],
|
||||
[unsigned char test[32] __attribute__(($1(__alignof__(int))));],
|
||||
[
|
||||
m4_warn([syntax], [Unsupported variable attribute $1, the test may fail])
|
||||
int var __attribute__(($1));
|
||||
])],
|
||||
[])],
|
||||
dnl By default, compilers may not classify attribute warnings as errors
|
||||
dnl (-Werror=attributes) when encountering an unknown attribute. Accept the
|
||||
dnl attribute only if no warnings were generated.
|
||||
[AS_IF([test -s conftest.err],
|
||||
[AS_VAR_SET([php_var], [no])],
|
||||
[AS_VAR_SET([php_var], [yes])])],
|
||||
[AS_VAR_SET([php_var], [no])])
|
||||
])
|
||||
AS_VAR_IF([php_var], [yes],
|
||||
[AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_ATTRIBUTE_$1]), [1],
|
||||
[Define to 1 if the compiler supports the '$1' variable attribute.])])
|
||||
AS_VAR_POPDEF([php_var])
|
||||
])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue