Skip to content

Commit 7edd23a

Browse files
committed
Serialization: allow different channels to share a module cache location
1 parent 1e4fe67 commit 7edd23a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,10 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
19441944
// that affects references serialized in the cached file.
19451945
sdkBuildVersion,
19461946

1947+
// Applying the distribution channel of the current compiler enables
1948+
// different compilers to share a module cache location.
1949+
version::getCurrentCompilerChannel(),
1950+
19471951
// Whether or not we're tracking system dependencies affects the
19481952
// invalidation behavior of this cache item.
19491953
genericSubInvocation.getFrontendOptions().shouldTrackSystemDependencies(),

test/Serialization/restrict-swiftmodule-to-channel.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ foo()
4949
// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \
5050
// RUN: -verify -verify-additional-prefix rebuild- -Rmodule-interface-rebuild
5151

52+
/// Importing for a different channel should rebuild without cache collision.
53+
// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=other-channel \
54+
// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \
55+
// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \
56+
// RUN: -verify -verify-additional-prefix rebuild- -Rmodule-interface-rebuild
57+
// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \
58+
// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \
59+
// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \
60+
// RUN: -verify -Rmodule-interface-rebuild
61+
5262
// RUN: rm %t/build/ResilientLib.swiftinterface
5363
// RUN: %empty-directory(%t/cache)
5464

0 commit comments

Comments
 (0)