Skip to content

[6.1 🍒][Dependency Scanning] Refine cross-import overlay detection algorithm #80651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Apr 8, 2025

Cherry-pick of #79550, #79676, #79809

Explanation: Previous implementation took the entire transitive dependency set and cross-referenced all of its members to determine which ones introduce requried cross-import overlays. That implementation differed from the cross-import overlay loading logic during source compilation, where a corresponding cross-import overlay module is only requested if the two constituent modules are reachable via direct 'import's from the same source file or an indirect @_exported import from a direct import. Meaning the dependency scanner before this change would report cross-import overlay dependencies which never got loaded by the corresponding client source compile.

This change implements a new implementation of cross-import overlay discovery which first computes sub-graphs of module dependencies directly reachable by 'import's for each source file of the module under scan and then performs pairwise cross-import overlay query per each such subgraph.

Issue: rdar://145157171

Risk: Minimal where explicitly-built modules are not enabled, Low where they are enabled - this change reduces the set of brought-in cross-import overlays in the scanner to match the behavior during the actual source compile. Still, it is a significant change to the cross-import overlay discovery functionality in the scanner to achieve the resulting sound outcome.

Testing: Added tests to test suite

Original PRs: #79550, #79676, #79809

Reviewers: @xymus, @cachemeifyoucan

…rce-file

Previous implementation took the entire transitive dependency set and cross-referenced all of its members to determine which ones introduce requried cross-import overlays. That implementation differed from the cross-import overlay loading logic during source compilation, where a corrsponding cross-import overlay module is only requested if the two constituent modules are reachable via direct 'import's from *the same source file*. Meaning the dependency scanner before this change would report cross-import overlay dependencies which never got loaded by the corresponding client source compile.

This change implements a new implementation of cross-import overlay discovery which first computes sub-graphs of module dependencies directly reachable by 'import's for each source file of the module under scan and then performs pairwise cross-import overlay query per each such sub-graph.

Resolves rdar://145157171
@artemcm artemcm requested a review from a team as a code owner April 8, 2025 20:16
@artemcm
Copy link
Contributor Author

artemcm commented Apr 8, 2025

@swift-ci test

artemcm added 3 commits April 8, 2025 13:51
The algorithm already performs pairwise checks on module dependencies brought into compilation per-source-file. Previously, the algorithm considered the entire sub-graph of a given source file. Actual source compiles do not consider the full transitive module dependency set for cross-import-overlay lookup, but rather only directly-imported modules in a given source file, and '@_exported import' Swift transitive dependencies.

This change adds tracking of whether a given import statement is 'exported' to the dependency scanner and then refines the cross-import overlay lookup logic to only consider transitive modules that are exported by directly-imported dependencies.
@artemcm artemcm force-pushed the 61FixEBMCrossImportDiscovery branch from 7a46674 to 41b5471 Compare April 8, 2025 20:51
@artemcm
Copy link
Contributor Author

artemcm commented Apr 8, 2025

@swift-ci test

@artemcm artemcm closed this Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant