@@ -1064,6 +1064,7 @@ class ModuleInterfaceLoaderImpl {
10641064 llvm::SmallString<256 > cachedOutputPath;
10651065 StringRef CacheHash;
10661066 astDelegate.computeCachedOutputPath (moduleName, interfacePath,
1067+ ctx.SearchPathOpts .getSDKPath (),
10671068 cachedOutputPath, CacheHash);
10681069
10691070 // Try to find the right module for this interface, either alongside it,
@@ -1144,7 +1145,9 @@ class ModuleInterfaceLoaderImpl {
11441145 Identifier realName = ctx.getRealModuleName (ctx.getIdentifier (moduleName));
11451146 ImplicitModuleInterfaceBuilder builder (
11461147 ctx.SourceMgr , diagsToUse,
1147- astDelegate, interfacePath, realName.str (), cacheDir,
1148+ astDelegate, interfacePath,
1149+ ctx.SearchPathOpts .getSDKPath (),
1150+ realName.str (), cacheDir,
11481151 prebuiltCacheDir, backupInterfaceDir, StringRef (),
11491152 Opts.disableInterfaceLock ,
11501153 ctx.IgnoreAdjacentModules , diagnosticLoc,
@@ -1177,7 +1180,9 @@ class ModuleInterfaceLoaderImpl {
11771180 // Set up a builder if we need to build the module. It'll also set up
11781181 // the genericSubInvocation we'll need to use to compute the cache paths.
11791182 ImplicitModuleInterfaceBuilder fallbackBuilder (
1180- ctx.SourceMgr , &ctx.Diags , astDelegate, backupPath, moduleName, cacheDir,
1183+ ctx.SourceMgr , &ctx.Diags , astDelegate, backupPath,
1184+ ctx.SearchPathOpts .getSDKPath (),
1185+ moduleName, cacheDir,
11811186 prebuiltCacheDir, backupInterfaceDir, StringRef (),
11821187 Opts.disableInterfaceLock ,
11831188 ctx.IgnoreAdjacentModules , diagnosticLoc,
@@ -1390,6 +1395,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
13901395 SerializeDependencyHashes, TrackSystemDependencies,
13911396 RequireOSSAModules, RequireNCGenerics);
13921397 ImplicitModuleInterfaceBuilder builder (SourceMgr, &Diags, astDelegate, InPath,
1398+ SearchPathOpts.getSDKPath (),
13931399 ModuleName, CacheDir, PrebuiltCacheDir,
13941400 BackupInterfaceDir, ABIOutputPath,
13951401 LoaderOpts.disableInterfaceLock ,
@@ -1409,6 +1415,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
14091415 assert (failed);
14101416 assert (!backInPath.empty ());
14111417 ImplicitModuleInterfaceBuilder backupBuilder (SourceMgr, &Diags, astDelegate, backInPath,
1418+ SearchPathOpts.getSDKPath (),
14121419 ModuleName, CacheDir, PrebuiltCacheDir,
14131420 BackupInterfaceDir, ABIOutputPath,
14141421 LoaderOpts.disableInterfaceLock ,
@@ -1865,13 +1872,14 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
18651872StringRef InterfaceSubContextDelegateImpl::computeCachedOutputPath (
18661873 StringRef moduleName,
18671874 StringRef useInterfacePath,
1875+ StringRef sdkPath,
18681876 llvm::SmallString<256 > &OutPath,
18691877 StringRef &CacheHash) {
18701878 OutPath = genericSubInvocation.getClangModuleCachePath ();
18711879 llvm::sys::path::append (OutPath, moduleName);
18721880 OutPath.append (" -" );
18731881 auto hashStart = OutPath.size ();
1874- OutPath.append (getCacheHash (useInterfacePath));
1882+ OutPath.append (getCacheHash (useInterfacePath, sdkPath ));
18751883 CacheHash = OutPath.str ().substr (hashStart);
18761884 OutPath.append (" ." );
18771885 auto OutExt = file_types::getExtension (file_types::TY_SwiftModuleFile);
@@ -1890,9 +1898,11 @@ StringRef InterfaceSubContextDelegateImpl::computeCachedOutputPath(
18901898// / with dead entries -- when other factors change, such as the contents of
18911899// / the .swiftinterface input or its dependencies.
18921900std::string
1893- InterfaceSubContextDelegateImpl::getCacheHash (StringRef useInterfacePath) {
1901+ InterfaceSubContextDelegateImpl::getCacheHash (StringRef useInterfacePath,
1902+ StringRef sdkPath) {
18941903 auto normalizedTargetTriple =
18951904 getTargetSpecificModuleTriple (genericSubInvocation.getLangOptions ().Target );
1905+ std::string sdkBuildVersion = getSDKBuildVersion (sdkPath);
18961906
18971907 llvm::hash_code H = hash_combine (
18981908 // Start with the compiler version (which will be either tag names or
@@ -1918,6 +1928,10 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath) {
19181928 // include it.
19191929 genericSubInvocation.getSDKPath (),
19201930
1931+ // The SDK build version may identify differences in headers
1932+ // that affects references serialized in the cached file.
1933+ sdkBuildVersion,
1934+
19211935 // Whether or not we're tracking system dependencies affects the
19221936 // invalidation behavior of this cache item.
19231937 genericSubInvocation.getFrontendOptions ().shouldTrackSystemDependencies (),
@@ -1934,11 +1948,12 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath) {
19341948std::error_code
19351949InterfaceSubContextDelegateImpl::runInSubContext (StringRef moduleName,
19361950 StringRef interfacePath,
1951+ StringRef sdkPath,
19371952 StringRef outputPath,
19381953 SourceLoc diagLoc,
19391954 llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
19401955 ArrayRef<StringRef>, StringRef)> action) {
1941- return runInSubCompilerInstance (moduleName, interfacePath, outputPath,
1956+ return runInSubCompilerInstance (moduleName, interfacePath, sdkPath, outputPath,
19421957 diagLoc, /* silenceErrors=*/ false ,
19431958 [&](SubCompilerInstanceInfo &info){
19441959 return action (info.Instance ->getASTContext (),
@@ -1952,6 +1967,7 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
19521967std::error_code
19531968InterfaceSubContextDelegateImpl::runInSubCompilerInstance (StringRef moduleName,
19541969 StringRef interfacePath,
1970+ StringRef sdkPath,
19551971 StringRef outputPath,
19561972 SourceLoc diagLoc,
19571973 bool silenceErrors,
@@ -1981,8 +1997,8 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
19811997 // Calculate output path of the module.
19821998 llvm::SmallString<256 > buffer;
19831999 StringRef CacheHash;
1984- auto hashedOutput = computeCachedOutputPath (moduleName, interfacePath, buffer,
1985- CacheHash);
2000+ auto hashedOutput = computeCachedOutputPath (moduleName, interfacePath,
2001+ sdkPath, buffer, CacheHash);
19862002 // If no specific output path is given, use the hashed output path.
19872003 if (outputPath.empty ()) {
19882004 outputPath = hashedOutput;
0 commit comments