diff options
author | Lluís Batlle i Rossell <viric@viric.name> | 2012-12-31 16:03:16 +0000 |
---|---|---|
committer | Lluís Batlle i Rossell <viric@viric.name> | 2012-12-31 16:03:16 +0000 |
commit | d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef (patch) | |
tree | a495143f5c331bbb4c20f291c1d2472e2c5a8779 /pkgs/stdenv/linux | |
parent | df65a79bb3dfa94209f66f668ac5a2ab46af779b (diff) | |
parent | 2402bb2613b80427feaeea1290c9f95702170584 (diff) | |
download | nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.tar nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.tar.gz nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.tar.bz2 nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.tar.lz nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.tar.xz nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.tar.zst nixlib-d16f4bb3ed4e0bc181726a1a5c661f2c8cdc50ef.zip |
Merge branch 'pi-stdenv-updates' into stdenv-updates
This adds raspberry pi support. I've almost tested all. Should fix https://github.com/NixOS/nixpkgs/issues/234
Diffstat (limited to 'pkgs/stdenv/linux')
-rw-r--r-- | pkgs/stdenv/linux/bootstrap/armv6l/default.nix | 15 | ||||
-rw-r--r-- | pkgs/stdenv/linux/default.nix | 5 | ||||
-rw-r--r-- | pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix | 269 | ||||
-rw-r--r-- | pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh | 28 |
4 files changed, 302 insertions, 15 deletions
diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix new file mode 100644 index 000000000000..ecda6be8bd32 --- /dev/null +++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix @@ -0,0 +1,15 @@ +{ + sh = ../armv5tel/sh; + bzip2 = ../armv5tel/bzip2; + mkdir = ../armv5tel/mkdir; + cpio = ../armv5tel/cpio; + ln = ../armv5tel/ln; + curl = ../armv5tel/curl.bz2; + + bootstrapTools = { + # Built from make-bootstrap-tools-crosspi.nix + # nixpkgs rev eb0422e4c1263a65a9b2b954fe10a1e03d67db3e + url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2; + sha256 = "1zb27x5h54k51yrvn3sy4wb1qprx8iv2kfbgklxwc0mcxp9b7ccd"; + }; +} diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index e4a8bd77076c..21a916231e05 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -16,6 +16,7 @@ rec { else if system == "x86_64-linux" then import ./bootstrap/x86_64 else if system == "powerpc-linux" then import ./bootstrap/powerpc else if system == "armv5tel-linux" then import ./bootstrap/armv5tel + else if system == "armv6l-linux" then import ./bootstrap/armv6l else if system == "armv7l-linux" then import ./bootstrap/armv5tel else if system == "mips64el-linux" then import ./bootstrap/loongson2f else abort "unsupported platform for the pure Linux stdenv"; @@ -57,7 +58,7 @@ rec { builder = bootstrapFiles.sh; args = - if system == "armv5tel-linux" + if (system == "armv5tel-linux" || system == "armv6l-linux") then [ ./scripts/unpack-bootstrap-tools-arm.sh ] else [ ./scripts/unpack-bootstrap-tools.sh ]; @@ -273,7 +274,7 @@ rec { inherit (stdenvLinuxBoot3Pkgs) binutils; inherit (stdenvLinuxBoot4Pkgs) coreutils; libc = stdenvLinuxGlibc; - gcc = stdenvLinuxBoot3Pkgs.gcc.gcc; + gcc = stdenvLinuxBoot4.gcc.gcc; shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash"; name = ""; }; diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix new file mode 100644 index 000000000000..9b2949e3e368 --- /dev/null +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -0,0 +1,269 @@ +{system ? builtins.currentSystem}: + +let + pkgsFun = import ../../top-level/all-packages.nix; + pkgsNoParams = pkgsFun {}; + raspberrypiCrossSystem = { + crossSystem = { + config = "armv6l-unknown-linux-gnueabi"; + bigEndian = false; + arch = "arm"; + float = "hard"; + fpu = "vfp"; + withTLS = true; + libc = "glibc"; + platform = pkgsNoParams.platforms.raspberrypi; + openssl.system = "linux-generic32"; + gcc = { + arch = "armv6"; + fpu = "vfp"; + float = "hard"; + }; + }; + }; + + raspberrypiCrossSystemUclibc = { + crossSystem = { + config = "armv6l-unknown-linux-gnueabi"; + bigEndian = false; + arch = "arm"; + float = "hard"; + fpu = "vfp"; + withTLS = true; + libc = "uclibc"; + platform = pkgsNoParams.platforms.raspberrypi; + openssl.system = "linux-generic32"; + gcc = { + arch = "armv6"; + fpu = "vfp"; + float = "hard"; + }; + uclibc.extraConfig = '' + ARCH_WANTS_BIG_ENDIAN n + ARCH_BIG_ENDIAN n + ARCH_WANTS_LITTLE_ENDIAN y + ARCH_LITTLE_ENDIAN y + ''; + }; + }; + + pkgsuclibc = pkgsFun ({inherit system;} // raspberrypiCrossSystemUclibc); + pkgs = pkgsFun ({inherit system;} // raspberrypiCrossSystem); + + inherit (pkgs) stdenv nukeReferences cpio binutilsCross; + + # We want coreutils without ACL support. + coreutils_base = pkgs.coreutils.override (args: { + aclSupport = false; + }); + + coreutils_ = coreutils_base.crossDrv; + + glibc = pkgs.libcCross; + bash = pkgs.bash.crossDrv; + findutils = pkgs.findutils.crossDrv; + diffutils = pkgs.diffutils.crossDrv; + gnused = pkgs.gnused.crossDrv; + gnugrep = pkgs.gnugrep.crossDrv; + gawk = pkgs.gawk.crossDrv; + gnutar = pkgs.gnutar.crossDrv; + gzip = pkgs.gzip.crossDrv; + bzip2 = pkgs.bzip2.crossDrv; + gnumake = pkgs.gnumake.crossDrv; + patch = pkgs.patch.crossDrv; + patchelf = pkgs.patchelf.crossDrv; + replace = pkgs.replace.crossDrv; + gcc = pkgs.gcc47; + gmp = pkgs.gmp.crossDrv; + mpfr = pkgs.mpfr.crossDrv; + ppl = pkgs.ppl.crossDrv; + cloogppl = pkgs.cloogppl.crossDrv; + cloog = pkgs.cloog.crossDrv; + zlib = pkgs.zlib.crossDrv; + isl = pkgs.isl.crossDrv; + mpc = pkgs.mpc.crossDrv; + binutils = pkgs.binutils.crossDrv; + klibc = pkgs.klibc.crossDrv; + +in + +rec { + + curlStatic = import <nixpkgs/pkgs/tools/networking/curl> { + stdenv = pkgsuclibc.stdenv; + inherit (pkgsuclibc) fetchurl; + zlibSupport = false; + sslSupport = false; + linkStatic = true; + }; + + bzip2Static = import <nixpkgs/pkgs/tools/compression/bzip2> { + stdenv = pkgsuclibc.stdenv; + inherit (pkgsuclibc) fetchurl; + linkStatic = true; + }; + + inherit pkgs; + + build = + + stdenv.mkDerivation { + name = "build"; + + buildInputs = [nukeReferences cpio binutilsCross]; + + crossConfig = stdenv.cross.config; + + buildCommand = '' + set -x + ensureDir $out/bin $out/lib $out/libexec + + # Copy what we need of Glibc. + cp -d ${glibc}/lib/ld-*.so* $out/lib + cp -d ${glibc}/lib/libc*.so* $out/lib + cp -d ${glibc}/lib/libc_nonshared.a $out/lib + cp -d ${glibc}/lib/libm*.so* $out/lib + cp -d ${glibc}/lib/libdl*.so* $out/lib + cp -d ${glibc}/lib/librt*.so* $out/lib + cp -d ${glibc}/lib/libpthread*.so* $out/lib + cp -d ${glibc}/lib/libnsl*.so* $out/lib + cp -d ${glibc}/lib/libutil*.so* $out/lib + cp -d ${glibc}/lib/crt?.o $out/lib + + cp -rL ${glibc}/include $out + chmod -R u+w $out/include + + # Hopefully we won't need these. + rm -rf $out/include/mtd $out/include/rdma $out/include/sound $out/include/video + find $out/include -name .install -exec rm {} \; + find $out/include -name ..install.cmd -exec rm {} \; + mv $out/include $out/include-glibc + + # Copy coreutils, bash, etc. + cp ${coreutils_}/bin/* $out/bin + (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users) + + cp ${bash}/bin/bash $out/bin + cp ${findutils}/bin/find $out/bin + cp ${findutils}/bin/xargs $out/bin + cp -d ${diffutils}/bin/* $out/bin + cp -d ${gnused}/bin/* $out/bin + cp -d ${gnugrep}/bin/* $out/bin + cp ${gawk}/bin/gawk $out/bin + cp -d ${gawk}/bin/awk $out/bin + cp ${gnutar}/bin/tar $out/bin + cp ${gzip}/bin/gzip $out/bin + cp ${bzip2}/bin/bzip2 $out/bin + cp -d ${gnumake}/bin/* $out/bin + cp -d ${patch}/bin/* $out/bin + cp ${patchelf}/bin/* $out/bin + cp ${replace}/bin/* $out/bin + + cp -d ${gnugrep.pcre.crossDrv}/lib/libpcre*.so* $out/lib # needed by grep + + # Copy what we need of GCC. + cp -d ${gcc.gcc.crossDrv}/bin/gcc $out/bin + cp -d ${gcc.gcc.crossDrv}/bin/cpp $out/bin + cp -d ${gcc.gcc.crossDrv}/bin/g++ $out/bin + cp -d ${gcc.gcc.crossDrv}/lib*/libgcc_s.so* $out/lib + cp -d ${gcc.gcc.crossDrv}/lib*/libstdc++.so* $out/lib + cp -rd ${gcc.gcc.crossDrv}/lib/gcc $out/lib + chmod -R u+w $out/lib + rm -f $out/lib/gcc/*/*/include*/linux + rm -f $out/lib/gcc/*/*/include*/sound + rm -rf $out/lib/gcc/*/*/include*/root + rm -f $out/lib/gcc/*/*/include-fixed/asm + rm -rf $out/lib/gcc/*/*/plugin + #rm -f $out/lib/gcc/*/*/*.a + cp -rd ${gcc.gcc.crossDrv}/libexec/* $out/libexec + mkdir $out/include + cp -rd ${gcc.gcc.crossDrv}/include/c++ $out/include + chmod -R u+w $out/include + rm -rf $out/include/c++/*/ext/pb_ds + rm -rf $out/include/c++/*/ext/parallel + + cp -d ${gmp}/lib/libgmp*.so* $out/lib + cp -d ${mpfr}/lib/libmpfr*.so* $out/lib + cp -d ${cloogppl}/lib/libcloog*.so* $out/lib + cp -d ${cloog}/lib/libcloog*.so* $out/lib + cp -d ${ppl}/lib/libppl*.so* $out/lib + cp -d ${isl}/lib/libisl*.so* $out/lib + cp -d ${mpc}/lib/libmpc*.so* $out/lib + cp -d ${zlib}/lib/libz.so* $out/lib + + # Copy binutils. + for i in as ld ar ranlib nm strip readelf objdump; do + cp ${binutils}/bin/$i $out/bin + done + + chmod -R u+w $out + + # Strip executables even further. + for i in $out/bin/* $out/libexec/gcc/*/*/*; do + if test -x $i -a ! -L $i; then + chmod +w $i + $crossConfig-strip -s $i || true + fi + done + + nuke-refs $out/bin/* + nuke-refs $out/lib/* + nuke-refs $out/libexec/gcc/*/*/* + nuke-refs $out/libexec/gcc/*/*/*/* + + mkdir $out/.pack + mv $out/* $out/.pack + mv $out/.pack $out/pack + + mkdir $out/on-server + (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2 + + mkdir $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/sh $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/ln $out/in-nixpkgs + cp ${curlStatic.crossDrv}/bin/curl $out/in-nixpkgs + cp ${bzip2Static.crossDrv}/bin/bzip2 $out/in-nixpkgs + chmod u+w $out/in-nixpkgs/* + $crossConfig-strip $out/in-nixpkgs/* + nuke-refs $out/in-nixpkgs/* + bzip2 $out/in-nixpkgs/curl + ''; # */ + + # The result should not contain any references (store paths) so + # that we can safely copy them out of the store and to other + # locations in the store. + allowedReferences = []; + }; + + + unpack = + + stdenv.mkDerivation { + name = "unpack"; + + buildCommand = '' + ${build}/in-nixpkgs/mkdir $out + ${build}/in-nixpkgs/bzip2 -d < ${build}/on-server/bootstrap-tools.cpio.bz2 | (cd $out && ${build}/in-nixpkgs/cpio -V -i) + + for i in $out/bin/* $out/libexec/gcc/*/*/*; do + echo patching $i + if ! test -L $i; then + LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \ + $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath $i + fi + done + + # Fix the libc linker script. + for i in $out/lib/libc.so; do + cat $i | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $i.tmp + mv $i.tmp $i + done + ''; # " */ + + allowedReferences = ["out"]; + }; + + +} diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh index 3709ac05041b..dcf819ad6f75 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh @@ -13,22 +13,24 @@ echo Patching the bootstrap tools... 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 - if ! test -L $i; then - 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 - fi + 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/libppl* $out/lib/libgmp*; do +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 - if ! test -L $i; then - 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 - fi + 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. |