Skip to content
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

[libc++] Add a escape hatch for making __libcpp_verbose_abort non-noexcept again #113310

Merged
merged 2 commits into from
Oct 23, 2024

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Oct 22, 2024

This allows a slightly smoother transition for people after #109151, as requested on that PR.

@ldionne ldionne requested a review from a team as a code owner October 22, 2024 12:50
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Oct 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

This allows a slightly smoother transition for people after #109151, as requested on that PR.


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

3 Files Affected:

  • (modified) libcxx/docs/ReleaseNotes/20.rst (+6-1)
  • (modified) libcxx/include/__verbose_abort (+7-1)
  • (modified) libcxx/src/verbose_abort.cpp (+1-1)
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 44912d2ddafac6..39546493ae8d6f 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -83,7 +83,9 @@ Deprecations and Removals
   ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in LLVM 20.
 
 - The function ``__libcpp_verbose_abort()`` is now ``noexcept``, to match ``std::terminate()``. (The combination of
-  ``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.)
+  ``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.) For backwards compatibility,
+  the ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro can be defined to make the function non-``noexcept``. That macro
+  will be removed in LLVM 21.
 
 Upcoming Deprecations and Removals
 ----------------------------------
@@ -106,6 +108,9 @@ LLVM 21
   If you are using C++03 in your project, you should consider moving to a newer version of the Standard to get the most
   out of libc++.
 
+- The ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro will be removed in LLVM 21, making ``std::__libcpp_verbose_abort``
+  unconditionally ``noexcept``.
+
 
 ABI Affecting Changes
 ---------------------
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index 73295cae426102..c975ea7f91c919 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -18,10 +18,16 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT)
+#  define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
+#else
+#  define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT
+#endif
+
 // This function should never be called directly from the code -- it should only be called through
 // the _LIBCPP_VERBOSE_ABORT macro.
 [[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
-_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
+_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
 
 // _LIBCPP_VERBOSE_ABORT(format, args...)
 //
diff --git a/libcxx/src/verbose_abort.cpp b/libcxx/src/verbose_abort.cpp
index 0019063405a810..6704709d247ca1 100644
--- a/libcxx/src/verbose_abort.cpp
+++ b/libcxx/src/verbose_abort.cpp
@@ -28,7 +28,7 @@ extern "C" void android_set_abort_message(const char* msg);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
+_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
   // Write message to stderr. We do this before formatting into a
   // buffer so that we still get some information out if that fails.
   {

Copy link

github-actions bot commented Oct 22, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@ldionne
Copy link
Member Author

ldionne commented Oct 23, 2024

@Caslyn This is the escape hatch you requested.

@ldionne ldionne merged commit d269ec3 into llvm:main Oct 23, 2024
68 checks passed
@ldionne ldionne deleted the review/verbose_abort_backwards_compat branch October 23, 2024 21:07
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 23, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-bootstrap-asan running on sanitizer-buildbot2 while building libcxx at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/3154

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86408 of 86409 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: lld :: ELF/lto/devirt_vcall_vis_localize.ll (85026 of 86408)
******************** TEST 'lld :: ELF/lto/devirt_vcall_vis_localize.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 5: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/devirt_vcall_vis_localize.ll
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/devirt_vcall_vis_localize.ll
RUN: at line 6: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/Inputs/devirt_vcall_vis_shared_def.ll
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/Inputs/devirt_vcall_vis_shared_def.ll
RUN: at line 7: echo '{ global: _start; local: *; };' > /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp.ver
+ echo '{ global: _start; local: *; };'
RUN: at line 9: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp.out --save-temps --lto-whole-program-visibility -shared    -mllvm -pass-remarks=. 2>&1 | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/count 0
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp.out --save-temps --lto-whole-program-visibility -shared -mllvm -pass-remarks=.
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/count 0
Expected 0 lines, got 1.

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
201.88s: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir
124.69s: Clang :: Driver/fsanitize.c
105.23s: Clang :: Preprocessor/riscv-target-features.c
95.84s: Clang :: Driver/arm-cortex-cpus-2.c
94.19s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp
93.54s: Clang :: Driver/arm-cortex-cpus-1.c
90.58s: Clang :: OpenMP/target_update_codegen.cpp
75.81s: Clang :: Preprocessor/arm-target-features.c
73.78s: Clang :: Preprocessor/aarch64-target-features.c
68.85s: Clang :: Analysis/a_flaky_crash.cpp
67.12s: Clang :: Preprocessor/predefined-arch-macros.c
62.94s: Clang :: Driver/linux-ld.c
62.15s: Clang :: Driver/clang_f_opts.c
58.23s: LLVM :: CodeGen/RISCV/attributes.ll
56.45s: Clang :: Driver/cl-options.c
55.55s: Clang :: CodeGen/aarch64-sve-intrinsics/acle_sve_reinterpret.c
Step 10 (stage2/asan check) failure: stage2/asan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:513: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86408 of 86409 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: lld :: ELF/lto/devirt_vcall_vis_localize.ll (85026 of 86408)
******************** TEST 'lld :: ELF/lto/devirt_vcall_vis_localize.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 5: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/devirt_vcall_vis_localize.ll
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/devirt_vcall_vis_localize.ll
RUN: at line 6: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/Inputs/devirt_vcall_vis_shared_def.ll
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/opt --thinlto-bc -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/test/ELF/lto/Inputs/devirt_vcall_vis_shared_def.ll
RUN: at line 7: echo '{ global: _start; local: *; };' > /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp.ver
+ echo '{ global: _start; local: *; };'
RUN: at line 9: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp.out --save-temps --lto-whole-program-visibility -shared    -mllvm -pass-remarks=. 2>&1 | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/count 0
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp1.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp2.o -o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/lld/test/ELF/lto/Output/devirt_vcall_vis_localize.ll.tmp.out --save-temps --lto-whole-program-visibility -shared -mllvm -pass-remarks=.
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/count 0
Expected 0 lines, got 1.

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
201.88s: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir
124.69s: Clang :: Driver/fsanitize.c
105.23s: Clang :: Preprocessor/riscv-target-features.c
95.84s: Clang :: Driver/arm-cortex-cpus-2.c
94.19s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp
93.54s: Clang :: Driver/arm-cortex-cpus-1.c
90.58s: Clang :: OpenMP/target_update_codegen.cpp
75.81s: Clang :: Preprocessor/arm-target-features.c
73.78s: Clang :: Preprocessor/aarch64-target-features.c
68.85s: Clang :: Analysis/a_flaky_crash.cpp
67.12s: Clang :: Preprocessor/predefined-arch-macros.c
62.94s: Clang :: Driver/linux-ld.c
62.15s: Clang :: Driver/clang_f_opts.c
58.23s: LLVM :: CodeGen/RISCV/attributes.ll
56.45s: Clang :: Driver/cl-options.c
55.55s: Clang :: CodeGen/aarch64-sve-intrinsics/acle_sve_reinterpret.c

@frobtech frobtech mentioned this pull request Oct 25, 2024
@Caslyn
Copy link
Contributor

Caslyn commented Oct 25, 2024

Thanks @ldionne!

NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…xcept again (llvm#113310)

This allows a slightly smoother transition for people after llvm#109151, as
requested on that PR.
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