diff --git a/libcxx/docs/Contributing.rst b/libcxx/docs/Contributing.rst --- a/libcxx/docs/Contributing.rst +++ b/libcxx/docs/Contributing.rst @@ -47,6 +47,7 @@ - Did you add all new named declarations to the ``std`` module? - If you added a header: + - Did you add it to ``include/__std_clang_module``? - Did you add it to ``include/module.modulemap.in``? - Did you add it to ``include/CMakeLists.txt``? - If it's a public header, did you update ``utils/libcxx/test/header_information.py``? diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -653,6 +653,7 @@ __ranges/views.h __ranges/zip_view.h __split_buffer + __std_clang_module __std_mbstate_t.h __stop_token/atomic_unique_lock.h __stop_token/intrusive_list_view.h diff --git a/libcxx/include/__std_clang_module b/libcxx/include/__std_clang_module new file mode 100644 --- /dev/null +++ b/libcxx/include/__std_clang_module @@ -0,0 +1,212 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// This header should not be directly included, it's exclusively to import all +// of the libc++ public clang modules for the `std` clang module to export. In +// other words, it's to facilitate `@import std;` in Objective-C++ and `import std` +// in Swift to expose all of the libc++ interfaces. This is generally not +// recommended, however there are some clients that need to import all of libc++ +// without knowing what "all" is. +#if !__building_module(std) +# error "Do not include this header directly, include individual headers instead" +#endif + +#include <__availability> +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +# ifndef _LIBCPP_HAS_NO_FILESYSTEM +# include +# endif +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# include + +# include +#endif + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +# include + +# include +# include +#endif + +#ifdef _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT +# include +#endif + +#if _LIBCPP_STD_VER >= 11 +# ifndef _LIBCPP_HAS_NO_THREADS +# include +# include +# include +# endif + +# include +# include +# include +# include +# include +# include +# include +# ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +# endif +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +#if _LIBCPP_STD_VER >= 14 +# ifndef _LIBCPP_HAS_NO_THREADS +# include +# endif +#endif + +#if _LIBCPP_STD_VER >= 17 +# ifndef _LIBCPP_HAS_NO_FILESYSTEM +# include +# endif +#endif + +#if _LIBCPP_STD_VER >= 20 +# include + +# ifndef _LIBCPP_HAS_NO_THREADS +# include +# include +# include +# include +# endif +#endif + +#if _LIBCPP_STD_VER >= 23 +# ifndef _LIBCPP_HAS_NO_THREADS +# include +# endif +#endif diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -627,6 +627,13 @@ } } +// Convenience method to get all of the above modules in a single import statement. +// Importing only the needed modules is likely to be more performant. +module std [system] { + header "__std_clang_module" + export * +} + // Implementation detail headers that are private to libc++. These modules // must not be directly imported. module std_private_assert [system] { diff --git a/libcxx/test/libcxx/modules_include.gen.py b/libcxx/test/libcxx/modules_include.gen.py --- a/libcxx/test/libcxx/modules_include.gen.py +++ b/libcxx/test/libcxx/modules_include.gen.py @@ -44,3 +44,31 @@ #include <{header}> """) + +print(f""" +//--- __std_clang_module.compile.pass.mm +// RUN{BLOCKLIT}: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only + +// UNSUPPORTED{BLOCKLIT}: use_module_std + +// GCC doesn't support -fcxx-modules +// UNSUPPORTED{BLOCKLIT}: gcc + +// The Windows headers don't appear to be compatible with modules +// UNSUPPORTED{BLOCKLIT}: windows +// UNSUPPORTED{BLOCKLIT}: buildhost=windows + +// The AIX headers don't appear to be compatible with modules +// UNSUPPORTED{BLOCKLIT}: LIBCXX-AIX-FIXME + +// The Android headers don't appear to be compatible with modules yet +// XFAIL{BLOCKLIT}: LIBCXX-ANDROID-FIXME + +// TODO: Investigate this failure +// UNSUPPORTED{BLOCKLIT}: LIBCXX-FREEBSD-FIXME + +#if __has_feature(modules) +@import std; +#endif + +""") diff --git a/libcxx/utils/generate_iwyu_mapping.py b/libcxx/utils/generate_iwyu_mapping.py --- a/libcxx/utils/generate_iwyu_mapping.py +++ b/libcxx/utils/generate_iwyu_mapping.py @@ -77,6 +77,8 @@ continue elif i == "__split_buffer": public = ["deque", "vector"] + elif i == "__std_clang_module": + continue elif i == "__std_mbstate_t.h": continue elif i == "__threading_support": diff --git a/libcxx/utils/libcxx/test/header_information.py b/libcxx/utils/libcxx/test/header_information.py --- a/libcxx/utils/libcxx/test/header_information.py +++ b/libcxx/utils/libcxx/test/header_information.py @@ -15,10 +15,8 @@ "coroutine": "// UNSUPPORTED: c++03, c++11, c++14, c++17", "cwchar": "// UNSUPPORTED: no-wide-characters", "cwctype": "// UNSUPPORTED: no-wide-characters", - "experimental/algorithm": "// UNSUPPORTED: c++03", "experimental/deque": "// UNSUPPORTED: c++03", "experimental/forward_list": "// UNSUPPORTED: c++03", - "experimental/functional": "// UNSUPPORTED: c++03", "experimental/iterator": "// UNSUPPORTED: c++03", "experimental/list": "// UNSUPPORTED: c++03", "experimental/map": "// UNSUPPORTED: c++03",