-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop][IRGen] Emit type metadata accessors correctly #74208
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
Conversation
@swift-ci please test |
@@ -1102,9 +1102,6 @@ MetadataAccessStrategy irgen::getTypeMetadataAccessStrategy(CanType type) { | |||
assert(type->hasUnboundGenericType()); | |||
} | |||
|
|||
if (type->isForeignReferenceType()) | |||
return MetadataAccessStrategy::PublicUniqueAccessor; | |||
|
|||
if (requiresForeignTypeMetadata(nominal)) | |||
return MetadataAccessStrategy::ForeignAccessor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what needs to be returned for a C++ reference type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. We were lazily emitting the type metadata when we first referenced in, but we were emitting it with strong linkage? Yes, this is the right fix, then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right
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
6a4f7a0
to
a5ce0dc
Compare
@swift-ci please smoke test |
…-metadata-accessor [cxx-interop][IRGen] Emit type metadata accessors correctly
…-metadata-accessor [cxx-interop][IRGen] Emit type metadata accessors correctly
…-metadata-accessor [cxx-interop][IRGen] Emit type metadata accessors correctly
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:
rdar://129027705