[PATCH] D88192: Add support for setting the path to llvm-symbolizer through an environment variable

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 18:20:38 PDT 2020


mehdi_amini created this revision.
mehdi_amini added a reviewer: MaskRay.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
mehdi_amini requested review of this revision.

This allows to point to an executable that isn't named exactly
"llvm-symbolizer" and not necessarily in the current PATH.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88192

Files:
  llvm/lib/Support/Signals.cpp


Index: llvm/lib/Support/Signals.cpp
===================================================================
--- llvm/lib/Support/Signals.cpp
+++ llvm/lib/Support/Signals.cpp
@@ -45,6 +45,7 @@
                          cl::location(DisableSymbolicationFlag), cl::Hidden);
 
 constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
+constexpr char LlvmSymbolizerPath[] = "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,10 @@
   // 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 (getenv(LlvmSymbolizerPath))
+    LLVMSymbolizerPathOrErr =
+        sys::findProgramByName(getenv(LlvmSymbolizerPath));
+  else if (!Argv0.empty()) {
     StringRef Parent = llvm::sys::path::parent_path(Argv0);
     if (!Parent.empty())
       LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", Parent);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88192.293906.patch
Type: text/x-patch
Size: 1136 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200924/9c5a0f69/attachment.bin>


More information about the llvm-commits mailing list