]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Darwin: Pass -macos_version_min to the linker [PR119172].
authorIain Sandoe <iain@sandoe.co.uk>
Sun, 9 Mar 2025 09:24:34 +0000 (09:24 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Sun, 16 Mar 2025 14:23:19 +0000 (14:23 +0000)
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.

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.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 36f5ea5806d246d78555e65273a057718833e3cd)

gcc/config.in
gcc/config/darwin.h
gcc/configure
gcc/configure.ac

index 2e7e0fe9942c84713ccca8cb157b2b04ac59420c..0b46faa1e512123ab65f848d8dac9bde971ca123 100644 (file)
 #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
index 328d878ca1183252f0006f105bc8e64d14b86d0a..3d2ced5fca311e93b9a53bed8473ec95e6e4f0a3 100644 (file)
@@ -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
index a34ae586d9088329d191387957d94886846a73d1..57640f92789f5e6aa4e261cc4c4499f13699d180 100755 (executable)
@@ -32650,6 +32650,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
@@ -32682,6 +32683,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.
@@ -32720,6 +32722,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_macosx_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_macosx_version_min=0
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_macosx_version_min" >&5
+$as_echo "$gcc_cv_ld64_macosx_version_min" >&6; }
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -32747,6 +32758,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_macosx_version_min
+_ACEOF
+
 fi
 
 if test x"$dsymutil_flag" = x"yes"; then
index 7e78ed6e1d9ef92e24163d2982f32ba999a1a87c..be77c182f9626f800de653f8686719cc119ff776 100644 (file)
@@ -6358,6 +6358,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
@@ -6388,6 +6389,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.
@@ -6418,6 +6420,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_macosx_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_macosx_version_min=0
+    fi
+    AC_MSG_RESULT($gcc_cv_ld64_macosx_version_min)
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -6433,6 +6442,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_macosx_version_min,
+  [Define to 1 if ld64 supports '-macos_version_min'.])
 fi
 
 if test x"$dsymutil_flag" = x"yes"; then