[llvm] 55bb1ba - Add support for setting the path to llvm-symbolizer through an environment variable
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 12:14:12 PDT 2020
Author: Mehdi Amini
Date: 2020-09-24T19:14:04Z
New Revision: 55bb1ba0fdd3c97d163f8115f818eafe11814623
URL: https://github.com/llvm/llvm-project/commit/55bb1ba0fdd3c97d163f8115f818eafe11814623
DIFF: https://github.com/llvm/llvm-project/commit/55bb1ba0fdd3c97d163f8115f818eafe11814623.diff
LOG: Add support for setting the path to llvm-symbolizer through an environment variable
This allows to point to an executable that isn't named exactly
"llvm-symbolizer" and not necessarily in the current PATH.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D88192
Added:
Modified:
llvm/lib/Support/Signals.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp
index 83a606b59df3..29be4df95954 100644
--- a/llvm/lib/Support/Signals.cpp
+++ b/llvm/lib/Support/Signals.cpp
@@ -45,6 +45,7 @@ static cl::opt<bool, true>
cl::location(DisableSymbolicationFlag), cl::Hidden);
constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
+constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";
// 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
@@ -119,7 +120,9 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,
// Use llvm-symbolizer tool to symbolize the stack traces. First look for it
// alongside our binary, then in $PATH.
ErrorOr<std::string> LLVMSymbolizerPathOrErr = std::error_code();
- if (!Argv0.empty()) {
+ if (const char *Path = getenv(LLVMSymbolizerPathEnv)) {
+ LLVMSymbolizerPathOrErr = sys::findProgramByName(Path);
+ } else if (!Argv0.empty()) {
StringRef Parent = llvm::sys::path::parent_path(Argv0);
if (!Parent.empty())
LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", Parent);
More information about the llvm-commits
mailing list