Skip to content

Commit 952e172

Browse files
committed
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. 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 <[email protected]> (cherry picked from commit 36f5ea5806d246d78555e65273a057718833e3cd)
1 parent 348d41e commit 952e172

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

gcc/config.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,12 @@
23322332
#endif
23332333

23342334

2335+
/* Define to 1 if ld64 supports '-macos_version_min'. */
2336+
#ifndef USED_FOR_TARGET
2337+
#undef LD64_HAS_MACOS_VERSION_MIN
2338+
#endif
2339+
2340+
23352341
/* Define to 1 if ld64 supports '-platform_version'. */
23362342
#ifndef USED_FOR_TARGET
23372343
#undef LD64_HAS_PLATFORM_VERSION

gcc/config/darwin.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,17 @@ extern GTY(()) int darwin_ms_struct;
284284
#define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
285285
#endif
286286

287-
#if LD64_HAS_PLATFORM_VERSION
288-
#define DARWIN_PLATFORM_ID \
289-
"%{mmacosx-version-min=*: -platform_version macos %* 0.0} "
287+
#if LD64_HAS_MACOS_VERSION_MIN
288+
# define DARWIN_PLATFORM_ID \
289+
"%{mmacosx-version-min=*:-macos_version_min %*} "
290290
#else
291-
#define DARWIN_PLATFORM_ID \
291+
# if LD64_HAS_PLATFORM_VERSION
292+
# define DARWIN_PLATFORM_ID \
293+
"%{mmacosx-version-min=*: -platform_version macos %* 0.0} "
294+
# else
295+
# define DARWIN_PLATFORM_ID \
292296
"%{mmacosx-version-min=*:-macosx_version_min %*} "
297+
# endif
293298
#endif
294299

295300
/* Code built with mdynamic-no-pic does not support PIE/PIC, so we disallow

gcc/configure

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32650,6 +32650,7 @@ if test x"$ld64_flag" = x"yes"; then
3265032650
# Set defaults for possibly untestable items.
3265132651
gcc_cv_ld64_export_dynamic=0
3265232652
gcc_cv_ld64_platform_version=0
32653+
gcc_cv_ld64_macos_version_min=0
3265332654
gcc_cv_ld64_demangle=0
3265432655

3265532656
if test "$build" = "$host"; then
@@ -32682,6 +32683,7 @@ $as_echo "$gcc_cv_ld64_major" >&6; }
3268232683
fi
3268332684
if test "$gcc_cv_ld64_major" -ge 512; then
3268432685
gcc_cv_ld64_platform_version=1
32686+
gcc_cv_ld64_macos_version_min=1
3268532687
fi
3268632688
elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
3268732689
# If the version was not specified, try to find it.
@@ -32720,6 +32722,15 @@ $as_echo_n "checking linker for -platform_version support... " >&6; }
3272032722
fi
3272132723
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_platform_version" >&5
3272232724
$as_echo "$gcc_cv_ld64_platform_version" >&6; }
32725+
32726+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -macos_version_min" >&5
32727+
$as_echo_n "checking linker for -macos_version_min... " >&6; }
32728+
gcc_cv_ld64_macosx_version_min=1
32729+
if $gcc_cv_ld -macos_version_min 10.5 < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
32730+
gcc_cv_ld64_macosx_version_min=0
32731+
fi
32732+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_macosx_version_min" >&5
32733+
$as_echo "$gcc_cv_ld64_macosx_version_min" >&6; }
3272332734
fi
3272432735

3272532736
if test x"${gcc_cv_ld64_version}" != x; then
@@ -32747,6 +32758,12 @@ cat >>confdefs.h <<_ACEOF
3274732758
#define LD64_HAS_PLATFORM_VERSION $gcc_cv_ld64_platform_version
3274832759
_ACEOF
3274932760

32761+
32762+
32763+
cat >>confdefs.h <<_ACEOF
32764+
#define LD64_HAS_MACOS_VERSION_MIN $gcc_cv_ld64_macosx_version_min
32765+
_ACEOF
32766+
3275032767
fi
3275132768

3275232769
if test x"$dsymutil_flag" = x"yes"; then

gcc/configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6358,6 +6358,7 @@ if test x"$ld64_flag" = x"yes"; then
63586358
# Set defaults for possibly untestable items.
63596359
gcc_cv_ld64_export_dynamic=0
63606360
gcc_cv_ld64_platform_version=0
6361+
gcc_cv_ld64_macos_version_min=0
63616362
gcc_cv_ld64_demangle=0
63626363

63636364
if test "$build" = "$host"; then
@@ -6388,6 +6389,7 @@ if test x"$ld64_flag" = x"yes"; then
63886389
fi
63896390
if test "$gcc_cv_ld64_major" -ge 512; then
63906391
gcc_cv_ld64_platform_version=1
6392+
gcc_cv_ld64_macos_version_min=1
63916393
fi
63926394
elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
63936395
# If the version was not specified, try to find it.
@@ -6418,6 +6420,13 @@ if test x"$ld64_flag" = x"yes"; then
64186420
gcc_cv_ld64_platform_version=0
64196421
fi
64206422
AC_MSG_RESULT($gcc_cv_ld64_platform_version)
6423+
6424+
AC_MSG_CHECKING(linker for -macos_version_min)
6425+
gcc_cv_ld64_macosx_version_min=1
6426+
if $gcc_cv_ld -macos_version_min 10.5 < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
6427+
gcc_cv_ld64_macosx_version_min=0
6428+
fi
6429+
AC_MSG_RESULT($gcc_cv_ld64_macosx_version_min)
64216430
fi
64226431

64236432
if test x"${gcc_cv_ld64_version}" != x; then
@@ -6433,6 +6442,9 @@ if test x"$ld64_flag" = x"yes"; then
64336442

64346443
AC_DEFINE_UNQUOTED(LD64_HAS_PLATFORM_VERSION, $gcc_cv_ld64_platform_version,
64356444
[Define to 1 if ld64 supports '-platform_version'.])
6445+
6446+
AC_DEFINE_UNQUOTED(LD64_HAS_MACOS_VERSION_MIN, $gcc_cv_ld64_macosx_version_min,
6447+
[Define to 1 if ld64 supports '-macos_version_min'.])
64366448
fi
64376449

64386450
if test x"$dsymutil_flag" = x"yes"; then

0 commit comments

Comments
 (0)