From 32c67e742ebc876bb0b12e1bf4d5e3bbd78c9687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rin=20Cat=20=28=E9=88=B4=E7=8C=AB=29?= Date: Thu, 18 Aug 2022 16:21:54 -0400 Subject: [PATCH] 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 --- numpy/core/setup_common.py | 4 +++- numpy/core/src/multiarray/temp_elide.c | 5 +++++ numpy/linalg/umath_linalg.cpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index 4b802de82846..ce966ddf2aea 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -141,7 +141,9 @@ def set_sig(sig): "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 34248076c98e..0bf500ed29c5 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 + +#if defined HAVE_EXECINFO_H #include +#elif defined HAVE_LIBUNWIND_H +#include +#endif /* * linear search pointer in table diff --git a/numpy/linalg/umath_linalg.cpp b/numpy/linalg/umath_linalg.cpp index bbeb37906fe4..bbb4bb896c3f 100644 --- a/numpy/linalg/umath_linalg.cpp +++ b/numpy/linalg/umath_linalg.cpp @@ -50,7 +50,11 @@ using dispatch_scalar = typename std::conditional::value, sc } while (0) #if 0 +#if defined HAVE_EXECINFO_H #include +#elif defined HAVE_LIBUNWIND_H +#include +#endif void dbg_stack_trace() {