This is a conditional revert of https://github.com/llvm/llvm-project/commit/b653a2823fe4b4c9c6d85cfe119f31d8e70c2fa0.
__attribute__((weak_import)) does not prevent Undefined symbol error.

--- a/compiler-rt/lib/builtins/os_version_check.c.orig	2023-11-28 09:52:28.000000000 +0100
+++ b/compiler-rt/lib/builtins/os_version_check.c	2024-08-29 15:29:18.000000000 +0200
@@ -13,6 +13,7 @@
 
 #ifdef __APPLE__
 
+#include <AvailabilityMacros.h>
 #include <TargetConditionals.h>
 #include <dispatch/dispatch.h>
 #include <dlfcn.h>
@@ -86,9 +87,11 @@
                                             CFStringEncoding);
 typedef void (*CFReleaseFuncTy)(CFTypeRef);
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
 extern __attribute__((weak_import))
 bool _availability_version_check(uint32_t count,
                                  dyld_build_version_t versions[]);
+#endif
 
 static void _initializeAvailabilityCheck(bool LoadPlist) {
   if (AvailabilityVersionCheck && !LoadPlist) {
@@ -98,8 +101,14 @@
   }
 
   // Use the new API if it's is available.
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
   if (_availability_version_check)
     AvailabilityVersionCheck = &_availability_version_check;
+#else
+  // __attribute__((weak_import)) does not prevent Undefined symbol error on 10.14
+  AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym(
+      RTLD_DEFAULT, "_availability_version_check");
+#endif
 
   if (AvailabilityVersionCheck && !LoadPlist) {
     // New API is supported and we're not being asked to load the plist,
