diff --git a/pkgs/development/interpreters/perl/default.nix b/pkgs/development/interpreters/perl/default.nix index 9c3c34c73aad1..78d1cc5b98d34 100644 --- a/pkgs/development/interpreters/perl/default.nix +++ b/pkgs/development/interpreters/perl/default.nix @@ -121,9 +121,6 @@ let EOF '' + optionalString stdenv.isDarwin '' substituteInPlace hints/darwin.sh --replace "env MACOSX_DEPLOYMENT_TARGET=10.3" "" - '' + optionalString (!enableThreading) '' - # We need to do this because the bootstrap doesn't have a static libpthread - sed -i 's,\(libswanted.*\)pthread,\1,g' Configure ''; # Default perl does not support --host= & co. diff --git a/pkgs/stdenv/linux/bootstrap-tools/scripts/unpack-bootstrap-tools.sh b/pkgs/stdenv/linux/bootstrap-tools/scripts/unpack-bootstrap-tools.sh index f394869ea915b..5f6c9fc61df4b 100644 --- a/pkgs/stdenv/linux/bootstrap-tools/scripts/unpack-bootstrap-tools.sh +++ b/pkgs/stdenv/linux/bootstrap-tools/scripts/unpack-bootstrap-tools.sh @@ -8,32 +8,42 @@ echo Patching the bootstrap tools... if test -f $out/lib/ld.so.?; then # MIPS case - LD_BINARY=$out/lib/ld.so.? + LD_BINARY=lib/ld.so.? elif test -f $out/lib/ld64.so.?; then # ppc64(le) - LD_BINARY=$out/lib/ld64.so.? + LD_BINARY=lib/ld64.so.? else # i686, x86_64 and armv5tel - LD_BINARY=$out/lib/ld-*so.? + LD_BINARY=lib/ld-*so.? fi -# On x86_64, ld-linux-x86-64.so.2 barfs on patchelf'ed programs. So -# use a copy of patchelf. -LD_LIBRARY_PATH=$out/lib $LD_BINARY $out/bin/cp $out/bin/patchelf . +# make a copy of patchelf and lib so we don't try patchelf'ing +# patchelf itself, or a library that patchelf itself links against -- +# this may cause segfaults due to lazy loading of binary images +LD_LIBRARY_PATH=$out/lib $out/$LD_BINARY $out/bin/cp -r $out/lib $out/bin/patchelf . -for i in $out/bin/* $out/libexec/gcc/*/*/*; do - if [ -L "$i" ]; then continue; fi - if [ -z "${i##*/liblto*}" ]; then continue; fi - echo patching "$i" - LD_LIBRARY_PATH=$out/lib $LD_BINARY \ - ./patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i" -done +export LD_LIBRARY_PATH=lib +for i in $($LD_BINARY $out/bin/find $out -type f -executable); do + + interp=$($LD_BINARY ./patchelf --print-interpreter $i 2>/dev/null || echo) + + # patchelf --set-interpreter only if a nuke-ref'd interpreter is found + if [ -n "${interp}" ] && [ -z "${interp##/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-*/lib*/*}" ]; then + echo patching interpreter of "$i" + $LD_BINARY ./patchelf --set-interpreter $out/$LD_BINARY "$i" + fi + + rpath=$($LD_BINARY ./patchelf --print-rpath $i 2>/dev/null || echo) -for i in $out/lib/librt-*.so $out/lib/libpcre*; do - if [ -L "$i" ]; then continue; fi - echo patching "$i" - $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i" + # patchelf --set-rpath only if a nuke-ref'd rpath is found + if [ -n "${rpath}" ] && [ -z "${rpath##/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-*}" ] && + # do not use patchelf --set-rpath on libgcc_s.so.1, because its rpath leaks into stdenv-final + [ -n "${i##*/lib*/libgcc_s.so.*}" ]; then + echo patching rpath of "$i" + $LD_BINARY ./patchelf --set-rpath $out/lib --force-rpath "$i" + fi done +export LD_LIBRARY_PATH= export PATH=$out/bin diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index e9104dd88cfa1..48f6d054b159c 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -212,13 +212,6 @@ in gcc-unwrapped coreutils gnugrep; ${localSystem.libc} = getLibc prevStage; - - # A threaded perl build needs glibc/libpthread_nonshared.a, - # which is not included in bootstrapTools, so disable threading. - # This is not an issue for the final stdenv, because this perl - # won't be included in the final stdenv and won't be exported to - # top-level pkgs as an override either. - perl = super.perl.override { enableThreading = false; }; }; })