Skip to content

Commit b9857e6

Browse files
mstorsjotstellar
authored andcommitted
[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 (cherry picked from commit 282744a)
1 parent 3555102 commit b9857e6

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
@@ -18,6 +18,7 @@
1818
#include "ResourceScriptToken.h"
1919

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

0 commit comments

Comments
 (0)