[libcxx-commits] [libcxx] [libc++][modules] Rewrite the modulemap to have fewer top-level modules (PR #107638)

Ian Anderson via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 9 12:15:59 PDT 2024


================
@@ -1,2111 +1,1609 @@
-// Main C++ standard library interfaces
-module std_algorithm [system] {
-  header "algorithm"
-  export *
-}
-module std_any [system] {
-  header "any"
-  export *
-}
-module std_array [system] {
-  header "array"
-  export *
-}
-module std_atomic [system] {
-  header "atomic"
-  export *
-}
-module std_barrier [system] {
-  header "barrier"
-  export *
-}
-module std_bit [system] {
-  header "bit"
-  export *
-}
-module std_bitset [system] {
-  header "bitset"
-  export *
-}
-module std_charconv [system] {
-  header "charconv"
-  module chars_format            { header "__charconv/chars_format.h" }
-  module from_chars_integral     { header "__charconv/from_chars_integral.h" }
-  module from_chars_result       { header "__charconv/from_chars_result.h" }
-  module tables                  { header "__charconv/tables.h" }
-  module to_chars                { header "__charconv/to_chars.h" }
-  module to_chars_base_10        { header "__charconv/to_chars_base_10.h" }
-  module to_chars_floating_point { header "__charconv/to_chars_floating_point.h" }
-  module to_chars_integral       { header "__charconv/to_chars_integral.h" }
-  module to_chars_result         { header "__charconv/to_chars_result.h" }
-  module traits                  { header "__charconv/traits.h" }
-  export *
-}
-module std_chrono [system] {
-  header "chrono"
-  export *
-}
-module std_codecvt [system] {
-  header "codecvt"
-  export *
-}
-module std_compare [system] {
-  header "compare"
-  export *
-}
-module std_complex [system] {
-  header "complex"
-  export *
-}
-module std_concepts [system] {
-  header "concepts"
-  export *
-}
-module std_condition_variable [system] {
-  header "condition_variable"
-  module condition_variable { header "__condition_variable/condition_variable.h" }
-  export *
-}
-module std_coroutine [system] {
-  header "coroutine"
-  module coroutine_handle      { header "__coroutine/coroutine_handle.h" }
-  module coroutine_traits      { header "__coroutine/coroutine_traits.h" }
-  module noop_coroutine_handle { header "__coroutine/noop_coroutine_handle.h" }
-  module trivial_awaitables    { header "__coroutine/trivial_awaitables.h" }
-  export *
-}
-module std_deque [system] {
-  header "deque"
-  export *
-}
-module std_exception [system] {
-  header "exception"
-  export *
-}
-module std_execution [system] {
-  header "execution"
+// This module contains headers related to the configuration of the library. These headers
+// are free of any dependency on the rest of libc++.
+module std_config [system] {
+  textual header "__config"
+  textual header "__configuration/abi.h"
+  textual header "__configuration/availability.h"
+  textual header "__configuration/compiler.h"
+  textual header "__configuration/language.h"
+  textual header "__configuration/platform.h"
+  textual header "version"
   export *
 }
-module std_expected [system] {
-  header "expected"
+
+module std_core [system] {
+  module cstddef {
+    header "__cstddef/byte.h"
+    header "__cstddef/max_align_t.h"
+    header "__cstddef/nullptr_t.h"
+    header "__cstddef/ptrdiff_t.h"
+    header "__cstddef/size_t.h"
+    export *
+  }
+
+  module cstdint {
+    header "cstdint"
+    export *
+  }
+
+  module fwd {
+    header "__fwd/byte.h"
+    header "__fwd/functional.h"
+    header "__fwd/pair.h"
+    header "__fwd/tuple.h"
+    export *
+  }
+
+  module limits {
+    header "limits"
+    export *
+  }
+
+  module math {
+    header "__math/abs.h"
+    header "__math/copysign.h"
+    header "__math/error_functions.h"
+    header "__math/exponential_functions.h"
+    header "__math/fdim.h"
+    header "__math/fma.h"
+    header "__math/gamma.h"
+    header "__math/hyperbolic_functions.h"
+    header "__math/hypot.h"
+    header "__math/inverse_hyperbolic_functions.h"
+    header "__math/inverse_trigonometric_functions.h"
+    header "__math/logarithms.h"
+    header "__math/min_max.h"
+    header "__math/modulo.h"
+    header "__math/remainder.h"
+    header "__math/roots.h"
+    header "__math/rounding_functions.h"
+    header "__math/special_functions.h"
+    header "__math/traits.h"
+    header "__math/trigonometric_functions.h"
+    export *
+  }
+
+  module type_traits {
+    header "type_traits"
+    header "__type_traits/add_const.h"
+    header "__type_traits/add_cv.h"
+    header "__type_traits/add_lvalue_reference.h"
+    header "__type_traits/add_pointer.h"
+    header "__type_traits/add_rvalue_reference.h"
+    header "__type_traits/add_volatile.h"
+    header "__type_traits/aligned_storage.h"
+    header "__type_traits/aligned_union.h"
+    header "__type_traits/alignment_of.h"
+    header "__type_traits/can_extract_key.h"
+    header "__type_traits/common_reference.h"
+    header "__type_traits/common_type.h"
+    header "__type_traits/conditional.h"
+    header "__type_traits/conjunction.h"
+    header "__type_traits/copy_cv.h"
+    header "__type_traits/copy_cvref.h"
+    header "__type_traits/datasizeof.h"
+    header "__type_traits/decay.h"
+    header "__type_traits/dependent_type.h"
+    header "__type_traits/desugars_to.h"
+    header "__type_traits/disjunction.h"
+    header "__type_traits/enable_if.h"
+    header "__type_traits/extent.h"
+    header "__type_traits/has_unique_object_representation.h"
+    header "__type_traits/has_virtual_destructor.h"
+    header "__type_traits/integral_constant.h"
+    header "__type_traits/invoke.h"
+    header "__type_traits/is_abstract.h"
+    header "__type_traits/is_aggregate.h"
+    header "__type_traits/is_allocator.h"
+    header "__type_traits/is_always_bitcastable.h"
+    header "__type_traits/is_arithmetic.h"
+    header "__type_traits/is_array.h"
+    header "__type_traits/is_assignable.h"
+    header "__type_traits/is_base_of.h"
+    header "__type_traits/is_bounded_array.h"
+    header "__type_traits/is_callable.h"
+    header "__type_traits/is_char_like_type.h"
+    header "__type_traits/is_class.h"
+    header "__type_traits/is_compound.h"
+    header "__type_traits/is_const.h"
+    header "__type_traits/is_constant_evaluated.h"
+    header "__type_traits/is_constructible.h"
+    header "__type_traits/is_convertible.h"
+    header "__type_traits/is_core_convertible.h"
+    header "__type_traits/is_destructible.h"
+    header "__type_traits/is_empty.h"
+    header "__type_traits/is_enum.h"
+    header "__type_traits/is_equality_comparable.h"
+    header "__type_traits/is_execution_policy.h"
+    header "__type_traits/is_final.h"
+    header "__type_traits/is_floating_point.h"
+    header "__type_traits/is_function.h"
+    header "__type_traits/is_fundamental.h"
+    header "__type_traits/is_implicitly_default_constructible.h"
+    header "__type_traits/is_integral.h"
+    header "__type_traits/is_literal_type.h"
+    header "__type_traits/is_member_pointer.h"
+    header "__type_traits/is_nothrow_assignable.h"
+    header "__type_traits/is_nothrow_constructible.h"
+    header "__type_traits/is_nothrow_convertible.h"
+    header "__type_traits/is_nothrow_destructible.h"
+    header "__type_traits/is_null_pointer.h"
+    header "__type_traits/is_object.h"
+    header "__type_traits/is_pod.h"
+    header "__type_traits/is_pointer.h"
+    header "__type_traits/is_polymorphic.h"
+    header "__type_traits/is_primary_template.h"
+    header "__type_traits/is_reference_wrapper.h"
+    header "__type_traits/is_reference.h"
+    header "__type_traits/is_referenceable.h"
+    header "__type_traits/is_same.h"
+    header "__type_traits/is_scalar.h"
+    header "__type_traits/is_signed_integer.h"
+    header "__type_traits/is_signed.h"
+    header "__type_traits/is_specialization.h"
+    header "__type_traits/is_standard_layout.h"
+    header "__type_traits/is_swappable.h"
+    header "__type_traits/is_trivial.h"
+    header "__type_traits/is_trivially_assignable.h"
+    header "__type_traits/is_trivially_constructible.h"
+    header "__type_traits/is_trivially_copyable.h"
+    header "__type_traits/is_trivially_destructible.h"
+    header "__type_traits/is_trivially_lexicographically_comparable.h"
+    header "__type_traits/is_trivially_relocatable.h"
+    header "__type_traits/is_unbounded_array.h"
+    header "__type_traits/is_union.h"
+    header "__type_traits/is_unsigned_integer.h"
+    header "__type_traits/is_unsigned.h"
+    header "__type_traits/is_valid_expansion.h"
+    header "__type_traits/is_void.h"
+    header "__type_traits/is_volatile.h"
+    header "__type_traits/lazy.h"
+    header "__type_traits/make_32_64_or_128_bit.h"
+    header "__type_traits/make_const_lvalue_ref.h"
+    header "__type_traits/make_signed.h"
+    header "__type_traits/make_unsigned.h"
+    header "__type_traits/maybe_const.h"
+    header "__type_traits/nat.h"
+    header "__type_traits/negation.h"
+    header "__type_traits/promote.h"
+    header "__type_traits/rank.h"
+    header "__type_traits/remove_all_extents.h"
+    header "__type_traits/remove_const_ref.h"
+    header "__type_traits/remove_const.h"
+    header "__type_traits/remove_cv.h"
+    header "__type_traits/remove_cvref.h"
+    header "__type_traits/remove_extent.h"
+    header "__type_traits/remove_pointer.h"
+    header "__type_traits/remove_reference.h"
+    header "__type_traits/remove_volatile.h"
+    header "__type_traits/result_of.h"
+    header "__type_traits/strip_signature.h"
+    header "__type_traits/type_identity.h"
+    header "__type_traits/type_list.h"
+    header "__type_traits/underlying_type.h"
+    header "__type_traits/unwrap_ref.h"
+    header "__type_traits/void_t.h"
+    export *
+  } // module type_traits
+
+  // Only the truly dependency-free parts of __utility are here
+  module utility {
+    header "__utility/declval.h"
+    header "__utility/forward.h"
+    export *
+  }
+
   export *
-}
-module std_filesystem [system] {
-  header "filesystem"
-  module copy_options                 { header "__filesystem/copy_options.h" }
-  module directory_entry              { header "__filesystem/directory_entry.h" }
-  module directory_iterator           { header "__filesystem/directory_iterator.h" }
-  module directory_options            { header "__filesystem/directory_options.h" }
-  module file_status                  { header "__filesystem/file_status.h" }
-  module file_time_type               { header "__filesystem/file_time_type.h" }
-  module file_type                    { header "__filesystem/file_type.h" }
-  module filesystem_error             {
-    header "__filesystem/filesystem_error.h"
-    export std_private_memory_shared_ptr
+} // module std_core
+
+module std [system] {
+  module algorithm {
+    header "algorithm"
+    header "__algorithm/adjacent_find.h"
+    header "__algorithm/all_of.h"
+    header "__algorithm/any_of.h"
+    header "__algorithm/binary_search.h"
+    header "__algorithm/clamp.h"
+    header "__algorithm/comp_ref_type.h"
+    header "__algorithm/comp.h"
+    header "__algorithm/copy_backward.h"
+    header "__algorithm/copy_if.h"
+    header "__algorithm/copy_move_common.h"
+    header "__algorithm/copy_n.h"
+    header "__algorithm/copy.h"
+    header "__algorithm/count_if.h"
+    header "__algorithm/count.h"
+    header "__algorithm/equal_range.h"
+    header "__algorithm/equal.h"
+    header "__algorithm/fill_n.h"
+    header "__algorithm/fill.h"
+    header "__algorithm/find_end.h"
+    header "__algorithm/find_first_of.h"
+    header "__algorithm/find_if_not.h"
+    header "__algorithm/find_if.h"
+    header "__algorithm/find_segment_if.h"
+    header "__algorithm/find.h"
+    header "__algorithm/fold.h"
+    header "__algorithm/for_each_n.h"
+    header "__algorithm/for_each_segment.h"
+    header "__algorithm/for_each.h"
+    header "__algorithm/generate_n.h"
+    header "__algorithm/generate.h"
+    header "__algorithm/half_positive.h"
+    header "__algorithm/in_found_result.h"
+    header "__algorithm/in_fun_result.h"
+    header "__algorithm/in_in_out_result.h"
+    header "__algorithm/in_in_result.h"
+    header "__algorithm/in_out_out_result.h"
+    header "__algorithm/in_out_result.h"
+    header "__algorithm/includes.h"
+    header "__algorithm/inplace_merge.h"
+    header "__algorithm/is_heap_until.h"
+    header "__algorithm/is_heap.h"
+    header "__algorithm/is_partitioned.h"
+    header "__algorithm/is_permutation.h"
+    header "__algorithm/is_sorted_until.h"
+    header "__algorithm/is_sorted.h"
+    header "__algorithm/iter_swap.h"
+    header "__algorithm/iterator_operations.h"
+    header "__algorithm/lexicographical_compare_three_way.h"
+    header "__algorithm/lexicographical_compare.h"
+    header "__algorithm/lower_bound.h"
+    header "__algorithm/make_heap.h"
+    header "__algorithm/make_projected.h"
+    header "__algorithm/max_element.h"
+    header "__algorithm/max.h"
+    header "__algorithm/merge.h"
+    header "__algorithm/min_element.h"
+    header "__algorithm/min_max_result.h"
+    header "__algorithm/min.h"
+    header "__algorithm/minmax_element.h"
+    header "__algorithm/minmax.h"
+    header "__algorithm/mismatch.h"
+    header "__algorithm/move_backward.h"
+    header "__algorithm/move.h"
+    header "__algorithm/next_permutation.h"
+    header "__algorithm/none_of.h"
+    header "__algorithm/nth_element.h"
+    header "__algorithm/partial_sort_copy.h"
+    header "__algorithm/partial_sort.h"
+    header "__algorithm/partition_copy.h"
+    header "__algorithm/partition_point.h"
+    header "__algorithm/partition.h"
+    header "__algorithm/pop_heap.h"
+    header "__algorithm/prev_permutation.h"
+    header "__algorithm/pstl.h"
+    header "__algorithm/push_heap.h"
+    header "__algorithm/ranges_adjacent_find.h"
+    header "__algorithm/ranges_all_of.h"
+    header "__algorithm/ranges_any_of.h"
+    header "__algorithm/ranges_binary_search.h"
+    header "__algorithm/ranges_clamp.h"
+    header "__algorithm/ranges_contains_subrange.h"
+    header "__algorithm/ranges_contains.h"
+    header "__algorithm/ranges_copy_backward.h"
+    header "__algorithm/ranges_copy_if.h"
+    header "__algorithm/ranges_copy_n.h"
+    header "__algorithm/ranges_copy.h"
+    header "__algorithm/ranges_count_if.h"
+    header "__algorithm/ranges_count.h"
+    header "__algorithm/ranges_ends_with.h"
+    header "__algorithm/ranges_equal_range.h"
+    header "__algorithm/ranges_equal.h"
+    header "__algorithm/ranges_fill_n.h"
+    header "__algorithm/ranges_fill.h"
+    header "__algorithm/ranges_find_end.h"
+    header "__algorithm/ranges_find_first_of.h"
+    header "__algorithm/ranges_find_if_not.h"
+    header "__algorithm/ranges_find_if.h"
+    header "__algorithm/ranges_find_last.h"
+    header "__algorithm/ranges_find.h"
+    header "__algorithm/ranges_for_each_n.h"
+    header "__algorithm/ranges_for_each.h"
+    header "__algorithm/ranges_generate_n.h"
+    header "__algorithm/ranges_generate.h"
+    header "__algorithm/ranges_includes.h"
+    header "__algorithm/ranges_inplace_merge.h"
+    header "__algorithm/ranges_is_heap_until.h"
+    header "__algorithm/ranges_is_heap.h"
+    header "__algorithm/ranges_is_partitioned.h"
+    header "__algorithm/ranges_is_permutation.h"
+    header "__algorithm/ranges_is_sorted_until.h"
+    header "__algorithm/ranges_is_sorted.h"
+    header "__algorithm/ranges_iterator_concept.h"
+    header "__algorithm/ranges_lexicographical_compare.h"
+    header "__algorithm/ranges_lower_bound.h"
+    header "__algorithm/ranges_make_heap.h"
+    header "__algorithm/ranges_max_element.h"
+    header "__algorithm/ranges_max.h"
+    header "__algorithm/ranges_merge.h"
+    header "__algorithm/ranges_min_element.h"
+    header "__algorithm/ranges_min.h"
+    header "__algorithm/ranges_minmax_element.h"
+    header "__algorithm/ranges_minmax.h"
+    header "__algorithm/ranges_mismatch.h"
+    header "__algorithm/ranges_move_backward.h"
+    header "__algorithm/ranges_move.h"
+    header "__algorithm/ranges_next_permutation.h"
+    header "__algorithm/ranges_none_of.h"
+    header "__algorithm/ranges_nth_element.h"
+    header "__algorithm/ranges_partial_sort_copy.h"
+    header "__algorithm/ranges_partial_sort.h"
+    header "__algorithm/ranges_partition_copy.h"
+    header "__algorithm/ranges_partition_point.h"
+    header "__algorithm/ranges_partition.h"
+    header "__algorithm/ranges_pop_heap.h"
+    header "__algorithm/ranges_prev_permutation.h"
+    header "__algorithm/ranges_push_heap.h"
+    header "__algorithm/ranges_remove_copy_if.h"
+    header "__algorithm/ranges_remove_copy.h"
+    header "__algorithm/ranges_remove_if.h"
+    header "__algorithm/ranges_remove.h"
+    header "__algorithm/ranges_replace_copy_if.h"
+    header "__algorithm/ranges_replace_copy.h"
+    header "__algorithm/ranges_replace_if.h"
+    header "__algorithm/ranges_replace.h"
+    header "__algorithm/ranges_reverse_copy.h"
+    header "__algorithm/ranges_reverse.h"
+    header "__algorithm/ranges_rotate_copy.h"
+    header "__algorithm/ranges_rotate.h"
+    header "__algorithm/ranges_sample.h"
+    header "__algorithm/ranges_search_n.h"
+    header "__algorithm/ranges_search.h"
+    header "__algorithm/ranges_set_difference.h"
+    header "__algorithm/ranges_set_intersection.h"
+    header "__algorithm/ranges_set_symmetric_difference.h"
+    header "__algorithm/ranges_set_union.h"
+    header "__algorithm/ranges_shuffle.h"
+    header "__algorithm/ranges_sort_heap.h"
+    header "__algorithm/ranges_sort.h"
+    header "__algorithm/ranges_stable_partition.h"
+    header "__algorithm/ranges_stable_sort.h"
+    header "__algorithm/ranges_starts_with.h"
+    header "__algorithm/ranges_swap_ranges.h"
+    header "__algorithm/ranges_transform.h"
+    header "__algorithm/ranges_unique_copy.h"
+    header "__algorithm/ranges_unique.h"
+    header "__algorithm/ranges_upper_bound.h"
+    header "__algorithm/remove_copy_if.h"
+    header "__algorithm/remove_copy.h"
+    header "__algorithm/remove_if.h"
+    header "__algorithm/remove.h"
+    header "__algorithm/replace_copy_if.h"
+    header "__algorithm/replace_copy.h"
+    header "__algorithm/replace_if.h"
+    header "__algorithm/replace.h"
+    header "__algorithm/reverse_copy.h"
+    header "__algorithm/reverse.h"
+    header "__algorithm/rotate_copy.h"
+    header "__algorithm/rotate.h"
+    header "__algorithm/sample.h"
+    header "__algorithm/search_n.h"
+    header "__algorithm/search.h"
+    header "__algorithm/set_difference.h"
+    header "__algorithm/set_intersection.h"
+    header "__algorithm/set_symmetric_difference.h"
+    header "__algorithm/set_union.h"
+    header "__algorithm/shift_left.h"
+    header "__algorithm/shift_right.h"
+    header "__algorithm/shuffle.h"
+    header "__algorithm/sift_down.h"
+    header "__algorithm/simd_utils.h"
+    header "__algorithm/sort_heap.h"
+    header "__algorithm/sort.h"
+    header "__algorithm/stable_partition.h"
+    header "__algorithm/stable_sort.h"
+    header "__algorithm/swap_ranges.h"
+    header "__algorithm/three_way_comp_ref_type.h"
+    header "__algorithm/transform.h"
+    header "__algorithm/uniform_random_bit_generator_adaptor.h"
+    header "__algorithm/unique_copy.h"
+    header "__algorithm/unique.h"
+    header "__algorithm/unwrap_iter.h"
+    header "__algorithm/unwrap_range.h"
+    header "__algorithm/upper_bound.h"
+
+    export debug_utils.strict_weak_ordering_check
+    export functional.ranges_operations
+    export iterator.aliasing_iterator
+    export iterator.iterator_traits
+    export type_traits.is_trivially_copyable
+    export utility.pair
----------------
ian-twilightcoder wrote:

Sure, but `export *` will export everything the module imported, and `export whatever` doesn't do anything if you didn't import `whatever`. So if you have `export *`, that's all you need, and in fact adding specific modules will mess clang up.

https://github.com/llvm/llvm-project/pull/107638


More information about the libcxx-commits mailing list