From 89b8ab2d78aee50bbcbbec0719d8a0f93fc0471b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 6 May 2009 13:49:12 +0000 Subject: [PATCH] * Work around /bin/sh being broken by an LD_LIBRARY_PATH that contains another Glibc. svn path=/nixpkgs/branches/stdenv-updates/; revision=15470 --- pkgs/stdenv/linux/default.nix | 3 ++- pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 90444a96d76..f269c4799b3 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -77,7 +77,8 @@ rec { param1 = bootstrapTools; preHook = builtins.toFile "prehook.sh" '' - export LD_LIBRARY_PATH=$param1/lib + # Put libpthread.so in LD_LIBRARY_PATH; some libraries need it. + export LD_LIBRARY_PATH=$param1/lib2 # Don't patch #!/interpreter because it leads to retained # dependencies on the bootstrapTools in the final stdenv. dontPatchShebangs=1 diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh index bb9c7071f3d..2e7b660c56f 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh @@ -33,3 +33,16 @@ ln -s bzip2 $out/bin/bunzip2 # fetchurl needs curl. bzip2 -d < $curl > $out/bin/curl chmod +x $out/bin/curl + +# Some libraries have libpthread in their DT_RUNPATH. PatchELF +# doesn't work on libraries, so we need to set LD_LIBRARY_PATH. +# However, setting LD_LIBRARY_PATH to $out/lib will confuse /bin/sh, +# since it might end up loading libraries from a different Glibc. So +# put *only* libpthread in LD_LIBRARY_PATH (via $out/lib2). !!! This +# is a temporary fix (since /bin/sh could have a dependency on +# libpthread as well). A better fix would be to make patchelf work on +# libraries, or to set the RPATH rather than the RUNPATH in the +# binaries in $out/bin (patchelf --force-rpath doesn't quite work, +# since it doesn't discard the existing RUNPATH). +mkdir $out/lib2 +ln -s $out/lib/libpthread* $out/lib2