[php-src] Issue #13727: PHP_TEST_BUILD macro false negatives with -Werror=strict-prototypes
| From: | orlitzky | Date: | Sat, 16 Mar 2024 11:13:38 +0000 |
| Subject: | [php-src] Issue #13727: PHP_TEST_BUILD macro false negatives with -Werror=strict-prototypes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246595@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13727
Author: orlitzky
### Description
The contents of the
PHP_TEST_BUILD macro are,
```
AC_DEFUN([PHP_TEST_BUILD], [
old_LIBS=$LIBS
LIBS="$4 $LIBS"
AC_LINK_IFELSE([AC_LANG_SOURCE([[
$5
char $1();
int main(void) {
$1();
return 0;
}
]])],[
LIBS=$old_LIBS
$2
],[
LIBS=$old_LIBS
$3
])
])
```
The char $1(); runs afoul of -Wstrict-prototypes, so when that warning is
turned into an error via CFLAGS, it can cause the build test to fail even if the
function/library it's checking for is present.
I found this accidentally while testing ext/gd with -Werror=strict-prototypes in my
CFLAGS (from working on an unrelated problem):
```
$ ./configure --disable-all --enable-gd
...
checking for GD support... yes
checking for external libgd... no
checking for libavif... no
checking for libwebp... no
checking for libjpeg... no
checking for libXpm... no
checking for FreeType 2... no
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for zlib... yes
checking for libpng... yes
configure: error: GD build test failed. Please check the config.log for details.
```
The generated program is,
```C
char foobar(void) { return '\0'; }
char foobar();
int main(void) {
foobar();
return 0;
}
```
and the compiler error was,
```
conftest.c:225:5: error: function declaration isn't a prototype [-Werror=strict-prototypes]
225 | char foobar();
| ^~~~
```
For now, "don't do that" is a valid response, but in a few years we'll start
seeing newer compilers enable these things by default. The result here is not too bad because the
build dies, but in the worst case, features could quietly be disabled.
### PHP Version
git HEAD
### Operating System
_No response_