Skip to content

Commit 8a7846f

Browse files
authored
[libc++] Bump the C++ Standard used to compile the dylib to C++23 (llvm#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.
1 parent a9070f2 commit 8a7846f

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

libcxx/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,10 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
504504
# Required flags ==============================================================
505505
function(cxx_add_basic_build_flags target)
506506

507-
# Require C++20 for all targets. C++17 is needed to use aligned allocation
508-
# in the dylib. C++20 is needed to use char8_t.
507+
# Use C++23 for all targets.
509508
set_target_properties(${target} PROPERTIES
510-
CXX_STANDARD 20
511-
CXX_STANDARD_REQUIRED YES
509+
CXX_STANDARD 23
510+
CXX_STANDARD_REQUIRED OFF
512511
CXX_EXTENSIONS NO)
513512

514513
# When building the dylib, don't warn for unavailable aligned allocation

libcxx/src/include/sso_allocator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP_SSO_ALLOCATOR_H
1212

1313
#include <__config>
14+
#include <cstddef>
1415
#include <memory>
1516
#include <new>
1617
#include <type_traits>
@@ -34,7 +35,7 @@ class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
3435
template <class _Tp, size_t _Np>
3536
class _LIBCPP_HIDDEN __sso_allocator
3637
{
37-
typename aligned_storage<sizeof(_Tp) * _Np>::type buf_;
38+
alignas(_Tp) std::byte buf_[sizeof(_Tp) * _Np];
3839
bool __allocated_;
3940
public:
4041
typedef size_t size_type;

libcxx/src/locale.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <algorithm>
1111
#include <clocale>
1212
#include <codecvt>
13+
#include <cstddef>
1314
#include <cstdio>
1415
#include <cstdlib>
1516
#include <cstring>
@@ -87,7 +88,7 @@ struct release
8788
template <class T, class ...Args>
8889
T& make(Args ...args)
8990
{
90-
static typename aligned_storage<sizeof(T)>::type buf;
91+
alignas(T) static std::byte buf[sizeof(T)];
9192
auto *obj = ::new (&buf) T(args...);
9293
return *obj;
9394
}
@@ -541,7 +542,7 @@ const locale&
541542
locale::__imp::make_classic()
542543
{
543544
// only one thread can get in here and it only gets in once
544-
static aligned_storage<sizeof(locale)>::type buf;
545+
alignas(locale) static std::byte buf[sizeof(locale)];
545546
locale* c = reinterpret_cast<locale*>(&buf);
546547
c->__locale_ = &make<__imp>(1u);
547548
return *c;
@@ -558,7 +559,7 @@ locale&
558559
locale::__imp::make_global()
559560
{
560561
// only one thread can get in here and it only gets in once
561-
static aligned_storage<sizeof(locale)>::type buf;
562+
alignas(locale) static std::byte buf[sizeof(locale)];
562563
auto *obj = ::new (&buf) locale(locale::classic());
563564
return *obj;
564565
}

libcxxabi/src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)
171171
set_target_properties(cxxabi_shared_objects
172172
PROPERTIES
173173
CXX_EXTENSIONS OFF
174-
CXX_STANDARD 20
174+
CXX_STANDARD 23
175175
CXX_STANDARD_REQUIRED OFF
176176
COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
177177
DEFINE_SYMBOL ""
@@ -251,7 +251,7 @@ target_link_libraries(cxxabi_static_objects PUBLIC cxxabi-headers)
251251
set_target_properties(cxxabi_static_objects
252252
PROPERTIES
253253
CXX_EXTENSIONS OFF
254-
CXX_STANDARD 20
254+
CXX_STANDARD 23
255255
CXX_STANDARD_REQUIRED OFF
256256
COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
257257
)

0 commit comments

Comments
 (0)