From 0f3c6b54bf61ec9aabcb2e6ef52ee78e795194c5 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 19 May 2021 17:38:45 -0700 Subject: compiler-rt: Fix sanitizer build on musl/x86_64 backtrace APIs are glibc specific so do not use them Signed-off-by: Khem Raj --- ...-Do-not-use-backtrace-APIs-on-non-glibc-l.patch | 68 ++++++++++++++++++++++ recipes-devtools/clang/common.inc | 1 + 2 files changed, 69 insertions(+) create mode 100644 recipes-devtools/clang/clang/0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch (limited to 'recipes-devtools') 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 @@ +From c2413de81c383407f6447edd41d9b3539641ff4f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 19 May 2021 17:32:13 -0700 +Subject: [PATCH] compiler-rt: Do not use backtrace APIs on non-glibc linux + +musl e.g. does not provide backtrace APIs + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + .../lib/gwp_asan/optional/backtrace_linux_libc.cpp | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp b/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp +index ea8e72be287d..0344074dd254 100644 +--- a/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp ++++ b/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp +@@ -7,7 +7,9 @@ + //===----------------------------------------------------------------------===// + + #include ++#ifdef __GLIBC__ + #include ++#endif + #include + #include + #include +@@ -21,8 +23,11 @@ + namespace { + size_t Backtrace(uintptr_t *TraceBuffer, size_t Size) { + static_assert(sizeof(uintptr_t) == sizeof(void *), "uintptr_t is not void*"); +- ++#ifdef __GLIBC__ + return backtrace(reinterpret_cast(TraceBuffer), Size); ++#else ++ return -1; ++#endif + } + + // We don't need any custom handling for the Segv backtrace - the libc unwinder +@@ -30,7 +35,11 @@ size_t Backtrace(uintptr_t *TraceBuffer, size_t Size) { + // to avoid the additional frame. + GWP_ASAN_ALWAYS_INLINE size_t SegvBacktrace(uintptr_t *TraceBuffer, size_t Size, + void * /*Context*/) { ++#ifdef __GLIBC__ + return Backtrace(TraceBuffer, Size); ++#else ++ return -1; ++#endif + } + + static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength, +@@ -40,6 +49,7 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength, + return; + } + ++#ifdef __GLIBC__ + char **BacktraceSymbols = + backtrace_symbols(reinterpret_cast(Trace), TraceLength); + +@@ -53,6 +63,7 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength, + Printf("\n"); + if (BacktraceSymbols) + free(BacktraceSymbols); ++#endif + } + } // anonymous namespace + 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 = "\ file://0026-llvm-Insert-anchor-for-adding-OE-distro-vendor-names.patch \ file://0027-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \ file://0028-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \ + file://0029-compiler-rt-Do-not-use-backtrace-APIs-on-non-glibc-l.patch \ " # Fallback to no-PIE if not set GCCPIE ??= "" -- cgit v1.2.3-54-g00ecf