summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2021-05-19 17:38:45 -0700
committerKhem Raj <raj.khem@gmail.com>2023-09-08 09:08:54 -0700
commit45d39ab0c1072ed82bde9ddc02b482bb124af7dc (patch)
treec964c26fb7e19e573d55dc7b280bfc5dc3941ea7
parentd800658d70dd0dc8be5a6fdf017515ee316e6b42 (diff)
downloadmeta-clang-45d39ab0c1072ed82bde9ddc02b482bb124af7dc.tar.gz
compiler-rt: Fix sanitizer build on musl/x86_64
backtrace APIs are glibc specific so do not use them Signed-off-by: Khem Raj <raj.khem@gmail.com> (cherry picked from commit 0f3c6b54bf61ec9aabcb2e6ef52ee78e795194c5)
-rw-r--r--recipes-devtools/clang/clang/0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch68
-rw-r--r--recipes-devtools/clang/common.inc1
2 files changed, 69 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch b/recipes-devtools/clang/clang/0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
new file mode 100644
index 0000000..372ac73
--- /dev/null
+++ b/recipes-devtools/clang/clang/0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
@@ -0,0 +1,68 @@
1From c2413de81c383407f6447edd41d9b3539641ff4f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 19 May 2021 17:32:13 -0700
4Subject: [PATCH] compiler-rt: Do not use backtrace APIs on non-glibc linux
5
6musl e.g. does not provide backtrace APIs
7
8Upstream-Status: Pending
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 .../lib/gwp_asan/optional/backtrace_linux_libc.cpp | 13 ++++++++++++-
12 1 file changed, 12 insertions(+), 1 deletion(-)
13
14diff --git a/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp b/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp
15index ea8e72be287d..0344074dd254 100644
16--- a/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp
17+++ b/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp
18@@ -7,7 +7,9 @@
19 //===----------------------------------------------------------------------===//
20
21 #include <assert.h>
22+#ifdef __GLIBC__
23 #include <execinfo.h>
24+#endif
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28@@ -21,8 +23,11 @@
29 namespace {
30 size_t Backtrace(uintptr_t *TraceBuffer, size_t Size) {
31 static_assert(sizeof(uintptr_t) == sizeof(void *), "uintptr_t is not void*");
32-
33+#ifdef __GLIBC__
34 return backtrace(reinterpret_cast<void **>(TraceBuffer), Size);
35+#else
36+ return -1;
37+#endif
38 }
39
40 // We don't need any custom handling for the Segv backtrace - the libc unwinder
41@@ -30,7 +35,11 @@ size_t Backtrace(uintptr_t *TraceBuffer, size_t Size) {
42 // to avoid the additional frame.
43 GWP_ASAN_ALWAYS_INLINE size_t SegvBacktrace(uintptr_t *TraceBuffer, size_t Size,
44 void * /*Context*/) {
45+#ifdef __GLIBC__
46 return Backtrace(TraceBuffer, Size);
47+#else
48+ return -1;
49+#endif
50 }
51
52 static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength,
53@@ -40,6 +49,7 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength,
54 return;
55 }
56
57+#ifdef __GLIBC__
58 char **BacktraceSymbols =
59 backtrace_symbols(reinterpret_cast<void **>(Trace), TraceLength);
60
61@@ -53,6 +63,7 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength,
62 Printf("\n");
63 if (BacktraceSymbols)
64 free(BacktraceSymbols);
65+#endif
66 }
67 } // anonymous namespace
68
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index 06a5ecb..69bb40a 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -37,6 +37,7 @@ SRC_URI = "\
37 file://0026-llvm-Insert-anchor-for-adding-OE-distro-vendor-names.patch \ 37 file://0026-llvm-Insert-anchor-for-adding-OE-distro-vendor-names.patch \
38 file://0027-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \ 38 file://0027-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \
39 file://0028-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \ 39 file://0028-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \
40 file://0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch \
40 file://0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \ 41 file://0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \
41 file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \ 42 file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \
42 file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \ 43 file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \