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 @@ -156,8 +156,23 @@ LLVMSymbolizerPathOrErr = sys::findProgramByName(Path); } else if (!Argv0.empty()) { StringRef Parent = llvm::sys::path::parent_path(Argv0); + std::vector paths; if (!Parent.empty()) - LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", Parent); + paths.push_back(Parent); + + // If Argv0 is symlink we should resolve and add its real path's + // parent directory as well. + if (llvm::sys::fs::is_symlink_file(Argv0)) { + llvm::SmallString<128> Resolved; + if (!llvm::sys::fs::real_path(Argv0, Resolved)) { + Parent = llvm::sys::path::parent_path(Resolved); + if (!Parent.empty()) + paths.push_back(Parent); + } + } + + if (!paths.empty()) + LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", paths); } if (!LLVMSymbolizerPathOrErr) LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer");