Merge remote-tracking branch 'upstream/staging' into gcc-7

Conflicts:
	pkgs/development/libraries/libidn/default.nix
	pkgs/top-level/all-packages.nix
This commit is contained in:
Tuomas Tynkkynen
2018-02-15 15:45:37 +02:00
906 changed files with 20608 additions and 10078 deletions
@@ -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";
};
}
@@ -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";
};
}
@@ -0,0 +1,11 @@
{
busybox = import <nix/fetchurl.nix> {
url = https://wdtz.org/files/030q34q7fk6jdfxkgcqp5rzr4yhw3pgx-stdenv-bootstrap-tools-x86_64-unknown-linux-musl/on-server/busybox;
sha256 = "16lzrwwvdk6q3g08gs45pldz0rh6xpln2343xr444960h6wqxl5v";
executable = true;
};
bootstrapTools = import <nix/fetchurl.nix> {
url = https://wdtz.org/files/030q34q7fk6jdfxkgcqp5rzr4yhw3pgx-stdenv-bootstrap-tools-x86_64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz;
sha256 = "0ly0wj8wzbikn2j8sn727vikk90bq36drh98qvfx1kkh5k5azm2j";
};
}
@@ -0,0 +1,18 @@
{ system, bootstrapFiles }:
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;
}
@@ -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/libiconv*.so $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
+51 -25
View File
@@ -6,16 +6,28 @@
{ lib
, localSystem, crossSystem, config, overlays
, bootstrapFiles ? { # switch
"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;
"mips64el-linux" = import ./bootstrap-files/loongson2f.nix;
}.${localSystem.system}
or (abort "unsupported platform for the pure Linux stdenv")
, 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;
"mips64el-linux" = import ./bootstrap-files/loongson2f.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;
};
};
archLookupTable = table.${localSystem.libc}
or (abort "unsupported libc for the pure Linux stdenv");
files = archLookupTable.${localSystem.system}
or (abort "unsupported platform for the pure Linux stdenv");
in files
}:
assert crossSystem == null;
@@ -40,7 +52,9 @@ let
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
bootstrapTools = import ./bootstrap-tools { inherit system bootstrapFiles; };
bootstrapTools = import (if localSystem.libc == "musl" then ./bootstrap-tools-musl else ./bootstrap-tools) { inherit system bootstrapFiles; };
getLibc = stage: stage.${localSystem.libc};
# This function builds the various standard environments used during
@@ -82,7 +96,7 @@ let
cc = prevStage.gcc-unwrapped;
bintools = prevStage.binutils;
isGNU = true;
libc = prevStage.glibc;
libc = getLibc prevStage;
inherit (prevStage) coreutils gnugrep;
name = name;
stdenvNoCC = prevStage.ccWrapperStdenv;
@@ -95,6 +109,7 @@ let
# stdenv.glibc is used by GCC build to figure out the system-level
# /usr/include directory.
# TODO: Remove this!
inherit (prevStage) glibc;
};
overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; };
@@ -113,7 +128,8 @@ in
__raw = true;
gcc-unwrapped = null;
glibc = null;
glibc = assert false; null;
musl = assert false; null;
binutils = null;
coreutils = null;
gnugrep = null;
@@ -135,12 +151,15 @@ in
# will search the Glibc headers before the GCC headers). So
# create a dummy Glibc here, which will be used in the stdenv of
# stage1.
glibc = self.stdenv.mkDerivation {
name = "bootstrap-glibc";
${localSystem.libc} = self.stdenv.mkDerivation {
name = "bootstrap-${localSystem.libc}";
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;
@@ -148,7 +167,7 @@ in
nativeTools = false;
nativeLibc = false;
buildPackages = { };
libc = self.glibc;
libc = getLibc self;
inherit (self) stdenvNoCC coreutils gnugrep;
bintools = bootstrapTools;
name = "bootstrap-binutils-wrapper";
@@ -177,7 +196,9 @@ in
binutils = super.binutils_nogold;
inherit (prevStage)
ccWrapperStdenv
glibc gcc-unwrapped coreutils gnugrep;
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.
@@ -203,7 +224,7 @@ in
binutils = prevStage.binutils.override {
# Rewrap the binutils with the new glibc, so both the next
# stage's wrappers use it.
libc = self.glibc;
libc = getLibc self;
};
};
})
@@ -218,8 +239,9 @@ in
overrides = self: super: rec {
inherit (prevStage)
ccWrapperStdenv
binutils glibc coreutils gnugrep
binutils coreutils gnugrep
perl patchelf linuxHeaders gnum4 bison;
${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.
@@ -247,8 +269,8 @@ in
# 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 glibc zlib linuxHeaders;
inherit (prevStage) gettext gnum4 bison gmp perl zlib linuxHeaders;
${localSystem.libc} = getLibc prevStage;
binutils = super.binutils.override {
# Don't use stdenv's shell but our own
shell = self.bash + "/bin/bash";
@@ -267,7 +289,7 @@ in
};
cc = prevStage.gcc-unwrapped;
bintools = self.binutils;
libc = self.glibc;
libc = getLibc self;
inherit (self) stdenvNoCC coreutils gnugrep;
name = "";
shell = self.bash + "/bin/bash";
@@ -314,7 +336,9 @@ in
inherit (prevStage.stdenv) fetchurlBoot;
extraAttrs = {
# TODO: remove this!
inherit (prevStage) glibc;
inherit platform bootstrapTools;
shellPackage = prevStage.bash;
};
@@ -332,18 +356,20 @@ in
++ lib.optional (gawk.libsigsegv != null) gawk.libsigsegv
)
# More complicated cases
++ [
glibc.out glibc.dev glibc.bin/*propagated from .dev*/ linuxHeaders
++ (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.optional (localSystem.libc == "musl") libiconv
++ lib.optionals localSystem.isAarch64
[ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ];
overrides = self: super: {
inherit (prevStage)
gzip bzip2 xz bash coreutils diffutils findutils gawk
glibc gnumake gnused gnutar gnugrep gnupatch patchelf
gnumake gnused gnutar gnugrep gnupatch patchelf
attr acl paxctl zlib pcre;
${localSystem.libc} = getLibc prevStage;
} // lib.optionalAttrs (super.targetPlatform == localSystem) {
# Need to get rid of these when cross-compiling.
inherit (prevStage) binutils binutils-raw;
@@ -7,10 +7,14 @@ let
};
in with (import ../../../lib).systems.examples; {
armv5tel = make sheevaplug;
scaleway = make scaleway-c1;
pogoplug4 = make pogoplug4;
armv6l = make raspberryPi;
armv7l = make armv7l-hf-multiplatform;
aarch64 = make aarch64-multiplatform;
armv5tel = make sheevaplug;
scaleway = make scaleway-c1;
pogoplug4 = make pogoplug4;
armv6l = make raspberryPi;
armv7l = make armv7l-hf-multiplatform;
aarch64 = make aarch64-multiplatform;
x86_64-musl = make musl64;
i686-musl = make musl32;
armv6l-musl = make muslpi;
aarch64-musl = make aarch64-multiplatform-musl;
}
+51 -25
View File
@@ -4,9 +4,7 @@
let
pkgs = import ../../.. { inherit localSystem crossSystem; };
glibc = if pkgs.hostPlatform != pkgs.buildPlatform
then pkgs.glibcCross
else pkgs.glibc;
libc = pkgs.stdenv.cc.libc;
in with pkgs; rec {
@@ -46,29 +44,30 @@ in with pkgs; rec {
set -x
mkdir -p $out/bin $out/lib $out/libexec
'' + (if (hostPlatform.libc == "glibc") then ''
# Copy what we need of Glibc.
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
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
cp -rL ${glibc.dev}/include $out
cp -rL ${libc.dev}/include $out
chmod -R u+w "$out"
# glibc can contain linker scripts: find them, copy their deps,
# 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 '${glibc.out}' | sort -u)
cp -d -t "$out/lib/" $(cat $lScripts | tr " " "\n" | grep -F '${libc.out}' | sort -u)
for f in $lScripts; do
substituteInPlace "$f" --replace '${glibc.out}/lib/' ""
substituteInPlace "$f" --replace '${libc.out}/lib/' ""
done
# Hopefully we won't need these.
@@ -76,7 +75,18 @@ in with pkgs; rec {
find $out/include -name .install -exec rm {} \;
find $out/include -name ..install.cmd -exec rm {} \;
mv $out/include $out/include-glibc
'' else if (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 ${coreutilsMinimal.out}/bin/* $out/bin
(cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
@@ -115,7 +125,7 @@ in with pkgs; rec {
cp -rd ${gcc.cc.out}/libexec/* $out/libexec
chmod -R u+w $out/libexec
rm -rf $out/libexec/gcc/*/*/plugin
mkdir $out/include
mkdir -p $out/include
cp -rd ${gcc.cc.out}/include/c++ $out/include
chmod -R u+w $out/include
rm -rf $out/include/c++/*/ext/pb_ds
@@ -126,6 +136,8 @@ in with pkgs; rec {
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 (hostPlatform.libc == "musl") ''
cp -d ${libiconv.out}/lib/libiconv*.so* $out/lib
'' + lib.optionalString (hostPlatform != buildPlatform) ''
# These needed for cross but not native tools because the stdenv
@@ -161,7 +173,7 @@ in with pkgs; rec {
mv $out/.pack $out/pack
mkdir $out/on-server
tar cvfJ $out/on-server/bootstrap-tools.tar.xz --hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 -C $out/pack .
XZ_OPT=-9 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
@@ -189,10 +201,17 @@ in with pkgs; rec {
bootstrapTools = runCommand "bootstrap-tools.tar.xz" {} "cp ${build}/on-server/bootstrap-tools.tar.xz $out";
};
bootstrapTools = import ./bootstrap-tools {
inherit (hostPlatform) system;
inherit bootstrapFiles;
};
bootstrapTools = if (hostPlatform.libc == "glibc") then
import ./bootstrap-tools {
inherit (hostPlatform) system;
inherit bootstrapFiles;
}
else if (hostPlatform.libc == "musl") then
import ./bootstrap-tools-musl {
inherit (hostPlatform) system;
inherit bootstrapFiles;
}
else throw "unsupported libc";
test = derivation {
name = "test-bootstrap-tools";
@@ -215,10 +234,17 @@ in with pkgs; rec {
grep --version
gcc --version
'' + lib.optionalString (hostPlatform.libc == "glibc") ''
ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
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 (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