[libcxx-commits] [libcxx] [libc++] First attempt to regroup a few modules in the modulemap (PR #98214)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 9 13:41:54 PDT 2024
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/98214
>From 0dd14df8e7db798e931241813cfb0b51eb3b707b Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Jul 2024 16:22:06 -0400
Subject: [PATCH 1/2] [libc++] First attempt to regroup a few modules in the
modulemap
We split up all the headers into top-level modules when we broke up
cycles with the C compatibility headers. However, this resulted in
a large number of small modules, which is awkward and clearly against
the philosophy of Clang modules. This was necessary to make things work.
This patch regroups a few headers from two leaf modules: stop_token and
pstl. It should be pretty uncontroversial that grouping these headers
into a single module doesn't introduce any cyclic dependency, yet it's
a first step towards reducing the number of top-level modules we have
in our modulemap.
---
libcxx/include/module.modulemap | 66 ++++++-------------
.../atomic_unique_lock.pass.cpp | 2 +-
.../intrusive_list_view.pass.cpp | 2 +-
.../intrusive_shared_ptr.pass.cpp | 2 +-
4 files changed, 23 insertions(+), 49 deletions(-)
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 9ffccf66ff094..59ad740ac164a 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -245,8 +245,15 @@ module std_stdexcept [system] {
header "stdexcept"
export *
}
-module std_stop_token {
+module std_stop_token [system] {
header "stop_token"
+ private header "__stop_token/atomic_unique_lock.h"
+ private header "__stop_token/intrusive_list_view.h"
+ private header "__stop_token/intrusive_shared_ptr.h"
+ private header "__stop_token/stop_callback.h"
+ private header "__stop_token/stop_source.h"
+ private header "__stop_token/stop_state.h"
+ private header "__stop_token/stop_token.h"
export *
}
module std_streambuf [system] {
@@ -1584,41 +1591,25 @@ module std_private_numeric_transform_exclusive_scan [system] { header "__numeric
module std_private_numeric_transform_inclusive_scan [system] { header "__numeric/transform_inclusive_scan.h" }
module std_private_numeric_transform_reduce [system] { header "__numeric/transform_reduce.h" }
-module std_private_pstl_backend [system] {
+module std_private_pstl [system] {
header "__pstl/backend.h"
- export *
-}
-module std_private_pstl_backend_fwd [system] {
header "__pstl/backend_fwd.h"
- export *
-}
-module std_private_pstl_backends_default [system] {
header "__pstl/backends/default.h"
- export *
-}
-module std_private_pstl_backends_libdispatch [system] {
header "__pstl/backends/libdispatch.h"
- export *
-}
-module std_private_pstl_backends_serial [system] {
header "__pstl/backends/serial.h"
- export *
-}
-module std_private_pstl_backends_std_thread [system] {
header "__pstl/backends/std_thread.h"
- export *
+ header "__pstl/cpu_algos/any_of.h"
+ header "__pstl/cpu_algos/cpu_traits.h"
+ header "__pstl/cpu_algos/fill.h"
+ header "__pstl/cpu_algos/find_if.h"
+ header "__pstl/cpu_algos/for_each.h"
+ header "__pstl/cpu_algos/merge.h"
+ header "__pstl/cpu_algos/stable_sort.h"
+ header "__pstl/cpu_algos/transform.h"
+ header "__pstl/cpu_algos/transform_reduce.h"
+ header "__pstl/dispatch.h"
+ header "__pstl/handle_exception.h"
}
-module std_private_pstl_cpu_algos_any_of [system] { header "__pstl/cpu_algos/any_of.h" }
-module std_private_pstl_cpu_algos_cpu_traits [system] { header "__pstl/cpu_algos/cpu_traits.h" }
-module std_private_pstl_cpu_algos_fill [system] { header "__pstl/cpu_algos/fill.h" }
-module std_private_pstl_cpu_algos_find_if [system] { header "__pstl/cpu_algos/find_if.h" }
-module std_private_pstl_cpu_algos_for_each [system] { header "__pstl/cpu_algos/for_each.h" }
-module std_private_pstl_cpu_algos_merge [system] { header "__pstl/cpu_algos/merge.h" }
-module std_private_pstl_cpu_algos_stable_sort [system] { header "__pstl/cpu_algos/stable_sort.h" }
-module std_private_pstl_cpu_algos_transform [system] { header "__pstl/cpu_algos/transform.h" }
-module std_private_pstl_cpu_algos_transform_reduce [system] { header "__pstl/cpu_algos/transform_reduce.h" }
-module std_private_pstl_dispatch [system] { header "__pstl/dispatch.h" }
-module std_private_pstl_handle_exception [system] { header "__pstl/handle_exception.h" }
module std_private_queue_fwd [system] { header "__fwd/queue.h" }
@@ -1773,23 +1764,6 @@ module std_private_span_span_fwd [system] { header "__fwd/span.h" }
module std_private_stack_fwd [system] { header "__fwd/stack.h" }
-module std_private_stop_token_atomic_unique_lock [system] { header "__stop_token/atomic_unique_lock.h" }
-module std_private_stop_token_intrusive_list_view [system] { header "__stop_token/intrusive_list_view.h" }
-module std_private_stop_token_intrusive_shared_ptr [system] { header "__stop_token/intrusive_shared_ptr.h" }
-module std_private_stop_token_stop_callback [system] { header "__stop_token/stop_callback.h" }
-module std_private_stop_token_stop_source [system] {
- header "__stop_token/stop_source.h"
- export *
-}
-module std_private_stop_token_stop_state [system] {
- header "__stop_token/stop_state.h"
- export *
-}
-module std_private_stop_token_stop_token [system] {
- header "__stop_token/stop_token.h"
- export *
-}
-
module std_private_string_char_traits [system] {
header "__string/char_traits.h"
export *
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
index 2a9b828f4389c..bd08ac17e9964 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
@@ -12,7 +12,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-#include <__stop_token/atomic_unique_lock.h>
+#include <stop_token>
#include <atomic>
#include <cassert>
#include <chrono>
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp
index 85cd978625895..35b96c0d84fea 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp
@@ -9,7 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-#include <__stop_token/intrusive_list_view.h>
+#include <stop_token>
#include <cassert>
#include "test_macros.h"
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp
index 47440015f2c50..3ba8f484d0c64 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp
@@ -9,7 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-#include <__stop_token/intrusive_shared_ptr.h>
+#include <stop_token>
#include <atomic>
#include <cassert>
#include <utility>
>From 99edfb4d3b2f9c3e5945ab810eb534acd5a1d86c Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Jul 2024 16:41:43 -0400
Subject: [PATCH 2/2] -Wno-private-header
---
.../thread/thread.stoptoken/atomic_unique_lock.pass.cpp | 9 ++++-----
.../thread/thread.stoptoken/intrusive_list_view.pass.cpp | 3 ++-
.../thread.stoptoken/intrusive_shared_ptr.pass.cpp | 3 ++-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
index bd08ac17e9964..44d51921ac74a 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/atomic_unique_lock.pass.cpp
@@ -5,14 +5,13 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: no-threads
-
-// XFAIL: availability-synchronization_library-missing
+// UNSUPPORTED: no-threads
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: availability-synchronization_library-missing
+// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header
-#include <stop_token>
+#include <__stop_token/atomic_unique_lock.h>
#include <atomic>
#include <cassert>
#include <chrono>
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp
index 35b96c0d84fea..d8cd2fb68e132 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_list_view.pass.cpp
@@ -8,8 +8,9 @@
//
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header
-#include <stop_token>
+#include <__stop_token/intrusive_list_view.h>
#include <cassert>
#include "test_macros.h"
diff --git a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp
index 3ba8f484d0c64..99d4226662a0b 100644
--- a/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp
@@ -8,8 +8,9 @@
//
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header
-#include <stop_token>
+#include <__stop_token/intrusive_shared_ptr.h>
#include <atomic>
#include <cassert>
#include <utility>
More information about the libcxx-commits
mailing list