Skip to content

Commit 07a2f30

Browse files
committed
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 5c1cf76 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
1 parent 978a44c commit 07a2f30

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

UPGRADING.INTERNALS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,14 @@ PHP 8.0 INTERNALS UPGRADE NOTES
440440
2. The PHP_CHECK_GCC_ARG() m4 macro has been removed in favor of
441441
AX_CHECK_COMPILE_FLAG().
442442

443+
3. The 6th argument of PHP_ADD_SOURCES_X has been removed.
444+
445+
4. The 'special-flags' (3rd) argument of PHP_ADD_SOURCES_X are
446+
now appended instead of prepended to previous compiler flags.
447+
This means compiler flags passed to PHP_NEW_EXTENSION and PHP_ADD_SOURCES
448+
are now appended, this allows to disable compiler flags set by Zend/Zend.m4
449+
(e.g. disable certain compiler flags enabled by -Wextra)
450+
443451
c. Windows build system changes
444452

445453
- The configuration option --enable-crt-debug has been removed. The VC

build/php.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ ifelse($1,shared,[
218218
])
219219

220220
dnl
221-
dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
221+
dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared]]])
222222
dnl
223223
dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the name of the
224224
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.
251251
252252
dnl Choose the right compiler/flags/etc. for the source-file.
253253
case $ac_src in
254-
*.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" ;;
255-
*.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" ;;
256-
*.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" ;;
257-
*.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" ;;
254+
*.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" ;;
255+
*.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" ;;
256+
*.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" ;;
257+
*.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" ;;
258258
esac
259259
260260
dnl Create a rule for the object/source combo.

0 commit comments

Comments
 (0)