@@ -1064,6 +1064,7 @@ class ModuleInterfaceLoaderImpl {
1064
1064
llvm::SmallString<256 > cachedOutputPath;
1065
1065
StringRef CacheHash;
1066
1066
astDelegate.computeCachedOutputPath (moduleName, interfacePath,
1067
+ ctx.SearchPathOpts .getSDKPath (),
1067
1068
cachedOutputPath, CacheHash);
1068
1069
1069
1070
// Try to find the right module for this interface, either alongside it,
@@ -1144,7 +1145,9 @@ class ModuleInterfaceLoaderImpl {
1144
1145
Identifier realName = ctx.getRealModuleName (ctx.getIdentifier (moduleName));
1145
1146
ImplicitModuleInterfaceBuilder builder (
1146
1147
ctx.SourceMgr , diagsToUse,
1147
- astDelegate, interfacePath, realName.str (), cacheDir,
1148
+ astDelegate, interfacePath,
1149
+ ctx.SearchPathOpts .getSDKPath (),
1150
+ realName.str (), cacheDir,
1148
1151
prebuiltCacheDir, backupInterfaceDir, StringRef (),
1149
1152
Opts.disableInterfaceLock ,
1150
1153
ctx.IgnoreAdjacentModules , diagnosticLoc,
@@ -1177,7 +1180,9 @@ class ModuleInterfaceLoaderImpl {
1177
1180
// Set up a builder if we need to build the module. It'll also set up
1178
1181
// the genericSubInvocation we'll need to use to compute the cache paths.
1179
1182
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,
1181
1186
prebuiltCacheDir, backupInterfaceDir, StringRef (),
1182
1187
Opts.disableInterfaceLock ,
1183
1188
ctx.IgnoreAdjacentModules , diagnosticLoc,
@@ -1390,6 +1395,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
1390
1395
SerializeDependencyHashes, TrackSystemDependencies,
1391
1396
RequireOSSAModules, RequireNCGenerics);
1392
1397
ImplicitModuleInterfaceBuilder builder (SourceMgr, &Diags, astDelegate, InPath,
1398
+ SearchPathOpts.getSDKPath (),
1393
1399
ModuleName, CacheDir, PrebuiltCacheDir,
1394
1400
BackupInterfaceDir, ABIOutputPath,
1395
1401
LoaderOpts.disableInterfaceLock ,
@@ -1409,6 +1415,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
1409
1415
assert (failed);
1410
1416
assert (!backInPath.empty ());
1411
1417
ImplicitModuleInterfaceBuilder backupBuilder (SourceMgr, &Diags, astDelegate, backInPath,
1418
+ SearchPathOpts.getSDKPath (),
1412
1419
ModuleName, CacheDir, PrebuiltCacheDir,
1413
1420
BackupInterfaceDir, ABIOutputPath,
1414
1421
LoaderOpts.disableInterfaceLock ,
@@ -1865,13 +1872,14 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
1865
1872
StringRef InterfaceSubContextDelegateImpl::computeCachedOutputPath (
1866
1873
StringRef moduleName,
1867
1874
StringRef useInterfacePath,
1875
+ StringRef sdkPath,
1868
1876
llvm::SmallString<256 > &OutPath,
1869
1877
StringRef &CacheHash) {
1870
1878
OutPath = genericSubInvocation.getClangModuleCachePath ();
1871
1879
llvm::sys::path::append (OutPath, moduleName);
1872
1880
OutPath.append (" -" );
1873
1881
auto hashStart = OutPath.size ();
1874
- OutPath.append (getCacheHash (useInterfacePath));
1882
+ OutPath.append (getCacheHash (useInterfacePath, sdkPath ));
1875
1883
CacheHash = OutPath.str ().substr (hashStart);
1876
1884
OutPath.append (" ." );
1877
1885
auto OutExt = file_types::getExtension (file_types::TY_SwiftModuleFile);
@@ -1890,9 +1898,11 @@ StringRef InterfaceSubContextDelegateImpl::computeCachedOutputPath(
1890
1898
// / with dead entries -- when other factors change, such as the contents of
1891
1899
// / the .swiftinterface input or its dependencies.
1892
1900
std::string
1893
- InterfaceSubContextDelegateImpl::getCacheHash (StringRef useInterfacePath) {
1901
+ InterfaceSubContextDelegateImpl::getCacheHash (StringRef useInterfacePath,
1902
+ StringRef sdkPath) {
1894
1903
auto normalizedTargetTriple =
1895
1904
getTargetSpecificModuleTriple (genericSubInvocation.getLangOptions ().Target );
1905
+ std::string sdkBuildVersion = getSDKBuildVersion (sdkPath);
1896
1906
1897
1907
llvm::hash_code H = hash_combine (
1898
1908
// Start with the compiler version (which will be either tag names or
@@ -1918,6 +1928,10 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath) {
1918
1928
// include it.
1919
1929
genericSubInvocation.getSDKPath (),
1920
1930
1931
+ // The SDK build version may identify differences in headers
1932
+ // that affects references serialized in the cached file.
1933
+ sdkBuildVersion,
1934
+
1921
1935
// Whether or not we're tracking system dependencies affects the
1922
1936
// invalidation behavior of this cache item.
1923
1937
genericSubInvocation.getFrontendOptions ().shouldTrackSystemDependencies (),
@@ -1934,11 +1948,12 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath) {
1934
1948
std::error_code
1935
1949
InterfaceSubContextDelegateImpl::runInSubContext (StringRef moduleName,
1936
1950
StringRef interfacePath,
1951
+ StringRef sdkPath,
1937
1952
StringRef outputPath,
1938
1953
SourceLoc diagLoc,
1939
1954
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
1940
1955
ArrayRef<StringRef>, StringRef)> action) {
1941
- return runInSubCompilerInstance (moduleName, interfacePath, outputPath,
1956
+ return runInSubCompilerInstance (moduleName, interfacePath, sdkPath, outputPath,
1942
1957
diagLoc, /* silenceErrors=*/ false ,
1943
1958
[&](SubCompilerInstanceInfo &info){
1944
1959
return action (info.Instance ->getASTContext (),
@@ -1952,6 +1967,7 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
1952
1967
std::error_code
1953
1968
InterfaceSubContextDelegateImpl::runInSubCompilerInstance (StringRef moduleName,
1954
1969
StringRef interfacePath,
1970
+ StringRef sdkPath,
1955
1971
StringRef outputPath,
1956
1972
SourceLoc diagLoc,
1957
1973
bool silenceErrors,
@@ -1981,8 +1997,8 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
1981
1997
// Calculate output path of the module.
1982
1998
llvm::SmallString<256 > buffer;
1983
1999
StringRef CacheHash;
1984
- auto hashedOutput = computeCachedOutputPath (moduleName, interfacePath, buffer,
1985
- CacheHash);
2000
+ auto hashedOutput = computeCachedOutputPath (moduleName, interfacePath,
2001
+ sdkPath, buffer, CacheHash);
1986
2002
// If no specific output path is given, use the hashed output path.
1987
2003
if (outputPath.empty ()) {
1988
2004
outputPath = hashedOutput;
0 commit comments