From 13255362a1f00ff57b82a31b1ea4fccf93abfd74 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun, 3 Jan 2021 12:24:45 +0000
Subject: [PATCH] Darwin, libgcc : Adjust min version supported for the OS.

Tools from later versions of the OS deprecate or fail to support
earlier OS revisions.

libgcc/
	* config.host: Arrange to set min Darwin OS versions from
	the configured host version.
        * config/i386/t-darwin: Amend to handle configured min OS
	versions.
        * config/t-darwin : Use the configured min OS versions.
        * config/t-darwin-min-1: New.
        * config/t-darwin-min-4: New.
        * config/t-darwin-min-5: New.
        * config/t-darwin-min-8: New.

(cherry picked from commit a618c9ca6ba25235b23e403ec1b06dac6d760281)
Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
---
 libgcc/config.host           | 7 ++++++-
 libgcc/config/t-darwin-min-4 | 3 +++
 libgcc/config/t-darwin-rpath | 3 ---
 3 files changed, 9 insertions(+), 4 deletions(-)
 create mode 100644 libgcc/config/t-darwin-min-4

diff --git libgcc/config.host libgcc/config.host
index 51edd5da997..66d7b37b0d6 100644
--- libgcc/config.host
+++ libgcc/config.host
@@ -242,6 +242,7 @@ case ${host} in
       *-darwin*)
         echo "but is needed after macOS 10.11 (setting it on)" 1>&2
         tmake_file="$tmake_file t-darwin-rpath "
+        enable_darwin_at_rpath=yes
         ;;
     esac
   else
@@ -253,7 +254,11 @@ case ${host} in
       tmake_file="t-darwin-min-8 $tmake_file"
       ;;
     *-*-darwin9* | *-*-darwin1[0-7]*)
-      tmake_file="t-darwin-min-5 $tmake_file"
+      if test "x$enable_darwin_at_rpath" = "xyes"; then
+        tmake_file="t-darwin-min-5 $tmake_file"
+      else
+        tmake_file="t-darwin-min-4 $tmake_file"
+      fi
       ;;
     *-*-darwin[4-8]*)
       tmake_file="t-darwin-min-1 $tmake_file"
diff --git libgcc/config/t-darwin-min-4 libgcc/config/t-darwin-min-4
new file mode 100644
index 00000000000..04e980de4d5
--- /dev/null
+++ libgcc/config/t-darwin-min-4
@@ -0,0 +1,3 @@
+# Support building with -mmacosx-version-min back to 10.4.
+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.4
+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.4
diff --git libgcc/config/t-darwin-rpath libgcc/config/t-darwin-rpath
index 7cf63d9cb6b..e73d7f378b0 100644
--- libgcc/config/t-darwin-rpath
+++ libgcc/config/t-darwin-rpath
@@ -1,5 +1,2 @@
 # Use @rpath and add a search path to exes and dylibs that depend on this.
 SHLIB_RPATH = @rpath
-
-# Which does not work for Darwin < 9
-HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.5
-- 
2.42.1

