@@ -1215,6 +1215,7 @@ class ModuleInterfaceLoaderImpl {
12151215 ctx.SourceMgr , diagsToUse,
12161216 astDelegate, interfacePath,
12171217 ctx.SearchPathOpts .getSDKPath (),
1218+ ctx.SearchPathOpts .getSysRoot (),
12181219 realName.str (), cacheDir,
12191220 prebuiltCacheDir, backupInterfaceDir, StringRef (),
12201221 Opts.disableInterfaceLock ,
@@ -1250,6 +1251,7 @@ class ModuleInterfaceLoaderImpl {
12501251 ImplicitModuleInterfaceBuilder fallbackBuilder (
12511252 ctx.SourceMgr , &ctx.Diags , astDelegate, backupPath,
12521253 ctx.SearchPathOpts .getSDKPath (),
1254+ ctx.SearchPathOpts .getSysRoot (),
12531255 moduleName, cacheDir,
12541256 prebuiltCacheDir, backupInterfaceDir, StringRef (),
12551257 Opts.disableInterfaceLock ,
@@ -1475,6 +1477,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
14751477 RequireOSSAModules);
14761478 ImplicitModuleInterfaceBuilder builder (SourceMgr, &Diags, astDelegate, InPath,
14771479 SearchPathOpts.getSDKPath (),
1480+ SearchPathOpts.getSysRoot (),
14781481 ModuleName, CacheDir, PrebuiltCacheDir,
14791482 BackupInterfaceDir, ABIOutputPath,
14801483 LoaderOpts.disableInterfaceLock ,
@@ -1495,6 +1498,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
14951498 assert (!backInPath.empty ());
14961499 ImplicitModuleInterfaceBuilder backupBuilder (SourceMgr, &Diags, astDelegate, backInPath,
14971500 SearchPathOpts.getSDKPath (),
1501+ SearchPathOpts.getSysRoot (),
14981502 ModuleName, CacheDir, PrebuiltCacheDir,
14991503 BackupInterfaceDir, ABIOutputPath,
15001504 LoaderOpts.disableInterfaceLock ,
@@ -2058,12 +2062,13 @@ std::error_code
20582062InterfaceSubContextDelegateImpl::runInSubContext (StringRef moduleName,
20592063 StringRef interfacePath,
20602064 StringRef sdkPath,
2065+ std::optional<StringRef> sysroot,
20612066 StringRef outputPath,
20622067 SourceLoc diagLoc,
20632068 llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
20642069 StringRef, StringRef)> action) {
2065- return runInSubCompilerInstance (moduleName, interfacePath, sdkPath, outputPath ,
2066- diagLoc, /* silenceErrors=*/ false ,
2070+ return runInSubCompilerInstance (moduleName, interfacePath, sdkPath, sysroot ,
2071+ outputPath, diagLoc, /* silenceErrors=*/ false ,
20672072 [&](SubCompilerInstanceInfo &info){
20682073 std::string UserModuleVer = info.Instance ->getInvocation ().getFrontendOptions ()
20692074 .UserModuleVersion .getAsString ();
@@ -2079,6 +2084,7 @@ std::error_code
20792084InterfaceSubContextDelegateImpl::runInSubCompilerInstance (StringRef moduleName,
20802085 StringRef interfacePath,
20812086 StringRef sdkPath,
2087+ std::optional<StringRef> sysroot,
20822088 StringRef outputPath,
20832089 SourceLoc diagLoc,
20842090 bool silenceErrors,
@@ -2110,6 +2116,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
21102116 subInvocation.setModuleName (moduleName);
21112117 BuildArgs.push_back (" -module-name" );
21122118 BuildArgs.push_back (moduleName);
2119+ if (sysroot) {
2120+ subInvocation.setSysRoot (sysroot.value ());
2121+ }
21132122
21142123 // FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
21152124 // of a CF_OPTIONS bug (rdar://142762174).
0 commit comments