[php-src] PR #25690: Fix GH-25688: C++ sources of intl and pdo_firebird are built without optimization
| From: | ArtUkrainskiy | Date: | Tue, 24 Nov 2026 01:41:22 +0000 |
| Subject: | [php-src] PR #25690: Fix GH-25688: C++ sources of intl and pdo_firebird are built without optimization | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40941@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25690
Author: ArtUkrainskiy
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.