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

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