nixpkgs/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh
Lluís Batlle i Rossell d8b0834973 unpack-bootstrap-tools: Removing the patch of libstdc++
Although patching it made some programs run (configure tests), some others
crashed with segfault. So I don't think there is any win patching it. The
proper way to solve the bootstrap in the raspberry pi is, as far as I've been
testing, use glibc 2.17 libs in bootstrap-tools with the same ld.so name as the
bootstrapped glibc.

This is a problem inherent in our way to bootstrap, that first replaces
the glibc of a given gcc+glibc (bootstrap-tools) with gcc-wrapper tricks, and
then builds a new gcc. A nicer way would be to build a gcc without glibc,
then the glibc, then the final gcc, as we do with cross-tools.

Some comments about this problem in
https://github.com/NixOS/nixpkgs/issues/234#issuecomment-11764352
2012-12-30 13:53:48 +00:00

57 lines
2.0 KiB
Bash

set -e
# Unpack the bootstrap tools tarball.
echo Unpacking the bootstrap tools...
$mkdir $out
$bzip2 -d < $tarball | (cd $out && $cpio -V -i)
# Set the ELF interpreter / RPATH in the bootstrap binaries.
echo Patching the bootstrap tools...
# 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 $out/lib/ld-linux*.so.? $out/bin/cp $out/bin/patchelf .
for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do
if test ${i%.la} != $i; then continue; fi
if test ${i%*.so*} != $i; then continue; fi
if ! test -f $i; then continue; fi
if test -L $i; then continue; fi
echo patching $i
LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
$out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
$out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
done
for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp*; do
if ! test -f $i; then continue; fi
if test -L $i; then continue; fi
echo patching $i
LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
$out/bin/patchelf --set-rpath $out/lib --force-rpath $i
LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
$out/bin/patchelf --set-rpath $out/lib --force-rpath $i
done
# Fix the libc linker script.
export PATH=$out/bin
cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp
mv $out/lib/libc.so.tmp $out/lib/libc.so
cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp
mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
# Provide some additional symlinks.
ln -s bash $out/bin/sh
ln -s bzip2 $out/bin/bunzip2
# Mimic the gunzip script as in gzip installations
cat > $out/bin/gunzip <<EOF
#!$out/bin/sh
exec $out/bin/gzip -d "\$@"
EOF
chmod +x $out/bin/gunzip
# fetchurl needs curl.
bzip2 -d < $curl > $out/bin/curl
chmod +x $out/bin/curl