Skip to content

ext/intl: fix clang build. #18535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: PHP-8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/apt-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ runs:
unixodbc-dev \
llvm \
clang \
libc++-dev \
libc++abi-dev \
libc-client-dev \
dovecot-core \
dovecot-pop3d \
Expand Down
10 changes: 9 additions & 1 deletion build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,15 @@ AC_DEFUN([PHP_REQUIRE_CXX],[
if test -z "$php_cxx_done"; then
AC_PROG_CXX
AC_PROG_CXXCPP
PHP_ADD_LIBRARY(stdc++)
case "$CXX" in
*clang++*)
PHP_ADD_LIBRARY(c++)
PHP_ADD_LIBRARY(c++abi)
;;
*)
PHP_ADD_LIBRARY(stdc++)
;;
esac
php_cxx_done=yes
fi
])
Expand Down
5 changes: 5 additions & 0 deletions build/php_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ AC_DEFUN([PHP_CXX_COMPILE_STDCXX], [dnl
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
case "$CXX" in
*clang++*)
switch="${switch} -stdlib=libc++"
;;
esac
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ int main(void) {
CFLAGS="$OLD_CFLAGS"
if test "$php_cv_ubsan_no_function" = yes; then
CFLAGS="$CFLAGS -fno-sanitize=function"
CXXFLAGS="$CFLAGS -fno-sanitize=function"
CXXFLAGS="$CFLAGS -fno-sanitize=function,vptr"
fi
], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])])
fi
Expand Down
4 changes: 4 additions & 0 deletions ext/intl/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ if test "$PHP_INTL" != "no"; then
AS_IF([$PKG_CONFIG icu-uc --atleast-version=74],[
AC_MSG_RESULT([yes])
PHP_CXX_COMPILE_STDCXX(17, mandatory, PHP_INTL_STDCXX)
case $CXX in
*clang++*) ICU_CXXFLAGS="$ICU_CXXFLAGS -stdlib=libc++" PHP_ADD_LIBRARY(c++) PHP_ADD_LIBRARY(c++abi)
esac
],[
AC_MSG_RESULT([no])
PHP_CXX_COMPILE_STDCXX(11, mandatory, PHP_INTL_STDCXX)
Expand All @@ -94,6 +97,7 @@ if test "$PHP_INTL" != "no"; then
case $host_alias in
*cygwin*) PHP_INTL_CXX_FLAGS="$PHP_INTL_CXX_FLAGS -D_POSIX_C_SOURCE=200809L"
esac

if test "$ext_shared" = "no"; then
PHP_ADD_SOURCES(PHP_EXT_DIR(intl), $PHP_INTL_CXX_SOURCES, $PHP_INTL_CXX_FLAGS)
else
Expand Down
Loading