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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,

// FIXME: Hack for Darwin.swiftmodule, which cannot be rebuilt with C++
// interop enabled by the Swift CI because it uses an old host SDK.
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.

subInvocation.getLangOptions().EnableCXXInterop = false;
subInvocation.getLangOptions().cxxInteropCompatVersion = {};
BuildArgs.erase(llvm::remove_if(BuildArgs,
Expand Down
9 changes: 9 additions & 0 deletions test/Interop/Cxx/objc-correctness/coregraphics.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s

// REQUIRES: objc_interop
// REQUIRES: VENDOR=apple

import CoreGraphics

var _: CGBitmapInfo! = nil