Skip to content

Clang: Return new layout path if cannot find CRT #87319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,21 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/true);
SmallString<128> OldPath(getCompilerRTPath());
llvm::sys::path::append(OldPath, CRTBasename);
if (Path.empty() || getVFS().exists(OldPath))
if (getVFS().exists(OldPath))
return std::string(OldPath);

// If none is found, use a file name from the new layout, which may get
// printed in an error message, aiding users in knowing what Clang is
// looking for.
if (Path.empty()) {
CRTBasename =
buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
SmallString<128> NewP(D.ResourceDir);
llvm::sys::path::append(NewP, "lib");
llvm::sys::path::append(NewP, getTriple().str());
llvm::sys::path::append(NewP, CRTBasename);
return std::string(NewP);
}
return std::string(Path);
}

Expand Down