From 9b0c2178bd4f4fd915cdf2064fc6a1183266dccc Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Date: Thu, 28 Dec 2017 21:49:22 -0800
Subject: [PATCH 3007/3008] MacPorts: Use LIBCXXABI_PATH for path to build-time
 libc++abi.dylib

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit 0c751aa4c9397dcb5ad54bae04f03dd56f4c2855)
---
 lib/buildit | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git libcxx-5.0.1.src/lib/buildit libcxx-5.0.1.src/lib/buildit
index 4fd356420..c10f876a7 100755
--- libcxx-5.0.1.src/lib/buildit
+++ libcxx-5.0.1.src/lib/buildit
@@ -55,6 +55,12 @@ case $TRIPLE in
       RC_CFLAGS="-arch i386 -arch x86_64"
     fi
     SOEXT=dylib
+
+    if [ -z "${LIBCXXABI_DYLIB_PATH}" ]
+    then
+        LIBCXXABI_DYLIB_PATH=/usr/lib/libc++abi.dylib
+    fi
+
     if [[ "$MACOSX_DEPLOYMENT_TARGET" == 10.[456] ]]
     then
         EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__"
@@ -63,31 +69,10 @@ case $TRIPLE in
             -current_version ${RC_ProjectSourceVersion} \
             -compatibility_version 1 \
             -install_name /usr/lib/libc++.1.dylib \
-            -Wl,-reexport_library,/usr/lib/libc++abi.dylib \
+            -Wl,-reexport_library,${LIBCXXABI_DYLIB_PATH} \
             -Wl,-unexported_symbols_list,libc++unexp.exp  \
             /usr/lib/libSystem.B.dylib /usr/lib/libgcc_s.1.dylib"
     else
-        if [ -n "$SDKROOT" ]
-        then
-            EXTRA_FLAGS+="-isysroot ${SDKROOT} "
-            if echo "${RC_ARCHS}" | grep -q "armv7"  
-            then
-                RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp"
-            else
-                RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib"
-            fi
-            CXX=`xcrun -sdk "${SDKROOT}"  -find clang++`
-            CC=`xcrun -sdk "${SDKROOT}"  -find clang`
-        else
-            # Check if we have _LIBCPPABI_VERSION, to determine the reexport list to use.
-            if (echo "#include <cxxabi.h>" | $CXX -E -dM -x c++ - | \
-                grep _LIBCPPABI_VERSION > /dev/null)
-            then
-                RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi2.exp"
-            else
-                RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp"
-            fi
-        fi
         LDSHARED_FLAGS="-o libc++.1.dylib \
             -dynamiclib -nodefaultlibs  \
             -current_version ${RC_ProjectSourceVersion} \
@@ -95,7 +80,8 @@ case $TRIPLE in
             -install_name /usr/lib/libc++.1.dylib \
             -lSystem  \
             -Wl,-unexported_symbols_list,libc++unexp.exp  \
-            ${RE_EXPORT_LINE}  \
+            -Wl,-reexport_library,${LIBCXXABI_DYLIB_PATH} \
+            -Wl,-reexported_symbols_list,libc++abi2.exp \
             -Wl,-force_symbols_not_weak_list,notweak.exp \
             -Wl,-force_symbols_weak_list,weak.exp"
     fi
-- 
2.15.1

