Skip to content

[libc++] Add __assertion_handler as forwarding header #134351

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

Closed
wants to merge 1 commit into from

Conversation

atetubou
Copy link
Contributor

@atetubou atetubou commented Apr 4, 2025

After #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.

@atetubou atetubou requested a review from a team as a code owner April 4, 2025 06:51
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2025

@llvm/pr-subscribers-libcxx

Author: Takuto Ikuta (atetubou)

Changes

After #131031, Clang modules build failes 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 and we'll .


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

1 Files Affected:

  • (added) libcxx/include/__assertion_handler (+15)
diff --git a/libcxx/include/__assertion_handler b/libcxx/include/__assertion_handler
new file mode 100644
index 0000000000000..b5eb532859476
--- /dev/null
+++ b/libcxx/include/__assertion_handler
@@ -0,0 +1,15 @@
+// -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ASSERTION_HANDLER
+#define _LIBCPP___ASSERTION_HANDLER
+
+#include_next <__assertion_handler> // Note: this include is generated by CMake and is potentially vendor-provided.
+
+#endif // _LIBCPP___ASSERTION_HANDLER

@atetubou atetubou changed the title [libcxx] Add __assertion_handler as forwarding header [libc++] Add __assertion_handler as forwarding header Apr 7, 2025
@atetubou
Copy link
Contributor Author

atetubou commented Apr 7, 2025

@ldionne do you think this is acceptable PR to llvm repository?

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.
@atetubou atetubou force-pushed the add_assertion_handler branch from 49203db to 13d936d Compare April 8, 2025 08:01
@philnik777
Copy link
Contributor

This looks more like you're building libc++ wrong to me. The __assertion_handler should live besides the rest of the normal headers.

@atetubou
Copy link
Contributor Author

atetubou commented Apr 8, 2025

But #131031 requires __assertion_handler to be in the same directory with other normal headers along with module.modulemap file?

Currently, we have a libcxx subdrectory folk in https://chromium.googlesource.com/chromium/llvm-project/libcxx/, and using __assertion_handler in https://source.chromium.org/chromium/chromium/src/+/main:buildtools/third_party/libc++/__assertion_handler for non-module build. But the PR makes it not possible to use __assertion_handler in different place than module.modulemap dir.

Or do you think we should fix how we build libc++ in our side?

@philnik777
Copy link
Contributor

But #131031 requires __assertion_handler to be in the same directory with other normal headers along with module.modulemap file?

Currently, we have a libcxx subdrectory folk in https://chromium.googlesource.com/chromium/llvm-project/libcxx/, and using __assertion_handler in https://source.chromium.org/chromium/chromium/src/+/main:buildtools/third_party/libc++/__assertion_handler for non-module build. But the PR makes it not possible to use __assertion_handler in different place than module.modulemap dir.

Or do you think we should fix how we build libc++ in our side?

Yes. CMake is the only supported build tool, and we expect anybody using libc++ to use the same layout as we generate with CMake if you want to use your own build tool. I don't know exactly how you build your stuff, but it shouldn't be impossible to put your __assertion_handler in the right place.

@atetubou
Copy link
Contributor Author

atetubou commented Apr 8, 2025

OK, I'll update chromium's build config so that llvm doesn't need to have this kind of change.
Thank you for your review.

@atetubou atetubou closed this Apr 8, 2025
@atetubou atetubou deleted the add_assertion_handler branch April 8, 2025 09:06
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.

4 participants