Skip to content

[6.2][cxx-interop] Types exposed from ObjC modules should be behind a macro #83065

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

Open
wants to merge 2 commits into
base: release/6.2
Choose a base branch
from

Conversation

Xazax-hun
Copy link
Contributor

@Xazax-hun Xazax-hun commented Jul 15, 2025

Explanation: We the generated reverse interop headers to be valid C++, so every declaration coming from an Obj-C module should be behind an ifdef. Unfortunately, we do not always have this information. So this PR introduces an experimental flag to determine which modules should be considered ObjC.
Issues: rdar://152836730
Original PRs: #83002, #83130
Risk: Low, the change is noop for users not using the flag and not having requires objc in their modulemap.
Testing: Added a compiler test.
Reviewers: @egorzhdan

@Xazax-hun Xazax-hun requested a review from a team as a code owner July 15, 2025 16:23
@Xazax-hun Xazax-hun added c++ interop Feature: Interoperability with C++ 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jul 15, 2025
… macro

Explanation: We the generated reverse interop headers to be valid C++,
so every declaration coming from an Obj-C module should be behind an
ifdef. Unfortunately, we do not always have this information but we do
know that our frameworks contain Obj-C code. So this PR makes sure every
entity coming from our frameworks are behind ifdef.
Issues: rdar://152836730
Original PRs: swiftlang#83002
Risk: Low, the change is narrow and straightforward.
Testing: Added a compiler test.
Reviewers: @egorzhdan
@Xazax-hun Xazax-hun force-pushed the guard-more-objc-on-6.2 branch from a8130d8 to ab12392 Compare July 16, 2025 10:20
We sometimes don't have the information in the modulemaps whether a
module requires ObjC or not. This info is useful for reverse interop.
This PR introduces a frontend flag to have a comma separated list of
modules that we should import as if they had "requires ObjC" in their
modulemaps.
@Xazax-hun
Copy link
Contributor Author

@swift-ci please test

@Xazax-hun Xazax-hun requested a review from DougGregor July 18, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant