I was reading through this document https://github.com/apple/swift/blob/master/docs/DependencyAnalysis.md and the following seemed surprising to me.
External dependencies, including imported Swift module files and Clang headers, are tracked using a special
depends-externalset. These dependencies refer to files that are external to the module. The Swift driver interprets this set specially and decides whether or not the cross-module dependencies have changed.
Because every Swift file in the module at least has its imports resolved, currently every file in the module has the same (complete) list of external dependencies. This means if an external dependency changes, everything in the module is rebuilt.
Is there any technical reason that all files in a module need to depend on all the external dependencies? It seems like each file could have a list of external dependencies based on its imports and the the references symbols.
Is this just work that hasn’t been done? Am I missing something? Or best case, has this or similar optimizations happened already and the docs are out of date?