Skip to content

🍒[cxx-interop][IRGen] Emit type metadata accessors correctly #74224

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

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jun 7, 2024

Explanation: This makes sure we correctly emit IR for type metadata accessors for C++ reference types: This fixes linker errors when a type metadata of a C++ reference type is used in multiple object files that are later linked together, for instance, if a C++ reference type is conformed to different Swift protocols in different Swift source files:

duplicate symbol 'type metadata accessor for __C.SharedObject' in:
  main.o
  second.o
ld: 1 duplicate symbols

Scope: Changes IRGen of type metadata for C++ reference types only.
Risk: Low, only affects C++ foreign reference types.
Testing: Added a compile test.
Issue: rdar://129027705
Reviewer: @rjmccall

Original PR: #74208

This change makes sure we correctly emit IR for type metadata accessors for C++ reference types.

This fixes linker errors when a type metadata of a C++ reference type is used in multiple object files that are later linked together, for instance, if a C++ reference type is conformed to different Swift protocols in different Swift source files:
```
duplicate symbol 'type metadata accessor for __C.SharedObject' in:
  main.o
  second.o
ld: 1 duplicate symbols
```

rdar://129027705
(cherry picked from commit a5ce0dc)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 7, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review June 7, 2024 21:55
@egorzhdan egorzhdan requested a review from a team as a code owner June 7, 2024 21:55
@egorzhdan egorzhdan changed the title [cxx-interop][IRGen] Emit type metadata accessors correctly 🍒[cxx-interop][IRGen] Emit type metadata accessors correctly Jun 7, 2024
@egorzhdan egorzhdan merged commit b2f4e80 into release/6.0 Jun 8, 2024
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.0-frt-duplicate-metadata-accessor branch June 8, 2024 15:59
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.

2 participants