-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Objc interop #12702
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
Objc interop #12702
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
67fae03
ClangImporter: minor clang-format fixing (NFC)
compnerd 4dba0a3
ClangImporter: allow control over ObjCInterop
compnerd 3d1889c
ClangImporter: default to ios objc runtime on non-darwin platforms
fjricci 3c417d5
swift-ide-test: Allow objc-interop to be configured
fjricci 1822c88
test: Test objc-interop on linux
fjricci 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
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.
This will let us make some progress, but eventually you'll need to decide which Objective-C runtime(s) to target outside of Darwin. For example, Clang supports GNUstep, and one could imagine surfacing Clang's understanding of the Objective-C runtime so that Swift could build on top of it (rather than duplicating it).
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 don't have much time to work on it, but I'm happy to provide advice to anyone who wants to add support for the GNUstep runtime (and add any missing runtime features that Swift needs).
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.
Until we get GNUStep to the point where the object layout works in a compatible manner (or change the swift object layout), I think that not permitting control over the runtime is quite reasonable.
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.
Are Swift's requirements documented anywhere?
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 don't think so. Off the top of my head two of the biggest requirements are:
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.
The second requirement is easy - we have a flags field and can reserve a bit for Swift to use.
The first is a bit harder because the clang generates these structures without providing hooks to add fields. The structure is defined here.
This will change in the next version of the runtime, and the current prototype for the new ABI would make this more difficult, because it puts all of the class structures in a section and the loader in the runtime expects them to be contiguous in memory, so adding other fields would mean that the runtime would need to be aware of the structure.
I'm also rearranging some of the fields to split the structure into ones that are likely to be modified at run time and ones that aren't, based on feedback from Microsoft that the runtime generates more CoW faults at start than they'd like - I'm not sure where the Swift fields would like to go, but if it's on the immutable part then that's probably easier, because that will be reachable via a pointer to the start from the mutable part, and that can easily be a pointer to the middle of a larger structure.