[libcxx-commits] [libcxx] 8a7846f - [libc++] Bump the C++ Standard used to compile the dylib to C++23 (#66824)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 5 05:40:56 PST 2023
Author: Louis Dionne
Date: 2023-11-05T08:40:51-05:00
New Revision: 8a7846fe86f95e82c6bd5f4f45b8dd311320e903
URL: https://github.com/llvm/llvm-project/commit/8a7846fe86f95e82c6bd5f4f45b8dd311320e903
DIFF: https://github.com/llvm/llvm-project/commit/8a7846fe86f95e82c6bd5f4f45b8dd311320e903.diff
LOG: [libc++] Bump the C++ Standard used to compile the dylib to C++23 (#66824)
This is necessary in order to implement some papers like P2467R1, which
require using C++23 declarations in the dylib. It is a good habit to
keep building the dylib with a recent standard version regardless.
With this patch, we also stop strictly enforcing that the targets are
built with C++23. Concretely, C++23 will soon be required in order to
build the dylib, but not enforcing it strictly works around some issues
like the documentation bots using an old and unsupported compiler. Since
these bots do not actually build the library, not strictly enforcing the
C++ Standard makes our CMake build more resilient to these kinds of
situation. This is just a workaround though, the better way of going
about would be to update the compiler on the documentation bot but we
don't seem to have control over that.
Added:
Modified:
libcxx/CMakeLists.txt
libcxx/src/include/sso_allocator.h
libcxx/src/locale.cpp
libcxxabi/src/CMakeLists.txt
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index d03421afde1e755..de7fa8e3be31a8a 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -504,11 +504,10 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
# Required flags ==============================================================
function(cxx_add_basic_build_flags target)
- # Require C++20 for all targets. C++17 is needed to use aligned allocation
- # in the dylib. C++20 is needed to use char8_t.
+ # Use C++23 for all targets.
set_target_properties(${target} PROPERTIES
- CXX_STANDARD 20
- CXX_STANDARD_REQUIRED YES
+ CXX_STANDARD 23
+ CXX_STANDARD_REQUIRED OFF
CXX_EXTENSIONS NO)
# When building the dylib, don't warn for unavailable aligned allocation
diff --git a/libcxx/src/include/sso_allocator.h b/libcxx/src/include/sso_allocator.h
index 6a682fc43f86fc5..0cc8738815ddd46 100644
--- a/libcxx/src/include/sso_allocator.h
+++ b/libcxx/src/include/sso_allocator.h
@@ -11,6 +11,7 @@
#define _LIBCPP_SSO_ALLOCATOR_H
#include <__config>
+#include <cstddef>
#include <memory>
#include <new>
#include <type_traits>
@@ -34,7 +35,7 @@ class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
template <class _Tp, size_t _Np>
class _LIBCPP_HIDDEN __sso_allocator
{
- typename aligned_storage<sizeof(_Tp) * _Np>::type buf_;
+ alignas(_Tp) std::byte buf_[sizeof(_Tp) * _Np];
bool __allocated_;
public:
typedef size_t size_type;
diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index 317b4dec7d241e5..c37e091dcc4671b 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -10,6 +10,7 @@
#include <algorithm>
#include <clocale>
#include <codecvt>
+#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@@ -87,7 +88,7 @@ struct release
template <class T, class ...Args>
T& make(Args ...args)
{
- static typename aligned_storage<sizeof(T)>::type buf;
+ alignas(T) static std::byte buf[sizeof(T)];
auto *obj = ::new (&buf) T(args...);
return *obj;
}
@@ -541,7 +542,7 @@ const locale&
locale::__imp::make_classic()
{
// only one thread can get in here and it only gets in once
- static aligned_storage<sizeof(locale)>::type buf;
+ alignas(locale) static std::byte buf[sizeof(locale)];
locale* c = reinterpret_cast<locale*>(&buf);
c->__locale_ = &make<__imp>(1u);
return *c;
@@ -558,7 +559,7 @@ locale&
locale::__imp::make_global()
{
// only one thread can get in here and it only gets in once
- static aligned_storage<sizeof(locale)>::type buf;
+ alignas(locale) static std::byte buf[sizeof(locale)];
auto *obj = ::new (&buf) locale(locale::classic());
return *obj;
}
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 06a9a5fa91d9454..aec97104fffae46 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -171,7 +171,7 @@ target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)
set_target_properties(cxxabi_shared_objects
PROPERTIES
CXX_EXTENSIONS OFF
- CXX_STANDARD 20
+ CXX_STANDARD 23
CXX_STANDARD_REQUIRED OFF
COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
DEFINE_SYMBOL ""
@@ -251,7 +251,7 @@ target_link_libraries(cxxabi_static_objects PUBLIC cxxabi-headers)
set_target_properties(cxxabi_static_objects
PROPERTIES
CXX_EXTENSIONS OFF
- CXX_STANDARD 20
+ CXX_STANDARD 23
CXX_STANDARD_REQUIRED OFF
COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
)
More information about the libcxx-commits
mailing list