Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Remove obsolete header restrictions for _LIBCPP_HAS_NO_THREADS #107437

Merged

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Sep 5, 2024

The _LIBCPP_HAS_NO_THREADS carve-out does not result in hard errors
anymore, but the patch that changed that forgot to update the header
restrictions we use to auto-generate several files.

We can also remove the restrictions for the no-localization build and
no-wide-characters, but doing it is less straightforward so I'm leaving
it out of this patch.

@ldionne ldionne requested a review from a team as a code owner September 5, 2024 17:30
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 5, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 5, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

The _LIBCPP_HAS_NO_THREADS and _LIBCPP_HAS_NO_LOCALIZATION carve-outs do not result in hard errors anymore, but the patch that changed that forgot to update the header restrictions we use to auto-generate several files.


Full diff: https://github.com/llvm/llvm-project/pull/107437.diff

4 Files Affected:

  • (modified) libcxx/include/__std_clang_module (+23-69)
  • (modified) libcxx/modules/std.compat.cppm.in (+1-3)
  • (modified) libcxx/modules/std.cppm.in (+21-63)
  • (modified) libcxx/utils/libcxx/header_information.py (-28)
diff --git a/libcxx/include/__std_clang_module b/libcxx/include/__std_clang_module
index 18d6ce6b46c1f6..703c8099ed584a 100644
--- a/libcxx/include/__std_clang_module
+++ b/libcxx/include/__std_clang_module
@@ -33,9 +33,7 @@
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #  include <atomic>
 #endif
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <barrier>
-#endif
+#include <barrier>
 #include <bit>
 #include <bitset>
 #include <cassert>
@@ -49,13 +47,9 @@
 #include <cinttypes>
 #include <ciso646>
 #include <climits>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <clocale>
-#endif
+#include <clocale>
 #include <cmath>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <codecvt>
-#endif
+#include <codecvt>
 #include <compare>
 #include <complex.h>
 #include <complex>
@@ -97,40 +91,22 @@
 #include <float.h>
 #include <format>
 #include <forward_list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <fstream>
-#endif
+#include <fstream>
 #include <functional>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <future>
-#endif
+#include <future>
 #include <initializer_list>
 #include <inttypes.h>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <iomanip>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <ios>
-#endif
+#include <iomanip>
+#include <ios>
 #include <iosfwd>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <iostream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <istream>
-#endif
+#include <iostream>
+#include <istream>
 #include <iterator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <latch>
-#endif
+#include <latch>
 #include <limits>
 #include <list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <locale.h>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <locale>
-#endif
+#include <locale.h>
+#include <locale>
 #include <map>
 #include <math.h>
 #include <mdspan>
@@ -141,60 +117,38 @@
 #include <numbers>
 #include <numeric>
 #include <optional>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <ostream>
-#endif
+#include <ostream>
 #include <print>
 #include <queue>
 #include <random>
 #include <ranges>
 #include <ratio>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <regex>
-#endif
+#include <regex>
 #include <scoped_allocator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <semaphore>
-#endif
+#include <semaphore>
 #include <set>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <shared_mutex>
-#endif
+#include <shared_mutex>
 #include <source_location>
 #include <span>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <sstream>
-#endif
+#include <sstream>
 #include <stack>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-#  include <stdatomic.h>
-#endif
+#include <stdatomic.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdexcept>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <stop_token>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <streambuf>
-#endif
+#include <stop_token>
+#include <streambuf>
 #include <string.h>
 #include <string>
 #include <string_view>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <strstream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <syncstream>
-#endif
+#include <strstream>
+#include <syncstream>
 #include <system_error>
 #include <tgmath.h>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <thread>
-#endif
+#include <thread>
 #include <tuple>
 #include <type_traits>
 #include <typeindex>
diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in
index 0f547a2dc8b715..d743da50ca04f0 100644
--- a/libcxx/modules/std.compat.cppm.in
+++ b/libcxx/modules/std.compat.cppm.in
@@ -24,9 +24,7 @@ module;
 #include <cfloat>
 #include <cinttypes>
 #include <climits>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <clocale>
-#endif
+#include <clocale>
 #include <cmath>
 #include <csetjmp>
 #include <csignal>
diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in
index ad8a639b7f71a1..4a3cc2d38fc6b3 100644
--- a/libcxx/modules/std.cppm.in
+++ b/libcxx/modules/std.cppm.in
@@ -23,9 +23,7 @@ module;
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #  include <atomic>
 #endif
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <barrier>
-#endif
+#include <barrier>
 #include <bit>
 #include <bitset>
 #include <cassert>
@@ -37,13 +35,9 @@ module;
 #include <chrono>
 #include <cinttypes>
 #include <climits>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <clocale>
-#endif
+#include <clocale>
 #include <cmath>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <codecvt>
-#endif
+#include <codecvt>
 #include <compare>
 #include <complex>
 #include <concepts>
@@ -72,36 +66,20 @@ module;
 #include <filesystem>
 #include <format>
 #include <forward_list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <fstream>
-#endif
+#include <fstream>
 #include <functional>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <future>
-#endif
+#include <future>
 #include <initializer_list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <iomanip>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <ios>
-#endif
+#include <iomanip>
+#include <ios>
 #include <iosfwd>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <iostream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <istream>
-#endif
+#include <iostream>
+#include <istream>
 #include <iterator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <latch>
-#endif
+#include <latch>
 #include <limits>
 #include <list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <locale>
-#endif
+#include <locale>
 #include <map>
 #include <mdspan>
 #include <memory>
@@ -111,50 +89,30 @@ module;
 #include <numbers>
 #include <numeric>
 #include <optional>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <ostream>
-#endif
+#include <ostream>
 #include <print>
 #include <queue>
 #include <random>
 #include <ranges>
 #include <ratio>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <regex>
-#endif
+#include <regex>
 #include <scoped_allocator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <semaphore>
-#endif
+#include <semaphore>
 #include <set>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <shared_mutex>
-#endif
+#include <shared_mutex>
 #include <source_location>
 #include <span>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <sstream>
-#endif
+#include <sstream>
 #include <stack>
 #include <stdexcept>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <stop_token>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <streambuf>
-#endif
+#include <stop_token>
+#include <streambuf>
 #include <string>
 #include <string_view>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <strstream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <syncstream>
-#endif
+#include <strstream>
+#include <syncstream>
 #include <system_error>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <thread>
-#endif
+#include <thread>
 #include <tuple>
 #include <type_traits>
 #include <typeindex>
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 166c9a77c08e70..c2b900670d4c93 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -11,34 +11,6 @@
 header_restrictions = {
     # headers with #error directives
     "atomic": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)",
-    "stdatomic.h": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)",
-
-    # headers with #error directives
-    "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "locale.h": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    # transitive includers of the above headers
-    "clocale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "codecvt": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "fstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "iomanip": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "iostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "istream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "locale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "ostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "sstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "streambuf": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "strstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-    "syncstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-
-    # headers with #error directives
-    "barrier": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "future": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "latch": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "semaphore": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "shared_mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "stop_token": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "thread": "!defined(_LIBCPP_HAS_NO_THREADS)",
 
     # headers with #error directives
     "wchar.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",

@ldionne ldionne force-pushed the review/remove-obsolete-header-restrictions branch from 7ae129b to c660cf0 Compare September 10, 2024 14:57
@ldionne ldionne changed the title [libc++] Remove obsolete header restrictions [libc++] Remove obsolete header restrictions for _LIBCPP_HAS_NO_THREADS Sep 10, 2024
The _LIBCPP_HAS_NO_THREADS carve-out does not result in hard errors
anymore, but the patch that changed that forgot to update the header
restrictions we use to auto-generate several files.

We can also remove the restrictions for the no-localization build and
no-wide-characters, but doing it is less straightforward so I'm leaving
it out of this patch.
@ldionne ldionne force-pushed the review/remove-obsolete-header-restrictions branch from c660cf0 to 0059e30 Compare September 10, 2024 15:00
@ldionne ldionne merged commit 695cb55 into llvm:main Sep 11, 2024
61 checks passed
@ldionne ldionne deleted the review/remove-obsolete-header-restrictions branch September 11, 2024 21:47
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Sep 12, 2024
…DS (llvm#107437)

The _LIBCPP_HAS_NO_THREADS carve-out does not result in hard errors
anymore, but the patch that changed that forgot to update the header
restrictions we use to auto-generate several files.

We can also remove the restrictions for the no-localization build and
no-wide-characters, but doing it is less straightforward so I'm leaving
it out of this patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants