1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[Bug #18879] Fix macOS version detections

macOS's AvailabilityMacros.h does not contain macros for future
versions.  If a version macro is not defined, consider only earlier
versions to be targeted.
This commit is contained in:
Nobuyoshi Nakada 2022-06-27 00:20:21 +09:00
parent 49d5921550
commit fc8020c68e
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 31 additions and 7 deletions

View file

@ -3808,13 +3808,26 @@ AS_CASE(["$target_os"],
],
[darwin*], [
RUBY_APPEND_OPTION(CFLAGS, -pipe)
AC_MSG_CHECKING([whether Security framework is needed])
AC_COMPILE_IFELSE([
AC_LANG_BOOL_COMPILE_TRY([@%:@include <AvailabilityMacros.h>],
[MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 &&
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10])],
AC_LANG_BOOL_COMPILE_TRY([
@%:@include <AvailabilityMacros.h>
enum {
least = MAC_OS_X_VERSION_10_7, /* just fail if undefined */
required = MAC_OS_X_VERSION_MIN_REQUIRED,
upper /* bigger than MIN_REQUIRED, or */
@%:@ifdef MAC_OS_X_VERSION_10_10
= MAC_OS_X_VERSION_10_10
@%:@endif
};],
[required >= least && required < upper])],
[dnl
AC_MSG_RESULT(yes)
RUBY_APPEND_OPTION(XLDFLAGS, [-framework Security])
RUBY_APPEND_OPTION(LIBRUBYARG_STATIC, [-framework Security])
],dnl
[dnl
AC_MSG_RESULT(no)
]dnl
)
RUBY_APPEND_OPTION(XLDFLAGS, [-framework CoreFoundation])

19
dln.c
View file

@ -294,8 +294,21 @@ dln_incompatible_library_p(void *handle, const char **libname)
COMPILER_WARNING_POP
#endif
#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11)
#if !defined(MAC_OS_X_VERSION_MIN_REQUIRED)
/* assume others than old Mac OS X have no problem */
# define dln_disable_dlclose() false
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
/* targeting newer versions only */
# define dln_disable_dlclose() false
#elif !defined(MAC_OS_X_VERSION_10_11) || \
(MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11)
/* targeting older versions only */
# define dln_disable_dlclose() true
#else
/* support both versions, and check at runtime */
# include <sys/sysctl.h>
static bool
@ -308,8 +321,6 @@ dln_disable_dlclose(void)
if (rev < MAC_OS_X_VERSION_10_11) return true;
return false;
}
#else
# define dln_disable_dlclose() false
#endif
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)