Skip to content

[libc++] Add __assertion_handler to the modulemap #131031

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

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Mar 12, 2025

That header is generated via CMake, but it is nonetheless present in the final installation, so it should be covered by the modulemap.

rdar://131418726

@ldionne ldionne requested a review from a team as a code owner March 12, 2025 20:59
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2025

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

That header is generated via CMake, but it is nonetheless present in the final installation, so it should be covered by the modulemap.

rdar://131418726


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

1 Files Affected:

  • (modified) libcxx/include/module.modulemap (+1)
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index b9964dac84acd..fd87c290406a4 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -2285,6 +2285,7 @@ module std [system] {
   }
   module internal_assert {
     header "__assert"
+    header "__assertion_handler" // Generated via CMake
     export *
   }
 

@@ -2285,6 +2285,7 @@ module std [system] {
}
module internal_assert {
header "__assert"
header "__assertion_handler" // Generated via CMake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a separate submodule - in general each submodule should have only a single header statement, otherwise you "fuse" the two headers. i.e. wherever you have #include <__assertion_handler> it'll also include __assert which is at least unintuitive.

That header is generated via CMake, but it is nonetheless present
in the final installation, so it should be covered by the modulemap.

rdar://131418726
@ldionne ldionne force-pushed the review/add-assertion_handler-to-modulemap branch from 1f606d1 to 755233d Compare March 18, 2025 17:31
@ldionne
Copy link
Member Author

ldionne commented Mar 19, 2025

I had to make the header textual since otherwise I get:

In file included from <...>/include/c++/v1/__algorithm/binary_search.h:13:
  # | <...>/include/c++/v1/__algorithm/comp_ref_type.h:47:5: error: use of undeclared identifier '_LIBCPP_VERBOSE_ABORT'
  # |    47 |     _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering");
  # |       |     ^
  # | <...>/include/c++/v1/__assert:93:71: note: expanded from macro '_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT'
  # |    93 | #  define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message)    _LIBCPP_ASSERT(expression, message)
  # |       |                                                                       ^
  # | <...>/include/c++/v1/__assert:23:10: note: expanded from macro '_LIBCPP_ASSERT'
  # |    23 |        : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING(            \
  # |       |          ^
  # | <...>/include/c++/v1/__assertion_handler:27:46: note: expanded from macro '_LIBCPP_ASSERTION_HANDLER'
  # |    27 | #  define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)
  # |       |                                              ^
  # | While building module 'std' imported from /__w/llvm-project/llvm-project/libcxx/test/support/check_assertion.h:12:

That's because I would have to export std.verbose_abort from std.assertion_handler -- which I can't do since that header may be provided externally (IOW another header might require an export that's different from std.verbose_abort).

@ian-twilightcoder
Copy link
Contributor

Can we make __assertion_handler's module export * instead? __assertion_handler has declarations in it, and so it shouldn't be textual. (We have this problem with some other headers that we should eventually tackle, but let's not add to the list?)

@ldionne ldionne merged commit fdbd26b into llvm:main Mar 24, 2025
86 checks passed
@ldionne ldionne deleted the review/add-assertion_handler-to-modulemap branch March 24, 2025 16:30
atetubou added a commit to atetubou/llvm-project that referenced this pull request Apr 8, 2025
After llvm#131031, Clang modules build
fails in chromium as we use libcxx directory directly like below.

```
stderr:
../../third_party/libc++/src/include/module.modulemap:2325:12: error: header '__assertion_handler' not found
 2325 |     header "__assertion_handler" // generated via CMake
      |            ^
1 error generated.
```

To fix this error, I added `__assertion_handler` as a forward header for our usage.
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.

3 participants