Skip to content

Commit 072409a

Browse files
committed
[Dependency Scanning] Remove references to per-triple PCM variant compilation
1 parent f4b3d89 commit 072409a

File tree

8 files changed

+13
-297
lines changed

8 files changed

+13
-297
lines changed

Sources/CSwiftScan/include/swiftscan_header.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ typedef struct {
135135
(*swiftscan_swift_textual_detail_get_command_line)(swiftscan_module_details_t);
136136
swiftscan_string_set_t *
137137
(*swiftscan_swift_textual_detail_get_bridging_pch_command_line)(swiftscan_module_details_t);
138-
swiftscan_string_set_t *
139-
(*swiftscan_swift_textual_detail_get_extra_pcm_args)(swiftscan_module_details_t);
140138
swiftscan_string_ref_t
141139
(*swiftscan_swift_textual_detail_get_context_hash)(swiftscan_module_details_t);
142140
bool
@@ -181,8 +179,6 @@ typedef struct {
181179
(*swiftscan_clang_detail_get_context_hash)(swiftscan_module_details_t);
182180
swiftscan_string_set_t *
183181
(*swiftscan_clang_detail_get_command_line)(swiftscan_module_details_t);
184-
swiftscan_string_set_t *
185-
(*swiftscan_clang_detail_get_captured_pcm_args)(swiftscan_module_details_t);
186182
swiftscan_string_ref_t
187183
(*swiftscan_clang_detail_get_module_cache_key)(swiftscan_module_details_t);
188184

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public struct Driver {
7070
case optionRequiresAnother(String, String)
7171
// Explicit Module Build Failures
7272
case malformedModuleDependency(String, String)
73-
case missingPCMArguments(String)
7473
case missingModuleDependency(String)
7574
case missingContextHashOnSwiftDependency(String)
7675
case dependencyScanningFailure(Int, String)
@@ -124,8 +123,6 @@ public struct Driver {
124123
// Explicit Module Build Failures
125124
case .malformedModuleDependency(let moduleName, let errorDescription):
126125
return "Malformed Module Dependency: \(moduleName), \(errorDescription)"
127-
case .missingPCMArguments(let moduleName):
128-
return "Missing extraPcmArgs to build Clang module: \(moduleName)"
129126
case .missingModuleDependency(let moduleName):
130127
return "Missing Module Dependency Info: \(moduleName)"
131128
case .missingContextHashOnSwiftDependency(let moduleName):

Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
193193
return jobs
194194
}
195195

196-
/// Generate a build job for each Clang module in the set of supplied `dependencies`. Once per each required
197-
/// PCMArgSet as queried from the supplied `clangPCMSetMap`
196+
/// Generate a build job for each Clang module in the set of supplied `dependencies`.
198197
private mutating func generateClangDependenciesBuildJobs(for dependencies: Set<ModuleDependencyId>)
199198
throws -> [Job] {
200199
var jobs: [Job] = []
@@ -391,25 +390,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
391390
}
392391
}
393392

394-
private func updateClangPCMArgSetMap(for moduleId: ModuleDependencyId,
395-
clangPCMSetMap: inout [ModuleDependencyId : Set<[String]>])
396-
throws {
397-
guard let moduleDependencies = reachabilityMap[moduleId] else {
398-
fatalError("Expected reachability information for the module: \(moduleId.moduleName).")
399-
}
400-
let pcmArgs = try dependencyGraph.swiftModulePCMArgs(of: moduleId)
401-
for dependencyId in moduleDependencies {
402-
guard case .clang(_) = dependencyId else {
403-
continue
404-
}
405-
if clangPCMSetMap[dependencyId] != nil {
406-
clangPCMSetMap[dependencyId]!.insert(pcmArgs)
407-
} else {
408-
clangPCMSetMap[dependencyId] = [pcmArgs]
409-
}
410-
}
411-
}
412-
413393
public func getLinkLibraryLoadCommandFlags(_ commandLine: inout [Job.ArgTemplate]) throws {
414394
var allLinkLibraries: [LinkLibraryInfo] = []
415395
for (_, moduleInfo) in dependencyGraph.modules {
@@ -550,26 +530,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
550530
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
551531
return try encoder.encode(allDependencyArtifacts)
552532
}
553-
554-
private func getPCMHashParts(pcmArgs: [String], contextHash: String) -> [String] {
555-
var results: [String] = []
556-
results.append(contextHash)
557-
results.append(contentsOf: pcmArgs)
558-
if integratedDriver {
559-
return results
560-
}
561-
562-
// We need this to enable explicit modules in the driver-as-executable mode. For instance,
563-
// we have two Swift targets A and B, where A depends on X.pcm which in turn depends on Y.pcm,
564-
// and B only depends on Y.pcm. In the driver-as-executable mode, the build system isn't aware
565-
// of the shared dependency of Y.pcm so it will be generated multiple times. If all these Y.pcm
566-
// share the same name, X.pcm may fail to be loaded because its dependency Y.pcm may have a
567-
// changed mod time.
568-
// We only differentiate these PCM names in the non-integrated mode due to the lacking of
569-
// inter-module planning.
570-
results.append(mainModuleName!)
571-
return results
572-
}
573533
}
574534

575535
/// Encapsulates some of the common queries of the ExplicitDependencyBuildPlanner with error-checking
@@ -605,11 +565,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
605565
}
606566
return clangModuleDetails
607567
}
608-
609-
func swiftModulePCMArgs(of moduleId: ModuleDependencyId) throws -> [String] {
610-
let moduleDetails = try swiftModuleDetails(of: moduleId)
611-
return moduleDetails.extraPcmArgs
612-
}
613568
}
614569

615570
internal extension ExplicitDependencyBuildPlanner {

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/CommonDependencyOperations.swift

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -117,67 +117,6 @@ extension InterModuleDependencyGraph {
117117
}
118118

119119
@_spi(Testing) public extension InterModuleDependencyGraph {
120-
/// Merge a module with a given ID and Info into a ModuleInfoMap
121-
static func mergeModule(_ moduleId: ModuleDependencyId,
122-
_ moduleInfo: ModuleInfo,
123-
into moduleInfoMap: inout ModuleInfoMap) throws {
124-
switch moduleId {
125-
case .swift:
126-
let prebuiltExternalModuleEquivalentId =
127-
ModuleDependencyId.swiftPrebuiltExternal(moduleId.moduleName)
128-
let placeholderEquivalentId =
129-
ModuleDependencyId.swiftPlaceholder(moduleId.moduleName)
130-
if moduleInfoMap[prebuiltExternalModuleEquivalentId] != nil ||
131-
moduleInfoMap[moduleId] != nil {
132-
// If the set of discovered externalModules contains a .swiftPrebuiltExternal or .swift module
133-
// with the same name, do not replace it.
134-
break
135-
} else if moduleInfoMap[placeholderEquivalentId] != nil {
136-
// Replace the placeholder module with a full .swift ModuleInfo
137-
// and fixup other externalModules' dependencies
138-
replaceModule(originalId: placeholderEquivalentId, replacementId: moduleId,
139-
replacementInfo: moduleInfo, in: &moduleInfoMap)
140-
} else {
141-
// Insert the new module
142-
moduleInfoMap[moduleId] = moduleInfo
143-
}
144-
145-
case .swiftPrebuiltExternal:
146-
// If the set of discovered externalModules contains a .swift module with the same name,
147-
// replace it with the prebuilt version and fixup other externalModules' dependencies
148-
let swiftModuleEquivalentId = ModuleDependencyId.swift(moduleId.moduleName)
149-
let swiftPlaceholderEquivalentId = ModuleDependencyId.swiftPlaceholder(moduleId.moduleName)
150-
if moduleInfoMap[swiftModuleEquivalentId] != nil {
151-
// If the ModuleInfoMap contains an equivalent .swift module, replace it with the prebuilt
152-
// version and update all other externalModules' dependencies
153-
replaceModule(originalId: swiftModuleEquivalentId, replacementId: moduleId,
154-
replacementInfo: moduleInfo, in: &moduleInfoMap)
155-
} else if moduleInfoMap[swiftPlaceholderEquivalentId] != nil {
156-
// If the moduleInfoMap contains an equivalent .swiftPlaceholder module, replace it with
157-
// the prebuilt version and update all other externalModules' dependencies
158-
replaceModule(originalId: swiftPlaceholderEquivalentId, replacementId: moduleId,
159-
replacementInfo: moduleInfo, in: &moduleInfoMap)
160-
} else {
161-
// Insert the new module
162-
moduleInfoMap[moduleId] = moduleInfo
163-
}
164-
165-
case .clang:
166-
guard let existingModuleInfo = moduleInfoMap[moduleId] else {
167-
moduleInfoMap[moduleId] = moduleInfo
168-
break
169-
}
170-
// If this module *has* been seen before, merge the module infos to capture
171-
// the super-set of so-far discovered dependencies of this module at various
172-
// PCMArg scanning actions.
173-
let combinedDependenciesInfo = mergeClangModuleInfoDependencies(moduleInfo,
174-
existingModuleInfo)
175-
replaceModule(originalId: moduleId, replacementId: moduleId,
176-
replacementInfo: combinedDependenciesInfo, in: &moduleInfoMap)
177-
case .swiftPlaceholder:
178-
fatalError("Unresolved placeholder dependency at graph merge operation: \(moduleId)")
179-
}
180-
}
181120

182121
/// Replace an existing module in the moduleInfoMap
183122
static func replaceModule(originalId: ModuleDependencyId, replacementId: ModuleDependencyId,
@@ -207,53 +146,6 @@ extension InterModuleDependencyGraph {
207146
}
208147
}
209148
}
210-
211-
/// Given two moduleInfos of clang externalModules, merge them by combining their directDependencies and
212-
/// dependenciesCapturedPCMArgs and sourceFiles fields. These fields may differ across the same module
213-
/// scanned at different PCMArgs (e.g. -target option).
214-
static func mergeClangModuleInfoDependencies(_ firstInfo: ModuleInfo, _ secondInfo:ModuleInfo
215-
) -> ModuleInfo {
216-
guard case .clang(let firstDetails) = firstInfo.details,
217-
case .clang(let secondDetails) = secondInfo.details
218-
else {
219-
fatalError("mergeClangModules expected two valid ClangModuleDetails objects.")
220-
}
221-
222-
// As far as their dependencies go, these module infos are identical
223-
if firstInfo.directDependencies == secondInfo.directDependencies,
224-
firstDetails.capturedPCMArgs == secondDetails.capturedPCMArgs,
225-
firstInfo.sourceFiles == secondInfo.sourceFiles {
226-
return firstInfo
227-
}
228-
229-
// Create a new moduleInfo that represents this module with combined dependency information
230-
let firstModuleSources = firstInfo.sourceFiles ?? []
231-
let secondModuleSources = secondInfo.sourceFiles ?? []
232-
let combinedSourceFiles = Array(Set(firstModuleSources + secondModuleSources))
233-
234-
let firstModuleDependencies = firstInfo.directDependencies ?? []
235-
let secondModuleDependencies = secondInfo.directDependencies ?? []
236-
let combinedDependencies = Array(Set(firstModuleDependencies + secondModuleDependencies))
237-
let firstLinkLibraries = firstInfo.linkLibraries ?? []
238-
let secondLinkLibraries = secondInfo.linkLibraries ?? []
239-
let combinedLinkLibraries = Array(Set(firstLinkLibraries + secondLinkLibraries))
240-
241-
let firstModuleCapturedPCMArgs = firstDetails.capturedPCMArgs ?? Set<[String]>()
242-
let secondModuleCapturedPCMArgs = secondDetails.capturedPCMArgs ?? Set<[String]>()
243-
let combinedCapturedPCMArgs = firstModuleCapturedPCMArgs.union(secondModuleCapturedPCMArgs)
244-
245-
let combinedModuleDetails =
246-
ClangModuleDetails(moduleMapPath: firstDetails.moduleMapPath,
247-
contextHash: firstDetails.contextHash,
248-
commandLine: firstDetails.commandLine,
249-
capturedPCMArgs: combinedCapturedPCMArgs)
250-
251-
return ModuleInfo(modulePath: firstInfo.modulePath,
252-
sourceFiles: combinedSourceFiles,
253-
directDependencies: combinedDependencies,
254-
linkLibraries: combinedLinkLibraries,
255-
details: .clang(combinedModuleDetails))
256-
}
257149
}
258150

259151
/// Incremental Build Machinery

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyGraph.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ public struct SwiftModuleDetails: Codable, Hashable {
132132
/// corresponding to the main module being built.
133133
public var contextHash: String?
134134

135-
/// To build a PCM to be used by this Swift module, we need to append these
136-
/// arguments to the generic PCM build arguments reported from the dependency
137-
/// graph.
138-
public var extraPcmArgs: [String]
139-
140135
/// A flag to indicate whether or not this module is a framework.
141136
public var isFramework: Bool?
142137

@@ -192,10 +187,6 @@ public struct ClangModuleDetails: Codable, Hashable {
192187
/// Options to the compile command
193188
public var commandLine: [String] = []
194189

195-
/// Set of PCM Arguments of depending modules which
196-
/// are covered by the directDependencies info of this module
197-
public var capturedPCMArgs: Set<[String]>?
198-
199190
/// The module cache key of the output module.
200191
public var moduleCacheKey: String?
201192
}

Sources/SwiftDriver/SwiftScan/DependencyGraphBuilder.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ private extension SwiftScan {
178178
let bridgingPchCommandLine = supportsBridgingHeaderPCHCommand ?
179179
try getOptionalStringArrayDetail(from: moduleDetailsRef,
180180
using: api.swiftscan_swift_textual_detail_get_bridging_pch_command_line) : nil
181-
let extraPcmArgs =
182-
try getStringArrayDetail(from: moduleDetailsRef,
183-
using: api.swiftscan_swift_textual_detail_get_extra_pcm_args,
184-
fieldName: "extraPCMArgs")
185181
let contextHash =
186182
try getOptionalStringDetail(from: moduleDetailsRef,
187183
using: api.swiftscan_swift_textual_detail_get_context_hash)
@@ -206,7 +202,6 @@ private extension SwiftScan {
206202
commandLine: commandLine,
207203
bridgingPchCommandLine : bridgingPchCommandLine,
208204
contextHash: contextHash,
209-
extraPcmArgs: extraPcmArgs,
210205
isFramework: isFramework,
211206
swiftOverlayDependencies: swiftOverlayDependencies,
212207
moduleCacheKey: moduleCacheKey)
@@ -291,22 +286,12 @@ private extension SwiftScan {
291286
using: api.swiftscan_clang_detail_get_command_line,
292287
fieldName: "clang_detail.commandLine")
293288

294-
let capturedPCMArgs : Set<[String]>?
295-
if clangDetailsHaveCapturedPCMArgs {
296-
let capturedArgs = try getStringArrayDetail(from: moduleDetailsRef,
297-
using: api.swiftscan_clang_detail_get_captured_pcm_args,
298-
fieldName: "clang_detail.capturedPCMArgs")
299-
capturedPCMArgs = [capturedArgs]
300-
} else {
301-
capturedPCMArgs = nil
302-
}
303289
let moduleCacheKey = supportsCaching ? try getOptionalStringDetail(from: moduleDetailsRef,
304290
using: api.swiftscan_clang_detail_get_module_cache_key) : nil
305291

306292
return ClangModuleDetails(moduleMapPath: moduleMapPath,
307293
contextHash: contextHash,
308294
commandLine: commandLine,
309-
capturedPCMArgs: capturedPCMArgs,
310295
moduleCacheKey: moduleCacheKey)
311296
}
312297
}

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,6 @@ private extension String {
229229
api.swiftscan_swift_binary_detail_get_header_dependency_module_dependencies != nil
230230
}
231231

232-
@_spi(Testing) public var clangDetailsHaveCapturedPCMArgs : Bool {
233-
api.swiftscan_clang_detail_get_captured_pcm_args != nil
234-
}
235-
236232
@_spi(Testing) public var supportsBinaryModuleHeaderDependencies : Bool {
237233
return api.swiftscan_swift_binary_detail_get_header_dependencies != nil
238234
}
@@ -478,10 +474,6 @@ private extension swiftscan_functions_t {
478474
self.swiftscan_compiler_target_info_query_v2 =
479475
loadOptional("swiftscan_compiler_target_info_query_v2")
480476

481-
// Clang dependency captured PCM args
482-
self.swiftscan_clang_detail_get_captured_pcm_args =
483-
loadOptional("swiftscan_clang_detail_get_captured_pcm_args")
484-
485477
// Scanner diagnostic emission query
486478
self.swiftscan_scanner_diagnostics_query =
487479
loadOptional("swiftscan_scanner_diagnostics_query")
@@ -657,8 +649,6 @@ private extension swiftscan_functions_t {
657649
try loadRequired("swiftscan_swift_textual_detail_get_bridging_module_dependencies")
658650
self.swiftscan_swift_textual_detail_get_command_line =
659651
try loadRequired("swiftscan_swift_textual_detail_get_command_line")
660-
self.swiftscan_swift_textual_detail_get_extra_pcm_args =
661-
try loadRequired("swiftscan_swift_textual_detail_get_extra_pcm_args")
662652
self.swiftscan_scan_invocation_get_argc =
663653
try loadRequired("swiftscan_scan_invocation_get_argc")
664654
self.swiftscan_scan_invocation_get_argv =

0 commit comments

Comments
 (0)