From 4856da26e188c28bf691d0210ce8016264c00940 Mon Sep 17 00:00:00 2001 From: Dario Mylonopoulos <32958057+ramenguy99@users.noreply.github.com> Date: Sat, 6 Sep 2025 04:38:08 +0200 Subject: 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 --- source/core/slang-platform.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/core') 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 #endif +#if SLANG_HAS_BACKTRACE +#include +#endif #if SLANG_LINUX_FAMILY -#include #include #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); -- cgit v1.2.3