Skip to content

Commit 394c88b

Browse files
committed
[Incremental Builds][Explicit Module Builds] Treat Binary-only Swift module dependencies as up-to-date
Instead of conservatively assuming them to be new/updated in order to invalidate their dependents. This behavior is no longer necessary since the implementation of swiftlang#1628 (adce133) which will ensure that if a binary module dependnecy is newer than any of its dependents they will get invalidated and re-built.
1 parent dafcec6 commit 394c88b

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/CommonDependencyOperations.swift

+7-6
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ internal extension InterModuleDependencyGraph {
367367
}
368368
}
369369

370-
// Check if any of the textual sources of this module are newer than this module
370+
// Check if any of the input sources of this module are newer than this module
371371
switch checkedModuleInfo.details {
372372
case .swift(let swiftDetails):
373373
if let moduleInterfacePath = swiftDetails.moduleInterfacePath {
@@ -400,11 +400,12 @@ internal extension InterModuleDependencyGraph {
400400
}
401401
}
402402
case .swiftPrebuiltExternal(_):
403-
// TODO: We have to give-up here until we have a way to verify the timestamp of the binary module.
404-
// We can do better here by knowing if this module hasn't changed - which would allows us to not
405-
// invalidate any of the dependencies that depend on it.
406-
reporter?.report("Unable to verify binary module dependency up-to-date: \(moduleID.moduleNameForDiagnostic)")
407-
return false;
403+
// We do not verify the binary module itself being out-of-date if we do not have a textual
404+
// interface it was built from, but we can safely treat it as up-to-date, particularly
405+
// because if it is newer than any of the modules they depend on it, they will
406+
// still get invalidated in the check above for whether a module has
407+
// any dependencies newer than it.
408+
return true;
408409
case .swiftPlaceholder(_):
409410
// TODO: This should never ever happen. Hard error?
410411
return false;

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

+23
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,29 @@ extension IncrementalCompilationTests {
516516
linking
517517
}
518518
}
519+
520+
func testExplicitIncrementalBuildUnchangedBinaryDependencyDoesNotInvalidateUpstreamDependencies() throws {
521+
replace(contentsOf: "other", with: "import J;")
522+
try buildInitialState(checkDiagnostics: false, explicitModuleBuild: true)
523+
// Touch one of the inputs to actually trigger the incremental build, so that we can ensure
524+
// no module deps get re-built
525+
touch(inputPath(basename: "other"))
526+
527+
try doABuild(
528+
"Unchanged binary dependency (G)",
529+
checkDiagnostics: false,
530+
extraArguments: explicitBuildArgs,
531+
whenAutolinking: autolinkLifecycleExpectedDiags
532+
) {
533+
readGraph
534+
enablingCrossModule
535+
readInterModuleGraph
536+
interModuleDependencyGraphUpToDate
537+
schedulingChangedInitialQueuing("other")
538+
reading(deps: "other")
539+
schedLinking
540+
}
541+
}
519542
}
520543

521544
extension IncrementalCompilationTests {

0 commit comments

Comments
 (0)