[PATCH] D150397: [darwin] Declare _availability_version_check as weak_import instead of looking it up at runtime using dlsym

Akira Hatanaka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 17:23:24 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb653a2823fe4: Declare _availability_version_check as weak_import instead of looking it (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150397/new/

https://reviews.llvm.org/D150397

Files:
  compiler-rt/lib/builtins/os_version_check.c


Index: compiler-rt/lib/builtins/os_version_check.c
===================================================================
--- compiler-rt/lib/builtins/os_version_check.c
+++ compiler-rt/lib/builtins/os_version_check.c
@@ -86,6 +86,10 @@
                                             CFStringEncoding);
 typedef void (*CFReleaseFuncTy)(CFTypeRef);
 
+extern __attribute__((weak_import))
+bool _availability_version_check(uint32_t count,
+                                 dyld_build_version_t versions[]);
+
 static void _initializeAvailabilityCheck(bool LoadPlist) {
   if (AvailabilityVersionCheck && !LoadPlist) {
     // New API is supported and we're not being asked to load the plist,
@@ -94,8 +98,8 @@
   }
 
   // Use the new API if it's is available.
-  AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym(
-      RTLD_DEFAULT, "_availability_version_check");
+  if (_availability_version_check)
+    AvailabilityVersionCheck = &_availability_version_check;
 
   if (AvailabilityVersionCheck && !LoadPlist) {
     // New API is supported and we're not being asked to load the plist,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150397.521508.patch
Type: text/x-patch
Size: 1099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/db3c723e/attachment.bin>


More information about the llvm-commits mailing list