diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-06-27 00:20:21 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-06-27 01:08:46 +0900 |
commit | fc8020c68eb9f640185a1bce322eba6605bde151 (patch) | |
tree | f9dabc4f90622bebc268f0824a7a4c5b01834e2d | |
parent | 49d59215506a30c8a11766627f7af0cdfe0de9d4 (diff) | |
download | ruby-fc8020c68eb9f640185a1bce322eba6605bde151.tar.gz |
[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.
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | 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"], ], [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]) @@ -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) |