@@ -2071,8 +2071,24 @@ StringRef InterfaceSubContextDelegateImpl::computeCachedOutputPath(
2071
2071
std::string
2072
2072
InterfaceSubContextDelegateImpl::getCacheHash (StringRef useInterfacePath,
2073
2073
StringRef sdkPath) {
2074
- auto normalizedTargetTriple =
2075
- getTargetSpecificModuleTriple (genericSubInvocation.getLangOptions ().Target );
2074
+ // When doing dependency scanning for explicit module, use strict context hash
2075
+ // to ensure sound module hash.
2076
+ bool useStrictCacheHash =
2077
+ genericSubInvocation.getFrontendOptions ().RequestedAction ==
2078
+ FrontendOptions::ActionType::ScanDependencies;
2079
+
2080
+ // Include the normalized target triple when not using strict hash.
2081
+ // Otherwise, use the full target to ensure soundness of the hash. In
2082
+ // practice, .swiftinterface files will be in target-specific subdirectories
2083
+ // and would have target-specific pieces #if'd out. However, it doesn't hurt
2084
+ // to include it, and it guards against mistakenly reusing cached modules
2085
+ // across targets. Note that this normalization explicitly doesn't include the
2086
+ // minimum deployment target (e.g. the '12.0' in 'ios12.0').
2087
+ auto targetToHash = useStrictCacheHash
2088
+ ? genericSubInvocation.getLangOptions ().Target
2089
+ : getTargetSpecificModuleTriple (
2090
+ genericSubInvocation.getLangOptions ().Target );
2091
+
2076
2092
std::string sdkBuildVersion = getSDKBuildVersion (sdkPath);
2077
2093
const auto ExtraArgs = genericSubInvocation.getClangImporterOptions ()
2078
2094
.getReducedExtraArgsForSwiftModuleDependency ();
@@ -2089,13 +2105,8 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
2089
2105
// anyways.
2090
2106
useInterfacePath,
2091
2107
2092
- // Include the normalized target triple. In practice, .swiftinterface
2093
- // files will be in target-specific subdirectories and would have
2094
- // target-specific pieces #if'd out. However, it doesn't hurt to include
2095
- // it, and it guards against mistakenly reusing cached modules across
2096
- // targets. Note that this normalization explicitly doesn't include the
2097
- // minimum deployment target (e.g. the '12.0' in 'ios12.0').
2098
- normalizedTargetTriple.str (),
2108
+ // The target triple to hash.
2109
+ targetToHash.str (),
2099
2110
2100
2111
// The SDK path is going to affect how this module is imported, so
2101
2112
// include it.
@@ -2121,6 +2132,10 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
2121
2132
// module.
2122
2133
llvm::hash_combine_range (ExtraArgs.begin (), ExtraArgs.end ()),
2123
2134
2135
+ // / Application extension.
2136
+ unsigned (
2137
+ genericSubInvocation.getLangOptions ().EnableAppExtensionRestrictions ),
2138
+
2124
2139
// Whether or not OSSA modules are enabled.
2125
2140
//
2126
2141
// If OSSA modules are enabled, we use a separate namespace of modules to
0 commit comments