summary refs log tree commit diff
path: root/pkgs/build-support/cc-wrapper
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2017-07-26 20:26:57 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-07-31 17:02:56 -0400
commit1cd74ac70a69f60b826b20d2e31644f2a2be98ea (patch)
treef0f8d61c7f99c291ba1154609cf436db66f3cfd3 /pkgs/build-support/cc-wrapper
parent9242c8b331a3571debb04b6485b0783386371838 (diff)
downloadnixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.tar
nixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.tar.gz
nixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.tar.bz2
nixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.tar.lz
nixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.tar.xz
nixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.tar.zst
nixlib-1cd74ac70a69f60b826b20d2e31644f2a2be98ea.zip
cc-wrapper: Make sure symbol tables of child delegators is not empty
As described in https://github.com/NixOS/nixpkgs/issues/18461, MacOS no
longer accepts dylibs which only reexport other dylibs, because their
symbol tables are empty. To get around this, we define an object file
with a single "private extern" symbol, which hopefully won't clobber
anything.
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix9
-rw-r--r--pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash16
2 files changed, 17 insertions, 8 deletions
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index 371db540b0ab..43cf3b1cafeb 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -299,10 +299,11 @@ stdenv.mkDerivation {
     '' + (if !useMacosReexportHack then ''
       wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
     '' else ''
-      export ldWrapper="$out/bin/${prefix}ld" innerLd="${prefix}ld-reexport-delegate"
-      wrap "$innerLd" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${prefix}ld}
-      wrap "${prefix}ld" ${./ld-wrapper.sh} "$out/bin/$innerLd"
-      unset ldWrapper
+      export binPrefix=${prefix}
+      ldInner="${prefix}ld-reexport-delegate"
+      wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${prefix}ld}
+      wrap "${prefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner"
+      unset ldInner
     '') + ''
 
       if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
diff --git a/pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash b/pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash
index 548be0c4dd45..ae920e4fdad1 100644
--- a/pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash
+++ b/pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash
@@ -74,18 +74,26 @@ else
 
     mkdir -p "$out/lib"
 
+    PATH="$PATH:@out@/bin"
+
+    symbolBloatObject=$outputNameLibless-symbol-hack.o
+    if [[ ! -e $symbolBloatObject ]]; then
+        printf '.private_extern _______child_hack_foo\nchild_hack_foo:\n' \
+            | @binPrefix@as -- -o $symbolBloatObject
+    fi
+
     # first half of libs
-    @ldWrapper@ -macosx_version_min 10.10 -arch x86_64 -dylib \
+    @binPrefix@ld -macosx_version_min 10.10 -arch x86_64 -dylib \
       -o "$out/lib/lib${children[0]}.dylib" \
       -install_name "$out/lib/lib${children[0]}.dylib" \
-      "${childrenLookup[@]}" \
+      "${childrenLookup[@]}" "$symbolBloatObject" \
       "${childrenLink[@]:0:$((${#childrenLink[@]} / 2 ))}"
 
     # second half of libs
-    @ldWrapper@ -macosx_version_min 10.10 -arch x86_64 -dylib \
+    @binPrefix@ld -macosx_version_min 10.10 -arch x86_64 -dylib \
       -o "$out/lib/lib${children[1]}.dylib" \
       -install_name "$out/lib/lib${children[1]}.dylib" \
-      "${childrenLookup[@]}" \
+      "${childrenLookup[@]}" "$symbolBloatObject" \
       "${childrenLink[@]:$((${#childrenLink[@]} / 2 ))}"
 
     allArgs+=("-L$out/lib" "-l${children[0]}" "-l${children[1]}")