diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -561,8 +561,11 @@ #if ENABLE_BACKTRACES static void *StackTrace[256]; int depth = 0; -#if defined(HAVE_BACKTRACE) +#if defined(HAVE_BACKTRACE) && !defined(__riscv) // Use backtrace() to output a backtrace on Linux systems with glibc. + // Don't use it on RISC-V Linux because it's highly unlikely to work but it + // may return 1 or 2 entries, preventing the retry with _Unwind_Backtrace + // below. if (!depth) depth = backtrace(StackTrace, static_cast(std::size(StackTrace))); #endif