Skip to content

🍒[cxx-interop] Workaround compiler error when importing CoreGraphics with C++ interop #78657

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
Jan 17, 2025

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jan 15, 2025

Explanation: The CoreGraphics overlay refers to symbols declared via CF_OPTIONS macro, which is causing issues in C++ language mode due to the macro definition being different.
This teaches the module interface loader to drop the C++ interop flag when rebuilding the CoreGraphics overlay from its interface.
Scope: This changes the compiler flags used to rebuild CoreGraphics when C++ interop is enabled.
Risk: Low, this only affects rebuilding of a single SDK module from its interface when C++ interop is enabled.
Testing: Added anew compiler test.
Issue: rdar://142762174
Reviewer: @Xazax-hun

Original PR: #78636

…ith C++ interop

The CoreGraphics overlay refers to symbols declared via `CF_OPTIONS` macro, which is causing issues in C++ language mode due to the macro definition being different.

This teaches the module interface loader to drop the C++ interop flag when rebuilding the CoreGraphics overlay from its interface.

rdar://142762174
(cherry picked from commit d72006e)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jan 15, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review January 15, 2025 15:46
@egorzhdan egorzhdan requested a review from a team as a code owner January 15, 2025 15:46
if (moduleName == "Darwin") {
// FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
// of a CF_OPTIONS bug (rdar://142762174).
if (moduleName == "Darwin" || moduleName == "CoreGraphics") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hoist this out of the compiler and into arguments? I suspect that there will be a number of other modules that need this behaviour (I can see submodules in WinSDK wanting this as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what would be the case where we would want to apply this to a WinSDK module?

This isn't intended to be something accessible via a compiler flag, since it might result in linker errors if you try using any of the problematic types from Swift. In this case the CF_OPTIONS types are triggering a compiler bug when C++ interop is enabled, which is a bug that we'll need to fix.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @compnerd said, this is likely to affect other modules, so while I'm going to approve this to address the regression, I'd like us to find either a general solution to the underlying problem or to make it easier to extend the list of modules that need this workaround.

@egorzhdan egorzhdan merged commit 0565209 into release/6.1 Jan 17, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.1-coregraphics-workaround branch January 17, 2025 15:50
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++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants