Skip to content

Runtime: Fix condition for class stubs support #24188

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
Apr 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions stdlib/public/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,12 +2674,19 @@ _swift_initClassMetadataImpl(ClassMetadata *self,
setUpObjCRuntimeGetImageNameFromClass();
}, nullptr);

#ifndef OBJC_REALIZECLASSFROMSWIFT_DEFINED
// Temporary workaround until _objc_realizeClassFromSwift is in the SDK.
static auto _objc_realizeClassFromSwift =
(Class (*)(Class _Nullable, const void *_Nullable))
(Class (*)(Class _Nullable, void *_Nullable))
dlsym(RTLD_NEXT, "_objc_realizeClassFromSwift");
#endif

// Temporary workaround until objc_loadClassref is in the SDK.
static auto objc_loadClassref =
(Class (*)(void *))
dlsym(RTLD_NEXT, "objc_loadClassref");
#endif

// Copy field offsets, generic arguments and (if necessary) vtable entries
// from our superclass.
copySuperclassMetadataToSubclass(self, layoutFlags);
Expand All @@ -2705,12 +2712,13 @@ _swift_initClassMetadataImpl(ClassMetadata *self,
// however we should not be using it for anything in a non-generic
// class.
if (auto *stub = description->getObjCResilientClassStub()) {
if (_objc_realizeClassFromSwift == nullptr) {
if (_objc_realizeClassFromSwift == nullptr ||
objc_loadClassref == nullptr) {
fatalError(0, "class %s requires missing Objective-C runtime feature; "
"the deployment target was newer than this OS\n",
self->getDescription()->Name.get());
}
_objc_realizeClassFromSwift((Class) self, stub);
_objc_realizeClassFromSwift((Class) self, const_cast<void *>(stub));
} else
swift_instantiateObjCClass(self);
}
Expand Down Expand Up @@ -2762,7 +2770,7 @@ _swift_updateClassMetadataImpl(ClassMetadata *self,
#ifndef OBJC_REALIZECLASSFROMSWIFT_DEFINED
// Temporary workaround until _objc_realizeClassFromSwift is in the SDK.
static auto _objc_realizeClassFromSwift =
(Class (*)(Class _Nullable, const void *_Nullable))
(Class (*)(Class _Nullable, void *_Nullable))
dlsym(RTLD_NEXT, "_objc_realizeClassFromSwift");
#endif

Expand Down