Skip to content

[5.1 EARLY] [Frontend] Avoid doing whole-module work under primary-file typecheck #27159

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

jrose-apple
Copy link
Contributor

Same as #27158, but for the early cut 5.1 branch.

Explanation: Indexing logic in Xcode invokes swiftc in a way that just performs type-checking for a single file and then emits indexing data. However, the build invocation Xcode is using still implies the creation of auxiliary outputs that require whole-module knowledge, like module interface files. For now, avoid crashing on this by checking if we're not in a whole-module context and bailing out if so.

Scope: Only affects invocations of swiftc that use -index-file (and direct invocations of the compiler frontend, which is considered an unstable and unsupported interface for external tools).

Issue: rdar://problem/53117124

Risk: Very low. This code path is not used for compilation.

Testing: Added a compiler regression test that previously produced the same crash signature as in the Radar.

Reviewed by: @akyrtzi

…swiftlang#27153)

...a situation we get into with indexing. The way Xcode generates
indexing invocations is to take a build command and add additional
flags to it; in order for the Driver to produce a single frontend
command from /that/, it currently plans as if it's going to do a
whole-module -typecheck and then turns around and uses -primary-file
anyway. This is questionable practice, to be sure...

...but meanwhile, let's not crash by trying to access declarations
that haven't been type-checked yet.

rdar://problem/53117124
(cherry picked from commit 9e6d4db)
@jrose-apple jrose-apple requested a review from a team as a code owner September 13, 2019 00:59
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple jrose-apple merged commit 28c0468 into swiftlang:swift-5.1-branch-08-28-2019 Sep 13, 2019
@jrose-apple jrose-apple deleted the 5.1-EARLY-i-prefer-two-percent-modules-myself branch September 13, 2019 03:20
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