Skip to content

Preload standard library in ModuleInterfaceBuilder #36594

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 3 commits into from
Apr 15, 2021

Conversation

beccadax
Copy link
Contributor

@beccadax beccadax commented Mar 25, 2021

Previously, when the standard library module interface was broken, Swift would try to rebuild it repeatedly during -compile-module-from-interface jobs because ASTContext::getStdlibModule() would try to load the standard library again each time it was called. This led to extremely slow compilations that repeatedly emitted the same errors, and sometimes to crashes in non-asserts compilers when they expected a standard library but couldn't find one.

To avoid this, we make ModuleInterfaceBuilder try to load the standard library right away and bail out if it can’t.

This PR also includes a couple of fixes for issues that occur when trying to use -verify mode with module interfaces. One of these (the SourceLoc translation issue) is implicitly exercised by the new test; the other is a simple command-line flag validation bug.

Fixes rdar://75669548.

This commit fixes two weird bugs in -verify mode:

1. SourceLocs from the wrong SourceManager could be passed through a ForwardingDiagnosticConsumer into the DiagnosticVerifier.

2. -verify-additional-file did not error out correctly when the file couldn’t be opened.

No tests, as we only have basic tests for the diagnostic verifier.
@beccadax beccadax requested a review from nkcsgexi March 25, 2021 23:07
@beccadax
Copy link
Contributor Author

@swift-ci please smoke 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! This could also be fixed by explicit module build.

Previously, when the standard library module interface was broken, Swift would try to rebuild it repeatedly during -compile-module-from-interface jobs because `ASTContext::getStdlibModule()` would try to load the standard library again each time it was called. This led to extremely slow compilations that repeatedly emitted the same errors.

To avoid this, we make ModuleInterfaceBuilder try to load the standard library right away and bail out if it can’t.

Fixes rdar://75669548.
@beccadax beccadax force-pushed the nonstandard-library branch from 8a59fd8 to 02c7476 Compare March 26, 2021 01:48
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

(Test needed to be tweaked for Windows.)

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test Linux platform

@beccadax
Copy link
Contributor Author

This swift-driver error should have been cleared by swiftlang/swift-driver#571...

@swift-ci please clean smoke test Linux platform

@beccadax
Copy link
Contributor Author

@swift-ci please clean smoke test Linux platform

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test windows platform

@beccadax
Copy link
Contributor Author

beccadax commented Apr 6, 2021

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

I'm going to end up disabling the test on Windows, but I want to have information about the failure to file a bug.

@swift-ci please smoke test windows platform

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax beccadax merged commit 6e710b2 into swiftlang:main Apr 15, 2021
ahoppen added a commit to ahoppen/swift that referenced this pull request Apr 16, 2021
swiftlang#36928 changed the error message while swiftlang#36594 added a test case looking for the old error message. Update the test to look for the non-dynamic substring of the new error message.
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.

2 participants