mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ModuleInterfaces] Combine the normalized target triple into the cache hash
Previously, we'd combine just the target architecture, and rely on the fact that the .swiftinterface is in a reasonably-target-specific subdirectory to include enough entropy to avoid hash collisions. But in the presence of a VFS or if two targets are sharing the same .swiftinterface file (which can sometimes happen in tests), they will collide since the hash only includes architecture. Instead, use the same normalization that the serialized module loader uses, and serialize the normalized target triple instead. Fixes rdar://55881335
This commit is contained in:
@@ -391,12 +391,15 @@ class ModuleInterfaceLoaderImpl {
|
||||
// anyways.
|
||||
H = hash_combine(H, interfacePath);
|
||||
|
||||
// Include the target CPU architecture. In practice, .swiftinterface files
|
||||
// will be in architecture-specific subdirectories and would have
|
||||
// architecture-specific pieces #if'd out. However, it doesn't hurt to
|
||||
// Include the normalized target triple. In practice, .swiftinterface files
|
||||
// will be in target-specific subdirectories and would have
|
||||
// target-specific pieces #if'd out. However, it doesn't hurt to
|
||||
// include it, and it guards against mistakenly reusing cached modules
|
||||
// across architectures.
|
||||
H = hash_combine(H, SubInvocation.getLangOptions().Target.getArchName());
|
||||
// across targets. Note that this normalization explicitly doesn't
|
||||
// include the minimum deployment target (e.g. the '12.0' in 'ios12.0').
|
||||
auto normalizedTargetTriple =
|
||||
getTargetSpecificModuleTriple(SubInvocation.getLangOptions().Target);
|
||||
H = hash_combine(H, normalizedTargetTriple.str());
|
||||
|
||||
// The SDK path is going to affect how this module is imported, so include
|
||||
// it.
|
||||
|
||||
Reference in New Issue
Block a user