diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index a1355d880a5f7..3edabcb5b1a86 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -702,8 +702,16 @@ void importer::getNormalInvocationArguments( invocationArgStrs.push_back(searchPathOpts.getSDKPath().str()); } else { if (auto sysroot = searchPathOpts.getSysRoot()) { + // Both the sdk path and sysroot are provided. Pass along the sysroot + // to Clang but also ensure the SDK include path is provided. invocationArgStrs.push_back("--sysroot"); invocationArgStrs.push_back(sysroot->str()); + + llvm::SmallString<256> path; + path = searchPathOpts.getSDKPath(); + llvm::sys::path::append(path, "usr", "include"); + invocationArgStrs.push_back("-isystem"); + invocationArgStrs.push_back(path.str().str()); } else { invocationArgStrs.push_back("--sysroot"); invocationArgStrs.push_back(searchPathOpts.getSDKPath().str());