Skip to content

Commit 7cca34a

Browse files
committed
[llvm-rc]: Find <target>-clang over just clang
This patch makes llvm-rc/windres prefer <target>-clang over clang when doing it's preprocessing. This is so that we can have a .cfg file for <target> and configure sysroot and other important flags. Config files not picked up with clang --target=<target> automatically. We only look for <target>-clang in the same dir as llvm-windres and not for all PATHs to minimize the change. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D119219
1 parent 6449bea commit 7cca34a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,14 @@ std::string createTempFile(const Twine &Prefix, StringRef Suffix) {
124124
return static_cast<std::string>(FileName);
125125
}
126126

127-
ErrorOr<std::string> findClang(const char *Argv0) {
127+
ErrorOr<std::string> findClang(const char *Argv0, StringRef Triple) {
128128
StringRef Parent = llvm::sys::path::parent_path(Argv0);
129129
ErrorOr<std::string> Path = std::error_code();
130+
std::string TargetClang = (Triple + "-clang").str();
130131
if (!Parent.empty()) {
131132
// First look for the tool with all potential names in the specific
132133
// directory of Argv0, if known
133-
for (const auto *Name : {"clang", "clang-cl"}) {
134+
for (const auto *Name : {TargetClang.c_str(), "clang", "clang-cl"}) {
134135
Path = sys::findProgramByName(Name, Parent);
135136
if (Path)
136137
return Path;
@@ -219,7 +220,7 @@ bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
219220
if (Opts.PrintCmdAndExit) {
220221
Clang = "clang";
221222
} else {
222-
ErrorOr<std::string> ClangOrErr = findClang(Argv0);
223+
ErrorOr<std::string> ClangOrErr = findClang(Argv0, Opts.Triple);
223224
if (ClangOrErr) {
224225
Clang = *ClangOrErr;
225226
} else {

0 commit comments

Comments
 (0)