Index: lib/Driver/ToolChains/Gnu.cpp =================================================================== --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -1670,6 +1670,15 @@ GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the / Prefixes.push_back(GCCToolchainDir); + + // If we have a SysRoot, try that too as GCCToolchainDir may not + // have support for the target. This can happen, for example, if + // clang was configured with -DGCC_INSTALL_PREFIX and we run + // regression tests with --sysroot. + if (!D.SysRoot.empty()) { + Prefixes.push_back(D.SysRoot); + AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot); + } } else { // If we have a SysRoot, try that first. if (!D.SysRoot.empty()) {