From 5d31528f4eaeebf1918f573cf3c61810594b8fa9 Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 17:44:35 -0700
Subject: [PATCH 13/24] clang: add back runtime libraries used on 10.4 and 10.5

removed in https://github.com/llvm/llvm-project/commit/3434ade2b7ca351b61522f7da4b55070d811b83f

related, the following code used to add libclang_rt_10.4.a to Tiger, but this library
is no longer built in the runtime library collections. If building for Tiger, it
may be required to replace this library at some point.
The line below this, adding "builtins" adds libclang_rt.osx.a, does the second part of this.
it may be easiest to just add Tiger functions to libclang_rt.osx.a directly
   // if (isMacosxVersionLT(10, 5))
   //   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
   // else
   //   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
---
 clang/lib/Driver/ToolChains/Darwin.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index daa8e520e404..da1d171ce859 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1334,6 +1334,12 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
         getTriple().getArch() != llvm::Triple::aarch64)
       CmdArgs.push_back("-lgcc_s.1");
   }
+  if (isTargetMacOS()) {
+    if (isMacosxVersionLT(10, 5))
+      CmdArgs.push_back("-lgcc_s.10.4");
+    else if (isMacosxVersionLT(10, 6))
+      CmdArgs.push_back("-lgcc_s.10.5");
+  }
   AddLinkRuntimeLib(Args, CmdArgs, "builtins");
 }
 
-- 
2.21.1 (Apple Git-122.3)

