[llvm-branch-commits] [llvm] b9857e6 - [llvm-rc] Look for "clang-<major>" when locating a suitable preprocessor
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Apr 4 10:56:04 PDT 2023
Author: Martin Storsjö
Date: 2023-04-04T10:55:36-07:00
New Revision: b9857e6711a2d352a059d8b58a5d88b2ef16bb15
URL: https://github.com/llvm/llvm-project/commit/b9857e6711a2d352a059d8b58a5d88b2ef16bb15
DIFF: https://github.com/llvm/llvm-project/commit/b9857e6711a2d352a059d8b58a5d88b2ef16bb15.diff
LOG: [llvm-rc] Look for "clang-<major>" when locating a suitable preprocessor
In some cases, there's no adjacent executable named "clang" or
"clang-cl", but one name "clang-<major>". This logic doesn't
cover every possible deployment setup of course, but should
cover more fairly common/reasonable cases.
See
https://github.com/curl/curl-for-win/commit/caaae171ac43af5b883403714dafd42030d8de61#commitcomment-105808524
for discussion about a case where this would have been helpful.
Differential Revision: https://reviews.llvm.org/D146794
(cherry picked from commit 282744a9ce18120dc0a6eceb02693b36980d9498)
Added:
Modified:
llvm/tools/llvm-rc/llvm-rc.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index b6b44d4f58992..30c1569bc956e 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -18,6 +18,7 @@
#include "ResourceScriptToken.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/Object/WindowsResource.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
@@ -137,10 +138,12 @@ ErrorOr<std::string> findClang(const char *Argv0, StringRef Triple) {
StringRef Parent = llvm::sys::path::parent_path(Argv0);
ErrorOr<std::string> Path = std::error_code();
std::string TargetClang = (Triple + "-clang").str();
+ std::string VersionedClang = ("clang-" + Twine(LLVM_VERSION_MAJOR)).str();
if (!Parent.empty()) {
// First look for the tool with all potential names in the specific
// directory of Argv0, if known
- for (const auto *Name : {TargetClang.c_str(), "clang", "clang-cl"}) {
+ for (const auto *Name :
+ {TargetClang.c_str(), VersionedClang.c_str(), "clang", "clang-cl"}) {
Path = sys::findProgramByName(Name, Parent);
if (Path)
return Path;
More information about the llvm-branch-commits
mailing list