diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/ManagedStatic.h" @@ -124,13 +125,14 @@ return static_cast(FileName); } -ErrorOr findClang(const char *Argv0) { +ErrorOr findClang(const char *Argv0, StringRef triple) { StringRef Parent = llvm::sys::path::parent_path(Argv0); ErrorOr Path = std::error_code(); + std::string TargetClang = llvm::formatv("{0}-clang", triple); if (!Parent.empty()) { // First look for the tool with all potential names in the specific // directory of Argv0, if known - for (const auto *Name : {"clang", "clang-cl"}) { + for (const auto *Name : {TargetClang.c_str(), "clang", "clang-cl"}) { Path = sys::findProgramByName(Name, Parent); if (Path) return Path; @@ -219,7 +221,7 @@ if (Opts.PrintCmdAndExit) { Clang = "clang"; } else { - ErrorOr ClangOrErr = findClang(Argv0); + ErrorOr ClangOrErr = findClang(Argv0, Opts.Triple); if (ClangOrErr) { Clang = *ClangOrErr; } else {