diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp --- a/llvm/lib/Support/Signals.cpp +++ b/llvm/lib/Support/Signals.cpp @@ -44,6 +44,8 @@ cl::desc("Disable symbolizing crash backtraces."), cl::location(DisableSymbolicationFlag), cl::Hidden); +constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION"; + // Callbacks to run in signal handler must be lock-free because a signal handler // could be running as we add new callbacks. We don't add unbounded numbers of // callbacks, an array is therefore sufficient. @@ -105,7 +107,7 @@ LLVM_ATTRIBUTE_USED static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, int Depth, llvm::raw_ostream &OS) { - if (DisableSymbolicationFlag) + if (DisableSymbolicationFlag || getenv(DisableSymbolizationEnv)) return false; // Don't recursively invoke the llvm-symbolizer binary. diff --git a/llvm/test/tools/not/disable-symbolization.test b/llvm/test/tools/not/disable-symbolization.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/not/disable-symbolization.test @@ -0,0 +1,5 @@ +# RUN: not --crash env > %t || true +# RUN: FileCheck %s < %t + +# CHECK-DAG: LLVM_DISABLE_CRASH_REPORT=1 +# CHECK-DAG: LLVM_DISABLE_SYMBOLIZATION=1 diff --git a/llvm/utils/not/not.cpp b/llvm/utils/not/not.cpp --- a/llvm/utils/not/not.cpp +++ b/llvm/utils/not/not.cpp @@ -27,6 +27,11 @@ ++argv; --argc; ExpectCrash = true; + + // Crash is expected, so disable crash report and symbolization to reduce + // output and avoid potentially slow symbolization. + setenv("LLVM_DISABLE_CRASH_REPORT", "1", 0); + setenv("LLVM_DISABLE_SYMBOLIZATION", "1", 0); } if (argc == 0)