Skip to content
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

[libc++][modules] Consolidate modules for math and tuple #107398

Closed

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Sep 5, 2024

The module for tuple is kept private and does not contain itself, because that pulls in too many dependencies. Only the utilities related to tuple are consolidated into a single module.

@ldionne ldionne requested a review from a team as a code owner September 5, 2024 12:48
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 5, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 5, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

The module for tuple is kept private and does not contain <tuple> itself, because that pulls in too many dependencies. Only the utilities related to tuple are consolidated into a single module.


Full diff: https://github.com/llvm/llvm-project/pull/107398.diff

11 Files Affected:

  • (modified) libcxx/include/__math/copysign.h (-1)
  • (modified) libcxx/include/__math/remainder.h (-1)
  • (modified) libcxx/include/__tuple/find_index.h (+1-1)
  • (modified) libcxx/include/__tuple/make_tuple_types.h (+1-1)
  • (modified) libcxx/include/__tuple/sfinae_helpers.h (+1-1)
  • (modified) libcxx/include/__tuple/tuple_element.h (+1-1)
  • (modified) libcxx/include/__tuple/tuple_indices.h (+1-1)
  • (modified) libcxx/include/__tuple/tuple_like_ext.h (+1-1)
  • (modified) libcxx/include/__tuple/tuple_like_no_subrange.h (+1-1)
  • (modified) libcxx/include/__tuple/tuple_size.h (+1-1)
  • (modified) libcxx/include/module.modulemap (+41-41)
diff --git a/libcxx/include/__math/copysign.h b/libcxx/include/__math/copysign.h
index b38690bb581a11..2c3b0dd6f97b70 100644
--- a/libcxx/include/__math/copysign.h
+++ b/libcxx/include/__math/copysign.h
@@ -13,7 +13,6 @@
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_arithmetic.h>
 #include <__type_traits/promote.h>
-#include <limits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__math/remainder.h b/libcxx/include/__math/remainder.h
index 0fbf0b8ef97b9e..0adb7f3af5de2c 100644
--- a/libcxx/include/__math/remainder.h
+++ b/libcxx/include/__math/remainder.h
@@ -14,7 +14,6 @@
 #include <__type_traits/is_arithmetic.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/promote.h>
-#include <limits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/find_index.h b/libcxx/include/__tuple/find_index.h
index 133b00419d0c6c..cc7329d3e89b4b 100644
--- a/libcxx/include/__tuple/find_index.h
+++ b/libcxx/include/__tuple/find_index.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TUPLE_FIND_INDEX_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/is_same.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple/make_tuple_types.h
index 9e0fefae2f2f58..53e98c3d6e9757 100644
--- a/libcxx/include/__tuple/make_tuple_types.h
+++ b/libcxx/include/__tuple/make_tuple_types.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/array.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_element.h>
@@ -19,7 +20,6 @@
 #include <__type_traits/copy_cvref.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_reference.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/sfinae_helpers.h b/libcxx/include/__tuple/sfinae_helpers.h
index c7145e0b011a99..a785cec138b2f8 100644
--- a/libcxx/include/__tuple/sfinae_helpers.h
+++ b/libcxx/include/__tuple/sfinae_helpers.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___TUPLE_SFINAE_HELPERS_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/tuple.h>
 #include <__tuple/make_tuple_types.h>
 #include <__tuple/tuple_element.h>
@@ -23,7 +24,6 @@
 #include <__type_traits/is_same.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_element.h b/libcxx/include/__tuple/tuple_element.h
index 9127c47dc8f1a5..1404460e743529 100644
--- a/libcxx/include/__tuple/tuple_element.h
+++ b/libcxx/include/__tuple/tuple_element.h
@@ -10,9 +10,9 @@
 #define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__tuple/tuple_indices.h>
 #include <__tuple/tuple_types.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_indices.h b/libcxx/include/__tuple/tuple_indices.h
index 501e711255ec10..25dc9ec6859161 100644
--- a/libcxx/include/__tuple/tuple_indices.h
+++ b/libcxx/include/__tuple/tuple_indices.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__utility/integer_sequence.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_like_ext.h b/libcxx/include/__tuple/tuple_like_ext.h
index 0cc21e0b75fd1a..45c0e65d62ff3c 100644
--- a/libcxx/include/__tuple/tuple_like_ext.h
+++ b/libcxx/include/__tuple/tuple_like_ext.h
@@ -10,12 +10,12 @@
 #define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/array.h>
 #include <__fwd/pair.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_types.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_like_no_subrange.h b/libcxx/include/__tuple/tuple_like_no_subrange.h
index 274b0bf188e1f4..30018d6a05ae29 100644
--- a/libcxx/include/__tuple/tuple_like_no_subrange.h
+++ b/libcxx/include/__tuple/tuple_like_no_subrange.h
@@ -10,13 +10,13 @@
 #define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/array.h>
 #include <__fwd/complex.h>
 #include <__fwd/pair.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_size.h>
 #include <__type_traits/remove_cvref.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_size.h b/libcxx/include/__tuple/tuple_size.h
index 21c9811abeee7b..b970280fe37842 100644
--- a/libcxx/include/__tuple/tuple_size.h
+++ b/libcxx/include/__tuple/tuple_size.h
@@ -10,13 +10,13 @@
 #define _LIBCPP___TUPLE_TUPLE_SIZE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_types.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_const.h>
 #include <__type_traits/is_volatile.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 3abc11723a5a92..65a93fbffd800d 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -517,6 +517,26 @@ module std_locale_h [system] {
 }
 module std_math_h [system] {
   header "math.h"
+  module abs                             { header "__math/abs.h" }
+  module copysign                        { header "__math/copysign.h" }
+  module error_functions                 { header "__math/error_functions.h" }
+  module exponential_functions           { header "__math/exponential_functions.h" }
+  module fdim                            { header "__math/fdim.h" }
+  module fma                             { header "__math/fma.h" }
+  module gamma                           { header "__math/gamma.h" }
+  module hyperbolic_functions            { header "__math/hyperbolic_functions.h" }
+  module hypot                           { header "__math/hypot.h" }
+  module inverse_hyperbolic_functions    { header "__math/inverse_hyperbolic_functions.h" }
+  module inverse_trigonometric_functions { header "__math/inverse_trigonometric_functions.h" }
+  module logarithms                      { header "__math/logarithms.h" }
+  module min_max                         { header "__math/min_max.h" }
+  module modulo                          { header "__math/modulo.h" }
+  module remainder                       { header "__math/remainder.h" }
+  module roots                           { header "__math/roots.h" }
+  module rounding_functions              { header "__math/rounding_functions.h" }
+  module special_functions               { header "__math/special_functions.h" }
+  module traits                          { header "__math/traits.h" }
+  module trigonometric_functions         { header "__math/trigonometric_functions.h" }
   export *
 }
 // <setjmp.h> provided by C library.
@@ -1469,27 +1489,6 @@ module std_private_locale_locale_base_api                      [system] {
   export *
 }
 
-module std_private_math_abs                             [system] { header "__math/abs.h" }
-module std_private_math_copysign                        [system] { header "__math/copysign.h" }
-module std_private_math_error_functions                 [system] { header "__math/error_functions.h" }
-module std_private_math_exponential_functions           [system] { header "__math/exponential_functions.h" }
-module std_private_math_fdim                            [system] { header "__math/fdim.h" }
-module std_private_math_fma                             [system] { header "__math/fma.h" }
-module std_private_math_gamma                           [system] { header "__math/gamma.h" }
-module std_private_math_hyperbolic_functions            [system] { header "__math/hyperbolic_functions.h" }
-module std_private_math_hypot                           [system] { header "__math/hypot.h" }
-module std_private_math_inverse_hyperbolic_functions    [system] { header "__math/inverse_hyperbolic_functions.h" }
-module std_private_math_inverse_trigonometric_functions [system] { header "__math/inverse_trigonometric_functions.h" }
-module std_private_math_logarithms                      [system] { header "__math/logarithms.h" }
-module std_private_math_min_max                         [system] { header "__math/min_max.h" }
-module std_private_math_modulo                          [system] { header "__math/modulo.h" }
-module std_private_math_remainder                       [system] { header "__math/remainder.h" }
-module std_private_math_roots                           [system] { header "__math/roots.h" }
-module std_private_math_rounding_functions              [system] { header "__math/rounding_functions.h" }
-module std_private_math_special_functions               [system] { header "__math/special_functions.h" }
-module std_private_math_traits                          [system] { header "__math/traits.h" }
-module std_private_math_trigonometric_functions         [system] { header "__math/trigonometric_functions.h" }
-
 module std_private_memory_addressof                       [system] { header "__memory/addressof.h" }
 module std_private_memory_align                           [system] { header "__memory/align.h" }
 module std_private_memory_aligned_alloc                   [system] { header "__memory/aligned_alloc.h" }
@@ -1805,26 +1804,27 @@ module std_private_thread_thread               [system] {
 }
 module std_private_thread_timed_backoff_policy [system] { header "__thread/timed_backoff_policy.h" }
 
-module std_private_tuple_find_index             [system] { header "__tuple/find_index.h" }
-module std_private_tuple_ignore                 [system] { header "__tuple/ignore.h" }
-module std_private_tuple_make_tuple_types       [system] { header "__tuple/make_tuple_types.h" }
-module std_private_tuple_tuple_like_no_subrange [system] {
-  header "__tuple/tuple_like_no_subrange.h"
-}
-module std_private_tuple_sfinae_helpers         [system] { header "__tuple/sfinae_helpers.h" }
-module std_private_tuple_tuple_element          [system] { header "__tuple/tuple_element.h" }
-module std_private_tuple_tuple_fwd              [system] { header "__fwd/tuple.h" }
-module std_private_tuple_tuple_indices          [system] { header "__tuple/tuple_indices.h" }
-module std_private_tuple_tuple_like             [system] {
-  header "__tuple/tuple_like.h"
-  export *
-}
-module std_private_tuple_tuple_like_ext         [system] { header "__tuple/tuple_like_ext.h" }
-module std_private_tuple_tuple_size             [system] {
-  header "__tuple/tuple_size.h"
-  export std_private_type_traits_integral_constant
+module std_private_tuple_fwd [system] { header "__fwd/tuple.h" }
+
+module std_private_tuple [system] {
+  module find_index             { header "__tuple/find_index.h" }
+  module ignore                 { header "__tuple/ignore.h" }
+  module make_tuple_types       { header "__tuple/make_tuple_types.h" }
+  module tuple_like_no_subrange { header "__tuple/tuple_like_no_subrange.h" }
+  module sfinae_helpers         { header "__tuple/sfinae_helpers.h" }
+  module tuple_element          { header "__tuple/tuple_element.h" }
+  module tuple_indices          { header "__tuple/tuple_indices.h" }
+  module tuple_like             {
+    header "__tuple/tuple_like.h"
+    export *
+  }
+  module tuple_like_ext         { header "__tuple/tuple_like_ext.h" }
+  module tuple_size             {
+    header "__tuple/tuple_size.h"
+    export std_private_type_traits_integral_constant
+  }
+  module tuple_types            { header "__tuple/tuple_types.h" }
 }
-module std_private_tuple_tuple_types            [system] { header "__tuple/tuple_types.h" }
 
 module std_private_type_traits_add_const                                 [system] { header "__type_traits/add_const.h" }
 module std_private_type_traits_add_cv                                    [system] { header "__type_traits/add_cv.h" }
@@ -2079,7 +2079,7 @@ module std_private_utility_no_destroy             [system] { header "__utility/n
 module std_private_utility_pair                   [system] {
   header "__utility/pair.h"
   export std_private_ranges_subrange_fwd
-  export std_private_tuple_pair_like
+  export std_private_tuple.pair_like
   export std_private_type_traits_is_assignable
   export std_private_type_traits_is_constructible
   export std_private_type_traits_is_convertible

The module for tuple is kept private and does not contain <tuple>
itself, because that pulls in too many dependencies. Only the
utilities related to tuple are consolidated into a single module.
@ldionne ldionne force-pushed the review/modularization-math-and-tuple branch from adafeed to c2d0830 Compare September 5, 2024 14:42
@ldionne ldionne marked this pull request as draft September 5, 2024 22:10
@ldionne
Copy link
Member Author

ldionne commented Sep 5, 2024

Putting on hold since I might have found another approach that doesn't require this change.

@ldionne
Copy link
Member Author

ldionne commented Sep 9, 2024

Closing since I don't think I will pursue this. This is superseded by #107638.

@ldionne ldionne closed this Sep 9, 2024
@ldionne ldionne deleted the review/modularization-math-and-tuple branch September 9, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants