-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc++][NFC] Move __memory/aligned_alloc.h into src/ #166172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
c0a6dfd to
82a5fd8
Compare
|
@llvm/pr-subscribers-libcxxabi Author: Nikolas Klauser (philnik777) ChangesThis header is only ever used inside Full diff: https://github.com/llvm/llvm-project/pull/166172.diff 7 Files Affected:
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index de9819cf5346a..e4ccc68cc7404 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -567,7 +567,6 @@ set(files
__mdspan/mdspan.h
__memory/addressof.h
__memory/align.h
- __memory/aligned_alloc.h
__memory/allocate_at_least.h
__memory/allocation_guard.h
__memory/allocator.h
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 357f77b7d27d6..3be35423b2bbe 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -670,27 +670,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1
# endif
-// It is not yet possible to use aligned_alloc() on all Apple platforms since
-// 10.15 was the first version to ship an implementation of aligned_alloc().
-# if defined(__APPLE__)
-# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
- (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
- (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) || \
- (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000)
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
-# else
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
-# endif
-# elif defined(__ANDROID__) && __ANDROID_API__ < 28
-// Android only provides aligned_alloc when targeting API 28 or higher.
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
-# else
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
-# endif
-
# if defined(__APPLE__) || defined(__FreeBSD__)
# define _LIBCPP_WCTYPE_IS_MASK
# endif
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 11ab61d959e22..b4cf5cf53eaee 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1634,7 +1634,6 @@ module std [system] {
module memory {
module addressof { header "__memory/addressof.h" }
module align { header "__memory/align.h" }
- module aligned_alloc { header "__memory/aligned_alloc.h" }
module allocate_at_least { header "__memory/allocate_at_least.h" }
module allocation_guard { header "__memory/allocation_guard.h" }
module allocator {
diff --git a/libcxx/include/__memory/aligned_alloc.h b/libcxx/src/include/aligned_alloc.h
similarity index 90%
rename from libcxx/include/__memory/aligned_alloc.h
rename to libcxx/src/include/aligned_alloc.h
index fb36983d9c3dc..24ca26ce04525 100644
--- a/libcxx/include/__memory/aligned_alloc.h
+++ b/libcxx/src/include/aligned_alloc.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___MEMORY_ALIGNED_ALLOC_H
-#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H
+#ifndef _LIBCPP_SRC_ALIGNED_ALLOC_H
+#define _LIBCPP_SRC_ALIGNED_ALLOC_H
#include <__config>
#include <cstdlib>
@@ -29,7 +29,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
# if defined(_LIBCPP_MSVCRT_LIKE)
return ::_aligned_malloc(__size, __alignment);
-# elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC
+
+// Android only provides aligned_alloc when targeting API 28 or higher.
+# elif !defined(__ANDROID__) || __ANDROID_API__ >= 28
// aligned_alloc() requires that __size is a multiple of __alignment,
// but for C++ [new.delete.general], only states "if the value of an
// alignment argument passed to any of these functions is not a valid
@@ -60,4 +62,4 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP___MEMORY_ALIGNED_ALLOC_H
+#endif // _LIBCPP_SRC_ALIGNED_ALLOC_H
diff --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
index 4bb42cb532078..282d49d727c8c 100644
--- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -21,6 +21,8 @@
// GCC doesn't support the aligned-allocation flags.
// XFAIL: gcc
+// ADDITIONAL_COMPILE_FLAGS: -I %{libcxx-dir}/src -Wno-macro-redefined
+
// RUN: %{build} -faligned-allocation -fsized-deallocation
// RUN: %{run}
// RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
@@ -36,10 +38,7 @@
#include "test_macros.h"
-TEST_DIAGNOSTIC_PUSH
-TEST_CLANG_DIAGNOSTIC_IGNORED("-Wprivate-header")
-#include <__memory/aligned_alloc.h>
-TEST_DIAGNOSTIC_POP
+#include "include/aligned_alloc.h"
struct alloc_stats {
alloc_stats() { reset(); }
diff --git a/libcxxabi/src/fallback_malloc.cpp b/libcxxabi/src/fallback_malloc.cpp
index 75788fe9be8d9..6a261e6f009fe 100644
--- a/libcxxabi/src/fallback_malloc.cpp
+++ b/libcxxabi/src/fallback_malloc.cpp
@@ -16,7 +16,7 @@
#endif
#endif
-#include <__memory/aligned_alloc.h>
+#include "include/aligned_alloc.h" // from libc++
#include <__assert>
#include <stdlib.h> // for malloc, calloc, free
#include <string.h> // for memset
diff --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp
index b5ed59958d17e..dbb75b128a2a4 100644
--- a/libcxxabi/src/stdlib_new_delete.cpp
+++ b/libcxxabi/src/stdlib_new_delete.cpp
@@ -8,8 +8,8 @@
#include "__cxxabi_config.h"
#include "abort_message.h"
+#include "include/aligned_alloc.h" // from libc++
#include "include/overridable_function.h" // from libc++
-#include <__memory/aligned_alloc.h>
#include <cstddef>
#include <cstdlib>
#include <new>
|
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThis header is only ever used inside Full diff: https://github.com/llvm/llvm-project/pull/166172.diff 7 Files Affected:
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index de9819cf5346a..e4ccc68cc7404 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -567,7 +567,6 @@ set(files
__mdspan/mdspan.h
__memory/addressof.h
__memory/align.h
- __memory/aligned_alloc.h
__memory/allocate_at_least.h
__memory/allocation_guard.h
__memory/allocator.h
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 357f77b7d27d6..3be35423b2bbe 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -670,27 +670,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1
# endif
-// It is not yet possible to use aligned_alloc() on all Apple platforms since
-// 10.15 was the first version to ship an implementation of aligned_alloc().
-# if defined(__APPLE__)
-# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
- (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
- (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) || \
- (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000)
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
-# else
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
-# endif
-# elif defined(__ANDROID__) && __ANDROID_API__ < 28
-// Android only provides aligned_alloc when targeting API 28 or higher.
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
-# else
-# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
-# endif
-
# if defined(__APPLE__) || defined(__FreeBSD__)
# define _LIBCPP_WCTYPE_IS_MASK
# endif
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 11ab61d959e22..b4cf5cf53eaee 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1634,7 +1634,6 @@ module std [system] {
module memory {
module addressof { header "__memory/addressof.h" }
module align { header "__memory/align.h" }
- module aligned_alloc { header "__memory/aligned_alloc.h" }
module allocate_at_least { header "__memory/allocate_at_least.h" }
module allocation_guard { header "__memory/allocation_guard.h" }
module allocator {
diff --git a/libcxx/include/__memory/aligned_alloc.h b/libcxx/src/include/aligned_alloc.h
similarity index 90%
rename from libcxx/include/__memory/aligned_alloc.h
rename to libcxx/src/include/aligned_alloc.h
index fb36983d9c3dc..24ca26ce04525 100644
--- a/libcxx/include/__memory/aligned_alloc.h
+++ b/libcxx/src/include/aligned_alloc.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___MEMORY_ALIGNED_ALLOC_H
-#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H
+#ifndef _LIBCPP_SRC_ALIGNED_ALLOC_H
+#define _LIBCPP_SRC_ALIGNED_ALLOC_H
#include <__config>
#include <cstdlib>
@@ -29,7 +29,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
# if defined(_LIBCPP_MSVCRT_LIKE)
return ::_aligned_malloc(__size, __alignment);
-# elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC
+
+// Android only provides aligned_alloc when targeting API 28 or higher.
+# elif !defined(__ANDROID__) || __ANDROID_API__ >= 28
// aligned_alloc() requires that __size is a multiple of __alignment,
// but for C++ [new.delete.general], only states "if the value of an
// alignment argument passed to any of these functions is not a valid
@@ -60,4 +62,4 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP___MEMORY_ALIGNED_ALLOC_H
+#endif // _LIBCPP_SRC_ALIGNED_ALLOC_H
diff --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
index 4bb42cb532078..282d49d727c8c 100644
--- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -21,6 +21,8 @@
// GCC doesn't support the aligned-allocation flags.
// XFAIL: gcc
+// ADDITIONAL_COMPILE_FLAGS: -I %{libcxx-dir}/src -Wno-macro-redefined
+
// RUN: %{build} -faligned-allocation -fsized-deallocation
// RUN: %{run}
// RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
@@ -36,10 +38,7 @@
#include "test_macros.h"
-TEST_DIAGNOSTIC_PUSH
-TEST_CLANG_DIAGNOSTIC_IGNORED("-Wprivate-header")
-#include <__memory/aligned_alloc.h>
-TEST_DIAGNOSTIC_POP
+#include "include/aligned_alloc.h"
struct alloc_stats {
alloc_stats() { reset(); }
diff --git a/libcxxabi/src/fallback_malloc.cpp b/libcxxabi/src/fallback_malloc.cpp
index 75788fe9be8d9..6a261e6f009fe 100644
--- a/libcxxabi/src/fallback_malloc.cpp
+++ b/libcxxabi/src/fallback_malloc.cpp
@@ -16,7 +16,7 @@
#endif
#endif
-#include <__memory/aligned_alloc.h>
+#include "include/aligned_alloc.h" // from libc++
#include <__assert>
#include <stdlib.h> // for malloc, calloc, free
#include <string.h> // for memset
diff --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp
index b5ed59958d17e..dbb75b128a2a4 100644
--- a/libcxxabi/src/stdlib_new_delete.cpp
+++ b/libcxxabi/src/stdlib_new_delete.cpp
@@ -8,8 +8,8 @@
#include "__cxxabi_config.h"
#include "abort_message.h"
+#include "include/aligned_alloc.h" // from libc++
#include "include/overridable_function.h" // from libc++
-#include <__memory/aligned_alloc.h>
#include <cstddef>
#include <cstdlib>
#include <new>
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/17840 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/27571 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/197/builds/11211 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/193/builds/12414 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/38/builds/6507 Here is the relevant piece of the build log for the reference |
|
We started seeing a failure in our Mac toolchain builders after this patch landed. I verified that the referenced forward fix (d9cf0db) did not resolve the issue. |
|
@gulfemsavrun you beat me by mere seconds in reporting the same issue :) |
|
It's not replaced because libc++ only support macOS 11 and later. |
|
Interesting, I didn't know that. Does the documentation need to be updated? |
This header is only ever used inside `src/`, so we might as well move it there. As a drive-by this also removes some dead code.
|
A different question about the same file: We're instead seeing: The PR description says "This header is only ever used inside src/". I suppose libcxxabi/src is also inside src/ – is libcxx/src supposed to be on libcxxabi's include search path? |
|
…nevermind, looks like this just requires updating libcxx and libcxxabi at the same time. |
Yeah, looks like it. |
Yes, it's very unfortunate. This is yet another reason libc++abi should be merged into libc++. |
This morally picks up a single upstream PR that touches both libc++ and libc++abi: llvm/llvm-project#166172 Since we mirror libc++ and libc++abi separately, this single commit has been split into one commit in each repo. ...and then there was a follow-up libc++-only buildfix for it: llvm/llvm-project#169418 To pick both of these up, this rolls libcxxabi by one revision, and libcxx by two. It combines these two rolls: 1. Roll libcxxabi from de02e5d57052 to 83a852080747 (1 revision) https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/de02e5d57052..83a852080747 2025-11-24 [email protected] [libc++][NFC] Move __memory/aligned_alloc.h into src/ (#166172) 2. Roll libc++ from 25731e23e3aa to 13cfd0942dfd (2 revisions) https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git/+log/25731e23e3aa..13cfd0942dfd 2025-11-24 [email protected] Fix path to aligned_alloc.h in #include statement (#169418) 2025-11-24 [email protected] [libc++][NFC] Move __memory/aligned_alloc.h into src/ (#166172) Change-Id: I04f1081884978d693d8a6dac8089e5c417b355e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7201052 Commit-Queue: Nico Weber <[email protected]> Reviewed-by: Hans Wennborg <[email protected]> Cr-Commit-Position: refs/heads/main@{#1551246}
This morally picks up a single upstream PR that touches both libc++ and libc++abi: llvm/llvm-project#166172 Since we mirror libc++ and libc++abi separately, this single commit has been split into one commit in each repo. ...and then there was a follow-up libc++-only buildfix for it: llvm/llvm-project#169418 To pick both of these up, this rolls libcxxabi by one revision, and libcxx by two. It combines these two rolls: 1. Roll libcxxabi from de02e5d57052 to 83a852080747 (1 revision) https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/de02e5d57052..83a852080747 2025-11-24 [email protected] [libc++][NFC] Move __memory/aligned_alloc.h into src/ (#166172) 2. Roll libc++ from 25731e23e3aa to 13cfd0942dfd (2 revisions) https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git/+log/25731e23e3aa..13cfd0942dfd 2025-11-24 [email protected] Fix path to aligned_alloc.h in #include statement (#169418) 2025-11-24 [email protected] [libc++][NFC] Move __memory/aligned_alloc.h into src/ (#166172) Change-Id: I04f1081884978d693d8a6dac8089e5c417b355e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7201052 Commit-Queue: Nico Weber <[email protected]> Reviewed-by: Hans Wennborg <[email protected]> Cr-Commit-Position: refs/heads/main@{#1551246} NOKEYCHECK=True GitOrigin-RevId: d9b454f01e84d2a064c8a230cd30702cfe2e6a93
This header is only ever used inside
src/, so we might as well move it there. As a drive-by this also removes some dead code.