Skip to content

[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

Merged
merged 1 commit into from
Jul 9, 2020

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jul 8, 2020

It needs to check against the provided ExplicitModuleMap instead of looking into search paths.

@artemcm artemcm requested review from beccadax and nkcsgexi July 8, 2020 00:14
@artemcm
Copy link
Contributor Author

artemcm commented Jul 8, 2020

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jul 8, 2020

@swift-ci Please test Windows platform

…wiftModuleLoader

It needs to check against the provided ExplicitModuleMap instead of looking into search paths.
@artemcm artemcm force-pushed the CanImportExplicitly branch from b6aab2c to f361b25 Compare July 8, 2020 17:12
@artemcm
Copy link
Contributor Author

artemcm commented Jul 8, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 8, 2020

Build failed
Swift Test Linux Platform
Git Sha - b6aab2c2d2295d466dd8c27e7c14b157823e5b69

@swift-ci
Copy link
Contributor

swift-ci commented Jul 8, 2020

Build failed
Swift Test OS X Platform
Git Sha - b6aab2c2d2295d466dd8c27e7c14b157823e5b69

Copy link
Contributor

@beccadax beccadax left a 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);
Copy link
Contributor

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 StringRefs? I would expect Identifier keys to be faster, since Identifiers are interned and can be compared more efficiently.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@artemcm artemcm merged commit 7dd220f into swiftlang:master Jul 9, 2020
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.

👍

@nkcsgexi
Copy link
Contributor

Independent of this change, we should also teach scan-dependencies action to eliminate all non-importable modules from the reported dependencies.

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