[libcxx-commits] [libcxx] [libc++] Bump the C++ Standard used to compile the dylib to C++23 (PR #66824)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 19 14:32:02 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/66824.diff
5 Files Affected:
- (modified) libcxx/CMakeLists.txt (+2-3)
- (modified) libcxx/src/include/sso_allocator.h (+2-1)
- (modified) libcxx/src/locale.cpp (+4-3)
- (modified) libcxx/test/tools/clang_tidy_checks/CMakeLists.txt (+2-2)
- (modified) libcxxabi/src/CMakeLists.txt (+2-2)
``````````diff
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index bb2898b799bcef9..892f28ad9dd1046 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -500,10 +500,9 @@ 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.
+ # Require C++23 for all targets.
set_target_properties(${target} PROPERTIES
- CXX_STANDARD 20
+ CXX_STANDARD 23
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
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/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
index a8cd113fc6eb6a9..4fbbfb0e98255e2 100644
--- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
@@ -37,7 +37,7 @@ set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake c
message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
-set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD 23)
# Link only against clangTidy itself, not anything that clangTidy uses; otherwise we run setup code multiple times
# which results in clang-tidy crashing
@@ -62,7 +62,7 @@ add_library(cxx-tidy MODULE ${SOURCES})
target_link_libraries(cxx-tidy clangTidy)
set_target_properties(cxx-tidy PROPERTIES
- CXX_STANDARD 20
+ CXX_STANDARD 23
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 3ad755803ac9c87..2824226465fd982 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -173,7 +173,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 ""
@@ -253,7 +253,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}"
)
``````````
</details>
https://github.com/llvm/llvm-project/pull/66824
More information about the libcxx-commits
mailing list