File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -885,12 +885,23 @@ getClangInvocationFileMapping(ASTContext &ctx) {
885885 if (triple.isAndroid ())
886886 return {};
887887
888+ // Extract the libstdc++ installation path from Clang driver.
888889 auto clangDiags = clang::CompilerInstance::createDiagnostics (
889890 new clang::DiagnosticOptions ());
890891 clang::driver::Driver clangDriver (ctx.ClangImporterOpts .clangPath ,
891892 triple.str (), *clangDiags);
893+ llvm::opt::InputArgList clangDriverArgs;
894+ // If an SDK path was explicitly passed to Swift, make sure to pass it to
895+ // Clang driver as well. It affects the resulting include paths.
896+ auto sdkPath = ctx.SearchPathOpts .getSDKPath ();
897+ if (!sdkPath.empty ()) {
898+ unsigned argIndex = clangDriverArgs.MakeIndex (" --sysroot" , sdkPath);
899+ clangDriverArgs.append (new llvm::opt::Arg (
900+ clangDriver.getOpts ().getOption (clang::driver::options::OPT__sysroot),
901+ sdkPath, argIndex));
902+ }
892903 auto cxxStdlibDirs =
893- clangDriver.getLibStdCxxIncludePaths (llvm::opt::InputArgList () , triple);
904+ clangDriver.getLibStdCxxIncludePaths (clangDriverArgs , triple);
894905 if (cxxStdlibDirs.empty ()) {
895906 ctx.Diags .diagnose (SourceLoc (), diag::libstdcxx_not_found, triple.str ());
896907 return {};
You can’t perform that action at this time.
0 commit comments