Skip to content

Commit

Permalink
compiler-rt-sanitizers: Fix hwsan builds with llvm libunwind
Browse files Browse the repository at this point in the history
Signed-off-by: Khem Raj <raj.khem@gmail.com>
  • Loading branch information
kraj committed Jun 8, 2021
1 parent a360486 commit e9a764e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From fbc9b98b9f668bb6729c7f4c6cc9de9d40c674ce Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 29 May 2021 13:42:25 -0700
Subject: [PATCH] compiler-rt: Use uintptr_t instead of _Unwind_Word

_Unwind_Word is defined in compiler specific unwind.h but not in
libunwind provided unwind.h header, it works in most cases because
compilers search compiler headers ahead of system headers but for some
systems e.g. musl bases systems the compiler provided versions are not
preferred over system headers and therefore relying on _Unwind_Word
means its expecting this define in all unwind.h headers which is not the
case, using uintptr_t means we don't need this from unwind.h

See https://reviews.llvm.org/D65699

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
compiler-rt/lib/hwasan/hwasan_exceptions.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/hwasan/hwasan_exceptions.cpp b/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
index 169e7876cb58..6ed1da335428 100644
--- a/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
@@ -29,8 +29,8 @@ typedef _Unwind_Reason_Code PersonalityFn(int version, _Unwind_Action actions,
// is statically linked and the sanitizer runtime and the program are linked
// against different unwinders. The _Unwind_Context data structure is opaque so
// it may be incompatible between unwinders.
-typedef _Unwind_Word GetGRFn(_Unwind_Context* context, int index);
-typedef _Unwind_Word GetCFAFn(_Unwind_Context* context);
+typedef uintptr_t GetGRFn(_Unwind_Context* context, int index);
+typedef uintptr_t GetCFAFn(_Unwind_Context* context);

extern "C" SANITIZER_INTERFACE_ATTRIBUTE _Unwind_Reason_Code
__hwasan_personality_wrapper(int version, _Unwind_Action actions,
1 change: 1 addition & 0 deletions recipes-devtools/clang/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ SRC_URI = "\
file://0031-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \
file://0032-compiler-rt-Link-scudo-standalone-with-libatomic-on-.patch \
file://0033-libunwind-Added-unw_backtrace-method.patch \
file://0034-compiler-rt-Use-uintptr_t-instead-of-_Unwind_Word.patch \
"
# Fallback to no-PIE if not set
GCCPIE ??= ""
Expand Down

0 comments on commit e9a764e

Please sign in to comment.