-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Dependency Scanner] Produce complete compile commands for building explicit Swift interface dependencies #63460
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
[Dependency Scanner] Produce complete compile commands for building explicit Swift interface dependencies #63460
Conversation
ce6b3c5 to
3ada2f9
Compare
|
@swift-ci test |
nkcsgexi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much simpler. Thank you!
3ada2f9 to
032f59a
Compare
|
@swift-ci test |
cachemeifyoucan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any plan to change explicit-swift-module-map-file used by swiftinterface compilation? I didn't check if the order of that is deterministic and I don't really care about if it is command-line or file input but ideally I would like that to be generated by libSwiftScan, not driver so I can compute a cache key during scanning without driver involved.
…dencies on the command line
Do this by computing a transitive closure on the computed dependency graph, relying on the fact that it is a DAG.
The used algorithm is:
```
for each v ∈ V {
T(v) = { v }
}
for v ∈ V in reverse topological order {
for each (v, w) ∈ E {
T(v) = T(v) ∪ T(w)
}
}
```
… for self-contained commands - '-o <output_path>' - '-disable-implicit-swift-modules' - '-Xcc -fno-implicit-modules' and '-Xcc -fno-implicit-module-maps' - '-candidate-module-file' These were previously supplied by the driver. Instead, they will now be ready to be run directly from the dependency scanner's output.
032f59a to
be3812d
Compare
As of this change, swiftinterface dependencies will no longer be using We can revisit the format and usage of |
|
One nice bonus of this change is that the dependency scanner output uses the newly-computed topological ordering of all the modules, which makes it a bit more deterministic for the clients, and nicer to consume by humans in the JSON output. |
Wanted to clarify that we will also need swiftlang/swift-driver#1282 for this. |
cachemeifyoucan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
This change causes the dependency scanner to emit complete command-line argument sets for Swift module dependencies that must be built from their
.swiftinterface. Previously, the scanner emitted command-line sets which the client (SwiftDriver) modified to make complete by adding:-o <output_path>-disable-implicit-swift-modules-Xcc -fno-implicit-modulesand-Xcc -fno-implicit-module-maps-candidate-module-file <module_path>And, crucially, all of a given dependency module's explicit dependency inputs, via:
-explicit-swift-module-map-filefor Swift dependencies-Xcc -fmodule-file=and-Xcc -fmodule-map-file=for Clang dependenciesAll of the above are now specified by the scanner. This change (re)adds a flag for specifying an explicit module dependency on the command-line, instead of via a JSON file input:
-swift-module-file. Module dependencies built from interface files do not require the full functionality provided by explicit module maps, and benefit from having the expanded command-line itself be a complete specification of compilation.Unlike the prior version of this flag,
-swift-module-fileno longer requires the specified argument input binary module files to be loaded into memory and opened to determine which module they belong. Instead, it specifies the following format:-swift-module-file=<module_name>=<module_path>, analogous to Clang's-fmodule-file=<>=<>.The JSON format of
-explicit-swift-module-map-filewill continue to be used for source module compile commands, as produced by SwiftDriver.The full set of dependencies for a given textual Swift module's compile command is produced by computing a transitive closure on the dependency graph, relying on the fact that it is a directed acyclic graph.
The algorithm used is the same one as currently in-use in the driver to do so: