-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Explicit Module Builds] Add canImport functionality to the ExplicitSwiftModuleLoader #32754
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
Conversation
@swift-ci please test |
@swift-ci Please test Windows platform |
…wiftModuleLoader It needs to check against the provided ExplicitModuleMap instead of looking into search paths.
b6aab2c
to
f361b25
Compare
@swift-ci please test |
Build failed |
Build failed |
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.
Nice and simple. 🙂
bool ExplicitSwiftModuleLoader::canImportModule( | ||
Located<Identifier> mID) { | ||
StringRef moduleName = mID.Item.str(); | ||
auto it = Impl.ExplicitModuleMap.find(moduleName); |
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.
This is not something you would change in this PR, but…why is ExplicitModuleMap
keyed by StringRef
s? I would expect Identifier
keys to be faster, since Identifier
s are interned and can be compared more efficiently.
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.
I suspect this is to do with the fact that ExplicitModuleMap
is built by parsing out a JSON file (generated in the swift-driver), and at the point it is created perhaps Identifier
keys are not available. @nkcsgexi can confirm.
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.
This is because we initially used StringRef
to the underlying JSON buffer as the key, but we could potentially change it to ASTContext
-owned identifiers now.
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.
👍
Independent of this change, we should also teach scan-dependencies action to eliminate all non-importable modules from the reported dependencies. |
It needs to check against the provided ExplicitModuleMap instead of looking into search paths.