@@ -2071,8 +2071,24 @@ StringRef InterfaceSubContextDelegateImpl::computeCachedOutputPath(
20712071std::string
20722072InterfaceSubContextDelegateImpl::getCacheHash (StringRef useInterfacePath,
20732073 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+
20762092 std::string sdkBuildVersion = getSDKBuildVersion (sdkPath);
20772093 const auto ExtraArgs = genericSubInvocation.getClangImporterOptions ()
20782094 .getReducedExtraArgsForSwiftModuleDependency ();
@@ -2089,13 +2105,8 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
20892105 // anyways.
20902106 useInterfacePath,
20912107
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 (),
20992110
21002111 // The SDK path is going to affect how this module is imported, so
21012112 // include it.
@@ -2121,6 +2132,10 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
21212132 // module.
21222133 llvm::hash_combine_range (ExtraArgs.begin (), ExtraArgs.end ()),
21232134
2135+ // / Application extension.
2136+ unsigned (
2137+ genericSubInvocation.getLangOptions ().EnableAppExtensionRestrictions ),
2138+
21242139 // Whether or not OSSA modules are enabled.
21252140 //
21262141 // If OSSA modules are enabled, we use a separate namespace of modules to
0 commit comments