From ba3d665b91d33f808ffd39e9ee4675b72e564526 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Wed, 17 Aug 2022 14:14:50 +0200
Subject: [PATCH] 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 d9dde5adc24c..2219c7a7374c 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1313,6 +1313,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.37.2

