1From b7a166acaddc4c78afa2b653e25114d9114699f3 Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Sat, 6 Aug 2016 11:24:50 +0200
4Subject: [PATCH] Proper detection of cxxabi.h and execinfo.h
5
6The current code in webrtc/base/checks.cc assumes that if __GLIBCXX__ is
7defined and __UCLIBC__ is not defined, then both cxxabi.h and execinfo.h
8will be available.
9
10Unfortunately, this is not correct with the musl C library:
11
12 - It defines __GLIBCXX__
13 - It does not define __UCLIBC__ (it's not uClibc after all!)
14 - But it also doesn't provide execinfo.h
15
16Therefore, in order to make things work properly, we switch to proper
17autoconf checks for cxxabi.h and execinfo.h, and only use the backtrace
18functionality if both are provided.
19
20Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
21---
22 configure.ac          | 2 ++
23 webrtc/base/checks.cc | 4 ++--
24 2 files changed, 4 insertions(+), 2 deletions(-)
25
26diff --git a/configure.ac b/configure.ac
27index acbb3e2..ff4c752 100644
28--- a/configure.ac
29+++ b/configure.ac
30@@ -45,6 +45,8 @@ AC_SUBST(GNUSTL_CFLAGS)
31 # Borrowed from gst-plugins-bad
32 AC_CHECK_HEADER(MobileCoreServices/MobileCoreServices.h, HAVE_IOS="yes", HAVE_IOS="no", [-])
33
34+AC_CHECK_HEADERS([cxxabi.h execinfo.h])
35+
36 # Based on gst-plugins-bad configure.ac and defines in
37 # <chromium source>/build/config/BUILDCONFIG.gn and
38 # webrtc/BUILD.gn
39diff --git a/webrtc/base/checks.cc b/webrtc/base/checks.cc
40index 49a31f2..05d23a6 100644
41--- a/webrtc/base/checks.cc
42+++ b/webrtc/base/checks.cc
43@@ -16,7 +16,7 @@
44 #include <cstdio>
45 #include <cstdlib>
46
47-#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
48+#if defined(HAVE_CXX_ABI_H) && defined(HAVE_EXECINFO_H)
49 #include <cxxabi.h>
50 #include <execinfo.h>
51 #endif
52@@ -55,7 +55,7 @@ void PrintError(const char* format, ...) {
53 // to get usable symbols on Linux. This is copied from V8. Chromium has a more
54 // advanced stace trace system; also more difficult to copy.
55 void DumpBacktrace() {
56-#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
57+#if defined(HAVE_CXX_ABI_H) && defined(HAVE_EXECINFO_H)
58   void* trace[100];
59   int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
60   char** symbols = backtrace_symbols(trace, size);
61--
622.7.4
63
64