Skip to content

Commit 5665927

Browse files
committed
[cxx-interop] Workaround compiler error when importing CoreGraphics with 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)
1 parent 7b29c84 commit 5665927

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
21932193

21942194
// FIXME: Hack for Darwin.swiftmodule, which cannot be rebuilt with C++
21952195
// interop enabled by the Swift CI because it uses an old host SDK.
2196-
if (moduleName == "Darwin") {
2196+
// FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
2197+
// of a CF_OPTIONS bug (rdar://142762174).
2198+
if (moduleName == "Darwin" || moduleName == "CoreGraphics") {
21972199
subInvocation.getLangOptions().EnableCXXInterop = false;
21982200
subInvocation.getLangOptions().cxxInteropCompatVersion = {};
21992201
BuildArgs.erase(llvm::remove_if(BuildArgs,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: VENDOR=apple
5+
6+
import CoreGraphics
7+
8+
var _: CGBitmapInfo! = nil
9+

0 commit comments

Comments
 (0)