-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Deployment-gate treatment of protocols without witness tables as never-dependent #75769
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
DougGregor
merged 2 commits into
swiftlang:main
from
DougGregor:deployment-gate-nondependent-marker-conformances
Aug 8, 2024
Merged
Deployment-gate treatment of protocols without witness tables as never-dependent #75769
DougGregor
merged 2 commits into
swiftlang:main
from
DougGregor:deployment-gate-nondependent-marker-conformances
Aug 8, 2024
Conversation
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
…r-dependent Within Swift 6.0, we expanded an optimization for witness tables that that allowed direct access to the witness table for conformances to any protocol that can never have a witness table, rather than requiring access through `swift_getWitnessTable` that might need to instantiate the witness table. The previous optimization only covered Objective-C protocols, but Swift 6.0 expanded that to marker protocols (such as `Sendable`) as well. However, this constituted an API break when a Swift 6.0 compiler uses a witness table that comes from a library built with an earlier version of Swift, when the protocol inherits from Sendable but the conformance to that protocol otherwise does not require an instantiation function. In such cases, Swift 6.0 would generate code that directly accesses the uninstantiated witness table symbol, which will have NULL entries for any conformance in it that was considered "dependent" by the earlier Swift compiler. Introduce a deployment target check to guard the new optimization. Specifically, when building for a deployment target that predates Swift 6.0, treat conformances to marker protocols as if they might be dependent (so the access patterns go through `swift_getWitnessTable` for potential instantiation on older platforms). For newer deployment targets, use the more efficent direct access pattern. Fixes rdar://133157093.
Member
Author
|
@swift-ci please smoke test |
….0 marker protocol
Member
Author
|
@swift-ci please smoke test |
aschwaighofer
approved these changes
Aug 8, 2024
DougGregor
added a commit
to DougGregor/swift
that referenced
this pull request
Sep 10, 2024
… targets A change to the way we determined whether a protocol conformance is "dependent" for marker protocols caused an ABI break for Sendable-refining protocols built with pre-6.0 Swift compilers. The fix for this issue (swiftlang#75769) gated the change on deployment target. The deployment target change fixed the original problem, then caused a related issue when a project mixes deployment targets (pre-6.0 and 6.0+) with non-resilient protocols. Rework the logic here to (1) look at the availability of the protocol rather than the deployment target, and (2) always use the more efficient (non-dependent) answer for non-resilient protocols. Fixes rdar://134953989.
DougGregor
added a commit
to DougGregor/swift
that referenced
this pull request
Sep 10, 2024
… targets A change to the way we determined whether a protocol conformance is "dependent" for marker protocols caused an ABI break for Sendable-refining protocols built with pre-6.0 Swift compilers. The fix for this issue (swiftlang#75769) gated the change on deployment target. The deployment target change fixed the original problem, then caused a related issue when a project mixes deployment targets (pre-6.0 and 6.0+) with non-resilient protocols. Exempt non-resilient protocols from this change so we get consistent behavior. Fixes rdar://134953989.
DougGregor
added a commit
to DougGregor/swift
that referenced
this pull request
Sep 10, 2024
… targets A change to the way we determined whether a protocol conformance is "dependent" for marker protocols caused an ABI break for Sendable-refining protocols built with pre-6.0 Swift compilers. The fix for this issue (swiftlang#75769) gated the change on deployment target. The deployment target change fixed the original problem, then caused a related issue when a project mixes deployment targets (pre-6.0 and 6.0+) with non-resilient protocols. Exempt non-resilient protocols from this change so we get consistent behavior. Fixes rdar://134953989.
DougGregor
added a commit
that referenced
this pull request
Sep 11, 2024
… targets A change to the way we determined whether a protocol conformance is "dependent" for marker protocols caused an ABI break for Sendable-refining protocols built with pre-6.0 Swift compilers. The fix for this issue (#75769) gated the change on deployment target. The deployment target change fixed the original problem, then caused a related issue when a project mixes deployment targets (pre-6.0 and 6.0+) with non-resilient protocols. Exempt non-resilient protocols from this change so we get consistent behavior. Fixes rdar://134953989.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Within Swift 6.0, we expanded an optimization for witness tables that that allowed direct access to the witness table for conformances to any protocol that can never have a witness table, rather than requiring access through
swift_getWitnessTablethat might need to instantiate the witness table.The previous optimization only covered Objective-C protocols, but Swift 6.0 expanded that to marker protocols (such as
Sendable) as well.However, this constituted an ABI break when a Swift 6.0 compiler uses a witness table that comes from a library built with an earlier version of Swift, when the protocol inherits from Sendable but the conformance to that protocol otherwise does not require an instantiation function. In such cases, Swift 6.0 would generate code that directly accesses the uninstantiated witness table symbol, which will have NULL entries for any conformance in it that was considered "dependent" by the earlier Swift compiler.
Introduce a deployment target check to guard the new optimization. Specifically, when building for a deployment target that predates Swift 6.0, treat conformances to marker protocols as if they might be dependent (so the access patterns go through
swift_getWitnessTablefor potential instantiation on older platforms). For newer deployment targets, use the more efficent direct access pattern.Fixes rdar://133157093, fixes #75155