[PATCH] D104176: [libunwind] Define and use portable macro for checking for presence of ASAN
Daniel Levin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 23:32:44 PDT 2021
daniel-levin created this revision.
Herald added a project: libunwind.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libunwind.
daniel-levin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
- libunwind does not build with GCC due to a change introduced in adf1561d6ce8 <https://reviews.llvm.org/rGadf1561d6ce8af057127c65af863b3f0e1c77e60> which uses the clang-only __has_feature macro.
- The problem is resolved by defining an "Is asan present?" macro that works across different compilers
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104176
Files:
libunwind/src/libunwind.cpp
Index: libunwind/src/libunwind.cpp
===================================================================
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,7 +16,15 @@
#include <stdlib.h>
-#if __has_feature(address_sanitizer)
+#if defined(__has_feature)
+#define has_asan_portable __has_feature(address_sanitizer)
+#elif defined(__SANITIZE_ADDRESS__)
+#define has_asan_portable __SANITIZE_ADDRESS__
+#else
+#define has_asan_portable 0
+#endif
+
+#if has_asan_portable
#include <sanitizer/asan_interface.h>
#endif
@@ -187,7 +195,7 @@
/// Resume execution at cursor position (aka longjump).
_LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
_LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast<void *>(cursor));
-#if __has_feature(address_sanitizer)
+#if has_asan_portable
// Inform the ASan runtime that now might be a good time to clean stuff up.
__asan_handle_no_return();
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104176.351640.patch
Type: text/x-patch
Size: 936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210612/2a9c6e62/attachment.bin>
More information about the llvm-commits
mailing list