diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in index f199e194e60b1..651d6ec7b9fe2 100644 --- a/libcxx/modules/std.compat.cppm.in +++ b/libcxx/modules/std.compat.cppm.in @@ -17,38 +17,17 @@ module; // The headers of Table 24: C++ library headers [tab:headers.cpp] // and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c] -#include -#include -#include -#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) -# include -#endif -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#include -#include #include #include #include #include #include -#include -#include #include #include #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) # include #endif #include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#include -#include -#include -#include #include #include #include @@ -65,107 +44,6 @@ module; #if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) # include #endif -#include -#include -#include -#include -#include -#include -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#include -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#include -#include -#include -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#include -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#include -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#include -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include -#endif -#include -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // *** Headers not yet available *** #if __has_include() @@ -203,6 +81,7 @@ module; #endif // __has_include() export module std.compat; +export import std; + -@LIBCXX_MODULE_STD_INCLUDE_SOURCES@ @LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES@ \ No newline at end of file diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index b46c52e781f82..6ce8e287737b8 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -204,4 +204,5 @@ module; export module std; + @LIBCXX_MODULE_STD_INCLUDE_SOURCES@ diff --git a/libcxx/test/libcxx/module_std_compat.gen.py b/libcxx/test/libcxx/module_std_compat.gen.py index 2866066ccedc8..270d131779e5b 100644 --- a/libcxx/test/libcxx/module_std_compat.gen.py +++ b/libcxx/test/libcxx/module_std_compat.gen.py @@ -21,6 +21,7 @@ import sys sys.path.append(sys.argv[1]) +from libcxx.header_information import module_c_headers from libcxx.test.modules import module_test_generator generator = module_test_generator( @@ -37,27 +38,5 @@ print("//--- module_std_compat.sh.cpp") generator.write_test( "std.compat", - [ - "cassert", - "cctype", - "cerrno", - "cfenv", - "cfloat", - "cinttypes", - "climits", - "clocale", - "cmath", - "csetjmp", - "csignal", - "cstdarg", - "cstddef", - "cstdint", - "cstdio", - "cstdlib", - "cstring", - "ctime", - "cuchar", - "cwchar", - "cwctype", - ], + module_c_headers, ) diff --git a/libcxx/utils/generate_libcxx_cppm_in.py b/libcxx/utils/generate_libcxx_cppm_in.py index f957406778d39..2d3f829847fb9 100644 --- a/libcxx/utils/generate_libcxx_cppm_in.py +++ b/libcxx/utils/generate_libcxx_cppm_in.py @@ -9,6 +9,7 @@ import os.path import sys +from libcxx.header_information import module_c_headers from libcxx.header_information import module_headers from libcxx.header_information import header_restrictions from libcxx.header_information import headers_not_available @@ -44,7 +45,7 @@ def write_file(module): // and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c] """ ) - for header in module_headers: + for header in module_headers if module == "std" else module_c_headers: if header in header_restrictions: module_cpp_in.write( f"""\ @@ -69,8 +70,9 @@ def write_file(module): module_cpp_in.write( f""" export module {module}; +{'export import std;' if module == 'std.compat' else ''} -@LIBCXX_MODULE_STD_INCLUDE_SOURCES@ +{'@LIBCXX_MODULE_STD_INCLUDE_SOURCES@' if module == 'std' else ''} {'@LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES@' if module == 'std.compat' else ''}""" ) diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py index 2268034bae204..b2aa3739ea697 100644 --- a/libcxx/utils/libcxx/header_information.py +++ b/libcxx/utils/libcxx/header_information.py @@ -215,3 +215,28 @@ def is_modulemap_header(header): # These headers have been removed in C++20 so are never part of a module. and not header in ["ccomplex", "ciso646", "cstdbool", "ctgmath"] ] + +# The C headers used in the std and std.compat modules. +module_c_headers = [ + "cassert", + "cctype", + "cerrno", + "cfenv", + "cfloat", + "cinttypes", + "climits", + "clocale", + "cmath", + "csetjmp", + "csignal", + "cstdarg", + "cstddef", + "cstdint", + "cstdio", + "cstdlib", + "cstring", + "ctime", + "cuchar", + "cwchar", + "cwctype", +] diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py index c605e8796ac54..13175214879c4 100644 --- a/libcxx/utils/libcxx/test/format.py +++ b/libcxx/utils/libcxx/test/format.py @@ -171,6 +171,7 @@ def parseScript(test, preamble): "%dbg(MODULE std.compat) %{cxx} %{flags} " f"{compileFlags} " "-Wno-reserved-module-identifier -Wno-reserved-user-defined-literal " + "-fmodule-file=std=%T/std.pcm " # The std.compat module imports std. "--precompile -o %T/std.compat.pcm -c %{module}/std.compat.cppm", ) moduleCompileFlags.extend(