Skip to content

Commit 64a9c94

Browse files
committed
Revert "[libc++] Build the dylib with C++17 to allow aligned new/delete"
This reverts commit 1ac403b, which broke some non-libc++ build bots because they use an ancient CMake.
1 parent 2488ea4 commit 64a9c94

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

libcxx/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
520520
# Required flags ==============================================================
521521
function(cxx_add_basic_build_flags target)
522522

523-
# Require C++17 for all targets. C++17 is needed to use aligned allocation
524-
# in the dylib.
523+
# Require C++14 for all targets. C++14 is needed to ensure constant
524+
# initialization for certain globals (ex global memory resources).
525525
set_target_properties(${target} PROPERTIES
526-
CXX_STANDARD 17
526+
CXX_STANDARD 14
527527
CXX_STANDARD_REQUIRED YES
528528
CXX_EXTENSIONS NO)
529529

libcxx/src/barrier.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@ class __barrier_algorithm_base {
2626
} __tickets[64];
2727
};
2828

29-
ptrdiff_t& __expected;
30-
unique_ptr<__state_t[]> __state;
29+
ptrdiff_t& __expected;
30+
unique_ptr<char[]> __state_allocation;
31+
__state_t* __state;
3132

3233
_LIBCPP_HIDDEN
3334
__barrier_algorithm_base(ptrdiff_t& __expected)
3435
: __expected(__expected)
3536
{
3637
size_t const __count = (__expected + 1) >> 1;
37-
__state = unique_ptr<__state_t[]>(new __state_t[__count]);
38+
size_t const __size = sizeof(__state_t) * __count;
39+
size_t __allocation_size = __size + alignof(__state_t);
40+
__state_allocation = unique_ptr<char[]>(new char[__allocation_size]);
41+
void* __allocation = __state_allocation.get();
42+
void* const __state_ = align(alignof(__state_t), __size, __allocation, __allocation_size);
43+
__state = new (__state_) __barrier_algorithm_base::__state_t[__count];
3844
}
3945
_LIBCPP_HIDDEN
4046
bool __arrive(__barrier_phase_t __old_phase)

0 commit comments

Comments
 (0)