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) {
885
885
if (triple.isAndroid ())
886
886
return {};
887
887
888
+ // Extract the libstdc++ installation path from Clang driver.
888
889
auto clangDiags = clang::CompilerInstance::createDiagnostics (
889
890
new clang::DiagnosticOptions ());
890
891
clang::driver::Driver clangDriver (ctx.ClangImporterOpts .clangPath ,
891
892
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
+ }
892
903
auto cxxStdlibDirs =
893
- clangDriver.getLibStdCxxIncludePaths (llvm::opt::InputArgList () , triple);
904
+ clangDriver.getLibStdCxxIncludePaths (clangDriverArgs , triple);
894
905
if (cxxStdlibDirs.empty ()) {
895
906
ctx.Diags .diagnose (SourceLoc (), diag::libstdcxx_not_found, triple.str ());
896
907
return {};
You can’t perform that action at this time.
0 commit comments