[6.0🍒][Explicit Module Builds] Cherry-pick Explicit Module Loading fixes and improvements #72743
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation:
This PR is a collection of Explicit Module Build improvements and fixes:
Otherwise Swift Overlay paths do not get printed for dependency cycles where the sink is the same module as the source module being built.
Relying on the corresponding field in the '-explicit-swift-module-map-file' provided by the driver.
Swift interfaces will only ever query module inputs by-name, so parsing modulemap files to resolve their headers is not necessary. The exception to this is textual header ingestion directly into the Swift compiler (ClangImporter). Because then the compiler may need to resolve header includes to the corresponding module (.pcm) inputs. This requires explicitly-specified module maps, until we switch to eager module loading.
This occurs when there is a a dependency on a binary Swift module, which was built with a bridging header, and this bridging header was serialized into the .swiftmodule and must be ingested by all clients. In this case, we must ensure that all clients of said binary module, direct and transitive, are passed -fmodule-map-file= flags corresponding to dependencies of said header.
This operation is not necessary for explicitly-built dependencies and causes redundant filesystem traffic when checking dependency files. With explicit modules, the up-to-date checks on module dependencies are performed by the build-system (Swift Driver).
Otherwise libSwiftScan clients which rely on EmbeddedSwift feature are not able to execute dependency scans.
Scope: These changes affect dependency scanning and explicit module dependency compilation. While these actions are by-default disabled in
swiftc
, there are projects that rely on them. swift/72699 is a diagnostic improvement that only affects the code-path triggered on build failure. swift/72104 is an [NFC] change that affects configuration of libSwiftScan to use Swift-written compiler components. swift/72499 is an [NFC] change that disables a redundant operation during explicit module pre-compilation. swift/72599 and swift/72668 reduce the amount of-fmodule-map-file
flags passed to explicit module dependency compilation tasks only to the.modulemap
files of modules required for header include resolution. This should be a safe change that will only affect projects with bridging headers with their own module dependencies.Risk: Low. Code-paths disabled by-default and the changes are meant to improve overall soundness and performance of builds.
Testing: Each of the above changes has corresponding test-suite additions.
Reviewed By: @cachemeifyoucan, @eeckstein, @tshortli, @xymus, @nkcsgexi (for various corresponding changes above).