Skip to content

Fix GH-13727: Building with -Werror=strict-prototypes - #14029

Merged
petk merged 1 commit into
php:PHP-8.2from
petk:patch-GH-13727-strict-prototypes
Apr 22, 2024
Merged

petk merged 1 commit into
php:PHP-8.2from
petk:patch-GH-13727-strict-prototypes

Conversation

@petk

@petk petk commented Apr 21, 2024

Copy link
Copy Markdown
Member

This is addon to the GH-13727 bug fix that was fixed in GH-13732. 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.

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@arnaud-lb arnaud-lb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many checks are at risk of being silently broken by -Werror unfortunately.

The --enable-werror switch adds -Werror to CFLAGS after all checks have run, which avoids this problem.

Unfortunately users may add -Werror manually and unknowingly break something. I don't know if we can do something about this. Maybe error out early if CFLAGS contain Werror? Or remove Werror during checks? Or remove Werror at the beginning of configure and re-add it at the end?

@petk

petk commented Apr 21, 2024

Copy link
Copy Markdown
Member Author

Compiler might have this enabled by default, so it won't be in the CFLAGS. This above example with CFLAGS is only to test it on compilers without this enabled.

@arnaud-lb

Copy link
Copy Markdown
Member

Do you know which compilers treat warnings as errors by default? To be clear I don't oppose the change, but I was wondering how we could handle this problem generally

@petk

petk commented Apr 21, 2024 •

Copy link
Copy Markdown
Member Author

As far as I understand, Clang 16+ and GCC 14+ on future Fedora systems is one of these examples. Probably also on Gentoo. I have no list of these yet. 🤷 I just follow comments from other PRs in this case :D

Also, from what I read is that when compiler will follow C standards more strictly, this will become an issue. But there's still enough time to fix these kind of syntax before this will be enabled.

Probably @remicollet or @orlitzky might know more here.

@arnaud-lb

Copy link
Copy Markdown
Member

Do you mean new warnings, or treating them as error by default?

@petk

petk commented Apr 21, 2024

Copy link
Copy Markdown
Member Author

Do you mean new warnings, or treating them as error by default?

Yes, not only warning, but errors:

@arnaud-lb

Copy link
Copy Markdown
Member

Thank you!

@orlitzky

Copy link
Copy Markdown
Contributor

Gentoo is rolling-release, source-based, and has crazy users. As soon as these new compilers are released, they'll be available, and someone will make it his default and try to rebuild his entire system with it.

So +1 for fixing these issues before that guy files a bug about it. Thanks!

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
petk force-pushed the patch-GH-13727-strict-prototypes branch from f6b40be to 3a77a7f Compare April 22, 2024 19:20
@petk
petk merged commit 44775b7 into php:PHP-8.2 Apr 22, 2024
petk added a commit that referenced this pull request Apr 22, 2024
* PHP-8.2:
  Fix GH-13727: Building with -Werror=strict-prototypes (#14029)
petk added a commit that referenced this pull request Apr 22, 2024
* PHP-8.3:
  Fix GH-13727: Building with -Werror=strict-prototypes (#14029)
@petk
petk deleted the patch-GH-13727-strict-prototypes branch April 22, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants