diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2023-05-11 17:22:49 -0700 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2023-05-11 17:22:50 -0700 |
commit | b653a2823fe4b4c9c6d85cfe119f31d8e70c2fa0 (patch) | |
tree | 750f0e567331a19559628a30462619278ed10465 /compiler-rt | |
parent | ba566fffb205a338c0a6e382b64d84b3a1e21fb6 (diff) | |
download | llvm-b653a2823fe4b4c9c6d85cfe119f31d8e70c2fa0.tar.gz |
Declare _availability_version_check as weak_import instead of looking it
up at runtime using dlsym
Calling dlsym with RTLD_DEFAULT can be very slow as all images in the
process are searched for the symbol.
Differential Revision: https://reviews.llvm.org/D150397
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/builtins/os_version_check.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler-rt/lib/builtins/os_version_check.c b/compiler-rt/lib/builtins/os_version_check.c index ebfb2dfc72dd..182eabe7a6ae 100644 --- a/compiler-rt/lib/builtins/os_version_check.c +++ b/compiler-rt/lib/builtins/os_version_check.c @@ -86,6 +86,10 @@ typedef Boolean (*CFStringGetCStringFuncTy)(CFStringRef, char *, CFIndex, 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 @@ static void _initializeAvailabilityCheck(bool LoadPlist) { } // 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, |