summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/clang/clang/0024-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-devtools/clang/clang/0024-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch')
-rw-r--r--recipes-devtools/clang/clang/0024-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0024-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch b/recipes-devtools/clang/clang/0024-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
new file mode 100644
index 0000000..639563d
--- /dev/null
+++ b/recipes-devtools/clang/clang/0024-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch
@@ -0,0 +1,68 @@
1From 5ffa9adacd28053b6ff42d30907991fedb2ce75a 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