-
Notifications
You must be signed in to change notification settings - Fork 13.5k
flang: Fix build with latest libc++ #127362
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
Conversation
I think this first stopped working with 9548366. This patch fixes the following error: /home/runner/work/llvm-project/llvm-project/flang/runtime/io-api-minimal.cpp:153:11: error: '__libcpp_verbose_abort' is missing exception specification 'noexcept' 153 | void std::__libcpp_verbose_abort(char const *format, ...) { | ^ | noexcept /mnt/build/bin/../include/c++/v1/__verbose_abort:30:28: note: previous declaration is here 30 | __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT; | ^ 1 error generated.
@llvm/pr-subscribers-flang-runtime Author: Tom Stellard (tstellar) ChangesI think this first stopped working with /home/runner/work/llvm-project/llvm-project/flang/runtime/io-api-minimal.cpp:153:11: error: '__libcpp_verbose_abort' is missing exception specification 'noexcept' Full diff: https://github.com/llvm/llvm-project/pull/127362.diff 1 Files Affected:
diff --git a/flang/runtime/io-api-minimal.cpp b/flang/runtime/io-api-minimal.cpp
index 68768427be0c2..e53089e02d93d 100644
--- a/flang/runtime/io-api-minimal.cpp
+++ b/flang/runtime/io-api-minimal.cpp
@@ -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 {
va_list list;
va_start(list, format);
std::vfprintf(stderr, format, list);
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
I can't comment on the general question whether it is supported by libc++ to use headers from the STL without linking to the library. |
flang/runtime/io-api-minimal.cpp
Outdated
#if !defined(_LIBCPP_VERBOSE_ABORT_NOEXCEPT) | ||
#define _LIBCPP_VERBOSE_ABORT_NOEXCEPT | ||
#endif | ||
|
||
void std::__libcpp_verbose_abort( | ||
char const *format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The right way of fixing this would be:
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you don't link against the libc++ built library?
That is a very good question that I was pondering myself repeatedly.
I hope it is ok to ask @sscalpone for clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ldionne I've implemented your suggested fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think Flang should figure out why they're not linking against libc++ since that will break other stuff in the future. But in the interest of fixing the current state of trunk, this patch works and doesn't make anything worse than it already is.
/cherry-pick 2b340c1 |
/pull-request #127805 |
I think this first stopped working with 9548366. This patch fixes the following error: /home/runner/work/llvm-project/llvm-project/flang/runtime/io-api-minimal.cpp:153:11: error: '__libcpp_verbose_abort' is missing exception specification 'noexcept' 153 | void std::__libcpp_verbose_abort(char const *format, ...) { | ^ | noexcept /mnt/build/bin/../include/c++/v1/__verbose_abort:30:28: note: previous declaration is here 30 | __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT; | ^ 1 error generated. (cherry picked from commit 2b340c1)
I had already tried to fix this, but had to revert in 81c85ea due to a buildbot failure. Thanks for taking care. |
I think this first stopped working with
9548366. This patch fixes the following error:
/home/runner/work/llvm-project/llvm-project/flang/runtime/io-api-minimal.cpp:153:11: error: '__libcpp_verbose_abort' is missing exception specification 'noexcept'
153 | void std::__libcpp_verbose_abort(char const format, ...) {
| ^
| noexcept
/mnt/build/bin/../include/c++/v1/__verbose_abort:30:28: note: previous declaration is here
30 | printf, 1, 2) void __libcpp_verbose_abort(const char __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
| ^
1 error generated.