uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
11
pkgs/stdenv/linux/bootstrap-files/aarch64-musl.nix
Normal file
11
pkgs/stdenv/linux/bootstrap-files/aarch64-musl.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/busybox";
|
||||
sha256 = "01s6bwq84wyrjh3rdsgxni9gkzp7ss8rghg0cmp8zd87l79y8y4g";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz";
|
||||
sha256 = "0pbqrw9z4ifkijpfpx15l2dzi00rq8c5zg9ghimz5qgr5dx7f7cl";
|
||||
};
|
||||
}
|
||||
11
pkgs/stdenv/linux/bootstrap-files/aarch64.nix
Normal file
11
pkgs/stdenv/linux/bootstrap-files/aarch64.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/aarch64/c7c997a0662bf88264db52cbc41e67884eb7a1ff/busybox";
|
||||
sha256 = "sha256-4EN2vLvXUkelZZR2eKaAQA5kCEuHNvRZN6dcohxVY+c=";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/aarch64/c7c997a0662bf88264db52cbc41e67884eb7a1ff/bootstrap-tools.tar.xz";
|
||||
sha256 = "sha256-AjOvmaW8JFVZaBSRUMKufr9kJozg/tsZr7PvUEBQyi4=";
|
||||
};
|
||||
}
|
||||
18
pkgs/stdenv/linux/bootstrap-files/armv5tel.nix
Normal file
18
pkgs/stdenv/linux/bootstrap-files/armv5tel.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
# Note: do not use Hydra as a source URL. Ask a member of the
|
||||
# infrastructure team to mirror the job.
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
# from job: https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.armv5tel.dist/latest
|
||||
# from build: https://hydra.nixos.org/build/114203025
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/armv5tel/0eb0ddc4dbe3cd5415c6b6e657538eb809fc3778/busybox";
|
||||
# note: the following hash is different than the above hash, due to executable = true
|
||||
sha256 = "0qxp2fsvs4phbc17g9npj9bsm20ylr8myi5pivcrmxm5qqflgi8d";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
# from job: https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.armv5tel.dist/latest
|
||||
# from build: https://hydra.nixos.org/build/114203025
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/armv5tel/0eb0ddc4dbe3cd5415c6b6e657538eb809fc3778/bootstrap-tools.tar.xz";
|
||||
sha256 = "28327343db5ecc7f7811449ec69280d5867fa5d1d377cab0426beb9d4e059ed6";
|
||||
};
|
||||
}
|
||||
11
pkgs/stdenv/linux/bootstrap-files/armv6l-musl.nix
Normal file
11
pkgs/stdenv/linux/bootstrap-files/armv6l-musl.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "https://wdtz.org/files/xmz441m69qrlfdw47l2k10zf87fsya6r-stdenv-bootstrap-tools-armv6l-unknown-linux-musleabihf/on-server/busybox";
|
||||
sha256 = "01d0hp1xgrriiy9w0sd9vbqzwxnpwiyah80pi4vrpcmbwji36j1i";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "https://wdtz.org/files/xmz441m69qrlfdw47l2k10zf87fsya6r-stdenv-bootstrap-tools-armv6l-unknown-linux-musleabihf/on-server/bootstrap-tools.tar.xz";
|
||||
sha256 = "1r9mz9w8y5jd7gfwfsrvs20qarzxy7bvrp5dlm41hnx6z617if1h";
|
||||
};
|
||||
}
|
||||
18
pkgs/stdenv/linux/bootstrap-files/armv6l.nix
Normal file
18
pkgs/stdenv/linux/bootstrap-files/armv6l.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
# Note: do not use Hydra as a source URL. Ask a member of the
|
||||
# infrastructure team to mirror the job.
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
# from job: https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.armv6l.dist/latest
|
||||
# from build: https://hydra.nixos.org/build/114202834
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/armv6l/0eb0ddc4dbe3cd5415c6b6e657538eb809fc3778/busybox";
|
||||
# note: the following hash is different than the above hash, due to executable = true
|
||||
sha256 = "1q02537cq56wlaxbz3s3kj5vmh6jbm27jhvga6b4m4jycz5sxxp6";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
# from job: https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.armv6l.dist/latest
|
||||
# from build: https://hydra.nixos.org/build/114202834
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/armv6l/0eb0ddc4dbe3cd5415c6b6e657538eb809fc3778/bootstrap-tools.tar.xz";
|
||||
sha256 = "0810fe74f8cd09831f177d075bd451a66b71278d3cc8db55b07c5e38ef3fbf3f";
|
||||
};
|
||||
}
|
||||
18
pkgs/stdenv/linux/bootstrap-files/armv7l.nix
Normal file
18
pkgs/stdenv/linux/bootstrap-files/armv7l.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
# Note: do not use Hydra as a source URL. Ask a member of the
|
||||
# infrastructure team to mirror the job.
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
# from job: https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.armv7l.dist/latest
|
||||
# from build: https://hydra.nixos.org/build/114203060
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/armv7l/0eb0ddc4dbe3cd5415c6b6e657538eb809fc3778/busybox";
|
||||
# note: the following hash is different than the above hash, due to executable = true
|
||||
sha256 = "18qc6w2yykh7nvhjklsqb2zb3fjh4p9r22nvmgj32jr1mjflcsjn";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
# from job: https://hydra.nixos.org/job/nixpkgs/cross-trunk/bootstrapTools.armv7l.dist/latest
|
||||
# from build: https://hydra.nixos.org/build/114203060
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/armv7l/0eb0ddc4dbe3cd5415c6b6e657538eb809fc3778/bootstrap-tools.tar.xz";
|
||||
sha256 = "cf2968e8085cd3e6b3e9359624060ad24d253800ede48c5338179f6e0082c443";
|
||||
};
|
||||
}
|
||||
12
pkgs/stdenv/linux/bootstrap-files/i686.nix
Normal file
12
pkgs/stdenv/linux/bootstrap-files/i686.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/i686/4907fc9e8d0d82b28b3c56e3a478a2882f1d700f/busybox";
|
||||
sha256 = "ef4c1be6c7ae57e4f654efd90ae2d2e204d6769364c46469fa9ff3761195cba1";
|
||||
executable = true;
|
||||
};
|
||||
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/i686/c5aabb0d603e2c1ea05f5a93b3be82437f5ebf31/bootstrap-tools.tar.xz";
|
||||
sha256 = "b9bf20315f8c5c0411679c5326084420b522046057a0850367c67d9514794f1c";
|
||||
};
|
||||
}
|
||||
44
pkgs/stdenv/linux/bootstrap-files/loongson2f.nix
Normal file
44
pkgs/stdenv/linux/bootstrap-files/loongson2f.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
let
|
||||
|
||||
fetch = { file, sha256 }: import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/loongson2f/r22849/${file}";
|
||||
inherit sha256;
|
||||
executable = true;
|
||||
};
|
||||
|
||||
in {
|
||||
sh = fetch {
|
||||
file = "sh";
|
||||
sha256 = "02jjl49wdq85pgh61aqf78yaknn9mi3rcspbpk7hs9c4mida2rhf";
|
||||
};
|
||||
|
||||
bzip2 = fetch {
|
||||
file = "bzip2";
|
||||
sha256 = "1qn27y3amj9c6mnjk2kyb59y0d2w4yv16z9apaxx91hyq19gf29z";
|
||||
};
|
||||
|
||||
mkdir = fetch {
|
||||
file = "mkdir";
|
||||
sha256 = "1vbp2bv9hkyb2fwl8hjrffpywn1wrl1kc4yrwi2lirawlnc6kymh";
|
||||
};
|
||||
|
||||
cpio = fetch {
|
||||
file = "cpio";
|
||||
sha256 = "0mqxwdx0sl7skxx6049mk35l7d0fnibqsv174284kdp4p7iixwa0";
|
||||
};
|
||||
|
||||
ln = fetch {
|
||||
file = "ln";
|
||||
sha256 = "05lwx8qvga3yv8xhs8bjgsfygsfrcxsfck0lxw6gsdckx25fgi7s";
|
||||
};
|
||||
|
||||
curl = fetch {
|
||||
file = "curl.bz2";
|
||||
sha256 = "0iblnz4my54gryac04i64fn3ksi9g3dx96yjq93fj39z6kx6151c";
|
||||
};
|
||||
|
||||
bootstrapTools = {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/loongson2f/r22849/cross-bootstrap-tools.cpio.bz2";
|
||||
sha256 = "00aavbk76qjj2gdlmpaaj66r8nzl4d7pyl8cv1gigyzgpbr5vv3j";
|
||||
};
|
||||
}
|
||||
25
pkgs/stdenv/linux/bootstrap-files/powerpc64le.nix
Normal file
25
pkgs/stdenv/linux/bootstrap-files/powerpc64le.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Files came from this Hydra build:
|
||||
#
|
||||
# https://hydra.nixos.org/build/172142499
|
||||
#
|
||||
# Which used nixpkgs revision 49a83445c28c4ffb8a1a90a1f68e6150ea48893b
|
||||
# to instantiate:
|
||||
#
|
||||
# /nix/store/gj272sd56gsj6qpyzh4njpfzwdhviliz-stdenv-bootstrap-tools-powerpc64le-unknown-linux-gnu.drv
|
||||
#
|
||||
# and then built:
|
||||
#
|
||||
# /nix/store/n81pljbd8m0xgypm84krc2bnvqgjrfxx-stdenv-bootstrap-tools-powerpc64le-unknown-linux-gnu
|
||||
#
|
||||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/powerpc64le/49a83445c28c4ffb8a1a90a1f68e6150ea48893b/busybox";
|
||||
sha256 = "sha256-UscnfGKOZAKLkPcRtwrbT5Uj8m3Kj9jhkKp9MUc1eCY=";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools =import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/powerpc64le/49a83445c28c4ffb8a1a90a1f68e6150ea48893b/bootstrap-tools.tar.xz";
|
||||
sha256 = "sha256-A20GKGn3rM8K2JcU0SApRp3+avUE+bIm1h632AitRzU=";
|
||||
};
|
||||
}
|
||||
12
pkgs/stdenv/linux/bootstrap-files/riscv64.nix
Normal file
12
pkgs/stdenv/linux/bootstrap-files/riscv64.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/busybox";
|
||||
sha256 = "6f61912f94bc4ef287d1ff48a9521ed16bd07d8d8ec775e471f32c64d346583d";
|
||||
executable = true;
|
||||
};
|
||||
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/riscv64/9bd3cf0063b80428bd85a286205adab4b6ffcbd6/bootstrap-tools.tar.xz";
|
||||
sha256 = "5466b19288e980125fc62ebb864d09908ffe0bc50cebe52cfee89acff14d5b9f";
|
||||
};
|
||||
}
|
||||
11
pkgs/stdenv/linux/bootstrap-files/x86_64-musl.nix
Normal file
11
pkgs/stdenv/linux/bootstrap-files/x86_64-musl.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
busybox = import <nix/fetchurl.nix> {
|
||||
url = "https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/busybox";
|
||||
sha256 = "0779c2wn00467h76xpqil678gfi1y2p57c7zq2d917jsv2qj5009";
|
||||
executable = true;
|
||||
};
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz";
|
||||
sha256 = "1dwiqw4xvnm0b5fdgl89lz2qq45f6s9icwxn6n6ams71xw0dbqyi";
|
||||
};
|
||||
}
|
||||
9
pkgs/stdenv/linux/bootstrap-files/x86_64.nix
Normal file
9
pkgs/stdenv/linux/bootstrap-files/x86_64.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Use busybox for i686-linux since it works on x86_64-linux as well.
|
||||
(import ./i686.nix) //
|
||||
|
||||
{
|
||||
bootstrapTools = import <nix/fetchurl.nix> {
|
||||
url = "http://tarballs.nixos.org/stdenv-linux/x86_64/c5aabb0d603e2c1ea05f5a93b3be82437f5ebf31/bootstrap-tools.tar.xz";
|
||||
sha256 = "a5ce9c155ed09397614646c9717fc7cd94b1023d7b76b618d409e4fefd6e9d39";
|
||||
};
|
||||
}
|
||||
18
pkgs/stdenv/linux/bootstrap-tools-musl/default.nix
Normal file
18
pkgs/stdenv/linux/bootstrap-tools-musl/default.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ system, bootstrapFiles, extraAttrs }:
|
||||
|
||||
derivation ({
|
||||
name = "bootstrap-tools";
|
||||
|
||||
builder = bootstrapFiles.busybox;
|
||||
|
||||
args = [ "ash" "-e" ./scripts/unpack-bootstrap-tools.sh ];
|
||||
|
||||
tarball = bootstrapFiles.bootstrapTools;
|
||||
|
||||
inherit system;
|
||||
|
||||
# Needed by the GCC wrapper.
|
||||
langC = true;
|
||||
langCC = true;
|
||||
isGNU = true;
|
||||
} // extraAttrs)
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
# Unpack the bootstrap tools tarball.
|
||||
echo Unpacking the bootstrap tools...
|
||||
$builder mkdir $out
|
||||
< $tarball $builder unxz | $builder tar x -C $out
|
||||
|
||||
# Set the ELF interpreter / RPATH in the bootstrap binaries.
|
||||
echo Patching the bootstrap tools...
|
||||
|
||||
if test -f $out/lib/ld.so.?; then
|
||||
# MIPS case
|
||||
LD_BINARY=$out/lib/ld.so.?
|
||||
else
|
||||
# i686, x86_64 and armv5tel
|
||||
LD_BINARY=$out/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 .
|
||||
|
||||
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
|
||||
|
||||
for i in $out/lib/libpcre* $out/lib/libc.so; do
|
||||
if [ -L "$i" ]; then continue; fi
|
||||
echo patching "$i"
|
||||
$out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
|
||||
done
|
||||
|
||||
export PATH=$out/bin
|
||||
|
||||
# Fix the libc linker script.
|
||||
#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
|
||||
|
||||
# Provide a gunzip script.
|
||||
cat > $out/bin/gunzip <<EOF
|
||||
#!$out/bin/sh
|
||||
exec $out/bin/gzip -d "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/gunzip
|
||||
|
||||
# Provide fgrep/egrep.
|
||||
echo "#! $out/bin/sh" > $out/bin/egrep
|
||||
echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
|
||||
echo "#! $out/bin/sh" > $out/bin/fgrep
|
||||
echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
|
||||
|
||||
# Provide xz (actually only xz -d will work).
|
||||
echo "#! $out/bin/sh" > $out/bin/xz
|
||||
echo "exec $builder unxz \"\$@\"" >> $out/bin/xz
|
||||
|
||||
chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/xz
|
||||
18
pkgs/stdenv/linux/bootstrap-tools/default.nix
Normal file
18
pkgs/stdenv/linux/bootstrap-tools/default.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ system, bootstrapFiles, extraAttrs }:
|
||||
|
||||
derivation ({
|
||||
name = "bootstrap-tools";
|
||||
|
||||
builder = bootstrapFiles.busybox;
|
||||
|
||||
args = [ "ash" "-e" ./scripts/unpack-bootstrap-tools.sh ];
|
||||
|
||||
tarball = bootstrapFiles.bootstrapTools;
|
||||
|
||||
inherit system;
|
||||
|
||||
# Needed by the GCC wrapper.
|
||||
langC = true;
|
||||
langCC = true;
|
||||
isGNU = true;
|
||||
} // extraAttrs)
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
# Unpack the bootstrap tools tarball.
|
||||
echo Unpacking the bootstrap tools...
|
||||
$builder mkdir $out
|
||||
< $tarball $builder unxz | $builder tar x -C $out
|
||||
|
||||
# Set the ELF interpreter / RPATH in the bootstrap binaries.
|
||||
echo Patching the bootstrap tools...
|
||||
|
||||
if test -f $out/lib/ld.so.?; then
|
||||
# MIPS case
|
||||
LD_BINARY=$out/lib/ld.so.?
|
||||
elif test -f $out/lib/ld64.so.?; then
|
||||
# ppc64(le)
|
||||
LD_BINARY=$out/lib/ld64.so.?
|
||||
else
|
||||
# i686, x86_64 and armv5tel
|
||||
LD_BINARY=$out/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 .
|
||||
|
||||
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
|
||||
|
||||
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"
|
||||
done
|
||||
|
||||
export PATH=$out/bin
|
||||
|
||||
# Provide some additional symlinks.
|
||||
ln -s bash $out/bin/sh
|
||||
ln -s bzip2 $out/bin/bunzip2
|
||||
|
||||
# Provide a gunzip script.
|
||||
cat > $out/bin/gunzip <<EOF
|
||||
#!$out/bin/sh
|
||||
exec $out/bin/gzip -d "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/gunzip
|
||||
|
||||
# Provide fgrep/egrep.
|
||||
echo "#! $out/bin/sh" > $out/bin/egrep
|
||||
echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
|
||||
echo "#! $out/bin/sh" > $out/bin/fgrep
|
||||
echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
|
||||
|
||||
# Provide xz (actually only xz -d will work).
|
||||
echo "#! $out/bin/sh" > $out/bin/xz
|
||||
echo "exec $builder unxz \"\$@\"" >> $out/bin/xz
|
||||
|
||||
chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/xz
|
||||
449
pkgs/stdenv/linux/default.nix
Normal file
449
pkgs/stdenv/linux/default.nix
Normal file
|
|
@ -0,0 +1,449 @@
|
|||
# This file constructs the standard build environment for the
|
||||
# Linux/i686 platform. It's completely pure; that is, it relies on no
|
||||
# external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C
|
||||
# compiler and linker that do not search in default locations,
|
||||
# ensuring purity of components produced by it.
|
||||
{ lib
|
||||
, localSystem, crossSystem, config, overlays, crossOverlays ? []
|
||||
|
||||
, bootstrapFiles ?
|
||||
let table = {
|
||||
glibc = {
|
||||
i686-linux = import ./bootstrap-files/i686.nix;
|
||||
x86_64-linux = import ./bootstrap-files/x86_64.nix;
|
||||
armv5tel-linux = import ./bootstrap-files/armv5tel.nix;
|
||||
armv6l-linux = import ./bootstrap-files/armv6l.nix;
|
||||
armv7l-linux = import ./bootstrap-files/armv7l.nix;
|
||||
aarch64-linux = import ./bootstrap-files/aarch64.nix;
|
||||
mipsel-linux = import ./bootstrap-files/loongson2f.nix;
|
||||
powerpc64le-linux = import ./bootstrap-files/powerpc64le.nix;
|
||||
riscv64-linux = import ./bootstrap-files/riscv64.nix;
|
||||
};
|
||||
musl = {
|
||||
aarch64-linux = import ./bootstrap-files/aarch64-musl.nix;
|
||||
armv6l-linux = import ./bootstrap-files/armv6l-musl.nix;
|
||||
x86_64-linux = import ./bootstrap-files/x86_64-musl.nix;
|
||||
};
|
||||
};
|
||||
|
||||
# Try to find an architecture compatible with our current system. We
|
||||
# just try every bootstrap we’ve got and test to see if it is
|
||||
# compatible with or current architecture.
|
||||
getCompatibleTools = lib.foldl (v: system:
|
||||
if v != null then v
|
||||
else if localSystem.canExecute (lib.systems.elaborate { inherit system; }) then archLookupTable.${system}
|
||||
else null) null (lib.attrNames archLookupTable);
|
||||
|
||||
archLookupTable = table.${localSystem.libc}
|
||||
or (abort "unsupported libc for the pure Linux stdenv");
|
||||
files = archLookupTable.${localSystem.system} or (if getCompatibleTools != null then getCompatibleTools
|
||||
else (abort "unsupported platform for the pure Linux stdenv"));
|
||||
in files
|
||||
}:
|
||||
|
||||
assert crossSystem == localSystem;
|
||||
|
||||
let
|
||||
inherit (localSystem) system;
|
||||
|
||||
commonPreHook =
|
||||
''
|
||||
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
|
||||
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
|
||||
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
|
||||
${if system == "mipsel-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
|
||||
'';
|
||||
|
||||
|
||||
# The bootstrap process proceeds in several steps.
|
||||
|
||||
|
||||
# Create a standard environment by downloading pre-built binaries of
|
||||
# coreutils, GCC, etc.
|
||||
|
||||
|
||||
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
|
||||
bootstrapTools = import (if localSystem.libc == "musl" then ./bootstrap-tools-musl else ./bootstrap-tools) {
|
||||
inherit system bootstrapFiles;
|
||||
extraAttrs = lib.optionalAttrs
|
||||
config.contentAddressedByDefault
|
||||
{
|
||||
__contentAddressed = true;
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
};
|
||||
};
|
||||
|
||||
getLibc = stage: stage.${localSystem.libc};
|
||||
|
||||
|
||||
# This function builds the various standard environments used during
|
||||
# the bootstrap. In all stages, we build an stdenv and the package
|
||||
# set that can be built with that stdenv.
|
||||
stageFun = prevStage:
|
||||
{ name, overrides ? (self: super: {}), extraNativeBuildInputs ? [] }:
|
||||
|
||||
let
|
||||
|
||||
thisStdenv = import ../generic {
|
||||
name = "${name}-stdenv-linux";
|
||||
buildPlatform = localSystem;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit config extraNativeBuildInputs;
|
||||
preHook =
|
||||
''
|
||||
# Don't patch #!/interpreter because it leads to retained
|
||||
# dependencies on the bootstrapTools in the final stdenv.
|
||||
dontPatchShebangs=1
|
||||
${commonPreHook}
|
||||
'';
|
||||
shell = "${bootstrapTools}/bin/bash";
|
||||
initialPath = [bootstrapTools];
|
||||
|
||||
fetchurlBoot = import ../../build-support/fetchurl/boot.nix {
|
||||
inherit system;
|
||||
};
|
||||
|
||||
cc = if prevStage.gcc-unwrapped == null
|
||||
then null
|
||||
else lib.makeOverridable (import ../../build-support/cc-wrapper) {
|
||||
name = "${name}-gcc-wrapper";
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
buildPackages = lib.optionalAttrs (prevStage ? stdenv) {
|
||||
inherit (prevStage) stdenv;
|
||||
};
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
bintools = prevStage.binutils;
|
||||
isGNU = true;
|
||||
libc = getLibc prevStage;
|
||||
inherit lib;
|
||||
inherit (prevStage) coreutils gnugrep;
|
||||
stdenvNoCC = prevStage.ccWrapperStdenv;
|
||||
};
|
||||
|
||||
overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; };
|
||||
};
|
||||
|
||||
in {
|
||||
inherit config overlays;
|
||||
stdenv = thisStdenv;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
[
|
||||
|
||||
({}: {
|
||||
__raw = true;
|
||||
|
||||
gcc-unwrapped = null;
|
||||
binutils = null;
|
||||
coreutils = null;
|
||||
gnugrep = null;
|
||||
})
|
||||
|
||||
# Build a dummy stdenv with no GCC or working fetchurl. This is
|
||||
# because we need a stdenv to build the GCC wrapper and fetchurl.
|
||||
(prevStage: stageFun prevStage {
|
||||
name = "bootstrap-stage0";
|
||||
|
||||
overrides = self: super: {
|
||||
# We thread stage0's stdenv through under this name so downstream stages
|
||||
# can use it for wrapping gcc too. This way, downstream stages don't need
|
||||
# to refer to this stage directly, which violates the principle that each
|
||||
# stage should only access the stage that came before it.
|
||||
ccWrapperStdenv = self.stdenv;
|
||||
# The Glibc include directory cannot have the same prefix as the
|
||||
# GCC include directory, since GCC gets confused otherwise (it
|
||||
# will search the Glibc headers before the GCC headers). So
|
||||
# create a dummy Glibc here, which will be used in the stdenv of
|
||||
# stage1.
|
||||
${localSystem.libc} = self.stdenv.mkDerivation {
|
||||
pname = "bootstrap-stage0-${localSystem.libc}";
|
||||
strictDeps = true;
|
||||
version = "bootstrap";
|
||||
enableParallelBuilding = true;
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
ln -s ${bootstrapTools}/lib $out/lib
|
||||
'' + lib.optionalString (localSystem.libc == "glibc") ''
|
||||
ln -s ${bootstrapTools}/include-glibc $out/include
|
||||
'' + lib.optionalString (localSystem.libc == "musl") ''
|
||||
ln -s ${bootstrapTools}/include-libc $out/include
|
||||
'';
|
||||
};
|
||||
gcc-unwrapped = bootstrapTools;
|
||||
binutils = import ../../build-support/bintools-wrapper {
|
||||
name = "bootstrap-stage0-binutils-wrapper";
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
buildPackages = { };
|
||||
libc = getLibc self;
|
||||
inherit lib;
|
||||
inherit (self) stdenvNoCC coreutils gnugrep;
|
||||
bintools = bootstrapTools;
|
||||
};
|
||||
coreutils = bootstrapTools;
|
||||
gnugrep = bootstrapTools;
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
# Create the first "real" standard environment. This one consists
|
||||
# of bootstrap tools only, and a minimal Glibc to keep the GCC
|
||||
# configure script happy.
|
||||
#
|
||||
# For clarity, we only use the previous stage when specifying these
|
||||
# stages. So stageN should only ever have references for stage{N-1}.
|
||||
#
|
||||
# If we ever need to use a package from more than one stage back, we
|
||||
# simply re-export those packages in the middle stage(s) using the
|
||||
# overrides attribute and the inherit syntax.
|
||||
(prevStage: stageFun prevStage {
|
||||
name = "bootstrap-stage1";
|
||||
|
||||
# Rebuild binutils to use from stage2 onwards.
|
||||
overrides = self: super: {
|
||||
binutils-unwrapped = super.binutils-unwrapped.override {
|
||||
enableGold = false;
|
||||
};
|
||||
inherit (prevStage)
|
||||
ccWrapperStdenv
|
||||
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; };
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
# 2nd stdenv that contains our own rebuilt binutils and is used for
|
||||
# compiling our own Glibc.
|
||||
(prevStage: stageFun prevStage {
|
||||
name = "bootstrap-stage2";
|
||||
|
||||
overrides = self: super: {
|
||||
inherit (prevStage)
|
||||
ccWrapperStdenv
|
||||
gcc-unwrapped coreutils gnugrep
|
||||
perl gnum4 bison;
|
||||
dejagnu = super.dejagnu.overrideAttrs (a: { doCheck = false; } );
|
||||
|
||||
# We need libidn2 and its dependency libunistring as glibc dependency.
|
||||
# To avoid the cycle, we build against bootstrap libc, nuke references,
|
||||
# and use the result as input for our final glibc. We also pass this pair
|
||||
# through, so the final package-set uses exactly the same builds.
|
||||
libunistring = super.libunistring.overrideAttrs (attrs: {
|
||||
postFixup = attrs.postFixup or "" + ''
|
||||
${self.nukeReferences}/bin/nuke-refs "$out"/lib/lib*.so.*.*
|
||||
'';
|
||||
# Apparently iconv won't work with bootstrap glibc, but it will be used
|
||||
# with glibc built later where we keep *this* build of libunistring,
|
||||
# so we need to trick it into supporting libiconv.
|
||||
am_cv_func_iconv_works = "yes";
|
||||
});
|
||||
libidn2 = super.libidn2.overrideAttrs (attrs: {
|
||||
postFixup = attrs.postFixup or "" + ''
|
||||
${self.nukeReferences}/bin/nuke-refs -e '${lib.getLib self.libunistring}' \
|
||||
"$out"/lib/lib*.so.*.*
|
||||
'';
|
||||
});
|
||||
|
||||
# This also contains the full, dynamically linked, final Glibc.
|
||||
binutils = prevStage.binutils.override {
|
||||
# Rewrap the binutils with the new glibc, so both the next
|
||||
# stage's wrappers use it.
|
||||
libc = getLibc self;
|
||||
|
||||
# Unfortunately, when building gcc in the next stage, its LTO plugin
|
||||
# would use the final libc but `ld` would use the bootstrap one,
|
||||
# and that can fail to load. Therefore we upgrade `ld` to use newer libc;
|
||||
# apparently the interpreter needs to match libc, too.
|
||||
bintools = self.stdenvNoCC.mkDerivation {
|
||||
inherit (prevStage.bintools.bintools) name;
|
||||
enableParallelBuilding = true;
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
strictDeps = true;
|
||||
# We wouldn't need to *copy* all, but it's easier and the result is temporary anyway.
|
||||
installPhase = ''
|
||||
mkdir -p "$out"/bin
|
||||
cp -a '${prevStage.bintools.bintools}'/bin/* "$out"/bin/
|
||||
chmod +w "$out"/bin/ld.bfd
|
||||
patchelf --set-interpreter '${getLibc self}'/lib/ld*.so.? \
|
||||
--set-rpath "${getLibc self}/lib:$(patchelf --print-rpath "$out"/bin/ld.bfd)" \
|
||||
"$out"/bin/ld.bfd
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# `libtool` comes with obsolete config.sub/config.guess that don't recognize Risc-V.
|
||||
extraNativeBuildInputs =
|
||||
lib.optional (localSystem.isRiscV) prevStage.updateAutotoolsGnuConfigScriptsHook;
|
||||
})
|
||||
|
||||
|
||||
# Construct a third stdenv identical to the 2nd, except that this
|
||||
# one uses the rebuilt Glibc from stage2. It still uses the recent
|
||||
# binutils and rest of the bootstrap tools, including GCC.
|
||||
(prevStage: stageFun prevStage {
|
||||
name = "bootstrap-stage3";
|
||||
|
||||
overrides = self: super: rec {
|
||||
inherit (prevStage)
|
||||
ccWrapperStdenv
|
||||
binutils coreutils gnugrep
|
||||
perl patchelf linuxHeaders gnum4 bison libidn2 libunistring;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
# Link GCC statically against GMP etc. This makes sense because
|
||||
# these builds of the libraries are only used by GCC, so it
|
||||
# reduces the size of the stdenv closure.
|
||||
gmp = super.gmp.override { stdenv = self.makeStaticLibraries self.stdenv; };
|
||||
mpfr = super.mpfr.override { stdenv = self.makeStaticLibraries self.stdenv; };
|
||||
libmpc = super.libmpc.override { stdenv = self.makeStaticLibraries self.stdenv; };
|
||||
isl_0_20 = super.isl_0_20.override { stdenv = self.makeStaticLibraries self.stdenv; };
|
||||
gcc-unwrapped = super.gcc-unwrapped.override {
|
||||
isl = isl_0_20;
|
||||
# Use a deterministically built compiler
|
||||
# see https://github.com/NixOS/nixpkgs/issues/108475 for context
|
||||
reproducibleBuild = true;
|
||||
profiledCompiler = false;
|
||||
};
|
||||
};
|
||||
extraNativeBuildInputs = [ prevStage.patchelf ] ++
|
||||
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
|
||||
lib.optional (!localSystem.isx86 || localSystem.libc == "musl")
|
||||
prevStage.updateAutotoolsGnuConfigScriptsHook;
|
||||
})
|
||||
|
||||
|
||||
# Construct a fourth stdenv that uses the new GCC. But coreutils is
|
||||
# still from the bootstrap tools.
|
||||
(prevStage: stageFun prevStage {
|
||||
name = "bootstrap-stage4";
|
||||
|
||||
overrides = self: super: {
|
||||
# Zlib has to be inherited and not rebuilt in this stage,
|
||||
# because gcc (since JAR support) already depends on zlib, and
|
||||
# then if we already have a zlib we want to use that for the
|
||||
# other purposes (binutils and top-level pkgs) too.
|
||||
inherit (prevStage) gettext gnum4 bison gmp perl texinfo zlib linuxHeaders libidn2 libunistring;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
binutils = super.binutils.override {
|
||||
# Don't use stdenv's shell but our own
|
||||
shell = self.bash + "/bin/bash";
|
||||
# Build expand-response-params with last stage like below
|
||||
buildPackages = {
|
||||
inherit (prevStage) stdenv;
|
||||
};
|
||||
};
|
||||
|
||||
gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
isGNU = true;
|
||||
buildPackages = {
|
||||
inherit (prevStage) stdenv;
|
||||
};
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
bintools = self.binutils;
|
||||
libc = getLibc self;
|
||||
inherit lib;
|
||||
inherit (self) stdenvNoCC coreutils gnugrep;
|
||||
shell = self.bash + "/bin/bash";
|
||||
};
|
||||
};
|
||||
extraNativeBuildInputs = [ prevStage.patchelf prevStage.xz ] ++
|
||||
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
|
||||
lib.optional (!localSystem.isx86 || localSystem.libc == "musl")
|
||||
prevStage.updateAutotoolsGnuConfigScriptsHook;
|
||||
})
|
||||
|
||||
# Construct the final stdenv. It uses the Glibc and GCC, and adds
|
||||
# in a new binutils that doesn't depend on bootstrap-tools, as well
|
||||
# as dynamically linked versions of all other tools.
|
||||
#
|
||||
# When updating stdenvLinux, make sure that the result has no
|
||||
# dependency (`nix-store -qR') on bootstrapTools or the first
|
||||
# binutils built.
|
||||
(prevStage: {
|
||||
inherit config overlays;
|
||||
stdenv = import ../generic rec {
|
||||
name = "stdenv-linux";
|
||||
|
||||
buildPlatform = localSystem;
|
||||
hostPlatform = localSystem;
|
||||
targetPlatform = localSystem;
|
||||
inherit config;
|
||||
|
||||
preHook = commonPreHook;
|
||||
|
||||
initialPath =
|
||||
((import ../common-path.nix) {pkgs = prevStage;});
|
||||
|
||||
extraNativeBuildInputs = [ prevStage.patchelf ] ++
|
||||
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
|
||||
lib.optional (!localSystem.isx86 || localSystem.libc == "musl")
|
||||
prevStage.updateAutotoolsGnuConfigScriptsHook;
|
||||
|
||||
cc = prevStage.gcc;
|
||||
|
||||
shell = cc.shell;
|
||||
|
||||
inherit (prevStage.stdenv) fetchurlBoot;
|
||||
|
||||
extraAttrs = {
|
||||
# remove before 22.11
|
||||
glibc = lib.warn
|
||||
( "`stdenv.glibc` is deprecated and will be removed in release 22.11."
|
||||
+ " Please use `pkgs.glibc` instead.")
|
||||
prevStage.glibc;
|
||||
|
||||
inherit bootstrapTools;
|
||||
shellPackage = prevStage.bash;
|
||||
};
|
||||
|
||||
# Mainly avoid reference to bootstrap tools
|
||||
allowedRequisites = with prevStage; with lib;
|
||||
# Simple executable tools
|
||||
concatMap (p: [ (getBin p) (getLib p) ]) [
|
||||
gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
|
||||
gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed
|
||||
]
|
||||
# Library dependencies
|
||||
++ map getLib (
|
||||
[ attr acl zlib pcre libidn2 libunistring ]
|
||||
++ lib.optional (gawk.libsigsegv != null) gawk.libsigsegv
|
||||
)
|
||||
# More complicated cases
|
||||
++ (map (x: getOutput x (getLibc prevStage)) [ "out" "dev" "bin" ] )
|
||||
++ [ /*propagated from .dev*/ linuxHeaders
|
||||
binutils gcc gcc.cc gcc.cc.lib gcc.expand-response-params
|
||||
]
|
||||
++ lib.optionals (!localSystem.isx86 || localSystem.libc == "musl")
|
||||
[ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ];
|
||||
|
||||
overrides = self: super: {
|
||||
inherit (prevStage)
|
||||
gzip bzip2 xz bash coreutils diffutils findutils gawk
|
||||
gnumake gnused gnutar gnugrep gnupatch patchelf
|
||||
attr acl zlib pcre libunistring libidn2;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
} // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
|
||||
# Need to get rid of these when cross-compiling.
|
||||
inherit (prevStage) binutils binutils-unwrapped;
|
||||
gcc = cc;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
]
|
||||
25
pkgs/stdenv/linux/make-bootstrap-tools-cross.nix
Normal file
25
pkgs/stdenv/linux/make-bootstrap-tools-cross.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{system ? builtins.currentSystem}:
|
||||
|
||||
let
|
||||
make = crossSystem: import ./make-bootstrap-tools.nix {
|
||||
localSystem = { inherit system; };
|
||||
inherit crossSystem;
|
||||
};
|
||||
lib = import ../../../lib;
|
||||
in lib.mapAttrs (n: make) (with lib.systems.examples; {
|
||||
armv5tel = sheevaplug;
|
||||
pogoplug4 = pogoplug4;
|
||||
armv6l = raspberryPi;
|
||||
armv7l = armv7l-hf-multiplatform;
|
||||
aarch64 = aarch64-multiplatform;
|
||||
x86_64-musl = musl64;
|
||||
armv6l-musl = muslpi;
|
||||
aarch64-musl = aarch64-multiplatform-musl;
|
||||
riscv64 = riscv64;
|
||||
mips64el-linux-gnuabin32 = mips64el-linux-gnuabin32;
|
||||
mips64el-linux-gnuabi64 = mips64el-linux-gnuabi64;
|
||||
powerpc64 = ppc64;
|
||||
powerpc64-musl = ppc64-musl;
|
||||
powerpc64le = powernv;
|
||||
powerpc64le-musl = musl-power;
|
||||
})
|
||||
305
pkgs/stdenv/linux/make-bootstrap-tools.nix
Normal file
305
pkgs/stdenv/linux/make-bootstrap-tools.nix
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
{ pkgs ? import ../../.. {} }:
|
||||
|
||||
let
|
||||
libc = pkgs.stdenv.cc.libc;
|
||||
in with pkgs; rec {
|
||||
|
||||
|
||||
coreutilsMinimal = coreutils.override (args: {
|
||||
# We want coreutils without ACL/attr support.
|
||||
aclSupport = false;
|
||||
attrSupport = false;
|
||||
# Our tooling currently can't handle scripts in bin/, only ELFs and symlinks.
|
||||
singleBinary = "symlinks";
|
||||
});
|
||||
|
||||
tarMinimal = gnutar.override { acl = null; };
|
||||
|
||||
busyboxMinimal = busybox.override {
|
||||
useMusl = !stdenv.targetPlatform.isRiscV;
|
||||
enableStatic = true;
|
||||
enableMinimal = true;
|
||||
extraConfig = ''
|
||||
CONFIG_ASH y
|
||||
CONFIG_ASH_ECHO y
|
||||
CONFIG_ASH_TEST y
|
||||
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
|
||||
CONFIG_MKDIR y
|
||||
CONFIG_TAR y
|
||||
CONFIG_UNXZ y
|
||||
'';
|
||||
};
|
||||
|
||||
bootGCC = gcc.cc.override { enableLTO = false; };
|
||||
bootBinutils = binutils.bintools.override {
|
||||
withAllTargets = false;
|
||||
# Don't need two linkers, disable whatever's not primary/default.
|
||||
enableGold = false;
|
||||
# bootstrap is easier w/static
|
||||
enableShared = false;
|
||||
};
|
||||
|
||||
build =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "stdenv-bootstrap-tools";
|
||||
|
||||
meta = {
|
||||
# Increase priority to unblock nixpkgs-unstable
|
||||
# https://github.com/NixOS/nixpkgs/pull/104679#issuecomment-732267288
|
||||
schedulingPriority = 200;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ buildPackages.nukeReferences buildPackages.cpio ];
|
||||
|
||||
buildCommand = ''
|
||||
set -x
|
||||
mkdir -p $out/bin $out/lib $out/libexec
|
||||
|
||||
'' + (if (stdenv.hostPlatform.libc == "glibc") then ''
|
||||
# Copy what we need of Glibc.
|
||||
cp -d ${libc.out}/lib/ld*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libc*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libc_nonshared.a $out/lib
|
||||
cp -d ${libc.out}/lib/libm*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libdl*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/librt*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libpthread*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libnsl*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libutil*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libnss*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/libresolv*.so* $out/lib
|
||||
cp -d ${libc.out}/lib/crt?.o $out/lib
|
||||
|
||||
# Hacky compat with our current unpack-bootstrap-tools.sh
|
||||
ln -s librt.so "$out"/lib/librt-dummy.so
|
||||
|
||||
cp -rL ${libc.dev}/include $out
|
||||
chmod -R u+w "$out"
|
||||
|
||||
# libc 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 '${libc.out}' | sort -u)
|
||||
for f in $lScripts; do
|
||||
substituteInPlace "$f" --replace '${libc.out}/lib/' ""
|
||||
done
|
||||
|
||||
# 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
|
||||
'' else if (stdenv.hostPlatform.libc == "musl") then ''
|
||||
# Copy what we need from musl
|
||||
cp ${libc.out}/lib/* $out/lib
|
||||
cp -rL ${libc.dev}/include $out
|
||||
chmod -R u+w "$out"
|
||||
|
||||
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-libc
|
||||
'' else throw "unsupported libc for bootstrap tools")
|
||||
+ ''
|
||||
# Copy coreutils, bash, etc.
|
||||
cp -d ${coreutilsMinimal.out}/bin/* $out/bin
|
||||
(cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
|
||||
|
||||
cp ${bash.out}/bin/bash $out/bin
|
||||
cp ${findutils.out}/bin/find $out/bin
|
||||
cp ${findutils.out}/bin/xargs $out/bin
|
||||
cp -d ${diffutils.out}/bin/* $out/bin
|
||||
cp -d ${gnused.out}/bin/* $out/bin
|
||||
cp -d ${gnugrep.out}/bin/grep $out/bin
|
||||
cp ${gawk.out}/bin/gawk $out/bin
|
||||
cp -d ${gawk.out}/bin/awk $out/bin
|
||||
cp ${tarMinimal.out}/bin/tar $out/bin
|
||||
cp ${gzip.out}/bin/gzip $out/bin
|
||||
cp ${bzip2.bin}/bin/bzip2 $out/bin
|
||||
cp -d ${gnumake.out}/bin/* $out/bin
|
||||
cp -d ${patch}/bin/* $out/bin
|
||||
cp ${patchelf}/bin/* $out/bin
|
||||
|
||||
cp -d ${gnugrep.pcre.out}/lib/libpcre*.so* $out/lib # needed by grep
|
||||
|
||||
# Copy what we need of GCC.
|
||||
cp -d ${bootGCC.out}/bin/gcc $out/bin
|
||||
cp -d ${bootGCC.out}/bin/cpp $out/bin
|
||||
cp -d ${bootGCC.out}/bin/g++ $out/bin
|
||||
cp -d ${bootGCC.lib}/lib/libgcc_s.so* $out/lib
|
||||
cp -d ${bootGCC.lib}/lib/libstdc++.so* $out/lib
|
||||
cp -d ${bootGCC.out}/lib/libssp.a* $out/lib
|
||||
cp -d ${bootGCC.out}/lib/libssp_nonshared.a $out/lib
|
||||
cp -rd ${bootGCC.out}/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 ${bootGCC.out}/libexec/* $out/libexec
|
||||
chmod -R u+w $out/libexec
|
||||
rm -rf $out/libexec/gcc/*/*/plugin
|
||||
mkdir -p $out/include
|
||||
cp -rd ${bootGCC.out}/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 ${gmpxx.out}/lib/libgmp*.so* $out/lib
|
||||
cp -d ${mpfr.out}/lib/libmpfr*.so* $out/lib
|
||||
cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
|
||||
cp -d ${zlib.out}/lib/libz.so* $out/lib
|
||||
cp -d ${libelf}/lib/libelf.so* $out/lib
|
||||
|
||||
'' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
||||
# 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.
|
||||
cp -d ${isl_0_20.out}/lib/libisl*.so* $out/lib
|
||||
|
||||
'' + lib.optionalString (stdenv.hostPlatform.isRiscV) ''
|
||||
# libatomic is required on RiscV platform for C/C++ atomics and pthread
|
||||
# even though they may be translated into native instructions.
|
||||
cp -d ${bootGCC.out}/lib/libatomic.a* $out/lib
|
||||
|
||||
'' + ''
|
||||
cp -d ${bzip2.out}/lib/libbz2.so* $out/lib
|
||||
|
||||
# Copy binutils.
|
||||
for i in as ld ar ranlib nm strip readelf objdump; do
|
||||
cp ${bootBinutils.out}/bin/$i $out/bin
|
||||
done
|
||||
cp -r '${lib.getLib binutils.bintools}'/lib/* "$out/lib/"
|
||||
|
||||
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
|
||||
$STRIP -s $i || true
|
||||
fi
|
||||
done
|
||||
|
||||
nuke-refs $out/bin/*
|
||||
nuke-refs $out/lib/*
|
||||
nuke-refs $out/lib/*/*
|
||||
nuke-refs $out/libexec/gcc/*/*/*
|
||||
nuke-refs $out/lib/gcc/*/*/*
|
||||
nuke-refs $out/lib/gcc/*/*/include-fixed/*{,/*}
|
||||
|
||||
mkdir $out/.pack
|
||||
mv $out/* $out/.pack
|
||||
mv $out/.pack $out/pack
|
||||
|
||||
mkdir $out/on-server
|
||||
XZ_OPT="-9 -e" tar cvJf $out/on-server/bootstrap-tools.tar.xz --hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 -C $out/pack .
|
||||
cp ${busyboxMinimal}/bin/busybox $out/on-server
|
||||
chmod u+w $out/on-server/busybox
|
||||
nuke-refs $out/on-server/busybox
|
||||
''; # */
|
||||
|
||||
# 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 = [];
|
||||
};
|
||||
|
||||
dist = stdenv.mkDerivation {
|
||||
name = "stdenv-bootstrap-tools";
|
||||
|
||||
meta = {
|
||||
# Increase priority to unblock nixpkgs-unstable
|
||||
# https://github.com/NixOS/nixpkgs/pull/104679#issuecomment-732267288
|
||||
schedulingPriority = 200;
|
||||
};
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
bootstrapFiles = {
|
||||
# Make them their own store paths to test that busybox still works when the binary is named /nix/store/HASH-busybox
|
||||
busybox = runCommand "busybox" {} "cp ${build}/on-server/busybox $out";
|
||||
bootstrapTools = runCommand "bootstrap-tools.tar.xz" {} "cp ${build}/on-server/bootstrap-tools.tar.xz $out";
|
||||
};
|
||||
|
||||
bootstrapTools =
|
||||
let extraAttrs = lib.optionalAttrs
|
||||
config.contentAddressedByDefault
|
||||
{
|
||||
__contentAddressed = true;
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
};
|
||||
in
|
||||
if (stdenv.hostPlatform.libc == "glibc") then
|
||||
import ./bootstrap-tools {
|
||||
inherit (stdenv.buildPlatform) system; # Used to determine where to build
|
||||
inherit bootstrapFiles extraAttrs;
|
||||
}
|
||||
else if (stdenv.hostPlatform.libc == "musl") then
|
||||
import ./bootstrap-tools-musl {
|
||||
inherit (stdenv.buildPlatform) system; # Used to determine where to build
|
||||
inherit bootstrapFiles extraAttrs;
|
||||
}
|
||||
else throw "unsupported libc";
|
||||
|
||||
test = derivation {
|
||||
name = "test-bootstrap-tools";
|
||||
inherit (stdenv.hostPlatform) system; # We cannot "cross test"
|
||||
builder = bootstrapFiles.busybox;
|
||||
args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
|
||||
|
||||
buildCommand = ''
|
||||
export PATH=${bootstrapTools}/bin
|
||||
|
||||
ls -l
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
sed --version
|
||||
find --version
|
||||
diff --version
|
||||
patch --version
|
||||
make --version
|
||||
awk --version
|
||||
grep --version
|
||||
gcc --version
|
||||
|
||||
'' + lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
|
||||
ldlinux=$(echo ${bootstrapTools}/lib/${builtins.baseNameOf binutils.dynamicLinker})
|
||||
export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
|
||||
export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
|
||||
export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
|
||||
'' + lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
|
||||
ldmusl=$(echo ${bootstrapTools}/lib/ld-musl*.so.?)
|
||||
export CPP="cpp -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools}"
|
||||
export CC="gcc -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"
|
||||
export CXX="g++ -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"
|
||||
'' + ''
|
||||
|
||||
echo '#include <stdio.h>' >> foo.c
|
||||
echo '#include <limits.h>' >> foo.c
|
||||
echo 'int main() { printf("Hello World\\n"); return 0; }' >> foo.c
|
||||
$CC -o $out/bin/foo foo.c
|
||||
$out/bin/foo
|
||||
|
||||
echo '#include <iostream>' >> bar.cc
|
||||
echo 'int main() { std::cout << "Hello World\\n"; }' >> bar.cc
|
||||
$CXX -v -o $out/bin/bar bar.cc
|
||||
$out/bin/bar
|
||||
|
||||
tar xvf ${hello.src}
|
||||
cd hello-*
|
||||
./configure --prefix=$out
|
||||
make
|
||||
make install
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue