[libcxx-commits] [libcxx] [libc++] Make libc++ forward-compatible with AppleClang's definition of __builtin_verbose_trap (PR #99529)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 18 10:18:35 PDT 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/99529
AppleClang as included in the Xcode 16 beta implements __builtin_verbose_trap, but it implements slightly different semantics from the ones implemented upstream. This patch makes libc++ compatible with either definition until we drop support for the version of AppleClang that differs from upstream.
>From 13740ee569591dc82ea931a34d1f41347613c5ab Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 18 Jul 2024 13:14:17 -0400
Subject: [PATCH] [libc++] Make libc++ forward-compatible with AppleClang's
definition of __builtin_verbose_trap
AppleClang as included in the Xcode 16 beta implements __builtin_verbose_trap,
but it implements slightly different semantics from the ones implemented
upstream. This patch makes libc++ compatible with either definition until
we drop support for the version of AppleClang that differs from upstream.
---
libcxx/vendor/llvm/default_assertion_handler.in | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libcxx/vendor/llvm/default_assertion_handler.in b/libcxx/vendor/llvm/default_assertion_handler.in
index 9bd831c227798..3b6d6b2cca53c 100644
--- a/libcxx/vendor/llvm/default_assertion_handler.in
+++ b/libcxx/vendor/llvm/default_assertion_handler.in
@@ -24,7 +24,13 @@
#else
# if __has_builtin(__builtin_verbose_trap)
-# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
+// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
+// version before upstream Clang actually got the builtin.
+# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 17000
+# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
+# else
+# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
+# endif
# else
# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
# endif
More information about the libcxx-commits
mailing list