Move RPATH shrinking from stdenv to a setup hook provided by patchelf
This commit is contained in:
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "c99f84d124347340c36707089ec8f70530abd56e7827c54d506eb4cc097a17e7";
|
sha256 = "c99f84d124347340c36707089ec8f70530abd56e7827c54d506eb4cc097a17e7";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setupHook = [ ./setup-hook.sh ];
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
homepage = http://nixos.org/patchelf.html;
|
homepage = http://nixos.org/patchelf.html;
|
||||||
license = "GPL";
|
license = "GPL";
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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() {
|
patchShebangs() {
|
||||||
# Rewrite all script interpreter file names (`#! /path') under the
|
# Rewrite all script interpreter file names (`#! /path') under the
|
||||||
# specified directory tree to paths found in $PATH. E.g.,
|
# specified directory tree to paths found in $PATH. E.g.,
|
||||||
@@ -886,10 +873,6 @@ _defaultFixupOutput() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$havePatchELF" = 1 -a -z "$dontPatchELF" ]; then
|
|
||||||
patchELF "$prefix"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$dontPatchShebangs" ]; then
|
if [ -z "$dontPatchShebangs" ]; then
|
||||||
patchShebangs "$prefix"
|
patchShebangs "$prefix"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ rec {
|
|||||||
commonPreHook =
|
commonPreHook =
|
||||||
''
|
''
|
||||||
export NIX_ENFORCE_PURITY=1
|
export NIX_ENFORCE_PURITY=1
|
||||||
havePatchELF=1
|
|
||||||
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
|
${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 ""}
|
${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
|
||||||
'';
|
'';
|
||||||
@@ -69,10 +68,10 @@ rec {
|
|||||||
# This function builds the various standard environments used during
|
# This function builds the various standard environments used during
|
||||||
# the bootstrap.
|
# the bootstrap.
|
||||||
stdenvBootFun =
|
stdenvBootFun =
|
||||||
{gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? [], fetchurl}:
|
{ gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraBuildInputs ? [], fetchurl }:
|
||||||
|
|
||||||
import ../generic {
|
import ../generic {
|
||||||
inherit system config;
|
inherit system config extraBuildInputs;
|
||||||
name = "stdenv-linux-boot";
|
name = "stdenv-linux-boot";
|
||||||
preHook =
|
preHook =
|
||||||
''
|
''
|
||||||
@@ -82,7 +81,7 @@ rec {
|
|||||||
${commonPreHook}
|
${commonPreHook}
|
||||||
'';
|
'';
|
||||||
shell = "${bootstrapTools}/bin/sh";
|
shell = "${bootstrapTools}/bin/sh";
|
||||||
initialPath = [bootstrapTools] ++ extraPath;
|
initialPath = [ bootstrapTools ];
|
||||||
fetchurlBoot = fetchurl;
|
fetchurlBoot = fetchurl;
|
||||||
inherit gcc;
|
inherit gcc;
|
||||||
# Having the proper 'platform' in all the stdenvs allows getting proper
|
# 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; };
|
ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
||||||
};
|
};
|
||||||
extraAttrs = {
|
extraAttrs = {
|
||||||
glibc = stdenvLinuxGlibc; # Required by gcc47 build
|
glibc = stdenvLinuxGlibc; # Required by gcc47 build
|
||||||
};
|
};
|
||||||
extraPath = [ stdenvLinuxBoot1Pkgs.paxctl ];
|
extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot1Pkgs.paxctl ];
|
||||||
inherit fetchurl;
|
inherit fetchurl;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -233,7 +232,7 @@ rec {
|
|||||||
gcc = stdenvLinuxBoot3Pkgs.gcc.gcc;
|
gcc = stdenvLinuxBoot3Pkgs.gcc.gcc;
|
||||||
name = "";
|
name = "";
|
||||||
};
|
};
|
||||||
extraPath = [ stdenvLinuxBoot3Pkgs.xz ];
|
extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot3Pkgs.xz ];
|
||||||
overrides = pkgs: {
|
overrides = pkgs: {
|
||||||
inherit (stdenvLinuxBoot1Pkgs) perl;
|
inherit (stdenvLinuxBoot1Pkgs) perl;
|
||||||
inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 gmp;
|
inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 gmp;
|
||||||
@@ -268,8 +267,10 @@ rec {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
initialPath =
|
initialPath =
|
||||||
((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;})
|
((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;});
|
||||||
++ [stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ];
|
|
||||||
|
extraBuildInputs =
|
||||||
|
[ stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ];
|
||||||
|
|
||||||
gcc = wrapGCC rec {
|
gcc = wrapGCC rec {
|
||||||
inherit (stdenvLinuxBoot4Pkgs) binutils coreutils;
|
inherit (stdenvLinuxBoot4Pkgs) binutils coreutils;
|
||||||
@@ -284,7 +285,7 @@ rec {
|
|||||||
fetchurlBoot = fetchurl;
|
fetchurlBoot = fetchurl;
|
||||||
|
|
||||||
extraAttrs = {
|
extraAttrs = {
|
||||||
inherit (stdenvLinuxBoot3Pkgs) glibc;
|
glibc = stdenvLinuxGlibc;
|
||||||
inherit platform bootstrapTools;
|
inherit platform bootstrapTools;
|
||||||
shellPackage = stdenvLinuxBoot4Pkgs.bash;
|
shellPackage = stdenvLinuxBoot4Pkgs.bash;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user