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