https://gcc.gnu.org/g:86b51d7287e9e12e9f9936f376537545e31ee03a

commit r14-11711-g86b51d7287e9e12e9f9936f376537545e31ee03a
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Sun Mar 9 09:24:34 2025 +0000

    Darwin: Pass -macos_version_min to the linker [PR119172].
    
    For binaries to be notarised, the SDK version must be available.
    Since we do not, at present, parse this information we have been
    passing "0.0" to ld64.  This now results in a warning and a fail
    to notarise.  As a quick-fix, we can fall back to letting ld64
    figure out the SDK version (which it does for -macos_version_min).
    
    TODO: Parse the SDKSetting.plist at some point.
    
    cherry-picked from 952e17223d3a9 and fc728cfd569e291a5
    
            PR target/119172
    
    gcc/ChangeLog:
    
            * config.in: Regenerate.
            * config/darwin.h (DARWIN_PLATFORM_ID): Add the option to
            use -macos_version_min where available.
            * configure: Regenerate.
            * configure.ac: Check for ld64 support of -macos_version_min.
    
    Co-authored-by: Andrew Pinski <quic_apin...@quicinc.com>
    
    Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Diff:
---
 gcc/config.in       |  6 ++++++
 gcc/config/darwin.h | 13 +++++++++----
 gcc/configure       | 17 +++++++++++++++++
 gcc/configure.ac    | 12 ++++++++++++
 4 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index df598c80bb2a..3daa90be0e8b 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2296,6 +2296,12 @@
 #endif
 
 
+/* Define to 1 if ld64 supports '-macos_version_min'. */
+#ifndef USED_FOR_TARGET
+#undef LD64_HAS_MACOS_VERSION_MIN
+#endif
+
+
 /* Define to 1 if ld64 supports '-platform_version'. */
 #ifndef USED_FOR_TARGET
 #undef LD64_HAS_PLATFORM_VERSION
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 0d8886c026c6..e7a6f5433ce3 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -284,12 +284,17 @@ extern GTY(()) int darwin_ms_struct;
 #define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
 #endif
 
-#if LD64_HAS_PLATFORM_VERSION
-#define DARWIN_PLATFORM_ID \
-  "%{mmacosx-version-min=*: -platform_version macos %* 0.0} "
+#if LD64_HAS_MACOS_VERSION_MIN
+# define DARWIN_PLATFORM_ID \
+  "%{mmacosx-version-min=*:-macos_version_min %*} "
 #else
-#define DARWIN_PLATFORM_ID \
+# if LD64_HAS_PLATFORM_VERSION
+#  define DARWIN_PLATFORM_ID \
+  "%{mmacosx-version-min=*: -platform_version macos %* 0.0} "
+# else
+#  define DARWIN_PLATFORM_ID \
   "%{mmacosx-version-min=*:-macosx_version_min %*} "
+# endif
 #endif
 
 /* Code built with mdynamic-no-pic does not support PIE/PIC, so  we disallow
diff --git a/gcc/configure b/gcc/configure
index 091b5f1f11fe..4e9c65225d34 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -32741,6 +32741,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
+  gcc_cv_ld64_macos_version_min=0
   gcc_cv_ld64_demangle=0
 
   if test "$build" = "$host"; then
@@ -32773,6 +32774,7 @@ $as_echo "$gcc_cv_ld64_major" >&6; }
     fi
     if test "$gcc_cv_ld64_major" -ge 512; then
       gcc_cv_ld64_platform_version=1
+      gcc_cv_ld64_macos_version_min=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.
@@ -32811,6 +32813,15 @@ $as_echo_n "checking linker for -platform_version 
support... " >&6; }
     fi
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_ld64_platform_version" >&5
 $as_echo "$gcc_cv_ld64_platform_version" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for 
-macos_version_min" >&5
+$as_echo_n "checking linker for -macos_version_min... " >&6; }
+    gcc_cv_ld64_macos_version_min=1
+    if $gcc_cv_ld -macos_version_min 10.5 < /dev/null 2>&1 | grep 'unknown 
option' > /dev/null; then
+      gcc_cv_ld64_macos_version_min=0
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_ld64_macos_version_min" >&5
+$as_echo "$gcc_cv_ld64_macos_version_min" >&6; }
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -32838,6 +32849,12 @@ cat >>confdefs.h <<_ACEOF
 #define LD64_HAS_PLATFORM_VERSION $gcc_cv_ld64_platform_version
 _ACEOF
 
+
+
+cat >>confdefs.h <<_ACEOF
+#define LD64_HAS_MACOS_VERSION_MIN $gcc_cv_ld64_macos_version_min
+_ACEOF
+
 fi
 
 if test x"$dsymutil_flag" = x"yes"; then
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 0986853fecdf..89d927cf0ac2 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6430,6 +6430,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
+  gcc_cv_ld64_macos_version_min=0
   gcc_cv_ld64_demangle=0
 
   if test "$build" = "$host"; then
@@ -6460,6 +6461,7 @@ if test x"$ld64_flag" = x"yes"; then
     fi
     if test "$gcc_cv_ld64_major" -ge 512; then
       gcc_cv_ld64_platform_version=1
+      gcc_cv_ld64_macos_version_min=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.
@@ -6490,6 +6492,13 @@ if test x"$ld64_flag" = x"yes"; then
       gcc_cv_ld64_platform_version=0
     fi
     AC_MSG_RESULT($gcc_cv_ld64_platform_version)
+
+    AC_MSG_CHECKING(linker for -macos_version_min)
+    gcc_cv_ld64_macos_version_min=1
+    if $gcc_cv_ld -macos_version_min 10.5 < /dev/null 2>&1 | grep 'unknown 
option' > /dev/null; then
+      gcc_cv_ld64_macos_version_min=0
+    fi
+    AC_MSG_RESULT($gcc_cv_ld64_macos_version_min)
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -6505,6 +6514,9 @@ if test x"$ld64_flag" = x"yes"; then
 
   AC_DEFINE_UNQUOTED(LD64_HAS_PLATFORM_VERSION, $gcc_cv_ld64_platform_version,
   [Define to 1 if ld64 supports '-platform_version'.])
+
+  AC_DEFINE_UNQUOTED(LD64_HAS_MACOS_VERSION_MIN, 
$gcc_cv_ld64_macos_version_min,
+  [Define to 1 if ld64 supports '-macos_version_min'.])
 fi
 
 if test x"$dsymutil_flag" = x"yes"; then

Reply via email to