[ObjcHeader] Fix objc header generation when pch is explicited passed #66000
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 apch
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