aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-29 15:04:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-29 15:04:30 +0200
commit0417338bbbe28377a5c20e1b0d38dc802ea06b2b (patch)
treee3cb305b4fae81843c8e9df7e6fbce632923cb73
parent5ea81f5bc791243ac77e82276a8a5a3faa3e155f (diff)
Only enable backtrace support on Linux if using glibc
Other libc implementations, for example musl, don't support this out of the box.
-rw-r--r--libbutl/backtrace.cxx7
-rw-r--r--libbutl/backtrace.mxx8
-rw-r--r--tests/backtrace/buildfile2
3 files changed, 10 insertions, 7 deletions
diff --git a/libbutl/backtrace.cxx b/libbutl/backtrace.cxx
index 7a8d615..a66faa2 100644
--- a/libbutl/backtrace.cxx
+++ b/libbutl/backtrace.cxx
@@ -12,14 +12,17 @@
// With glibc linking with -rdynamic gives (non-static) function names.
// FreeBSD requires explicitly linking -lexecinfo.
//
+// Note that some libc implementation on Linux (most notably, musl), don't
+// support this, at least not out of the box.
+//
#ifndef BUILD2_BOOTSTRAP
-# if defined(__linux__) || \
+# if defined(__GLIBC__) || \
defined(__APPLE__) || \
defined(__FreeBSD__)
# define LIBBUTL_BACKTRACE
# endif
#else
-# if defined(__linux__) || \
+# if defined(__GLIBC__) || \
defined(__APPLE__)
# define LIBBUTL_BACKTRACE
# endif
diff --git a/libbutl/backtrace.mxx b/libbutl/backtrace.mxx
index 25d0dcd..38b9ce2 100644
--- a/libbutl/backtrace.mxx
+++ b/libbutl/backtrace.mxx
@@ -31,10 +31,10 @@ LIBBUTL_MODEXPORT namespace butl
// with the binary name, address in that binary, and, if available, the
// function name for each stack frame.
//
- // Currently this functionality is only available on Linux, FreeBSD, and Mac
- // OS. On the first two platforms the address can be mapped to the function
- // name and, if built with debug info, to source location using the
- // addr2line(1) utility:
+ // Currently this functionality is only available on Linux (with glibc),
+ // FreeBSD, and Mac OS. On the first two platforms the address can be mapped
+ // to the function name and, if built with debug info, to source location
+ // using the addr2line(1) utility:
//
// $ addr2line -f -C -e <binary> <addr>
//
diff --git a/tests/backtrace/buildfile b/tests/backtrace/buildfile
index a4120df..d6b2773 100644
--- a/tests/backtrace/buildfile
+++ b/tests/backtrace/buildfile
@@ -8,5 +8,5 @@ exe{driver}: {hxx cxx}{*} $libs testscript
# Make sure backtrace() includes function names.
#
-if ($cxx.target.class == 'linux')
+if ($cxx.target.class == 'linux' && $cc.stdlib == 'glibc')
cxx.loptions += -rdynamic