summary refs log tree commit diff
path: root/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
diff options
context:
space:
mode:
authorDan Peebles <pumpkin@me.com>2016-10-10 09:50:25 -0400
committerDan Peebles <pumpkin@me.com>2016-10-12 00:08:13 -0400
commitd8a0307a5d36551c641578a3bf1a7d29103df511 (patch)
tree672e5fcbc1d77bc1f0a7addbcf9815c22567bf4d /pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
parent7098404505003887b62cdee10ee74dfa56ead741 (diff)
downloadnixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.tar
nixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.tar.gz
nixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.tar.bz2
nixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.tar.lz
nixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.tar.xz
nixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.tar.zst
nixlib-d8a0307a5d36551c641578a3bf1a7d29103df511.zip
[darwin.stdenv] Fix to work on Sierra
This reinstates the libSystem selective symbol export machinery we used
to have, but locks it to the symbols that were present in 10.11 and skips
the actual compiled code we put into that library in favor of the system
initialization code. That should make it more stable and less likely to
do weird stuff than the last time we did this.
Diffstat (limited to 'pkgs/stdenv/darwin/unpack-bootstrap-tools.sh')
-rw-r--r--pkgs/stdenv/darwin/unpack-bootstrap-tools.sh39
1 files changed, 37 insertions, 2 deletions
diff --git a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
index 8033c7004d93..66c4e9ebeda9 100644
--- a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
+++ b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
@@ -17,9 +17,44 @@ for i in $out/bin/*; do
   fi
 done
 
+install_name_tool \
+  -id $out/lib/system/libsystem_c.dylib \
+  $out/lib/system/libsystem_c.dylib
+
+install_name_tool \
+  -id $out/lib/system/libsystem_kernel.dylib \
+  $out/lib/system/libsystem_kernel.dylib
+
+# TODO: this logic basically duplicates similar logic in the Libsystem expression. Deduplicate them!
+libs=$(otool -arch x86_64 -L /usr/lib/libSystem.dylib | tail -n +3 | awk '{ print $1 }')
+
+for i in $libs; do
+  if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then
+    args="$args -reexport_library $i"
+  fi
+done
+
+ld -macosx_version_min 10.7 \
+   -arch x86_64 \
+   -dylib \
+   -o $out/lib/libSystem.B.dylib \
+   -compatibility_version 1.0 \
+   -current_version 1226.10.1 \
+   -reexport_library $out/lib/system/libsystem_c.dylib \
+   -reexport_library $out/lib/system/libsystem_kernel.dylib \
+   $args
+
+ln -s libSystem.B.dylib $out/lib/libSystem.dylib
+
+for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
+  ln -s libSystem.dylib $out/lib/lib$name.dylib
+done
+
+ln -s libresolv.9.dylib $out/lib/libresolv.dylib
+
 for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do
-  if ! test -L $i; then
-    echo patching $i
+  if test ! -L "$i" -a "$i" != "$out/lib/libSystem*.dylib"; then
+    echo "Patching $i"
 
     id=$(otool -D "$i" | tail -n 1)
     install_name_tool -id "$(dirname $i)/$(basename $id)" $i