From f1342ea845c1126f17dc6a8e73244c645e80d20f Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 17:58:11 -0700
Subject: [PATCH 17/24] 10.6 and less: libcxx work around no
 reexported_symbols_list before 10.7

---
 libcxx/src/CMakeLists.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 9965104cb5b2..3d64f728016f 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -222,6 +222,8 @@ if (LIBCXX_ENABLE_SHARED)
     set(LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON)
   endif()
 
+# MacPorts: work around no OS support for reexported_symbols_list before 10.7
+if (CMAKE_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 10.7)
   if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
     target_link_libraries(cxx_shared PRIVATE
       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++unexp.exp"
@@ -231,6 +233,17 @@ if (LIBCXX_ENABLE_SHARED)
 
     target_link_libraries(cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>)
   endif()
+else()
+  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,-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")
+
+    target_link_libraries(cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>)
+  endif()
+endif()
 
   # Generate a linker script in place of a libc++.so symlink.
   if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-- 
2.21.1 (Apple Git-122.3)

