summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRin Cat (鈴猫) <dev@rincat.ch>2022-08-18 16:21:54 -0400
committerRin Cat (鈴猫) <dev@rincat.ch>2022-08-18 16:21:54 -0400
commit1d4cb4ba641e7b3662f7cd498865a2ceea62ec47 (patch)
treec91282dd575b05e676c2e58730e0418fef422750 /numpy
parente8c45599c3272b7c9e32bb1444001fd0a6a83fcb (diff)
downloadnumpy-1d4cb4ba641e7b3662f7cd498865a2ceea62ec47.tar.gz
BUG: Support using libunwind for backtrack
Some system (e.g. musl) do not have "execinfo.h", and the backtracking is provided by libunwind. Fix: #22084
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/setup_common.py4
-rw-r--r--numpy/core/src/multiarray/temp_elide.c5
-rw-r--r--numpy/linalg/umath_linalg.cpp4
3 files changed, 12 insertions, 1 deletions
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index a751acc6f..b948f68cb 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -142,7 +142,9 @@ OPTIONAL_HEADERS = [
"immintrin.h", # AVX
"features.h", # for glibc version linux
"xlocale.h", # see GH#8367
- "dlfcn.h", # dladdr
+ "dlfcn.h", # dladdr
+ "execinfo.h", # backtrace
+ "libunwind.h", # backtrace for LLVM/Clang using libunwind
"sys/mman.h", #madvise
]
diff --git a/numpy/core/src/multiarray/temp_elide.c b/numpy/core/src/multiarray/temp_elide.c
index 34248076c..0bf500ed2 100644
--- a/numpy/core/src/multiarray/temp_elide.c
+++ b/numpy/core/src/multiarray/temp_elide.c
@@ -82,7 +82,12 @@
#define NPY_MIN_ELIDE_BYTES (32)
#endif
#include <dlfcn.h>
+
+#if defined HAVE_EXECINFO_H
#include <execinfo.h>
+#elif defined HAVE_LIBUNWIND_H
+#include <libunwind.h>
+#endif
/*
* linear search pointer in table
diff --git a/numpy/linalg/umath_linalg.cpp b/numpy/linalg/umath_linalg.cpp
index bbeb37906..bbb4bb896 100644
--- a/numpy/linalg/umath_linalg.cpp
+++ b/numpy/linalg/umath_linalg.cpp
@@ -50,7 +50,11 @@ using dispatch_scalar = typename std::conditional<std::is_scalar<typ>::value, sc
} while (0)
#if 0
+#if defined HAVE_EXECINFO_H
#include <execinfo.h>
+#elif defined HAVE_LIBUNWIND_H
+#include <libunwind.h>
+#endif
void
dbg_stack_trace()
{