diff --git a/pkgs/development/tools/misc/patchelf/default.nix b/pkgs/development/tools/misc/patchelf/default.nix index 06b5c2ef516d..5aa81e46bed1 100644 --- a/pkgs/development/tools/misc/patchelf/default.nix +++ b/pkgs/development/tools/misc/patchelf/default.nix @@ -8,6 +8,8 @@ stdenv.mkDerivation rec { sha256 = "c99f84d124347340c36707089ec8f70530abd56e7827c54d506eb4cc097a17e7"; }; + setupHook = [ ./setup-hook.sh ]; + meta = { homepage = http://nixos.org/patchelf.html; license = "GPL"; diff --git a/pkgs/development/tools/misc/patchelf/setup-hook.sh b/pkgs/development/tools/misc/patchelf/setup-hook.sh new file mode 100644 index 000000000000..e27d1ed5b00c --- /dev/null +++ b/pkgs/development/tools/misc/patchelf/setup-hook.sh @@ -0,0 +1,18 @@ +# This setup hook calls patchelf to automatically remove unneeded +# directories from the RPATH of every library or executable in every +# output. + +if [ -z "$dontPatchELF" ]; then + addHook fixupOutput 'patchELF "$prefix"' +fi + +patchELF() { + header "patching ELF executables and libraries in $prefix" + if [ -e "$prefix" ]; then + find "$prefix" \( \ + \( -type f -a -name "*.so*" \) -o \ + \( -type f -a -perm +0100 \) \ + \) -print -exec patchelf --shrink-rpath '{}' \; + fi + stopNest +} diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index d3d2d250e500..a953176127c7 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -702,19 +702,6 @@ checkPhase() { } -patchELF() { - # Patch all ELF executables and shared libraries. - header "patching ELF executables and libraries" - if [ -e "$prefix" ]; then - find "$prefix" \( \ - \( -type f -a -name "*.so*" \) -o \ - \( -type f -a -perm +0100 \) \ - \) -print -exec patchelf --shrink-rpath '{}' \; - fi - stopNest -} - - patchShebangs() { # Rewrite all script interpreter file names (`#! /path') under the # specified directory tree to paths found in $PATH. E.g., @@ -886,10 +873,6 @@ _defaultFixupOutput() { fi fi - if [ "$havePatchELF" = 1 -a -z "$dontPatchELF" ]; then - patchELF "$prefix" - fi - if [ -z "$dontPatchShebangs" ]; then patchShebangs "$prefix" fi diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 23cccf223f4f..7169ce9f94eb 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -26,7 +26,6 @@ rec { commonPreHook = '' export NIX_ENFORCE_PURITY=1 - havePatchELF=1 ${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""} ${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""} ''; @@ -46,7 +45,7 @@ rec { builder = bootstrapFiles.sh; args = - if system == "armv5tel-linux" || system == "armv6l-linux" + if system == "armv5tel-linux" || system == "armv6l-linux" || system == "armv7l-linux" then [ ./scripts/unpack-bootstrap-tools-arm.sh ] else [ ./scripts/unpack-bootstrap-tools.sh ]; @@ -69,10 +68,10 @@ rec { # This function builds the various standard environments used during # the bootstrap. stdenvBootFun = - {gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? [], fetchurl}: + { gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraBuildInputs ? [], fetchurl }: import ../generic { - inherit system config; + inherit system config extraBuildInputs; name = "stdenv-linux-boot"; preHook = '' @@ -82,7 +81,7 @@ rec { ${commonPreHook} ''; shell = "${bootstrapTools}/bin/sh"; - initialPath = [bootstrapTools] ++ extraPath; + initialPath = [ bootstrapTools ]; fetchurlBoot = fetchurl; inherit gcc; # Having the proper 'platform' in all the stdenvs allows getting proper @@ -208,9 +207,9 @@ rec { ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; }; extraAttrs = { - glibc = stdenvLinuxGlibc; # Required by gcc47 build + glibc = stdenvLinuxGlibc; # Required by gcc47 build }; - extraPath = [ stdenvLinuxBoot1Pkgs.paxctl ]; + extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot1Pkgs.paxctl ]; inherit fetchurl; }; @@ -233,7 +232,7 @@ rec { gcc = stdenvLinuxBoot3Pkgs.gcc.gcc; name = ""; }; - extraPath = [ stdenvLinuxBoot3Pkgs.xz ]; + extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot3Pkgs.xz ]; overrides = pkgs: { inherit (stdenvLinuxBoot1Pkgs) perl; inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 gmp; @@ -268,8 +267,10 @@ rec { ''; initialPath = - ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;}) - ++ [stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ]; + ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;}); + + extraBuildInputs = + [ stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ]; gcc = wrapGCC rec { inherit (stdenvLinuxBoot4Pkgs) binutils coreutils; @@ -284,7 +285,7 @@ rec { fetchurlBoot = fetchurl; extraAttrs = { - inherit (stdenvLinuxBoot3Pkgs) glibc; + glibc = stdenvLinuxGlibc; inherit platform bootstrapTools; shellPackage = stdenvLinuxBoot4Pkgs.bash; };