-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ScanDependency] Move binary module validation into scanner #72291
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
[ScanDependency] Move binary module validation into scanner #72291
Conversation
This is not ready to land yet because I need to find way to fix the tests and clean up some code. Want to collect feedback for the implementation before doing all the extra work. |
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.
Approach looks reasonable to me, though I'm not an expert on this area of the code
e69fe8e
to
bb1fcb2
Compare
@swift-ci please smoke test |
Update: The legacy behavior is preserved with a hidden frontend flag |
bb1fcb2
to
6164fc2
Compare
@swift-ci please smoke test |
6164fc2
to
e3fd19b
Compare
@swift-ci please smoke test |
e3fd19b
to
f201a65
Compare
Rename the new flag name to To clarify my previous comment, the behavior of the build should mostly stay the same (default to |
f201a65
to
955f3b8
Compare
Need swift-driver change: swiftlang/swift-driver#1563 so the tests there are not broken because the change in scanner causes swift-driver to schedule less jobs. |
955f3b8
to
ce98d99
Compare
@swift-ci please smoke test |
ping |
ce98d99
to
eebd2b3
Compare
@swift-ci please smoke test |
eebd2b3
to
0bec91b
Compare
@swift-ci please smoke test |
0bec91b
to
a37cc33
Compare
Improve swift dependency scanner by validating and selecting dependency module into scanner. This provides benefits that: * Build system does not need to schedule interface compilation task if the candidate module is picked, it can just use the candidate module directly. * There is no need for forwarding module in the explicit module build. Since the build system is coordinating the build, there is no need for the forwarding module in the module cache to avoid duplicated work, * This also correctly supports all the module loading modes in the dependency scanner. This is achieved by only adding validate and up-to-date binary module as the candidate module for swift interface module dependency. This allows caching build to construct the correct dependency in the CAS. If there is a candidate module for the interface module, dependency scanner will return a binary module dependency in the dependency graph. The legacy behavior is mostly preserved with a hidden frontend flag `-no-scanner-module-validation`, while the scanner output is mostly interchangeable with new scanner behavior with `prefer-interface` module loading mode except the candidate module will not be returned. rdar://123711823
Teach scanner to pick and choose binary modules correctly based on if it is testable import or not. Some situations that scanner need to be careful when testable is involved: * When it is a regular import, it should not import binary modules that are built with -enable-testing, it should prefer interfaces if that is available. * When testable import, it should only load binary module and it should make sure the internal imports from binary modules are actually required for testable import to work. If a testable import only find a regular binary module, dependency scanner currently will just preceed with such module and leave the diagnostics to swift-frontend, because the alternative (failed to find module) can be confusing to users. rdar://125914165
a37cc33
to
d4c90d6
Compare
@swift-ci please smoke test |
return std::make_error_code(std::errc::no_such_file_or_directory); | ||
} | ||
|
||
if (loadedModuleFile->isTestable() && !isTestableImport) { |
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.
Do we currently (before this change) have clients refuse to load isTestable
binary modules from a non-@testable
imports or is that a semantic change?
In theory, a non-@testable
import
should be able to load such a module just fine, as it represents a super set of the same module built without build-for-testing
.
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.
It can add in more dependency than needed which the user might or might not be able to satisfy.
Current explicit build will discover dependency from interface so it doesn't see those dependencies. I guess during forwarding module creation, it will see if it can satisfy all dependencies to see if it needs build from interface or create forwarding from testing module. That behavior is quite hard to support in this new model.
@swift-ci please smoke test macOS platform |
Improve swift dependency scanner by validating and selecting dependency module into scanner. This provides benefits that:
rdar://123711823