ruby-changes:72328
From: Nobuyoshi <ko1@a...>
Date: Mon, 27 Jun 2022 01:09:48 +0900 (JST)
Subject: [ruby-changes:72328] fc8020c68e (master): [Bug #18879] Fix macOS version detections
https://git.ruby-lang.org/ruby.git/commit/?id=fc8020c68e From fc8020c68eb9f640185a1bce322eba6605bde151 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 27 Jun 2022 00:20:21 +0900 Subject: [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. --- configure.ac | 19 ++++++++++++++++--- dln.c | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 6ddf78afeb..03677d85e2 100644 --- a/configure.ac +++ b/configure.ac @@ -3808,13 +3808,26 @@ AS_CASE(["$target_os"], https://github.com/ruby/ruby/blob/trunk/configure.ac#L3808 ], [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]) diff --git a/dln.c b/dln.c index 6fa68289dd..a31cbf936f 100644 --- a/dln.c +++ b/dln.c @@ -294,8 +294,21 @@ dln_incompatible_library_p(void *handle, const char **libname) https://github.com/ruby/ruby/blob/trunk/dln.c#L294 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) https://github.com/ruby/ruby/blob/trunk/dln.c#L321 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) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/