From 398061dfc593e97e7ea57321d4e97ed843ef449f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Mon, 25 Dec 2017 17:19:43 +0000 Subject: [PATCH] prebuilt ghcs: correctly handle rpaths --- pkgs/development/compilers/ghc/7.10.3-binary.nix | 12 +++++++----- pkgs/development/compilers/ghc/7.8.4-binary.nix | 12 +++++++----- pkgs/development/compilers/ghc/8.2.1-binary.nix | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/pkgs/development/compilers/ghc/7.10.3-binary.nix b/pkgs/development/compilers/ghc/7.10.3-binary.nix index 1711531fae1d..881e41708623 100644 --- a/pkgs/development/compilers/ghc/7.10.3-binary.nix +++ b/pkgs/development/compilers/ghc/7.10.3-binary.nix @@ -87,9 +87,6 @@ stdenv.mkDerivation rec { sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 - for prog in ld ar gcc strip ranlib; do - find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; - done ''; configurePlatforms = [ ]; @@ -109,8 +106,12 @@ stdenv.mkDerivation rec { # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. preFixup = stdenv.lib.optionalString stdenv.isLinux '' - find "$out" -type f -executable \ - -exec patchelf --set-rpath "${libPath}" {} \; + for p in $(find "$out" -type f -executable); do + if isELF "$p"; then + echo "Patchelfing $p" + patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p + fi + done '' + stdenv.lib.optionalString stdenv.isDarwin '' # not enough room in the object files for the full path to libiconv :( for exe in $(find "$out" -type f -executable); do @@ -126,6 +127,7 @@ stdenv.mkDerivation rec { doInstallCheck = true; installCheckPhase = '' + unset ${libEnvVar} # Sanity check, can ghc create executables? cd $TMP mkdir test-ghc; cd test-ghc diff --git a/pkgs/development/compilers/ghc/7.8.4-binary.nix b/pkgs/development/compilers/ghc/7.8.4-binary.nix index f9809d705739..81fc1dc49ce8 100644 --- a/pkgs/development/compilers/ghc/7.8.4-binary.nix +++ b/pkgs/development/compilers/ghc/7.8.4-binary.nix @@ -83,9 +83,6 @@ stdenv.mkDerivation rec { sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 - for prog in ld ar gcc strip ranlib; do - find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; - done ''; configurePlatforms = [ ]; @@ -105,8 +102,12 @@ stdenv.mkDerivation rec { # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. preFixup = stdenv.lib.optionalString stdenv.isLinux '' - find "$out" -type f -executable \ - -exec patchelf --set-rpath "${libPath}" {} \; + for p in $(find "$out" -type f -executable); do + if isELF "$p"; then + echo "Patchelfing $p" + patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p + fi + done '' + stdenv.lib.optionalString stdenv.isDarwin '' # not enough room in the object files for the full path to libiconv :( for exe in $(find "$out" -type f -executable); do @@ -122,6 +123,7 @@ stdenv.mkDerivation rec { doInstallCheck = true; installCheckPhase = '' + unset ${libEnvVar} # Sanity check, can ghc create executables? cd $TMP mkdir test-ghc; cd test-ghc diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index 2f48d29b0b41..5f18e6543e1c 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -91,9 +91,6 @@ stdenv.mkDerivation rec { sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 - for prog in ld ar gcc strip ranlib; do - find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; - done ''; configurePlatforms = [ ]; @@ -113,8 +110,12 @@ stdenv.mkDerivation rec { # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. preFixup = stdenv.lib.optionalString stdenv.isLinux '' - find "$out" -type f -executable \ - -exec patchelf --set-rpath "${libPath}" {} \; + for p in $(find "$out" -type f -executable); do + if isELF "$p"; then + echo "Patchelfing $p" + patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p + fi + done '' + stdenv.lib.optionalString stdenv.isDarwin '' # not enough room in the object files for the full path to libiconv :( for exe in $(find "$out" -type f -executable); do @@ -130,6 +131,7 @@ stdenv.mkDerivation rec { doInstallCheck = true; installCheckPhase = '' + unset ${libEnvVar} # Sanity check, can ghc create executables? cd $TMP mkdir test-ghc; cd test-ghc