2012-12-22 11:17:06 +00:00
|
|
|
{system ? builtins.currentSystem}:
|
|
|
|
|
2015-01-29 01:36:16 +00:00
|
|
|
let buildFor = toolsArch: (
|
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
let
|
2016-03-13 18:24:55 +00:00
|
|
|
pkgsFun = import ../../..;
|
2012-12-22 11:17:06 +00:00
|
|
|
pkgsNoParams = pkgsFun {};
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2015-02-05 20:37:29 +00:00
|
|
|
sheevaplugCrossSystem = {
|
|
|
|
crossSystem = rec {
|
2016-07-16 22:11:34 +01:00
|
|
|
config = "arm-linux-gnueabi";
|
2015-02-05 20:37:29 +00:00
|
|
|
bigEndian = false;
|
2016-07-16 22:11:34 +01:00
|
|
|
arch = "armv5te";
|
2015-02-05 20:37:29 +00:00
|
|
|
float = "soft";
|
|
|
|
withTLS = true;
|
|
|
|
libc = "glibc";
|
|
|
|
platform = pkgsNoParams.platforms.sheevaplug;
|
|
|
|
openssl.system = "linux-generic32";
|
2016-08-27 22:30:48 +01:00
|
|
|
inherit (platform) gcc;
|
2015-02-05 20:37:29 +00:00
|
|
|
};
|
|
|
|
};
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
raspberrypiCrossSystem = {
|
2015-01-29 01:36:16 +00:00
|
|
|
crossSystem = rec {
|
2016-07-16 22:11:34 +01:00
|
|
|
config = "arm-linux-gnueabihf";
|
2012-12-28 16:39:54 +00:00
|
|
|
bigEndian = false;
|
2016-07-16 22:11:34 +01:00
|
|
|
arch = "armv6";
|
2012-12-28 16:39:54 +00:00
|
|
|
float = "hard";
|
|
|
|
fpu = "vfp";
|
|
|
|
withTLS = true;
|
|
|
|
libc = "glibc";
|
|
|
|
platform = pkgsNoParams.platforms.raspberrypi;
|
|
|
|
openssl.system = "linux-generic32";
|
2015-01-29 01:36:16 +00:00
|
|
|
inherit (platform) gcc;
|
2012-12-22 11:17:06 +00:00
|
|
|
};
|
|
|
|
};
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2015-05-06 09:15:13 +01:00
|
|
|
armv7l-hf-multiplatform-crossSystem = {
|
2015-01-29 01:36:16 +00:00
|
|
|
crossSystem = rec {
|
2016-07-16 22:11:34 +01:00
|
|
|
config = "arm-linux-gnueabihf";
|
2012-12-28 16:39:54 +00:00
|
|
|
bigEndian = false;
|
2016-07-16 22:11:34 +01:00
|
|
|
arch = "armv7-a";
|
2012-12-28 16:39:54 +00:00
|
|
|
float = "hard";
|
2015-01-29 01:36:16 +00:00
|
|
|
fpu = "vfpv3-d16";
|
2012-12-28 16:39:54 +00:00
|
|
|
withTLS = true;
|
2015-01-29 01:36:16 +00:00
|
|
|
libc = "glibc";
|
2015-05-06 09:15:13 +01:00
|
|
|
platform = pkgsNoParams.platforms.armv7l-hf-multiplatform;
|
2012-12-28 16:39:54 +00:00
|
|
|
openssl.system = "linux-generic32";
|
2015-01-29 01:36:16 +00:00
|
|
|
inherit (platform) gcc;
|
2012-12-22 11:17:06 +00:00
|
|
|
};
|
|
|
|
};
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2015-01-29 01:36:16 +00:00
|
|
|
selectedCrossSystem =
|
2015-02-05 20:37:29 +00:00
|
|
|
if toolsArch == "armv5tel" then sheevaplugCrossSystem else
|
2015-01-29 01:36:16 +00:00
|
|
|
if toolsArch == "armv6l" then raspberrypiCrossSystem else
|
2015-05-06 09:15:13 +01:00
|
|
|
if toolsArch == "armv7l" then armv7l-hf-multiplatform-crossSystem else null;
|
2012-12-22 11:17:06 +00:00
|
|
|
|
2015-01-29 01:36:16 +00:00
|
|
|
pkgs = pkgsFun ({inherit system;} // selectedCrossSystem);
|
2012-12-22 11:17:06 +00:00
|
|
|
|
|
|
|
inherit (pkgs) stdenv nukeReferences cpio binutilsCross;
|
|
|
|
|
|
|
|
glibc = pkgs.libcCross;
|
2012-12-28 20:22:13 +00:00
|
|
|
bash = pkgs.bash.crossDrv;
|
|
|
|
findutils = pkgs.findutils.crossDrv;
|
|
|
|
diffutils = pkgs.diffutils.crossDrv;
|
|
|
|
gnused = pkgs.gnused.crossDrv;
|
|
|
|
gnugrep = pkgs.gnugrep.crossDrv;
|
|
|
|
gawk = pkgs.gawk.crossDrv;
|
|
|
|
gzip = pkgs.gzip.crossDrv;
|
|
|
|
bzip2 = pkgs.bzip2.crossDrv;
|
|
|
|
gnumake = pkgs.gnumake.crossDrv;
|
|
|
|
patch = pkgs.patch.crossDrv;
|
|
|
|
patchelf = pkgs.patchelf.crossDrv;
|
2015-01-29 01:36:16 +00:00
|
|
|
gcc = pkgs.gcc.cc.crossDrv;
|
|
|
|
gmpxx = pkgs.gmpxx.crossDrv;
|
2012-12-28 20:22:13 +00:00
|
|
|
mpfr = pkgs.mpfr.crossDrv;
|
|
|
|
zlib = pkgs.zlib.crossDrv;
|
2015-01-17 08:55:32 +00:00
|
|
|
libmpc = pkgs.libmpc.crossDrv;
|
2012-12-28 20:22:13 +00:00
|
|
|
binutils = pkgs.binutils.crossDrv;
|
2015-01-29 01:36:16 +00:00
|
|
|
libelf = pkgs.libelf.crossDrv;
|
2012-12-22 11:17:06 +00:00
|
|
|
|
2016-01-05 09:25:53 +00:00
|
|
|
# Keep these versions in sync with the versions used in the current GCC!
|
|
|
|
isl = pkgs.isl_0_14.crossDrv;
|
2012-12-22 11:17:06 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
|
2016-07-17 01:40:45 +01:00
|
|
|
|
2015-01-29 01:36:16 +00:00
|
|
|
coreutilsMinimal = (pkgs.coreutils.override (args: {
|
2017-01-04 22:46:34 +00:00
|
|
|
# We want coreutils without ACL/attr support.
|
2015-01-29 01:36:16 +00:00
|
|
|
aclSupport = false;
|
2017-01-04 22:46:34 +00:00
|
|
|
attrSupport = false;
|
2016-06-28 08:48:56 +01:00
|
|
|
# Our tooling currently can't handle scripts in bin/, only ELFs and symlinks.
|
|
|
|
singleBinary = "symlinks";
|
2015-01-29 01:36:16 +00:00
|
|
|
})).crossDrv;
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2016-07-17 01:40:45 +01:00
|
|
|
tarMinimal = (pkgs.gnutar.override { acl = null; }).crossDrv;
|
|
|
|
|
2015-01-29 01:36:16 +00:00
|
|
|
busyboxMinimal = (pkgs.busybox.override {
|
2016-06-01 20:52:34 +01:00
|
|
|
useMusl = true;
|
2015-01-29 01:36:16 +00:00
|
|
|
enableStatic = true;
|
|
|
|
enableMinimal = true;
|
|
|
|
extraConfig = ''
|
|
|
|
CONFIG_ASH y
|
|
|
|
CONFIG_ASH_BUILTIN_ECHO y
|
|
|
|
CONFIG_ASH_BUILTIN_TEST y
|
|
|
|
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
|
|
|
|
CONFIG_MKDIR y
|
|
|
|
CONFIG_TAR y
|
|
|
|
CONFIG_UNXZ y
|
|
|
|
'';
|
|
|
|
}).crossDrv;
|
2016-06-01 11:18:58 +01:00
|
|
|
|
|
|
|
build =
|
2012-12-22 11:17:06 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2016-07-17 01:40:45 +01:00
|
|
|
name = "stdenv-bootstrap-tools-cross";
|
|
|
|
crossConfig = stdenv.cross.config;
|
2012-12-22 11:17:06 +00:00
|
|
|
|
|
|
|
buildInputs = [nukeReferences cpio binutilsCross];
|
|
|
|
|
|
|
|
buildCommand = ''
|
2016-07-17 01:40:45 +01:00
|
|
|
set -x
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/bin $out/lib $out/libexec
|
2012-12-22 11:17:06 +00:00
|
|
|
|
|
|
|
# Copy what we need of Glibc.
|
2015-04-26 18:54:51 +01:00
|
|
|
cp -d ${glibc.out}/lib/ld-*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libc*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libc_nonshared.a $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libm*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libdl*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/librt*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libpthread*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libnsl*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libutil*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libnss*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/libresolv*.so* $out/lib
|
|
|
|
cp -d ${glibc.out}/lib/crt?.o $out/lib
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2015-04-26 18:54:51 +01:00
|
|
|
cp -rL ${glibc.dev}/include $out
|
2016-07-17 01:40:45 +01:00
|
|
|
chmod -R u+w "$out"
|
|
|
|
|
|
|
|
# glibc can contain linker scripts: find them, copy their deps,
|
|
|
|
# and get rid of absolute paths (nuke-refs would make them useless)
|
|
|
|
local lScripts=$(grep --files-with-matches --max-count=1 'GNU ld script' -R "$out/lib")
|
|
|
|
cp -d -t "$out/lib/" $(cat $lScripts | tr " " "\n" | grep -F '${glibc.out}' | sort -u)
|
|
|
|
for f in $lScripts; do
|
|
|
|
substituteInPlace "$f" --replace '${glibc.out}/lib/' ""
|
|
|
|
done
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
# 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
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
# Copy coreutils, bash, etc.
|
2015-01-29 01:36:16 +00:00
|
|
|
cp ${coreutilsMinimal}/bin/* $out/bin
|
2012-12-22 11:17:06 +00:00
|
|
|
(cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
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
|
2015-01-29 01:36:16 +00:00
|
|
|
cp -d ${gnugrep}/bin/grep $out/bin
|
2012-12-22 11:17:06 +00:00
|
|
|
cp ${gawk}/bin/gawk $out/bin
|
|
|
|
cp -d ${gawk}/bin/awk $out/bin
|
2016-07-17 01:40:45 +01:00
|
|
|
cp ${tarMinimal}/bin/tar $out/bin
|
2012-12-22 11:17:06 +00:00
|
|
|
cp ${gzip}/bin/gzip $out/bin
|
2016-02-01 18:45:57 +00:00
|
|
|
cp ${bzip2.bin}/bin/bzip2 $out/bin
|
2012-12-22 11:17:06 +00:00
|
|
|
cp -d ${gnumake}/bin/* $out/bin
|
|
|
|
cp -d ${patch}/bin/* $out/bin
|
|
|
|
cp ${patchelf}/bin/* $out/bin
|
|
|
|
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -d ${gnugrep.pcre.crossDrv.out}/lib/libpcre*.so* $out/lib # needed by grep
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
# Copy what we need of GCC.
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -d ${gcc.out}/bin/gcc $out/bin
|
|
|
|
cp -d ${gcc.out}/bin/cpp $out/bin
|
|
|
|
cp -d ${gcc.out}/bin/g++ $out/bin
|
|
|
|
cp -d ${gcc.lib}/lib*/libgcc_s.so* $out/lib
|
|
|
|
cp -d ${gcc.lib}/lib*/libstdc++.so* $out/lib
|
|
|
|
cp -rd ${gcc.out}/lib/gcc $out/lib
|
2012-12-22 11:17:06 +00:00
|
|
|
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
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -rd ${gcc.out}/libexec/* $out/libexec
|
2015-01-29 01:36:16 +00:00
|
|
|
chmod -R u+w $out/libexec
|
|
|
|
rm -rf $out/libexec/gcc/*/*/plugin
|
2012-12-22 11:17:06 +00:00
|
|
|
mkdir $out/include
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -rd ${gcc.out}/include/c++ $out/include
|
2012-12-22 11:17:06 +00:00
|
|
|
chmod -R u+w $out/include
|
|
|
|
rm -rf $out/include/c++/*/ext/pb_ds
|
|
|
|
rm -rf $out/include/c++/*/ext/parallel
|
|
|
|
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -d ${gmpxx.out}/lib/libgmp*.so* $out/lib
|
2016-01-24 07:30:00 +00:00
|
|
|
cp -d ${mpfr.out}/lib/libmpfr*.so* $out/lib
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
|
2016-01-24 07:30:24 +00:00
|
|
|
cp -d ${zlib.out}/lib/libz.so* $out/lib
|
2015-01-29 01:36:16 +00:00
|
|
|
cp -d ${libelf}/lib/libelf.so* $out/lib
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2016-01-05 09:25:53 +00:00
|
|
|
# These needed for cross but not native tools because the stdenv
|
|
|
|
# GCC has certain things built in statically. See
|
|
|
|
# pkgs/stdenv/linux/default.nix for the details.
|
2012-12-23 12:18:26 +00:00
|
|
|
cp -d ${isl}/lib/libisl*.so* $out/lib
|
2016-01-05 09:25:53 +00:00
|
|
|
# Also this is needed since bzip2 uses a custom build system
|
|
|
|
# for native builds but autoconf (via a patch) for cross builds
|
2016-06-01 21:01:57 +01:00
|
|
|
cp -d ${bzip2.out}/lib/libbz2.so* $out/lib
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
# Copy binutils.
|
|
|
|
for i in as ld ar ranlib nm strip readelf objdump; do
|
2016-06-01 21:01:57 +01:00
|
|
|
cp ${binutils.out}/bin/$i $out/bin
|
2012-12-22 11:17:06 +00:00
|
|
|
done
|
2016-01-24 07:28:57 +00:00
|
|
|
cp -d ${binutils.out}/lib/lib*.so* $out/lib
|
2012-12-22 11:17:06 +00:00
|
|
|
|
|
|
|
chmod -R u+w $out
|
2016-06-01 11:18:58 +01:00
|
|
|
|
2012-12-22 11:17:06 +00:00
|
|
|
# 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/*/*/*
|
|
|
|
|
|
|
|
mkdir $out/.pack
|
|
|
|
mv $out/* $out/.pack
|
|
|
|
mv $out/.pack $out/pack
|
|
|
|
|
|
|
|
mkdir $out/on-server
|
2016-07-18 23:04:53 +01:00
|
|
|
tar cvfJ $out/on-server/bootstrap-tools.tar.xz --hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 -C $out/pack .
|
2015-01-29 01:36:16 +00:00
|
|
|
cp ${busyboxMinimal}/bin/busybox $out/on-server
|
|
|
|
chmod u+w $out/on-server/busybox
|
|
|
|
nuke-refs $out/on-server/busybox
|
2012-12-22 11:17:06 +00:00
|
|
|
''; # */
|
|
|
|
|
|
|
|
# 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 = [];
|
|
|
|
};
|
|
|
|
|
2016-07-17 04:34:31 +01:00
|
|
|
dist = stdenv.mkDerivation {
|
|
|
|
name = "stdenv-bootstrap-tools-cross";
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "file tarball ${build}/on-server/bootstrap-tools.tar.xz" >> $out/nix-support/hydra-build-products
|
|
|
|
echo "file busybox ${build}/on-server/busybox" >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
};
|
2015-01-29 01:36:16 +00:00
|
|
|
}
|
2012-12-22 11:17:06 +00:00
|
|
|
|
2015-01-29 01:36:16 +00:00
|
|
|
); in {
|
2015-02-05 20:37:29 +00:00
|
|
|
armv5tel = buildFor "armv5tel";
|
2015-01-29 01:36:16 +00:00
|
|
|
armv6l = buildFor "armv6l";
|
|
|
|
armv7l = buildFor "armv7l";
|
2012-12-22 11:17:06 +00:00
|
|
|
}
|