-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Emit type metadata for foreign types more often #76011
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 smoke test |
623e284
to
1a968d7
Compare
@swift-ci please smoke test |
1a968d7
to
afc6195
Compare
Looks like emitting type metadata for foreing types on Windows is not supported at the moment. @swift-ci please smoke test |
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.
surface level from me, thanks for looking at my reported issue!
Metadata for foreign types are emitted lazily, when SILGen generates a reference to it. Unfortunately, C++ reverse interop can also introduce references to such metadata in the generated header when types are used as generic arguments. This adds a type visitor to make note of the type metadata use for those generic arguments in public APIs when C++ interop is enabled. rdar://132925256
afc6195
to
cdbe999
Compare
@swift-ci please smoke test |
@@ -2487,6 +2538,12 @@ void IRGenModule::emitSILFunction(SILFunction *f) { | |||
f->isAvailableExternally()) | |||
return; | |||
|
|||
// Type metadata for foreign references is not yet supported on Windows. Bug #76168. |
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.
Is there a reason that this is not supported on Windows?
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.
My understanding is that on Windows we end up requiring a metadata completion function for C++ foreign reference types. That logic just isn't implemented yet for C++ types.
Lines 6636 to 6639 in bd313de
void emitInitializeMetadata(IRGenFunction &IGF, llvm::Value *metadata, | |
MetadataDependencyCollector *collector) { | |
llvm_unreachable("Not implemented for foreign reference types."); | |
} |
@swift-ci please smoke test |
Only rerunning tests because the last completion was a long time ago (to make sure it does not conflict with anything added since then). |
@swift-ci please smoke test windows |
This is acceptable as a short-term workaround, but in the long term we don't want to be doing this. It is an important goal of C++ interop to be able to work with an arbitrary existing Swift module, which means we must not require the module to be emitted in a special way. Maybe we need some ability to emit a supporting .o when emitting a C++ interop header. |
Metadata for foreign types are emitted lazily, when SILGen generates a reference to it. Unfortunately, C++ reverse interop can also introduce references to such metadata in the generated header when types are used as generic arguments. This adds a type visitor to make note of the type metadata use for those generic arguments in public APIs when C++ interop is enabled. Fixes #75593
rdar://132925256