Move RPATH shrinking from stdenv to a setup hook provided by patchelf

+32 -28
+2
pkgs/development/tools/misc/patchelf/default.nix
··· 8 8 sha256 = "c99f84d124347340c36707089ec8f70530abd56e7827c54d506eb4cc097a17e7"; 9 9 }; 10 10 11 + setupHook = [ ./setup-hook.sh ]; 12 + 11 13 meta = { 12 14 homepage = http://nixos.org/patchelf.html; 13 15 license = "GPL";
+18
pkgs/development/tools/misc/patchelf/setup-hook.sh
··· 1 + # This setup hook calls patchelf to automatically remove unneeded 2 + # directories from the RPATH of every library or executable in every 3 + # output. 4 + 5 + if [ -z "$dontPatchELF" ]; then 6 + addHook fixupOutput 'patchELF "$prefix"' 7 + fi 8 + 9 + patchELF() { 10 + header "patching ELF executables and libraries in $prefix" 11 + if [ -e "$prefix" ]; then 12 + find "$prefix" \( \ 13 + \( -type f -a -name "*.so*" \) -o \ 14 + \( -type f -a -perm +0100 \) \ 15 + \) -print -exec patchelf --shrink-rpath '{}' \; 16 + fi 17 + stopNest 18 + }
-17
pkgs/stdenv/generic/setup.sh
··· 702 702 } 703 703 704 704 705 - patchELF() { 706 - # Patch all ELF executables and shared libraries. 707 - header "patching ELF executables and libraries" 708 - if [ -e "$prefix" ]; then 709 - find "$prefix" \( \ 710 - \( -type f -a -name "*.so*" \) -o \ 711 - \( -type f -a -perm +0100 \) \ 712 - \) -print -exec patchelf --shrink-rpath '{}' \; 713 - fi 714 - stopNest 715 - } 716 - 717 - 718 705 patchShebangs() { 719 706 # Rewrite all script interpreter file names (`#! /path') under the 720 707 # specified directory tree to paths found in $PATH. E.g., ··· 884 871 if [ -n "$stripAllList" ]; then 885 872 stripDirs "$stripAllList" "${stripAllFlags:--s}" 886 873 fi 887 - fi 888 - 889 - if [ "$havePatchELF" = 1 -a -z "$dontPatchELF" ]; then 890 - patchELF "$prefix" 891 874 fi 892 875 893 876 if [ -z "$dontPatchShebangs" ]; then
+12 -11
pkgs/stdenv/linux/default.nix
··· 26 26 commonPreHook = 27 27 '' 28 28 export NIX_ENFORCE_PURITY=1 29 - havePatchELF=1 30 29 ${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""} 31 30 ${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""} 32 31 ''; ··· 46 45 builder = bootstrapFiles.sh; 47 46 48 47 args = 49 - if system == "armv5tel-linux" || system == "armv6l-linux" 48 + if system == "armv5tel-linux" || system == "armv6l-linux" 50 49 || system == "armv7l-linux" 51 50 then [ ./scripts/unpack-bootstrap-tools-arm.sh ] 52 51 else [ ./scripts/unpack-bootstrap-tools.sh ]; ··· 69 68 # This function builds the various standard environments used during 70 69 # the bootstrap. 71 70 stdenvBootFun = 72 - {gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? [], fetchurl}: 71 + { gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraBuildInputs ? [], fetchurl }: 73 72 74 73 import ../generic { 75 - inherit system config; 74 + inherit system config extraBuildInputs; 76 75 name = "stdenv-linux-boot"; 77 76 preHook = 78 77 '' ··· 82 81 ${commonPreHook} 83 82 ''; 84 83 shell = "${bootstrapTools}/bin/sh"; 85 - initialPath = [bootstrapTools] ++ extraPath; 84 + initialPath = [ bootstrapTools ]; 86 85 fetchurlBoot = fetchurl; 87 86 inherit gcc; 88 87 # Having the proper 'platform' in all the stdenvs allows getting proper ··· 208 207 ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; 209 208 }; 210 209 extraAttrs = { 211 - glibc = stdenvLinuxGlibc; # Required by gcc47 build 210 + glibc = stdenvLinuxGlibc; # Required by gcc47 build 212 211 }; 213 - extraPath = [ stdenvLinuxBoot1Pkgs.paxctl ]; 212 + extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot1Pkgs.paxctl ]; 214 213 inherit fetchurl; 215 214 }; 216 215 ··· 233 232 gcc = stdenvLinuxBoot3Pkgs.gcc.gcc; 234 233 name = ""; 235 234 }; 236 - extraPath = [ stdenvLinuxBoot3Pkgs.xz ]; 235 + extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot3Pkgs.xz ]; 237 236 overrides = pkgs: { 238 237 inherit (stdenvLinuxBoot1Pkgs) perl; 239 238 inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 gmp; ··· 268 267 ''; 269 268 270 269 initialPath = 271 - ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;}) 272 - ++ [stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ]; 270 + ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;}); 271 + 272 + extraBuildInputs = 273 + [ stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ]; 273 274 274 275 gcc = wrapGCC rec { 275 276 inherit (stdenvLinuxBoot4Pkgs) binutils coreutils; ··· 284 285 fetchurlBoot = fetchurl; 285 286 286 287 extraAttrs = { 287 - inherit (stdenvLinuxBoot3Pkgs) glibc; 288 + glibc = stdenvLinuxGlibc; 288 289 inherit platform bootstrapTools; 289 290 shellPackage = stdenvLinuxBoot4Pkgs.bash; 290 291 };