mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-06 17:38:06 +00:00
[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
This commit is contained in:
parent
6449bea508
commit
7cca34acc4
@ -124,13 +124,14 @@ std::string createTempFile(const Twine &Prefix, StringRef Suffix) {
|
||||
return static_cast<std::string>(FileName);
|
||||
}
|
||||
|
||||
ErrorOr<std::string> findClang(const char *Argv0) {
|
||||
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();
|
||||
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 +220,7 @@ bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
|
||||
if (Opts.PrintCmdAndExit) {
|
||||
Clang = "clang";
|
||||
} else {
|
||||
ErrorOr<std::string> ClangOrErr = findClang(Argv0);
|
||||
ErrorOr<std::string> ClangOrErr = findClang(Argv0, Opts.Triple);
|
||||
if (ClangOrErr) {
|
||||
Clang = *ClangOrErr;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user