<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91831>91831</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
latest libc++ doesn't compile with gcc 14.1
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Chilledheart
</td>
</tr>
</table>
<pre>
libc++ doesn't compile with gcc 14.1 because it comes with new gcc `__remove_pointer` builtin which is incompatible with libc++.
gcc 14.1 is out https://lwn.net/Articles/972683/.
```
[39/48] Building CXX object third_part...xx.dir/trunk/src/filesystem/path.cpp.o
FAILED: third_party/libc++/CMakeFiles/cxx.dir/trunk/src/filesystem/path.cpp.o
/usr/bin/c++ -DCR_LIBCXX_REVISION=e3b94d0e5b86883fd77696bf10dc33ba250ba99b -DHAVE_LIBCXX -DLIBCXX_BUILDING_LIBCXXABI -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1 -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_LIBCPP_OVERRIDABLE_FUNC_VIS="__attribute__((__visibility__(\"default\")))" -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -I/home/hky/yass-develop/build-archlinux -I/home/hky/yass-develop/third_party/libc++/../libc++ -I/home/hky/yass-develop/third_party/libc++/../libc++/trunk/src -I/home/hky/yass-develop/third_party/libc++/../libc++/trunk/include -I/home/hky/yass-develop/third_party/libc++/trunk/include -fdata-sections -ffunction-sections -gdwarf-4 -g2 -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -pipe -pthread -fdiagnostics-color=always -nostdinc++ -isystem /home/hky/yass-develop/third_party/libc++ -isystem /home/hky/yass-develop/third_party/libc++/trunk/include -isystem /home/hky/yass-develop/third_party/libc++/../libc++abi/trunk/include -fno-builtin-abs -Wno-alloc-size-larger-than -Wno-stringop-overread -Wno-array-bounds -include /home/hky/yass-develop/third_party/libc++/__config_site -include /home/hky/yass-develop/third_party/libc++/__assertion_handler -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -DCR_LIBCXX_REVISION=e3b94d0e5b86883fd77696bf10dc33ba250ba99b -O3 -DNDEBUG -DNDEBUG -flto=auto -std=c++20 -fPIC -fstrict-aliasing -Wno-missing-declarations -Wno-attributes -fPIC -fvisibility-inlines-hidden -fvisibility=hidden -frtti -fno-exceptions -MD -MT third_party/libc++/CMakeFiles/cxx.dir/trunk/src/filesystem/path.cpp.o -MF third_party/libc++/CMakeFiles/cxx.dir/trunk/src/filesystem/path.cpp.o.d -o third_party/libc++/CMakeFiles/cxx.dir/trunk/src/filesystem/path.cpp.o -c /home/hky/yass-develop/third_party/libc++/trunk/src/filesystem/path.cpp
In file included from /home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/filesystem_error.h:15,
from /home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/directory_entry.h:20,
from /home/hky/yass-develop/third_party/libc++/trunk/include/filesystem:538,
from /home/hky/yass-develop/third_party/libc++/trunk/src/filesystem/path.cpp:10:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::append(const _Source&) [with _Source = char [3]]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:533:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
533 | _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) {
| ^~~~~~
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::append(const _Source&) [with _Source = char [1]]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:533:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::append(const _Source&) [with _Source = std::__Cr::basic_string_view<char>]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:533:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::operator/=(const _Source&) [with _Source = char [3]]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:528:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
528 | _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> operator/=(const _Source& __src) {
| ^~~~~~~~
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::operator/=(const _Source&) [with _Source = char [1]]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:528:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::operator/=(const _Source&) [with _Source = std::__Cr::basic_string_view<char>]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:528:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h: In instantiation of \u2018std::__Cr::__fs::filesystem::path::_EnableIfPathable<_Source> std::__Cr::__fs::filesystem::path::append(const _Source&) [with _Source = std::__Cr::basic_string<char>]\u2019:
/home/hky/yass-develop/third_party/libc++/trunk/include/__filesystem/path.h:533:52: error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
533 | _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) {
| ^~~~~~
[40/48] Building CXX object third_party/libc++/CMakeFiles/cxx.dir/trunk/src/locale.cpp.o
ninja: build stopped: subcommand failed.
```
```
[hky@arch build-archlinux]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.1 20240507 (GCC)
```
It compiles with below patch:
```
diff --git a/include/__type_traits/remove_pointer.h b/include/__type_traits/remove_pointer.h
index 54390a193..c01eb3c37 100644
--- a/include/__type_traits/remove_pointer.h
+++ b/include/__type_traits/remove_pointer.h
@@ -17,7 +17,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer)
+#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer) && !defined(_LIBCPP_GCC_VER)
template <class _Tp>
struct remove_pointer {
using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z4rjS_jXKjUqULQGBi1yAbWb9vgmkgMlmr1yyLGNtjOQjyUmYi_PbT8k2BGYyOx9J9uycSoqAUUvd7dbTH0ZNjREbyfkFGEzBIDyjtS2UvggKUZY8KzjV9ixV2e6iFCkDeArwFGaKGwnwuYVMbStRcvggbAE3jEG_3_NhyhmtDYeimcBNS5b8oZkChl6SaL5V9zyplJCWazD0YFqL0goJHwrBCigMFNJxp1akewFPKvSAFwJv0r4f5AoDVW1hYW1lAJkAPAN4Vj7InuQW4NlEW8FKbgCejc_xcEQAnp0wAkOve7VfB1MyBnjWH4FBCKe1KDMhNzC4vYUq_ZMzC20hdJZUVNter_f42MuEBnhmdS3vAJ4ZzQCe5aLkZmcs3wI8q6gteqyqeqoVMZvEl1EIyOSI1c4pfbhTgGfBFb3jM9Fqzn5MDOxuBc9q4xalQjom3UaiMFgml_E0uL1NltFNvIoXc0BCTtJxP_P4IB0NRyOSZ-fnw_EwzX0vY4SkFA-8lI7HKUThb5ObqOMAUdixmn6ML8N4_qEjTKYxRGEyiy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