Skip to content

[6.2] Lower imported C structs and unions as addressable-for-dependencies. #82843

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 1 commit into from
Jul 8, 2025

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Jul 7, 2025

Explanation: This causes the compiler to emit imported C types as "addressable-for-dependencies", which ensures we will represent arguments with dependent borrows as pointers, simplifying C interop if we introduce first-class borrows in the future.
Scope: ABI work for future language features.
Issue: rdar://153648393
Original PR: #82707
Risk: Low. No effect on code today; sets up an ABI rule we can take advantage of in future OSes.
Testing: Swift CI
Reviewers: @Xazax-hun

C code is highly likely to want to use pointers as references between dependent
structs, and we would like to be able to readily map these to lifetime-dependent
Swift values. Making C types addressable-for-dependencies ensures that any function
producing a dependency on such a value receives a stable in-memory address for that
value, allowing borrows and inout accesses to always be representable as pointers.

rdar://153648393
@jckarter jckarter requested a review from a team as a code owner July 7, 2025 16:02
@jckarter
Copy link
Contributor Author

jckarter commented Jul 7, 2025

@swift-ci Please test

@jckarter
Copy link
Contributor Author

jckarter commented Jul 7, 2025

@swift-ci Please test Windows

1 similar comment
@jckarter
Copy link
Contributor Author

jckarter commented Jul 7, 2025

@swift-ci Please test Windows

@jckarter jckarter merged commit 8bf8b54 into swiftlang:release/6.2 Jul 8, 2025
5 checks passed
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.

3 participants