From d3cc82dc9cc2d4f1021fc5d4c1463c3a14fc6795 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Fri, 12 Nov 2021 17:03:09 +0000 Subject: [PATCH] configure, Darwin: Check ld64 support for -platform-version. Newer versions of ld64 allow specifiying the OS target (e.g. macos or ios) the version and the SDK version all in a single command. This checks the availability of the command for the current toolchain. Signed-off-by: Iain Sandoe gcc/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Test ld64 for -platform-version support. --- gcc/config.in | 6 ++++++ gcc/configure | 21 ++++++++++++++++++++- gcc/configure.ac | 16 +++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index b5bec39..d6adc72 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -2226,6 +2226,12 @@ #endif +/* Define to 1 if ld64 supports '-platform_version'. */ +#ifndef USED_FOR_TARGET +#undef LD64_HAS_PLATFORM_VERSION +#endif + + /* Define to ld64 version. */ #ifndef USED_FOR_TARGET #undef LD64_VERSION diff --git a/gcc/configure b/gcc/configure index 920868b..74b9d9b 100755 --- a/gcc/configure +++ b/gcc/configure @@ -30398,6 +30398,7 @@ if test x"$ld64_flag" = x"yes"; then # Set defaults for possibly untestable items. gcc_cv_ld64_export_dynamic=0 + gcc_cv_ld64_platform_version=0 if test "$build" = "$host"; then darwin_try_test=1 @@ -30421,9 +30422,12 @@ $as_echo_n "checking ld64 specified version... " >&6; } gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_major" >&5 $as_echo "$gcc_cv_ld64_major" >&6; } - if test "$gcc_cv_ld64_major" -ge 236; then + if test "$gcc_cv_ld64_major" -ge 236; then gcc_cv_ld64_export_dynamic=1 fi + if test "$gcc_cv_ld64_major" -ge 512; then + gcc_cv_ld64_platform_version=1 + fi elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then # If the version was not specified, try to find it. { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker version" >&5 @@ -30442,6 +30446,15 @@ $as_echo_n "checking linker for -export_dynamic support... " >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_export_dynamic" >&5 $as_echo "$gcc_cv_ld64_export_dynamic" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -platform_version support" >&5 +$as_echo_n "checking linker for -platform_version support... " >&6; } + gcc_cv_ld64_platform_version=1 + if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then + gcc_cv_ld64_platform_version=0 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_platform_version" >&5 +$as_echo "$gcc_cv_ld64_platform_version" >&6; } fi if test x"${gcc_cv_ld64_version}" != x; then @@ -30457,6 +30470,12 @@ cat >>confdefs.h <<_ACEOF #define LD64_HAS_EXPORT_DYNAMIC $gcc_cv_ld64_export_dynamic _ACEOF + + +cat >>confdefs.h <<_ACEOF +#define LD64_HAS_PLATFORM_VERSION $gcc_cv_ld64_platform_version +_ACEOF + fi if test x"$dsymutil_flag" = x"yes"; then diff --git a/gcc/configure.ac b/gcc/configure.ac index 065080a..c9ee1fb 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6253,6 +6253,7 @@ if test x"$ld64_flag" = x"yes"; then # Set defaults for possibly untestable items. gcc_cv_ld64_export_dynamic=0 + gcc_cv_ld64_platform_version=0 if test "$build" = "$host"; then darwin_try_test=1 @@ -6274,9 +6275,12 @@ if test x"$ld64_flag" = x"yes"; then AC_MSG_CHECKING(ld64 specified version) gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'` AC_MSG_RESULT($gcc_cv_ld64_major) - if test "$gcc_cv_ld64_major" -ge 236; then + if test "$gcc_cv_ld64_major" -ge 236; then gcc_cv_ld64_export_dynamic=1 fi + if test "$gcc_cv_ld64_major" -ge 512; then + gcc_cv_ld64_platform_version=1 + fi elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then # If the version was not specified, try to find it. AC_MSG_CHECKING(linker version) @@ -6291,6 +6295,13 @@ if test x"$ld64_flag" = x"yes"; then gcc_cv_ld64_export_dynamic=0 fi AC_MSG_RESULT($gcc_cv_ld64_export_dynamic) + + AC_MSG_CHECKING(linker for -platform_version support) + gcc_cv_ld64_platform_version=1 + if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then + gcc_cv_ld64_platform_version=0 + fi + AC_MSG_RESULT($gcc_cv_ld64_platform_version) fi if test x"${gcc_cv_ld64_version}" != x; then @@ -6300,6 +6311,9 @@ if test x"$ld64_flag" = x"yes"; then AC_DEFINE_UNQUOTED(LD64_HAS_EXPORT_DYNAMIC, $gcc_cv_ld64_export_dynamic, [Define to 1 if ld64 supports '-export_dynamic'.]) + + AC_DEFINE_UNQUOTED(LD64_HAS_PLATFORM_VERSION, $gcc_cv_ld64_platform_version, + [Define to 1 if ld64 supports '-platform_version'.]) fi if test x"$dsymutil_flag" = x"yes"; then -- 2.7.4