Skip to content

Commit bc4d70c

Browse files
committed
Runtime: Fix condition for class stubs support
Fixes <rdar://problem/50068190>.
1 parent 4a98214 commit bc4d70c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,12 +2674,19 @@ _swift_initClassMetadataImpl(ClassMetadata *self,
26742674
setUpObjCRuntimeGetImageNameFromClass();
26752675
}, nullptr);
26762676

2677+
#ifndef OBJC_REALIZECLASSFROMSWIFT_DEFINED
26772678
// Temporary workaround until _objc_realizeClassFromSwift is in the SDK.
26782679
static auto _objc_realizeClassFromSwift =
2679-
(Class (*)(Class _Nullable, const void *_Nullable))
2680+
(Class (*)(Class _Nullable, void *_Nullable))
26802681
dlsym(RTLD_NEXT, "_objc_realizeClassFromSwift");
26812682
#endif
26822683

2684+
// Temporary workaround until objc_loadClassref is in the SDK.
2685+
static auto objc_loadClassref =
2686+
(Class (*)(void *))
2687+
dlsym(RTLD_NEXT, "objc_loadClassref");
2688+
#endif
2689+
26832690
// Copy field offsets, generic arguments and (if necessary) vtable entries
26842691
// from our superclass.
26852692
copySuperclassMetadataToSubclass(self, layoutFlags);
@@ -2705,12 +2712,13 @@ _swift_initClassMetadataImpl(ClassMetadata *self,
27052712
// however we should not be using it for anything in a non-generic
27062713
// class.
27072714
if (auto *stub = description->getObjCResilientClassStub()) {
2708-
if (_objc_realizeClassFromSwift == nullptr) {
2715+
if (_objc_realizeClassFromSwift == nullptr ||
2716+
objc_loadClassref == nullptr) {
27092717
fatalError(0, "class %s requires missing Objective-C runtime feature; "
27102718
"the deployment target was newer than this OS\n",
27112719
self->getDescription()->Name.get());
27122720
}
2713-
_objc_realizeClassFromSwift((Class) self, stub);
2721+
_objc_realizeClassFromSwift((Class) self, const_cast<void *>(stub));
27142722
} else
27152723
swift_instantiateObjCClass(self);
27162724
}
@@ -2762,7 +2770,7 @@ _swift_updateClassMetadataImpl(ClassMetadata *self,
27622770
#ifndef OBJC_REALIZECLASSFROMSWIFT_DEFINED
27632771
// Temporary workaround until _objc_realizeClassFromSwift is in the SDK.
27642772
static auto _objc_realizeClassFromSwift =
2765-
(Class (*)(Class _Nullable, const void *_Nullable))
2773+
(Class (*)(Class _Nullable, void *_Nullable))
27662774
dlsym(RTLD_NEXT, "_objc_realizeClassFromSwift");
27672775
#endif
27682776

0 commit comments

Comments
 (0)