diff options
| author | Dario Mylonopoulos <32958057+ramenguy99@users.noreply.github.com> | 2025-09-06 04:38:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-06 02:38:08 +0000 |
| commit | 4856da26e188c28bf691d0210ce8016264c00940 (patch) | |
| tree | a8136299b493cc7834f434c49dda868bc40723bb /source/core | |
| parent | ffd58977b4e64af5a83ebc5478555fd667f58e51 (diff) | |
Add check for backtrace availability (#8329)
The header execinfo.h and the related backtrace functionality is not
available on all linux platforms. In particular it's missing on musl
linux and on Android before API version 33. This causes compilation
errors on those platforms.
With this change, we first check if backtrace functionality is available
by checking if we are using glibc or a compatible Android version.
Tested on manylinux_2_28 with glibc 2.28 and musllinux_1_2 with musl
1.2, has not been tested on Android.
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-platform.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index 7f79d99e1..25e6bc6f0 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -15,9 +15,11 @@ #include <dlfcn.h> #endif +#if SLANG_HAS_BACKTRACE +#include <execinfo.h> +#endif #if SLANG_LINUX_FAMILY -#include <execinfo.h> #include <unistd.h> #endif @@ -363,7 +365,7 @@ static const PlatformFlags s_familyFlags[int(PlatformFamily::CountOf)] = { /* static */ void PlatformUtil::backtrace() { -#if SLANG_LINUX_FAMILY +#if SLANG_HAS_BACKTRACE // Print stack trace for debugging assistance void* stackTrace[64]; int stackDepth = ::backtrace(stackTrace, 64); |
