-
Notifications
You must be signed in to change notification settings - Fork 14k
[libc++] Remove trailing newline from _LIBCPP_ASSERTION_HANDLER calls #143573
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
@llvm/pr-subscribers-libcxx Author: Sam Clegg (sbc100) ChangesThis newline was originally added in https://reviews.llvm.org/D142184 but I think updating The I noticed this discrepancy when working on Full diff: https://github.com/llvm/llvm-project/pull/143573.diff 3 Files Affected:
diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index 90eaa6023587b..062dc636b58b7 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -21,7 +21,7 @@
(__builtin_expect(static_cast<bool>(expression), 1) \
? (void)0 \
: _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \
- expression) " failed: " message "\n"))
+ expression) " failed: " message))
// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear
// optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
diff --git a/libcxx/include/__cxx03/__assert b/libcxx/include/__cxx03/__assert
index f6c4d8e4a5d09..76579fece2829 100644
--- a/libcxx/include/__cxx03/__assert
+++ b/libcxx/include/__cxx03/__assert
@@ -21,7 +21,7 @@
(__builtin_expect(static_cast<bool>(expression), 1) \
? (void)0 \
: _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \
- expression) " failed: " message "\n"))
+ expression) " failed: " message))
// TODO: __builtin_assume can currently inhibit optimizations. Until this has been fixed and we can add
// assumptions without a clear optimization intent, disable that to avoid worsening the code generation.
diff --git a/libcxx/src/verbose_abort.cpp b/libcxx/src/verbose_abort.cpp
index 94bdb451dee7a..4167ff311901d 100644
--- a/libcxx/src/verbose_abort.cpp
+++ b/libcxx/src/verbose_abort.cpp
@@ -30,6 +30,9 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
va_list list;
va_start(list, format);
std::vfprintf(stderr, format, list);
+ // Callers of `__libcpp_verbose_abort` to not include a newline but when
+ // writing the message to stderr we need to include one.
+ std::vfprintf(stderr, "\n", list);
va_end(list);
}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
ae86f04
to
d6d878f
Compare
@vitalybuka WDYT? |
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.
I'm fine with this assuming CI is happy -- but let's give a bit of time for @vitalybuka to chime in.
This newline was originally added in https://reviews.llvm.org/D142184 but I think updating `__libcpp_verbose_abort` to add newline instead is more consistent, and works for other callers of `_LIBCPP_VERBOSE_ABORT`. The `_LIBCPP_ASSERTION_HANDLER` calls through to either `_LIBCPP_VERBOSE_ABORT` macro or the `__builtin_verbose_trap` From what I can tell neither of these function expect a trailing newline (At least non of the usage of `_LIBCPP_VERBOSE_ABORT` or `__builtin_verbose_trap` that I can find include a trailing newline except _LIBCPP_ASSERTION_HANDLER). I noticed this discrepancy when working on emscripten-core/emscripten#24543
d6d878f
to
4d5aa22
Compare
I'm seeing the following error from the CI:
presumably this is not related to this PR? |
@ldionne, are the CI bots here reliable? i.e. do we always wait for an all-green run? |
No, but yes. They currently aren't reliable, but if they run properly they give reliable results. There are currently just infrastructure issues. An all-green run is definitely preferred and a few restarts should be planned in currently. |
Can you confirm that the current failures look unrelated to this change? I've tried restarting and rebasing a few times and I'm not having any luck getting all-green here. |
It does look unrelated. I've restarted the failed job. If it fails again in the same way feel free to land. |
This is causing build failures in the Fuchsia toolchain builders across all platforms. Accordingly, I'm issuing a revert.
|
…RTION_HANDLER calls" (#144615) Reverts llvm/llvm-project#143573
This newline was originally added in https://reviews.llvm.org/D142184 but I think updating
__libcpp_verbose_abort
to add newline instead is more consistent, and works for other callers of_LIBCPP_VERBOSE_ABORT
.The
_LIBCPP_ASSERTION_HANDLER
calls through to either_LIBCPP_VERBOSE_ABORT
macro or the__builtin_verbose_trap
. From what I can tell neither of these function expect a trailing newline (at least none of the usage of_LIBCPP_VERBOSE_ABORT
or__builtin_verbose_trap
that I can find include a trailing newline except_LIBCPP_ASSERTION_HANDLER
).I noticed this discrepancy when working on
emscripten-core/emscripten#24543