-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add a new driver tool/mode to print the synthesized Swift interface for a module. #76872
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
allevato
merged 1 commit into
swiftlang:main
from
allevato:swift-synthesize-interface-tool
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be ideal if we could unify
InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface
with something like this.Because right now if these two get out-of-sync, I imagine this tool may produce outputs that would differ from what the compiler would actually do during compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing the connection here, since the primary goal for this mode is to print the synthesized Swift decls for a C/Obj-C/C++ module. What's the failure case you're thinking of? Someone using this with a
.swiftinterface
file on the search path and having it output something different than the interface that would result from compiling it, someone seeing a mismatch between the textual interface and the synthesized interface of an already compiled.swiftmodule
, or something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my mind went in the direction of using a tool like this for Swift code.
It is much less of a concern for C/Obj-C/C++ modules, you're correct.
These are the kinds of failure scenarios I was thinking of, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this tool has a similar interface to
swift-symbolgraph-extract
, it doesn't take any Swift source files as inputs; it just takes the command line arguments needed to set up the search paths of the compiler instance, and then the module specified by-module-name
will be loaded through the standard mechanisms.However, using it to dump the interface of an already compiled
.swiftmodule
would still be useful. I tested a couple of the cases you were concerned about, and they fail with the expected diagnostics. For example, if I compile a.swiftinterface
and.swiftmodule
for iOS and then try to runswift-synthesize-interface
with-target arm64-apple-macosx14.0
using either the binary module or the textual interface on the search path, I get the following error:Does that address your concerns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artemcm Friendly ping—are there any other cases you think I should consider?