Skip to content

Commit 9553b72

Browse files
committed
[Dependency Scanning] Do not specify placeholder modules by default as inputs to scanning actions
Instead allow the dependency scanning oracle to be configured such that the scanning actions use placeholders. In contexts where the driver's client can guarantee that all module dependencies have been built prior to planning of the dependee, placeholders are not necessary in the scanner, becuase the binary modules will simply be discovered on the filesystem. Resolves rdar://102339586
1 parent 87106af commit 9553b72

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyOracle.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ import Dispatch
3030
/// An abstraction of a cache and query-engine of inter-module dependencies
3131
public class InterModuleDependencyOracle {
3232
/// Allow external clients to instantiate the oracle
33-
public init() {}
33+
/// - Parameter scannerRequiresPlaceholderModules: Configures this driver's/oracle's scanner invocations to
34+
/// specify external module dependencies to be treated as placeholders. This is required in contexts
35+
/// where the dependency scanning action is invoked for a module which depends on another module
36+
/// that is part of the same build but has not yet been built. Treating it as a placeholder
37+
/// will allow the scanning action to not fail when it fails to detect this dependency on
38+
/// the filesystem. For example, SwiftPM plans all targets belonging to a package before *any* of them
39+
/// are built. So this setting is meant to be used there. In contexts where planning a module
40+
/// necessarily means all of its dependencies have already been built this is not necessary.
41+
public init(scannerRequiresPlaceholderModules: Bool = false) {
42+
self.scannerRequiresPlaceholderModules = scannerRequiresPlaceholderModules
43+
}
3444

3545
@_spi(Testing) public func getDependencies(workingDirectory: AbsolutePath,
3646
moduleAliases: [String: String]? = nil,
@@ -145,5 +155,7 @@ public class InterModuleDependencyOracle {
145155

146156
/// A reference to an instance of the compiler's libSwiftScan shared library
147157
private var swiftScanLibInstance: SwiftScan? = nil
158+
159+
internal let scannerRequiresPlaceholderModules: Bool
148160
}
149161

Sources/SwiftDriver/ExplicitModuleBuilds/ModuleDependencyScanning.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public extension Driver {
7474
// FIXME: MSVC runtime flags
7575

7676
// Pass in external target dependencies to be treated as placeholder dependencies by the scanner
77-
if let externalTargetDetailsMap = externalTargetModuleDetailsMap {
77+
if let externalTargetDetailsMap = externalTargetModuleDetailsMap,
78+
interModuleDependencyOracle.scannerRequiresPlaceholderModules {
7879
let dependencyPlaceholderMapFile =
7980
try serializeExternalDependencyArtifacts(externalTargetDependencyDetails: externalTargetDetailsMap)
8081
commandLine.appendFlag("-placeholder-dependency-module-map-file")

0 commit comments

Comments
 (0)