mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 05:40:09 +00:00
[libc++][modules] Improves std.compat module. (#76330)
Let the std.compat module use the std module instead of duplicating the exports. Based on @ChuanqiXu9's suggestion in #71438.
This commit is contained in:
parent
1d6b6132ff
commit
04757337cd
@ -17,38 +17,17 @@ module;
|
|||||||
|
|
||||||
// The headers of Table 24: C++ library headers [tab:headers.cpp]
|
// 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]
|
// and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
|
||||||
#include <algorithm>
|
|
||||||
#include <any>
|
|
||||||
#include <array>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
|
||||||
# include <atomic>
|
|
||||||
#endif
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <barrier>
|
|
||||||
#endif
|
|
||||||
#include <bit>
|
|
||||||
#include <bitset>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cfenv>
|
#include <cfenv>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <charconv>
|
|
||||||
#include <chrono>
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
||||||
# include <clocale>
|
# include <clocale>
|
||||||
#endif
|
#endif
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <codecvt>
|
|
||||||
#endif
|
|
||||||
#include <compare>
|
|
||||||
#include <complex>
|
|
||||||
#include <concepts>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <coroutine>
|
|
||||||
#include <csetjmp>
|
#include <csetjmp>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
@ -65,107 +44,6 @@ module;
|
|||||||
#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
|
#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
|
||||||
# include <cwctype>
|
# include <cwctype>
|
||||||
#endif
|
#endif
|
||||||
#include <deque>
|
|
||||||
#include <exception>
|
|
||||||
#include <execution>
|
|
||||||
#include <expected>
|
|
||||||
#include <filesystem>
|
|
||||||
#include <format>
|
|
||||||
#include <forward_list>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <fstream>
|
|
||||||
#endif
|
|
||||||
#include <functional>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <future>
|
|
||||||
#endif
|
|
||||||
#include <initializer_list>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <iomanip>
|
|
||||||
#endif
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <ios>
|
|
||||||
#endif
|
|
||||||
#include <iosfwd>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <iostream>
|
|
||||||
#endif
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <istream>
|
|
||||||
#endif
|
|
||||||
#include <iterator>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <latch>
|
|
||||||
#endif
|
|
||||||
#include <limits>
|
|
||||||
#include <list>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <locale>
|
|
||||||
#endif
|
|
||||||
#include <map>
|
|
||||||
#include <mdspan>
|
|
||||||
#include <memory>
|
|
||||||
#include <memory_resource>
|
|
||||||
#include <mutex>
|
|
||||||
#include <new>
|
|
||||||
#include <numbers>
|
|
||||||
#include <numeric>
|
|
||||||
#include <optional>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <ostream>
|
|
||||||
#endif
|
|
||||||
#include <print>
|
|
||||||
#include <queue>
|
|
||||||
#include <random>
|
|
||||||
#include <ranges>
|
|
||||||
#include <ratio>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <regex>
|
|
||||||
#endif
|
|
||||||
#include <scoped_allocator>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <semaphore>
|
|
||||||
#endif
|
|
||||||
#include <set>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <shared_mutex>
|
|
||||||
#endif
|
|
||||||
#include <source_location>
|
|
||||||
#include <span>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <sstream>
|
|
||||||
#endif
|
|
||||||
#include <stack>
|
|
||||||
#include <stdexcept>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <stop_token>
|
|
||||||
#endif
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <streambuf>
|
|
||||||
#endif
|
|
||||||
#include <string>
|
|
||||||
#include <string_view>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <strstream>
|
|
||||||
#endif
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
|
||||||
# include <syncstream>
|
|
||||||
#endif
|
|
||||||
#include <system_error>
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
|
||||||
# include <thread>
|
|
||||||
#endif
|
|
||||||
#include <tuple>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <typeindex>
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <utility>
|
|
||||||
#include <valarray>
|
|
||||||
#include <variant>
|
|
||||||
#include <vector>
|
|
||||||
#include <version>
|
|
||||||
|
|
||||||
// *** Headers not yet available ***
|
// *** Headers not yet available ***
|
||||||
#if __has_include(<debugging>)
|
#if __has_include(<debugging>)
|
||||||
@ -203,6 +81,7 @@ module;
|
|||||||
#endif // __has_include(<text_encoding>)
|
#endif // __has_include(<text_encoding>)
|
||||||
|
|
||||||
export module std.compat;
|
export module std.compat;
|
||||||
|
export import std;
|
||||||
|
|
||||||
|
|
||||||
@LIBCXX_MODULE_STD_INCLUDE_SOURCES@
|
|
||||||
@LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES@
|
@LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES@
|
@ -204,4 +204,5 @@ module;
|
|||||||
|
|
||||||
export module std;
|
export module std;
|
||||||
|
|
||||||
|
|
||||||
@LIBCXX_MODULE_STD_INCLUDE_SOURCES@
|
@LIBCXX_MODULE_STD_INCLUDE_SOURCES@
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append(sys.argv[1])
|
sys.path.append(sys.argv[1])
|
||||||
|
from libcxx.header_information import module_c_headers
|
||||||
from libcxx.test.modules import module_test_generator
|
from libcxx.test.modules import module_test_generator
|
||||||
|
|
||||||
generator = module_test_generator(
|
generator = module_test_generator(
|
||||||
@ -37,27 +38,5 @@ generator = module_test_generator(
|
|||||||
print("//--- module_std_compat.sh.cpp")
|
print("//--- module_std_compat.sh.cpp")
|
||||||
generator.write_test(
|
generator.write_test(
|
||||||
"std.compat",
|
"std.compat",
|
||||||
[
|
module_c_headers,
|
||||||
"cassert",
|
|
||||||
"cctype",
|
|
||||||
"cerrno",
|
|
||||||
"cfenv",
|
|
||||||
"cfloat",
|
|
||||||
"cinttypes",
|
|
||||||
"climits",
|
|
||||||
"clocale",
|
|
||||||
"cmath",
|
|
||||||
"csetjmp",
|
|
||||||
"csignal",
|
|
||||||
"cstdarg",
|
|
||||||
"cstddef",
|
|
||||||
"cstdint",
|
|
||||||
"cstdio",
|
|
||||||
"cstdlib",
|
|
||||||
"cstring",
|
|
||||||
"ctime",
|
|
||||||
"cuchar",
|
|
||||||
"cwchar",
|
|
||||||
"cwctype",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from libcxx.header_information import module_c_headers
|
||||||
from libcxx.header_information import module_headers
|
from libcxx.header_information import module_headers
|
||||||
from libcxx.header_information import header_restrictions
|
from libcxx.header_information import header_restrictions
|
||||||
from libcxx.header_information import headers_not_available
|
from libcxx.header_information import headers_not_available
|
||||||
@ -44,7 +45,7 @@ module;
|
|||||||
// and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
|
// 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:
|
if header in header_restrictions:
|
||||||
module_cpp_in.write(
|
module_cpp_in.write(
|
||||||
f"""\
|
f"""\
|
||||||
@ -69,8 +70,9 @@ module;
|
|||||||
module_cpp_in.write(
|
module_cpp_in.write(
|
||||||
f"""
|
f"""
|
||||||
export module {module};
|
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 ''}"""
|
{'@LIBCXX_MODULE_STD_COMPAT_INCLUDE_SOURCES@' if module == 'std.compat' else ''}"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -215,3 +215,28 @@ module_headers = [
|
|||||||
# These headers have been removed in C++20 so are never part of a module.
|
# These headers have been removed in C++20 so are never part of a module.
|
||||||
and not header in ["ccomplex", "ciso646", "cstdbool", "ctgmath"]
|
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",
|
||||||
|
]
|
||||||
|
@ -171,6 +171,7 @@ def parseScript(test, preamble):
|
|||||||
"%dbg(MODULE std.compat) %{cxx} %{flags} "
|
"%dbg(MODULE std.compat) %{cxx} %{flags} "
|
||||||
f"{compileFlags} "
|
f"{compileFlags} "
|
||||||
"-Wno-reserved-module-identifier -Wno-reserved-user-defined-literal "
|
"-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",
|
"--precompile -o %T/std.compat.pcm -c %{module}/std.compat.cppm",
|
||||||
)
|
)
|
||||||
moduleCompileFlags.extend(
|
moduleCompileFlags.extend(
|
||||||
|
Loading…
Reference in New Issue
Block a user