[flang-commits] [flang] flang: Fix build with latest libc++ (PR #127362)

Louis Dionne via flang-commits flang-commits at lists.llvm.org
Mon Feb 17 05:48:01 PST 2025


================
@@ -150,7 +150,12 @@ bool IODEF(OutputLogical)(Cookie cookie, bool truth) {
 // Provide own definition for `std::__libcpp_verbose_abort` to avoid dependency
 // on the version provided by libc++.
 
-void std::__libcpp_verbose_abort(char const *format, ...) {
+#if !defined(_LIBCPP_VERBOSE_ABORT_NOEXCEPT)
+#define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
+#endif
+
+void std::__libcpp_verbose_abort(
+    char const *format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
----------------
ldionne wrote:

The right way of fixing this would be:

```c++
void std::__libcpp_verbose_abort(char const *format, ...)
    noexcept(noexcept(std::__libcpp_verbose_abort("")))
{
  // ...
}
```

This allows unconditionally using the right noexcept-ness based on how the base function has been declared.

About the more general question of whether libc++ supports being used header-only (without linking against the dylib), the answer is no, but some stuff will still happen to work if you do that. That's a brittle setup though, for example I expect that you would encounter a linker error if you tried using `std::shared_ptr` or `std::sort(int*, int*)` anywhere since those are in the dylib. Is there a reason why you don't link against the libc++ built library?

https://github.com/llvm/llvm-project/pull/127362


More information about the flang-commits mailing list