Skip to content

Commit 6948dfe

Browse files
committed
Runtime: Fix condition for class stubs support
Fixes <rdar://problem/50068190>.
1 parent c374044 commit 6948dfe

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
@@ -2673,12 +2673,19 @@ _swift_initClassMetadataImpl(ClassMetadata *self,
26732673
setUpObjCRuntimeGetImageNameFromClass();
26742674
}, nullptr);
26752675

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

2683+
// Temporary workaround until objc_loadClassref is in the SDK.
2684+
static auto objc_loadClassref =
2685+
(Class (*)(void *))
2686+
dlsym(RTLD_NEXT, "objc_loadClassref");
2687+
#endif
2688+
26822689
// Copy field offsets, generic arguments and (if necessary) vtable entries
26832690
// from our superclass.
26842691
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)