Skip to content

[5.4][ClangImporter] Load the stdlib even if there is a -fmodule-map-file argument pointing to a missing file #37481

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
May 19, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 18, 2021

Cherry-picks #37252 to release/5.4.

  • Explanation:

If there is a -fmodule-map-file argument whose file doesn’t exist and SwiftShims is not in the module cache, we fail to build it, because clang throws an error about the missing module map. This causes SourceKit to drop all semantic functionality, even if the missing module map isn’t required.

To work around this, drop all -fmodule-map-file arguments with missing files from the clang importer’s arguments, reporting the error that clang would throw manually.

  • Scope: Invalid compiler invocations (module map is missing)
  • Risk: Low
  • Testing: Added a test to the test suite
  • Issue: rdar://78035990
  • Reviewer: Argyrios Kyrtzidis (@akyrtzi), Xi Ge (@nkcsgexi)

@ahoppen ahoppen added the r5.4 label May 18, 2021
@ahoppen
Copy link
Member Author

ahoppen commented May 18, 2021

@swift-ci Please nominate

@ahoppen ahoppen requested a review from akyrtzi May 18, 2021 16:59
@ahoppen ahoppen force-pushed the pr-5.4/rdar-78035990 branch from 92c823a to faa92ea Compare May 18, 2021 18:27
…` argument pointing to a missing file

If there is a `-fmodule-map-file` argument whose file doesn’t exist and SwiftShims is not in the module cache, we fail to build it, because clang throws an error about the missing module map. This causes SourceKit to drop all semantic functionality, even if the missing module map isn’t required.

To work around this, drop all `-fmodule-map-file` arguments with missing files from the clang importer’s arguments, reporting the eror that `clang` would throw manually.

Fixes rdar://77449671
@ahoppen ahoppen force-pushed the pr-5.4/rdar-78035990 branch from faa92ea to 631ff40 Compare May 18, 2021 20:30
@swiftlang swiftlang deleted a comment from swift-ci May 18, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 18, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 18, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 18, 2021
@ahoppen
Copy link
Member Author

ahoppen commented May 18, 2021

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented May 18, 2021

Compared to the original PR I’m cherry-picking, I needed to change the call to diagnose because e316a8e (which defined the diagnose method on ClangImporter::Implementation) is not in 5.4.

- importer->Impl.diagnose(SourceLoc(), diag::module_map_not_found,                              
-                         ModuleMapFile);
+ importer->Impl.SwiftContext.Diags.diagnose(
+     SourceLoc(), diag::module_map_not_found, ModuleMapFile);

The change uses a simplified version of the diagnose implementation that behaves like the emission of all diagnostics before the refactoring that added the method on ClangImporter::Implementation.

@ahoppen ahoppen merged commit 547ecb3 into swiftlang:release/5.4 May 19, 2021
@ahoppen ahoppen deleted the pr-5.4/rdar-78035990 branch May 19, 2021 19:39
@AnthonyLatsis AnthonyLatsis added swift 5.4 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants