Skip to content

[5.5][Dependency Scanning] Cherry-pick dependency scanner changes required for Explicit Module Builds #38704

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

Merged

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jul 30, 2021

#38684: [Dependency Scanning] include -sdk in Swift module building command
#38703: [Dependency Scanning] Have the scanner cache answer queries relevant to current search paths only.
#37723: [Dependency Scanning] Add ability for -scan-dependencies action to serialize and deserialize dependency scanner cache from a .moddepcache file. Using the serialization format added in #37585.
#37585: [Dependency Scanning] Add a binary serialization format for the Inter-Module Dependencies Cache
#38710: Frontend: remove -swift-module-file. NFC
#38761: [Dependency Scanning] Split the ModuleDependencyCache into two: current scan cache & global.

artemcm added 2 commits July 29, 2021 22:25
…-Module Dependencies Cache

- Adds serialization format based on the LLVM Bitcode File Format (https://llvm.org/docs/BitCodeFormat.html).
- Adds Serialization and Deserialization code.
…serialize and deserialize dependency scanner cache from a `.moddepcache` file.

Using the serialization format added in swiftlang#37585.

- Add load/save code for the `-scan-dependencies` code-path.
- Add `libSwiftDriver` entry-points to load/store the cache of a given scanner instance.
@artemcm artemcm requested a review from a team as a code owner July 30, 2021 05:33
@artemcm
Copy link
Contributor Author

artemcm commented Jul 30, 2021

@swift-ci please test

artemcm and others added 2 commits July 30, 2021 10:43
…to current search paths only.

The dependency scanner's cache persists across different queries and answering a subsequent query's module lookup with a module not in the query's search path is not correct.

For example, suppose we are looking for a Swift module `Foo` with a set of search paths `SP`.
And dependency scanner cache already contains a module `Foo`, for which we found an interface file at location `L`. If `L`∉`SP`, then we cannot re-use the cached entry because we’d be resolving the scanning query to a filesystem location that the current scanning context is not aware of.

Resolves rdar://81175942
Swift module building commands need -sdk because dependencies sometimes use
sdk-relative paths (prebuilt modules for example). Without -sdk, the command
will not be able to local these dependencies, leading to unnecessary
rebuilding from textual interfaces.

rdar://81177968
@artemcm artemcm force-pushed the DependencyScanningCherryFarming branch from 01f6773 to 2d89d9f Compare July 30, 2021 17:45
@artemcm
Copy link
Contributor Author

artemcm commented Jul 30, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2d89d9f

@nkcsgexi
Copy link
Contributor

@swift-ci please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the 5.5 branch

@artemcm artemcm force-pushed the DependencyScanningCherryFarming branch from f6e012c to f97cfad Compare August 6, 2021 20:57
@artemcm
Copy link
Contributor Author

artemcm commented Aug 6, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Aug 6, 2021

Build failed
Swift Test OS X Platform
Git Sha - f97cfaddfb5a5542fb5464190f6dcb88d9642166

…nt scan cache & global.

This change causes the cache to be layered with a local "cache" that wraps the global cache, which will serve as the source of truth. The local cache persists only for the duration of a given scanning action, and has a store of references to dependencies resolved as a part of the current scanning action only, while the global cache is the one that persists across scanning actions (e.g. in `DependencyScanningTool`) and stores actual module dependency info values.

Only the local cache can answer dependency lookup queries, checking current scanning action results first, before falling back to querying the global cache, with queries disambiguated by the current scannning action's search paths, ensuring we never resolve a dependency lookup query with a module info that could not be found in the current action's search paths.

This change is required because search-path disambiguation can lead to false-negatives: for example, the Clang dependency scanner may find modules relative to the compiler's path that are not on the compiler's direct search paths. While such false-negative query responses should be functionally safe, we rely on the current scanning action's results being always-present-in-the-cache for the scanner's functionality. This layering ensures that the cache use-sites remain unchanged and that we get both: preserved global state which can be queried disambiguated with the search path details, and an always-consistent local (current action) cache state.
@artemcm artemcm force-pushed the DependencyScanningCherryFarming branch from f97cfad to 0966277 Compare August 6, 2021 21:26
@artemcm
Copy link
Contributor Author

artemcm commented Aug 6, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Aug 10, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Aug 10, 2021

@swift-ci please test Windows platform

2 similar comments
@artemcm
Copy link
Contributor Author

artemcm commented Aug 10, 2021

@swift-ci please test Windows platform

@artemcm
Copy link
Contributor Author

artemcm commented Aug 10, 2021

@swift-ci please test Windows platform

@artemcm artemcm merged commit e84be85 into swiftlang:release/5.5 Aug 10, 2021
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.

4 participants