Skip to content

Commit 282744a

Browse files
committed
[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 curl/curl-for-win@caaae17#commitcomment-105808524 for discussion about a case where this would have been helpful. Differential Revision: https://reviews.llvm.org/D146794
1 parent d2fa6b6 commit 282744a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/tools/llvm-rc/llvm-rc.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "ResourceScriptStmt.h"
1818
#include "ResourceScriptToken.h"
1919

20+
#include "llvm/Config/llvm-config.h"
2021
#include "llvm/Object/WindowsResource.h"
2122
#include "llvm/Option/Arg.h"
2223
#include "llvm/Option/ArgList.h"
@@ -138,10 +139,12 @@ ErrorOr<std::string> findClang(const char *Argv0, StringRef Triple) {
138139
StringRef Parent = llvm::sys::path::parent_path(Argv0);
139140
ErrorOr<std::string> Path = std::error_code();
140141
std::string TargetClang = (Triple + "-clang").str();
142+
std::string VersionedClang = ("clang-" + Twine(LLVM_VERSION_MAJOR)).str();
141143
if (!Parent.empty()) {
142144
// First look for the tool with all potential names in the specific
143145
// directory of Argv0, if known
144-
for (const auto *Name : {TargetClang.c_str(), "clang", "clang-cl"}) {
146+
for (const auto *Name :
147+
{TargetClang.c_str(), VersionedClang.c_str(), "clang", "clang-cl"}) {
145148
Path = sys::findProgramByName(Name, Parent);
146149
if (Path)
147150
return Path;

0 commit comments

Comments
 (0)