[Driver] Obey computed sysroot when finding libc++ headers.

Summary:
A handful of targets will try some default paths if --sysroot is not provided.
If that is the case, it should be used for the libc++ header paths.

Reviewers: srhines, EricWF

Reviewed By: srhines

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45292

llvm-svn: 331389
This commit is contained in:
Dan Albert 2018-05-02 19:31:01 +00:00
parent 350c22c587
commit f6f114936a
1 changed files with 3 additions and 2 deletions

View File

@ -793,13 +793,14 @@ static std::string DetectLibcxxIncludePath(StringRef base) {
void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const { llvm::opt::ArgStringList &CC1Args) const {
const std::string& SysRoot = computeSysRoot();
const std::string LibCXXIncludePathCandidates[] = { const std::string LibCXXIncludePathCandidates[] = {
DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"), DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
// If this is a development, non-installed, clang, libcxx will // If this is a development, non-installed, clang, libcxx will
// not be found at ../include/c++ but it likely to be found at // not be found at ../include/c++ but it likely to be found at
// one of the following two locations: // one of the following two locations:
DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/local/include/c++"), DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++") }; DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
for (const auto &IncludePath : LibCXXIncludePathCandidates) { for (const auto &IncludePath : LibCXXIncludePathCandidates) {
if (IncludePath.empty() || !getVFS().exists(IncludePath)) if (IncludePath.empty() || !getVFS().exists(IncludePath))
continue; continue;