Skip to content

Commit cb19cef

Browse files
committed
[libc++] Bump the C++ Standard used to compile the dylib to C++23
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.
1 parent 95e11a9 commit cb19cef

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

libcxx/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,9 @@ 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+
# Require C++23 for all targets.
509508
set_target_properties(${target} PROPERTIES
510-
CXX_STANDARD 20
509+
CXX_STANDARD 23
511510
CXX_STANDARD_REQUIRED YES
512511
CXX_EXTENSIONS NO)
513512

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
}

libcxx/test/tools/clang_tidy_checks/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake c
3333

3434
message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
3535

36-
set(CMAKE_CXX_STANDARD 20)
36+
set(CMAKE_CXX_STANDARD 23)
3737

3838
# Link only against clangTidy itself, not anything that clangTidy uses; otherwise we run setup code multiple times
3939
# which results in clang-tidy crashing
@@ -58,7 +58,7 @@ add_library(cxx-tidy MODULE ${SOURCES})
5858
target_link_libraries(cxx-tidy clangTidy)
5959

6060
set_target_properties(cxx-tidy PROPERTIES
61-
CXX_STANDARD 20
61+
CXX_STANDARD 23
6262
CXX_STANDARD_REQUIRED YES
6363
CXX_EXTENSIONS NO)
6464

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)