Skip to content

Fix GH-25688: C++ sources of intl and pdo_firebird are built without optimization - #25690

Open
ArtUkrainskiy wants to merge 1 commit into
php:PHP-8.5from
ArtUkrainskiy:k9-intl-cxxflags
Open

ArtUkrainskiy wants to merge 1 commit into
php:PHP-8.5from
ArtUkrainskiy:k9-intl-cxxflags

Conversation

@ArtUkrainskiy

Copy link
Copy Markdown
Contributor

Fixes GH-25688

Since #16511 (PHP 8.5), configure.ac adds -DNDEBUG or -UNDEBUG to CXXFLAGS before the extensions run AC_PROG_CXX. AC_PROG_CXX sees CXXFLAGS set and skips its default -g -O2. So the C++ sources of intl and pdo_firebird are built without optimization when CXXFLAGS isn't set. Builds that set CXXFLAGS, and phpize builds, aren't affected.

This collects the NDEBUG flags for C++ and appends them to CXXFLAGS after the extensions are configured, next to -Werror. C flags don't change.

-g, -O and NDEBUG flags on the compile line of an intl C++ file:

configure before after
no flags -DNDEBUG -g -O2 -DNDEBUG
--enable-debug -UNDEBUG -g -O0 -g -O0 -UNDEBUG
CXXFLAGS=-O3 -O3 -DNDEBUG -O3 -DNDEBUG
CXXFLAGS=-UNDEBUG -UNDEBUG -DNDEBUG -UNDEBUG -DNDEBUG
--enable-debug-assertions -DNDEBUG -UNDEBUG -g -O2 -DNDEBUG -UNDEBUG

With --enable-zts, clang and --enable-address-sanitizer the C++ file gets the same -g -O2 -DNDEBUG as with no flags.

With -g -O2, MessageFormatter::format() and IntlBreakIterator take 9–11% fewer cycles on a Ryzen 9 5950X with GCC 15. IntlDateFormatter::format(), which is mostly C, doesn't change. ext/intl tests pass before and after, and also on ZTS with the fix. Debug builds keep C assert(), also with CFLAGS=-DNDEBUG. Not tested: Windows, which uses its own build scripts, and pdo_firebird.

…ut optimization

configure.ac appended -DNDEBUG or -UNDEBUG to CXXFLAGS before the
extensions ran AC_PROG_CXX. AC_PROG_CXX then skipped its default -g -O2,
so the C++ sources of intl and pdo_firebird were built without
optimization when CXXFLAGS was not set. The NDEBUG flags for C++ are now
collected and appended after the extensions are configured. C flags do
not change.

With -g -O2, MessageFormatter::format() and IntlBreakIterator take
9-11% fewer cycles (Ryzen 9 5950X, GCC 15).
@ArtUkrainskiy
ArtUkrainskiy marked this pull request as ready for review November 24, 2026 02:07
@TimWolla
TimWolla requested a review from petk November 24, 2026 07:38
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.

1 participant