Don't include system headers in php_config.h #17124
Draft
+48
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Configuration headers (config.h, etc.), as their name implies, are supposed to contain macro definitions to avoid having them to pass on the command line[1]. It seems fine if they include other configuration headers when needed. In any way, they are supposed to be included very early in compilation units which require them.
Doing more than defining simple macros, possibly guarded by defines set during compile time (such as a compiler or platform identification), can lead to subtle issues, which may go unnoticed such as the fallback definitions in the hard-coded (!) fpm_config.h, which may actually be used unconditionally, because the appropriate system headers have not
already been included.
[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.72/html_node/Configuration-Headers.html
So far this is only a partial clean-up of the different configuration files; particularly, almost all of fpm_config.h should be moved elsewhere (likely fpm.h). Before I do this, I'm asking for consensus on the approach outlined above.
Note that this PR is in no way supposed to clean up the module mess we have, nor the include mess, e.g.
php-src/sapi/fpm/fpm/fpm_main.c
Lines 22 to 35 in 07cd468
Includes php.h three times in not even 15 lines of code.