@@ -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 ,
@@ -2049,12 +2053,13 @@ std::error_code
20492053InterfaceSubContextDelegateImpl::runInSubContext (StringRef moduleName,
20502054 StringRef interfacePath,
20512055 StringRef sdkPath,
2056+ std::optional<StringRef> sysroot,
20522057 StringRef outputPath,
20532058 SourceLoc diagLoc,
20542059 llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
20552060 StringRef, StringRef)> action) {
2056- return runInSubCompilerInstance (moduleName, interfacePath, sdkPath, outputPath ,
2057- diagLoc, /* silenceErrors=*/ false ,
2061+ return runInSubCompilerInstance (moduleName, interfacePath, sdkPath, sysroot ,
2062+ outputPath, diagLoc, /* silenceErrors=*/ false ,
20582063 [&](SubCompilerInstanceInfo &info){
20592064 std::string UserModuleVer = info.Instance ->getInvocation ().getFrontendOptions ()
20602065 .UserModuleVersion .getAsString ();
@@ -2070,6 +2075,7 @@ std::error_code
20702075InterfaceSubContextDelegateImpl::runInSubCompilerInstance (StringRef moduleName,
20712076 StringRef interfacePath,
20722077 StringRef sdkPath,
2078+ std::optional<StringRef> sysroot,
20732079 StringRef outputPath,
20742080 SourceLoc diagLoc,
20752081 bool silenceErrors,
@@ -2101,6 +2107,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
21012107 subInvocation.setModuleName (moduleName);
21022108 BuildArgs.push_back (" -module-name" );
21032109 BuildArgs.push_back (moduleName);
2110+ if (sysroot) {
2111+ subInvocation.setSysRoot (sysroot.value ());
2112+ }
21042113
21052114 // FIXME: Hack for Darwin.swiftmodule, which cannot be rebuilt with C++
21062115 // interop enabled by the Swift CI because it uses an old host SDK.
0 commit comments