From 49c3f6ebc66f300886d4cb685cb9f1952b429b4f Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Mon, 1 Apr 2019 20:56:33 +0100
Subject: [PATCH] more ppc hacks on libcxx

---
 libcxx/lib/CMakeLists.txt               | 13 +++++++++++--
 libcxx/utils/libcxx/test/target_info.py |  2 +-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index 347f21ff45e..2f9a00011e9 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -148,7 +148,16 @@ if (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY)
     endif()
   endif()
 
-  if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
+  if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.5" )
+    add_link_flags(
+      "-compatibility_version 1"
+      "-current_version 1"
+      "-install_name @rpath/libc++.1.dylib"
+      "-Wl,-reexport_library,${LIBCXX_LIBRARY_DIR}/libc++abi.dylib"
+      "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
+      "/usr/lib/libgcc_s.10.5.dylib"
+      "/usr/lib/libSystem.B.dylib")
+  elseif ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
     add_definitions(-D__STRICT_ANSI__)
     add_link_flags(
       "-compatibility_version 1"
@@ -158,7 +167,7 @@ if (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY)
       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
       "/usr/lib/libSystem.B.dylib")
   else()
-	  if (DEFINED CMAKE_OSX_SYSROOT AND NOT CMAKE_OSX_SYSROOT STREQUAL "")
+    if (DEFINED CMAKE_OSX_SYSROOT AND NOT CMAKE_OSX_SYSROOT STREQUAL "")
       list(FIND CMAKE_OSX_ARCHITECTURES "armv7" OSX_HAS_ARMV7)
       if (NOT OSX_HAS_ARMV7 EQUAL -1)
         set(OSX_RE_EXPORT_LINE
diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py
index 179db775229..7cffcea359f 100644
--- a/libcxx/utils/libcxx/test/target_info.py
+++ b/libcxx/utils/libcxx/test/target_info.py
@@ -140,7 +140,7 @@ class DarwinLocalTI(DefaultTargetInfo):
             flags += ["-isysroot", sdk_path]
 
     def add_cxx_link_flags(self, flags):
-        flags += ['-lSystem']
+        flags += [ '-latomic', '-lgcc_s.10.5', '-lSystem']
 
     def configure_env(self, env):
         library_paths = []
