git: bc9e19dce0ab - main - Fix buildworld with gcc 12 after llvm-19 import
Date: Fri, 25 Oct 2024 16:08:51 UTC
The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=bc9e19dce0abee80750e6fa04aaf979873bfe0d2 commit bc9e19dce0abee80750e6fa04aaf979873bfe0d2 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-10-25 16:07:59 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-10-25 16:08:32 +0000 Fix buildworld with gcc 12 after llvm-19 import Unfortunately gcc 12's is not yet capable of compiling all of libc++ 19's C++23 code, which results in errors similar to: /usr/src/freebsd/src/contrib/llvm-project/libcxx/include/__algorithm/ranges_contains.h:41:3: error: 'static constexpr bool std::__1::ranges::__contains::__fn::operator()(_Iter, _Sent, const _Type&, _Proj)' must be a non-static member function 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) { | ^~~~~~~~ /usr/src/freebsd/src/contrib/llvm-project/libcxx/include/__algorithm/ranges_contains.h:48:3: error: 'static constexpr bool std::__1::ranges::__contains::__fn::operator()(_Range&&, const _Type&, _Proj)' must be a non-static member function 48 | operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) { | ^~~~~~~~ Until we can get rid of gcc 12, work around this by making it compile libc++ in C++20 mode instead. NOTE: The resulting libc++ library will not be C++23 compatible! Please try to avoid shipping it, and use gcc 13 instead, if you must use gcc. PR: 280562 MFC after: 3 days --- contrib/llvm-project/libcxx/src/expected.cpp | 2 ++ lib/libc++/Makefile | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/llvm-project/libcxx/src/expected.cpp b/contrib/llvm-project/libcxx/src/expected.cpp index f30efb516479..ed3bf9e37e35 100644 --- a/contrib/llvm-project/libcxx/src/expected.cpp +++ b/contrib/llvm-project/libcxx/src/expected.cpp @@ -9,5 +9,7 @@ #include <expected> _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER >= 23 const char* bad_expected_access<void>::what() const noexcept { return "bad access to std::expected"; } +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index b30eefd6e2f7..9c12f419f6f1 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -104,7 +104,15 @@ CFLAGS+= -ffunction-sections CFLAGS+= -fno-semantic-interposition CFLAGS+= -fvisibility-inlines-hidden CFLAGS+= -fvisibility=hidden + +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 130000 +# NOTE: gcc 12 cannot correctly compile all libc++'s C++23 code. To temporarily +# support gcc 12, compile libc++ in C++20 mode, but this will leave out any +# C++23 features. +CXXSTD?= c++20 +.else CXXSTD?= c++23 +.endif LIBADD+= cxxrt