[libunwind] e03be2e - unwind: allow building with GCC
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 13 14:46:21 PDT 2021
Author: Saleem Abdulrasool
Date: 2021-06-13T14:44:54-07:00
New Revision: e03be2efe564026ad3b04d459794c89c674e1ed9
URL: https://github.com/llvm/llvm-project/commit/e03be2efe564026ad3b04d459794c89c674e1ed9
DIFF: https://github.com/llvm/llvm-project/commit/e03be2efe564026ad3b04d459794c89c674e1ed9.diff
LOG: unwind: allow building with GCC
This was regressed in adf1561d6ce8. Since gcc does not support
`__has_feature`, this adjusts the build to use the
`__SANITIZE_ADDRESS__` macro which GCC defines to identify if ASAN is
enabled (similar to `__has_feature`). This allows building libunwind
with gcc again.
Patch by Daniel Levin!
Reviewed By: compnerd
Differential Revision: https://reviews.llvm.org/D104176
Added:
Modified:
libunwind/src/libunwind.cpp
Removed:
################################################################################
diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp
index 9b3b92bdff099..1faf000ce44a9 100644
--- a/libunwind/src/libunwind.cpp
+++ b/libunwind/src/libunwind.cpp
@@ -16,7 +16,13 @@
#include <stdlib.h>
-#if __has_feature(address_sanitizer)
+// Define the __has_feature extension for compilers that do not support it so
+// that we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
+#endif
+
+#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
#include <sanitizer/asan_interface.h>
#endif
@@ -187,7 +193,7 @@ _LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, unw_get_proc_info)
/// 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_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
// Inform the ASan runtime that now might be a good time to clean stuff up.
__asan_handle_no_return();
#endif
More information about the cfe-commits
mailing list