From 405593ea28846014c59d73ae1fd0c438a0660811 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Sun, 17 Nov 2024 15:54:49 +0100 Subject: [PATCH] chore: avoid stack overflow in debug tests (#6103) --- src/include/lean/lean.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/include/lean/lean.h b/src/include/lean/lean.h index 51e8984b8324..1ad7aac78389 100644 --- a/src/include/lean/lean.h +++ b/src/include/lean/lean.h @@ -37,7 +37,15 @@ extern "C" { #if defined(__GNUC__) || defined(__clang__) #define LEAN_UNLIKELY(x) (__builtin_expect((x), 0)) #define LEAN_LIKELY(x) (__builtin_expect((x), 1)) + +#ifdef NDEBUG #define LEAN_ALWAYS_INLINE __attribute__((always_inline)) +#else +// We have observed stack frame increases from forced inlining overflowing the stack in debug builds, +// let's leave the decision to the compiler in that case +#define LEAN_ALWAYS_INLINE +#endif + #else #define LEAN_UNLIKELY(x) (x) #define LEAN_LIKELY(x) (x)