ghc prebuilt: Simplify and harden Darwin fixup

- Patch all executables and libraries, while skipping scripts. Base at
   least uses libiconv, so should need this too---I suspect it wasn't a
   problem before as we got away with the immpurity.

 - Rather than hardcoding the symlinks to add, do one per mach-o as
   needed

TEMP no -L no script
This commit is contained in:
John Ericson 2017-09-23 10:13:21 -04:00 committed by Domen Kožar
parent 150255e318
commit b6867f71f4
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
2 changed files with 8 additions and 18 deletions

View file

@ -106,15 +106,10 @@ stdenv.mkDerivation rec {
-exec patchelf --set-rpath "${libPath}" {} \;
'' + stdenv.lib.optionalString stdenv.isDarwin ''
# not enough room in the object files for the full path to libiconv :(
ln -s ${libiconv}/lib/libiconv.dylib $out/bin
ln -s ${libiconv}/lib/libiconv.dylib $out/lib/ghc-${version}/libiconv.dylib
fix () {
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1
}
for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do
fix $(find "$out" -type f -name $file)
for exe in $(find "$out" -type f -executable); do
isScript $exe && continue
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
done
for file in $(find "$out" -name setup-config); do

View file

@ -107,15 +107,10 @@ stdenv.mkDerivation rec {
-exec patchelf --set-rpath "${libPath}" {} \;
'' + stdenv.lib.optionalString stdenv.isDarwin ''
# not enough room in the object files for the full path to libiconv :(
ln -s ${libiconv}/lib/libiconv.dylib $out/bin
ln -s ${libiconv}/lib/libiconv.dylib $out/lib/ghc-${version}/libiconv.dylib
fix () {
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1
}
for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do
fix $(find "$out" -type f -name $file)
for exe in $(find "$out" -type f -executable); do
isScript $exe && continue
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
done
for file in $(find "$out" -name setup-config); do