[ORC-RT] Don't check for objc image registration functions unless needed.
authorLang Hames <lhames@gmail.com>
Mon, 17 Apr 2023 20:40:42 +0000 (13:40 -0700)
committerLang Hames <lhames@gmail.com>
Mon, 17 Apr 2023 20:51:33 +0000 (13:51 -0700)
If we don't have any ObjC metadata to register we shouldn't require these
symbols to be available.

compiler-rt/lib/orc/macho_platform.cpp

index 33f7fbb..cb248aa 100644 (file)
@@ -861,15 +861,18 @@ Error MachOPlatformRuntimeState::registerObjCRegistrationObjects(
     JITDylibState &JDS) {
   ORC_RT_DEBUG(printdbg("Registering Objective-C / Swift metadata.\n"));
 
+  std::vector<char *> RegObjBases;
+  JDS.ObjCRuntimeRegistrationObjects.processNewSections(
+      [&](span<char> RegObj) { RegObjBases.push_back(RegObj.data()); });
+
+  if (RegObjBases.empty())
+    return Error::success();
+
   if (!_objc_map_images || !_objc_load_image)
     return make_error<StringError>(
         "Could not register Objective-C / Swift metadata: _objc_map_images / "
         "_objc_load_image not found");
 
-  std::vector<char *> RegObjBases;
-  JDS.ObjCRuntimeRegistrationObjects.processNewSections(
-      [&](span<char> RegObj) { RegObjBases.push_back(RegObj.data()); });
-
   std::vector<char *> Paths;
   Paths.resize(RegObjBases.size());
   _objc_map_images(RegObjBases.size(), Paths.data(),