Merge pull request #80007 from hjyamauchi/androidoverlay

Propagate sysroot to module loader subinvocation
This commit is contained in:
Hiroshi Yamauchi
2025-03-14 22:12:02 -07:00
committed by GitHub
7 changed files with 29 additions and 9 deletions

View File

@@ -1215,6 +1215,7 @@ class ModuleInterfaceLoaderImpl {
ctx.SourceMgr, diagsToUse,
astDelegate, interfacePath,
ctx.SearchPathOpts.getSDKPath(),
ctx.SearchPathOpts.getSysRoot(),
realName.str(), cacheDir,
prebuiltCacheDir, backupInterfaceDir, StringRef(),
Opts.disableInterfaceLock,
@@ -1250,6 +1251,7 @@ class ModuleInterfaceLoaderImpl {
ImplicitModuleInterfaceBuilder fallbackBuilder(
ctx.SourceMgr, &ctx.Diags, astDelegate, backupPath,
ctx.SearchPathOpts.getSDKPath(),
ctx.SearchPathOpts.getSysRoot(),
moduleName, cacheDir,
prebuiltCacheDir, backupInterfaceDir, StringRef(),
Opts.disableInterfaceLock,
@@ -1475,6 +1477,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
RequireOSSAModules);
ImplicitModuleInterfaceBuilder builder(SourceMgr, &Diags, astDelegate, InPath,
SearchPathOpts.getSDKPath(),
SearchPathOpts.getSysRoot(),
ModuleName, CacheDir, PrebuiltCacheDir,
BackupInterfaceDir, ABIOutputPath,
LoaderOpts.disableInterfaceLock,
@@ -1495,6 +1498,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
assert(!backInPath.empty());
ImplicitModuleInterfaceBuilder backupBuilder(SourceMgr, &Diags, astDelegate, backInPath,
SearchPathOpts.getSDKPath(),
SearchPathOpts.getSysRoot(),
ModuleName, CacheDir, PrebuiltCacheDir,
BackupInterfaceDir, ABIOutputPath,
LoaderOpts.disableInterfaceLock,
@@ -2058,12 +2062,13 @@ std::error_code
InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
StringRef interfacePath,
StringRef sdkPath,
std::optional<StringRef> sysroot,
StringRef outputPath,
SourceLoc diagLoc,
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
StringRef, StringRef)> action) {
return runInSubCompilerInstance(moduleName, interfacePath, sdkPath, outputPath,
diagLoc, /*silenceErrors=*/false,
return runInSubCompilerInstance(moduleName, interfacePath, sdkPath, sysroot,
outputPath, diagLoc, /*silenceErrors=*/false,
[&](SubCompilerInstanceInfo &info){
std::string UserModuleVer = info.Instance->getInvocation().getFrontendOptions()
.UserModuleVersion.getAsString();
@@ -2079,6 +2084,7 @@ std::error_code
InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
StringRef interfacePath,
StringRef sdkPath,
std::optional<StringRef> sysroot,
StringRef outputPath,
SourceLoc diagLoc,
bool silenceErrors,
@@ -2110,6 +2116,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
subInvocation.setModuleName(moduleName);
BuildArgs.push_back("-module-name");
BuildArgs.push_back(moduleName);
if (sysroot) {
subInvocation.setSysRoot(sysroot.value());
}
// FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
// of a CF_OPTIONS bug (rdar://142762174).