summaryrefslogtreecommitdiffstats
path: root/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2021-05-19 17:38:45 -0700
committerKhem Raj <raj.khem@gmail.com>2021-06-08 11:37:54 -0700
commit0f3c6b54bf61ec9aabcb2e6ef52ee78e795194c5 (patch)
tree0e7e1103b717fd35256e3d2468fee351509253d8 /recipes-devtools
parentd692c0338fe60cdbb3025dcedbb05ca466335650 (diff)
downloadmeta-clang-0f3c6b54bf61ec9aabcb2e6ef52ee78e795194c5.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>
Diffstat (limited to 'recipes-devtools')
-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 6e578d5..8e4ee8d 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" 41"
41# Fallback to no-PIE if not set 42# Fallback to no-PIE if not set
42GCCPIE ??= "" 43GCCPIE ??= ""