Skip to content

🍒[cxx-interop] Import CF_OPTIONS types such as Foundation.NSTextCheckingType correctly #67308

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 15, 2023

Conversation

egorzhdan
Copy link
Contributor

Explanation: This fixes linker errors which occurred when using Foundation extensions to Swift.String, such as func replacingOccurrences. After the last rebranch, Clang started wrapping certain types in clang::ElaboratedType. This caused CF_OPTIONS types such as Foundation.NSTextCheckingType to be imported incorrectly in C++ language mode (NSTextCheckingType was imported as uint64_t without getting the special treatment of a CF type), which was causing deserialization errors when Swift tried reading Foundation.swiftmodule. Those deserialization errors were silenced by default. The IR for those functions was not emitted, which caused linker errors later.
Scope: This teaches ClangImporter to unwrap clang::ElaboratedType when it handles CF typedefs.
Risk: Low, this brings back the pre-rebranch behavior.

Original PR: #67301

rdar://109830032
(cherry picked from commit e6b830b)

…ingType` correctly

This fixes linker errors which occurred when using Foundation extensions to `Swift.String`, such as `func replacingOccurrences`.

After the last rebranch, Clang started wrapping certain types in `clang::ElaboratedType`. This caused CF_OPTIONS types such as `Foundation.NSTextCheckingType` to be imported incorrectly in C++ language mode (`NSTextCheckingType` was imported as `uint64_t` without getting the special treatment of a CF type), which was causing deserialization errors when Swift tried reading `Foundation.swiftmodule`. Those deserialization errors were silenced by default. The IR for those functions was not emitted, which caused linker errors later.

rdar://109830032
(cherry picked from commit e6b830b)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jul 14, 2023
@egorzhdan egorzhdan requested a review from a team as a code owner July 14, 2023 19:40
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@ravikandhadai ravikandhadai left a comment

Choose a reason for hiding this comment

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

Thanks Egor.

@egorzhdan egorzhdan merged commit 59af451 into release/5.9 Jul 15, 2023
@egorzhdan egorzhdan deleted the egorzhdan/5.9-foundation-linker-errors branch July 15, 2023 01:46
@plotfi
Copy link
Contributor

plotfi commented Jul 21, 2023

Thanks @egorzhdan. This looks like a similar change to something I added in the mangler. I wonder if these can be consolidated?

@egorzhdan
Copy link
Contributor Author

@plotfi do you mean landing them both in the 5.9 release branch?

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.

3 participants