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

Conversation

devnexen
Copy link
Member

actually, with recent icu releases, this problem arises

checking whether clang++ supports C++17 features with -std=c++17... no
checking whether clang++ supports C++17 features with +std=c++17... no
checking whether clang++ supports C++17 features with -h std=c++17... no
checking whether clang++ supports C++17 features with -std=c++1z... no
checking whether clang++ supports C++17 features with +std=c++1z... no
checking whether clang++ supports C++17 features with -h std=c++1z... no
configure: error: *** A compiler with support for C++17 language features is required.

thus, proposing to falls into LLVM libc++ instead.

actually, with recent icu releases, this problem arises

```
checking whether clang++ supports C++17 features with -std=c++17... no
checking whether clang++ supports C++17 features with +std=c++17... no
checking whether clang++ supports C++17 features with -h std=c++17... no
checking whether clang++ supports C++17 features with -std=c++1z... no
checking whether clang++ supports C++17 features with +std=c++1z... no
checking whether clang++ supports C++17 features with -h std=c++1z... no
configure: error: *** A compiler with support for C++17 language features is required.
```

thus, proposing to falls into LLVM libc++ instead.
@devnexen
Copy link
Member Author

note it happens only when ubsan is enabled.

@devnexen
Copy link
Member Author

devnexen commented May 11, 2025

so intl itself might be compiled with rtti however we compile c++ w/o exceptions nor rtti (lean binaries ?) so had to disable vptr sanitizer check.

@devnexen devnexen marked this pull request as ready for review May 11, 2025 13:18
@devnexen devnexen requested a review from TimWolla as a code owner May 11, 2025 13:18
@TimWolla TimWolla removed their request for review May 11, 2025 13:57
@devnexen devnexen requested a review from iluuu1994 May 11, 2025 14:48
@iluuu1994
Copy link
Member

Sadly, I'm not very qualified to review this. 🙁 Maybe @petk can help?

@devnexen
Copy link
Member Author

devnexen commented May 17, 2025

Sadly, I'm not very qualified to review this. 🙁 Maybe @petk can help?

fair enough :) I suspect this might be one of the reasons @YuanchengJiang never build intl with clang (this PR fixes two distinct issues).

@petk
Copy link
Member

petk commented May 23, 2025

Hello, I can't seem to reproduce exactly this kind issue (but a whole lots of other ones unrelated to this issue :D). I've checked master branch, clang 18 (with llvm installed and without), clang 19, ICU library 74, with this:

CC=clang CXX=clang++ ./configure --enable-intl --enable-undefined-sanitizer

I have no idea. Does perhaps installing llvm library for that clang compiler help?

@devnexen
Copy link
Member Author

Hello, I can't seem to reproduce exactly this kind issue (but a whole lots of other ones unrelated to this issue :D). I've checked master branch, clang 18 (with llvm installed and without), clang 19, ICU library 74, with this:

CC=clang CXX=clang++ ./configure --enable-intl --enable-undefined-sanitizer

I have no idea. Does perhaps installing llvm library for that clang compiler help?

@petk long time no see :) did you try to build ? indeed with my other machine configure part pass but I stumble across linkage issue and yes I have llvm-dev/llvm installed. I may retry in the other machine which has clang 20 for the other problem. Cheers.

@devnexen
Copy link
Member Author

devnexen commented May 23, 2025

Here a taste of what I get

/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x5d6e): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x5d8b): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x5e57): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x5e74): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x5f87): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x5fa4): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x60e9): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:226:(.text+0x6106): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:228:(.text+0x616e): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:228:(.text+0x618b): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: ext/intl/breakiterator/codepointiterator_internal.o: in function `PHP::CodePointBreakIterator::refreshInputText(UText*, UErrorCode&)':
/home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:284:(.text+0x6687): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:284:(.text+0x66a1): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:285:(.text+0x66f6): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:285:(.text+0x6710): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:285:(.text+0x6774): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:285:(.text+0x678e): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:290:(.text+0x6857): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:290:(.text+0x6871): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:291:(.text+0x68c3): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.cpp:291:(.text+0x68dd): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: ext/intl/breakiterator/codepointiterator_internal.o: in function `PHP::CodePointBreakIterator::clearCurrentCharIter()':
/home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:96:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x76): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:96:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x90): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:96:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x11f): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:96:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x139): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:97:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x183): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:97:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x19d): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:98:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x1e6): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /home/dcarlier/Contribs/php-src/ext/intl/breakiterator/codepointiterator_internal.h:98:(.text._ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv[_ZN3PHP22CodePointBreakIterator20clearCurrentCharIterEv]+0x200): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: ext/intl/breakiterator/codepointiterator_internal.o: in function `std::type_info::operator!=(std::type_info const&) const':
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/typeinfo:114:(.text._ZNKSt9type_infoneERKS_[_ZNKSt9type_infoneERKS_]+0x7a): undefined reference to `__ubsan_vptr_type_cache'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/typeinfo:114:(.text._ZNKSt9type_infoneERKS_[_ZNKSt9type_infoneERKS_]+0x94): undefined reference to `__ubsan_handle_dynamic_type_cache_miss_abort'
/usr/bin/ld: ext/intl/breakiterator/codepointiterator_internal.o: in function `std::type_info::operator==(std::type_info const&) const':

this change fixes it. since we compile C++ with -fno-rtti -fno-exceptions and the sanitizer relies on type_info so ..

@iluuu1994
Copy link
Member

@devnexen I've experienced this issue in the past, and I believe linking with Clang++ fixes the issue, but I didn't know how to best achieve this in the build system.

@petk
Copy link
Member

petk commented May 23, 2025

did you try to build ?

Yes, I see. Link step fails the same as yours, yes. And adding the ,vptr fixes this.

@devnexen
Copy link
Member Author

@devnexen I've experienced this issue in the past, and I believe linking with Clang++ fixes the issue, but I didn't know how to best achieve this in the build system.

I won t mind just pushing just the ubsan change, the other part might be a bit "heavy" as forcing to use llvm c++ runtime but I may retest this a bit later.

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.

3 participants