summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-09-24 13:28:56 +0100
committerGeorge Peter Banyard <girgias@php.net>2020-09-28 13:18:47 +0100
commit07a2f304178269398f18e5b68c9d3e8ac1bb1b12 (patch)
tree2344123658c702de6ce8b25bfb112256877aaa1c
parent978a44c9c6aff5bb40067ae3c38536b5e27f195f (diff)
downloadphp-git-07a2f304178269398f18e5b68c9d3e8ac1bb1b12.tar.gz
Extensions should have the final say on their compiler flags
Currently compiler flags passed by extensions using the standard ``PHP_NEW_EXTENSION`` and ``PHP_ADD_SOURCES`` m4 macros are prepended before the ones defined by ``Zend/Zend.m4``. This was not really an issue before as ``Zend.m4`` only included ``-Wall`` but since the addition of ``-Wextra`` various issue about disabling flags have been brought up. A preliminary attempt was done in commit 5c1cf7669b937dcb4589cb0c8deccd343dfd85f9 but this turns out to be more or less irrelevant. The root issue is that ``PHP_NEW_EXTENSION`` and ``PHP_ADD_SOURCES`` call the ``PHP_ADD_SOURCES_X`` macro and pass their flags as the 3rd argument which prepends the flags. There exists a 6th argument for this macro which appends them but from a cursory look at https://heap.space/search?full=PHP_ADD_SOURCES_X&project=php-src this is not used. Moreover, the comment describing this macro explicitly informs that this macro should not be used directly. As such we drop the 6th argument of ``PHP_ADD_SOURCES_X`` and move the `special-flags` argument to be appended instead of prepended. Closes GH-6204
-rw-r--r--UPGRADING.INTERNALS8
-rw-r--r--build/php.m410
2 files changed, 13 insertions, 5 deletions
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index d69ca710f9..c15cbef3b1 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -440,6 +440,14 @@ PHP 8.0 INTERNALS UPGRADE NOTES
2. The PHP_CHECK_GCC_ARG() m4 macro has been removed in favor of
AX_CHECK_COMPILE_FLAG().
+ 3. The 6th argument of PHP_ADD_SOURCES_X has been removed.
+
+ 4. The 'special-flags' (3rd) argument of PHP_ADD_SOURCES_X are
+ now appended instead of prepended to previous compiler flags.
+ This means compiler flags passed to PHP_NEW_EXTENSION and PHP_ADD_SOURCES
+ are now appended, this allows to disable compiler flags set by Zend/Zend.m4
+ (e.g. disable certain compiler flags enabled by -Wextra)
+
c. Windows build system changes
- The configuration option --enable-crt-debug has been removed. The VC
diff --git a/build/php.m4 b/build/php.m4
index 1f77f38e57..b4cf3edcf3 100644
--- a/build/php.m4
+++ b/build/php.m4
@@ -218,7 +218,7 @@ ifelse($1,shared,[
])
dnl
-dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
+dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared]]])
dnl
dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the name of the
dnl array target-var directly, as well as whether shared objects will be built
@@ -251,10 +251,10 @@ dnl Append to the array which has been dynamically chosen at m4 time.
dnl Choose the right compiler/flags/etc. for the source-file.
case $ac_src in
- *.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
- *.s[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
- *.S[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
- *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;;
+ *.c[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;;
+ *.s[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;;
+ *.S[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;;
+ *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $ac_inc $b_cxx_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_cxx_post" ;;
esac
dnl Create a rule for the object/source combo.