Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP_TEST_BUILD macro false negatives with -Werror=strict-prototypes #13727

Closed
orlitzky opened this issue Mar 16, 2024 · 0 comments
Closed

PHP_TEST_BUILD macro false negatives with -Werror=strict-prototypes #13727

orlitzky opened this issue Mar 16, 2024 · 0 comments

Comments

@orlitzky
Copy link
Contributor

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,

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

devnexen added a commit to devnexen/php-src that referenced this issue Mar 16, 2024
devnexen added a commit to devnexen/php-src that referenced this issue Mar 17, 2024
devnexen added a commit to devnexen/php-src that referenced this issue Mar 18, 2024
autoconf/libtool generating code to test features missed `void` for
C calls prototypes w/o arguments.
Note that specific changes related to libtool have to upstreamed.
petk added a commit to petk/php-src that referenced this issue Apr 21, 2024
This is addon to the phpGH-13727 bug fix. When configuring the build with:

  ./configure CFLAGS=-Werror=strict-prototypes

libtool check for parsing nm command would fail:

  checking command to parse /usr/bin/nm -B output from cc object... failed

Upstream libtool has this specific check already fixed. Note that this
works only with Autoconf version 2.72 and later and is preparation for
future compilers that might have this error enabled by default.
petk added a commit to petk/php-src that referenced this issue Apr 22, 2024
This is addon to the phpGH-13727 bug fix. When configuring the build with:

  ./configure CFLAGS=-Werror=strict-prototypes

libtool check for parsing nm command would fail:

  checking command to parse /usr/bin/nm -B output from cc object... failed

Upstream libtool has this specific check already fixed. Note that this
works only with Autoconf version 2.72 and later and is preparation for
future compilers that might have this error enabled by default.
petk added a commit that referenced this issue Apr 22, 2024
This is addon to the GH-13727 bug fix. When configuring the build with:

  ./configure CFLAGS=-Werror=strict-prototypes

libtool check for parsing nm command would fail:

  checking command to parse /usr/bin/nm -B output from cc object... failed

Upstream libtool has this specific check already fixed. Note that this
works only with Autoconf version 2.72 and later and is preparation for
future compilers that might have this error enabled by default.
petk added a commit that referenced this issue Apr 22, 2024
* PHP-8.2:
  Fix GH-13727: Building with -Werror=strict-prototypes (#14029)
petk added a commit that referenced this issue Apr 22, 2024
* PHP-8.3:
  Fix GH-13727: Building with -Werror=strict-prototypes (#14029)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants