From 2619c3115f82a504540780ff29d5c932007d7ac3 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Wed, 17 Aug 2022 15:27:16 +0200
Subject: [PATCH] fix build of shared libc++.dylib on < 10.7

reexported_symbols_list is not accepted on < 10.7
but reexport_library is, and that is what was used previously
---
 libcxx/src/CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 2001c09761d9..ee3f9a4ad0d7 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -209,11 +209,11 @@ if (LIBCXX_ENABLE_SHARED)
   if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
     target_link_libraries(cxx_shared PRIVATE
       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++unexp.exp"
-      "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi.v${LIBCXX_LIBCPPABI_VERSION}.exp"
+      "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
       "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
       "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
 
-    if (LIBCXX_ENABLE_EXCEPTIONS)
+    if (LIBCXX_ENABLE_EXCEPTIONS AND (CMAKE_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 10.7))
       if ("${CMAKE_OSX_ARCHITECTURES}" MATCHES "^(armv6|armv7|armv7s)$")
         target_link_libraries(cxx_shared PRIVATE "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi-exceptions.sjlj.exp")
       else()
@@ -222,7 +222,9 @@ if (LIBCXX_ENABLE_SHARED)
     endif()
 
     if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
-      target_link_libraries(cxx_shared PRIVATE "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi-new-delete.exp")
+       if (CMAKE_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 10.7)
+         target_link_libraries(cxx_shared PRIVATE "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi-new-delete.exp")
+       endif()
     endif()
   endif()
 
-- 
2.37.2

