Skip to content

[ObjcHeader] Fix objc header generation when pch is explicited passed #66000

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

cachemeifyoucan
Copy link
Contributor

When swift-frontend is explicitly passed the pch file as bridging header on command-line through -import-objc-header, it needs to print the original source file name if needed to the generated objc header.

• Release: Swift 5.9
• Explanation: When swift-frontend is explicitly passed the pch file as bridging header on command-line through -import-objc-header, it needs to print the original source file name if needed to the generated objc header.
• Scope of Issue: When doing explicit module build, swift driver will explicit pass compiled PCH file to swift-frontend as bridging header. This can cause generated objc header from the swift module trying to include the compiled PCH file instead of bridging header source file.
• Origination: Explicit module build changes how bridging header pch file handling.
• Risk: Low. Only affects explicit module build.
• Reviewed By: @artemcm @benlangmuir

Detailed description:

When importing bridging header, swift-frontend can take a compiled .pch file directly from command line option -import-obcj-header instead of the bridging header source file. But in the case when a objc header for the swift module needs to be generated with underlying module, the generated header needs to include bridging header by its path. Currently, the path is taken directly from the command-line option, regardless if it is header source file or a PCH file. This can result in the user trying to textual include a pch file and error out.

This problem exists for previous releases, but made more prominent for explicit module build as swift driver now utilize the function of passing pch directly. This can result in the projects that rely on generated objc header hitting the issue. The default implicit module build is not affected since it still gets the header source file.

resolves: rdar://109411245

When swift-frontend is explicitly passed the pch file as bridging header
on command-line through `-import-objc-header`, it needs to print the
original source file name if needed to the generated objc header.

rdar://109411245
(cherry picked from commit 16e4cfa)
@cachemeifyoucan cachemeifyoucan requested a review from a team as a code owner May 18, 2023 17:46
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please 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.

This change is for explicit module only.

@cachemeifyoucan cachemeifyoucan merged commit 41364ab into swiftlang:release/5.9 May 18, 2023
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