Skip to content

Commit d204e54

Browse files
[Caching] Support -resolved-plugin-validation
Add support for `-resolved-plugin-validation`: * Unconditionally add the flag if supported for explicit module scan * Append `-cache-replay-prefix-map` to interface compilation jobs
1 parent e9ca0c6 commit d204e54

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
5353
private let mainModuleName: String?
5454
private let cas: SwiftScanCAS?
5555
private let swiftScanOracle: InterModuleDependencyOracle
56+
private let prefixMap: [(AbsolutePath, AbsolutePath)]
5657

5758
/// Clang PCM names contain a hash of the command-line arguments that were used to build them.
5859
/// We avoid re-running the hash computation with the use of this cache
@@ -73,7 +74,8 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
7374
dependencyOracle: InterModuleDependencyOracle,
7475
integratedDriver: Bool = true,
7576
supportsExplicitInterfaceBuild: Bool = false,
76-
cas: SwiftScanCAS? = nil) throws {
77+
cas: SwiftScanCAS? = nil,
78+
prefixMap: [(AbsolutePath, AbsolutePath)] = []) throws {
7779
self.dependencyGraph = dependencyGraph
7880
self.toolchain = toolchain
7981
self.swiftScanOracle = dependencyOracle
@@ -82,6 +84,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
8284
self.reachabilityMap = try dependencyGraph.computeTransitiveClosure()
8385
self.supportsExplicitInterfaceBuild = supportsExplicitInterfaceBuild
8486
self.cas = cas
87+
self.prefixMap = prefixMap
8588
}
8689

8790
/// Supports resolving bridging header pch command from swiftScan.
@@ -185,6 +188,12 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
185188
}
186189
}
187190

191+
// Add prefix mapping. The option is cache invariant so it can be added without affecting cache key.
192+
for (key, value) in prefixMap {
193+
commandLine.appendFlag("-cache-replay-prefix-map")
194+
commandLine.appendFlag(value.pathString + "=" + key.pathString)
195+
}
196+
188197
jobs.append(Job(
189198
moduleName: moduleId.moduleName,
190199
kind: .compileModuleFromInterface,
@@ -238,6 +247,12 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
238247
cacheKeys = [:]
239248
}
240249

250+
// Add prefix mapping. The option is cache invariant so it can be added without affecting cache key.
251+
for (key, value) in prefixMap {
252+
commandLine.appendFlag("-cache-replay-prefix-map")
253+
commandLine.appendFlag(value.pathString + "=" + key.pathString)
254+
}
255+
241256
jobs.append(Job(
242257
moduleName: moduleId.moduleName,
243258
kind: .generatePCM,

Sources/SwiftDriver/ExplicitModuleBuilds/ModuleDependencyScanning.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public extension Driver {
195195
}
196196
}
197197

198+
if isFrontendArgSupported(.resolvedPluginVerification) {
199+
commandLine.appendFlag(.resolvedPluginVerification)
200+
}
201+
198202
// Pass on the input files
199203
commandLine.append(contentsOf: inputFiles.filter { $0.type == .swift }.map { .path($0.file) })
200204
return (inputs, commandLine)

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@ extension Driver {
688688
integratedDriver: integratedDriver,
689689
supportsExplicitInterfaceBuild:
690690
isFrontendArgSupported(.explicitInterfaceModuleBuild),
691-
cas: cas)
691+
cas: cas,
692+
prefixMap: prefixMapping)
692693

693694
return try explicitDependencyBuildPlanner!.generateExplicitModuleDependenciesBuildJobs()
694695
}

0 commit comments

Comments
 (0)