diff --git a/libcxx/cmake/caches/Generic-no-localization.cmake b/libcxx/cmake/caches/Generic-no-localization.cmake --- a/libcxx/cmake/caches/Generic-no-localization.cmake +++ b/libcxx/cmake/caches/Generic-no-localization.cmake @@ -1 +1,2 @@ +set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically. set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "") diff --git a/libcxx/modules/std/chrono.inc b/libcxx/modules/std/chrono.inc --- a/libcxx/modules/std/chrono.inc +++ b/libcxx/modules/std/chrono.inc @@ -233,7 +233,9 @@ #endif } // namespace chrono +#ifndef _LIBCPP_HAS_NO_LOCALIZATION using std::formatter; +#endif // _LIBCPP_HAS_NO_LOCALIZATION namespace chrono { // using std::chrono::parse; diff --git a/libcxx/modules/std/complex.inc b/libcxx/modules/std/complex.inc --- a/libcxx/modules/std/complex.inc +++ b/libcxx/modules/std/complex.inc @@ -19,8 +19,10 @@ using std::operator/; using std::operator==; +#ifndef _LIBCPP_HAS_NO_LOCALIZATION using std::operator>>; using std::operator<<; +#endif // _LIBCPP_HAS_NO_LOCALIZATION // [complex.value.ops], values using std::imag; diff --git a/libcxx/modules/std/locale.inc b/libcxx/modules/std/locale.inc --- a/libcxx/modules/std/locale.inc +++ b/libcxx/modules/std/locale.inc @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// export namespace std { +#ifndef _LIBCPP_HAS_NO_LOCALIZATION // [locale], locale using std::has_facet; using std::locale; @@ -71,4 +72,5 @@ // [depr.conversions.string] using std::wstring_convert; +#endif // _LIBCPP_HAS_NO_LOCALIZATION } // namespace std diff --git a/libcxx/modules/std/thread.inc b/libcxx/modules/std/thread.inc --- a/libcxx/modules/std/thread.inc +++ b/libcxx/modules/std/thread.inc @@ -28,7 +28,9 @@ // [thread.thread.id] using std::operator==; using std::operator<=>; +#ifndef _LIBCPP_HAS_NO_LOCALIZATION using std::operator<<; +#endif // _LIBCPP_HAS_NO_LOCALIZATION using std::formatter; diff --git a/libcxx/test/libcxx/module_std.gen.py b/libcxx/test/libcxx/module_std.gen.py --- a/libcxx/test/libcxx/module_std.gen.py +++ b/libcxx/test/libcxx/module_std.gen.py @@ -22,6 +22,7 @@ sys.path.append(sys.argv[1]) from libcxx.header_information import module_headers +from libcxx.header_information import header_restrictions BLOCKLIT = ( "" # block Lit from interpreting a RUN/XFAIL/etc inside the generation script @@ -131,15 +132,34 @@ # Validate all module parts. for header in module_headers: + # Some headers cannot be included when a libc++ feature is disabled. + # In that case include the header conditionally. The header __config + # ensures the libc++ feature macros are available. + if header in header_restrictions: + include = ( + f"#include <__config>{nl}" + + f"#if {header_restrictions[header]}{nl}" + + f"# include <{header}>{nl}" + + f"#endif{nl}" + ) + elif header == "chrono": + # When localization is disabled the header string is not included. + # When string is included chrono's operator""s is a named declaration + # using std::chrono_literals::operator""s; + # else it is a named declaration + # using std::operator""s; + # TODO MODULES investigate why + include = f"#include {nl}#include {nl}" + else: + include = f"#include <{header}>{nl}" + # Generate a module partition for the header module includes. This # makes it possible to verify that all headers export all their # named declarations. - # - # TODO MODULES This needs to take the header restrictions into account. print( f"// RUN{BLOCKLIT}: echo -e \"" f"module;{nl}" - f"#include <{header}>{nl}" + f"{include}" f"{nl}" f"// Use __libcpp_module_
to ensure that modules {nl}" f"// are not named as keywords or reserved names.{nl}" @@ -195,7 +215,7 @@ ) # Clang-tidy needs a file input - print(f'// RUN{BLOCKLIT}: echo "#include <{header}>" > %t.{header}.cpp') + print(f'// RUN{BLOCKLIT}: echo -e "' f"{include}" f'" > %t.{header}.cpp') print( f"// RUN{BLOCKLIT}: %{{clang-tidy}} %t.{header}.cpp " " --checks='-*,libcpp-header-exportable-declarations' " diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -623,8 +623,11 @@ - "**/test-results.xml" - "**/*.abilist" env: - CC: "clang-${LLVM_HEAD_VERSION}" - CXX: "clang++-${LLVM_HEAD_VERSION}" + # Note: Modules require and absolute path for clang-scan-deps + # https://github.com/llvm/llvm-project/issues/61006 + CC: "/usr/lib/llvm-${LLVM_HEAD_VERSION}/bin/clang" + CXX: "/usr/lib/llvm-${LLVM_HEAD_VERSION}/bin/clang++" + CMAKE: "/opt/bin/cmake" ENABLE_CLANG_TIDY: "On" agents: queue: "libcxx-builders"