Issue 91831
Summary latest libc++ doesn't compile with gcc 14.1
Labels libc++
Assignees
Reporter Chilledheart
    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);
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to