2005-02-21 21:42:07 +01:00
|
|
|
# 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.
|
|
|
|
|
2008-05-19 17:12:03 +02:00
|
|
|
# The function defaults are for easy testing.
|
2011-12-14 15:31:56 +01:00
|
|
|
{ system ? builtins.currentSystem
|
2011-12-12 15:02:12 +01:00
|
|
|
, allPackages ? import ../../top-level/all-packages.nix
|
2014-07-01 17:21:32 +02:00
|
|
|
, platform ? null, config ? {}, lib }:
|
2005-02-21 21:42:07 +01:00
|
|
|
|
2004-11-04 13:19:32 +01:00
|
|
|
rec {
|
2004-10-19 17:16:14 +02:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
bootstrapFiles =
|
2014-04-20 01:27:15 +02:00
|
|
|
if system == "i686-linux" then import ./bootstrap/i686.nix
|
|
|
|
else if system == "x86_64-linux" then import ./bootstrap/x86_64.nix
|
|
|
|
else if system == "armv5tel-linux" then import ./bootstrap/armv5tel.nix
|
|
|
|
else if system == "armv6l-linux" then import ./bootstrap/armv6l.nix
|
|
|
|
else if system == "armv7l-linux" then import ./bootstrap/armv6l.nix
|
|
|
|
else if system == "mips64el-linux" then import ./bootstrap/loongson2f.nix
|
2006-10-24 22:57:06 +02:00
|
|
|
else abort "unsupported platform for the pure Linux stdenv";
|
2006-08-23 18:18:02 +02:00
|
|
|
|
|
|
|
|
2009-03-25 18:34:38 +01:00
|
|
|
commonPreHook =
|
|
|
|
''
|
|
|
|
export NIX_ENFORCE_PURITY=1
|
|
|
|
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
|
2012-01-21 01:34:51 +01:00
|
|
|
${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
|
2009-03-25 18:34:38 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The bootstrap process proceeds in several steps.
|
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
# 1) Create a standard environment by downloading pre-built binaries
|
|
|
|
# of coreutils, GCC, etc.
|
2005-02-22 10:55:03 +01:00
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
|
|
|
|
bootstrapTools = derivation {
|
|
|
|
name = "bootstrap-tools";
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
builder = bootstrapFiles.sh;
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2012-01-19 16:56:17 +01:00
|
|
|
args =
|
2014-06-27 11:15:28 +02:00
|
|
|
if system == "armv5tel-linux" || system == "armv6l-linux"
|
2013-01-05 19:49:31 +01:00
|
|
|
|| system == "armv7l-linux"
|
2012-01-19 16:56:17 +01:00
|
|
|
then [ ./scripts/unpack-bootstrap-tools-arm.sh ]
|
|
|
|
else [ ./scripts/unpack-bootstrap-tools.sh ];
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-04-20 01:16:12 +02:00
|
|
|
# FIXME: get rid of curl.
|
2009-02-01 22:44:56 +01:00
|
|
|
inherit (bootstrapFiles) bzip2 mkdir curl cpio;
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-04-20 00:46:22 +02:00
|
|
|
tarball = import <nix/fetchurl.nix> {
|
2009-02-01 22:44:56 +01:00
|
|
|
inherit (bootstrapFiles.bootstrapTools) url sha256;
|
|
|
|
};
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
inherit system;
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
# Needed by the GCC wrapper.
|
|
|
|
langC = true;
|
|
|
|
langCC = true;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2004-11-04 13:19:32 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
# This function builds the various standard environments used during
|
|
|
|
# the bootstrap.
|
|
|
|
stdenvBootFun =
|
2014-06-27 11:15:28 +02:00
|
|
|
{ gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraBuildInputs ? [], fetchurl }:
|
2004-11-04 13:19:32 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
import ../generic {
|
2014-06-27 11:15:28 +02:00
|
|
|
inherit system config extraBuildInputs;
|
2009-02-01 22:44:56 +01:00
|
|
|
name = "stdenv-linux-boot";
|
2012-01-19 16:56:17 +01:00
|
|
|
preHook =
|
2009-02-01 22:44:56 +01:00
|
|
|
''
|
|
|
|
# Don't patch #!/interpreter because it leads to retained
|
|
|
|
# dependencies on the bootstrapTools in the final stdenv.
|
|
|
|
dontPatchShebangs=1
|
2009-03-25 18:34:38 +01:00
|
|
|
${commonPreHook}
|
2009-02-01 22:44:56 +01:00
|
|
|
'';
|
|
|
|
shell = "${bootstrapTools}/bin/sh";
|
2014-06-27 11:15:28 +02:00
|
|
|
initialPath = [ bootstrapTools ];
|
2009-02-01 22:44:56 +01:00
|
|
|
fetchurlBoot = fetchurl;
|
2010-08-21 23:08:57 +02:00
|
|
|
inherit gcc;
|
|
|
|
# Having the proper 'platform' in all the stdenvs allows getting proper
|
|
|
|
# linuxHeaders for example.
|
|
|
|
extraAttrs = extraAttrs // { inherit platform; };
|
2011-12-14 15:31:56 +01:00
|
|
|
overrides = pkgs: (overrides pkgs) // {
|
2010-08-06 12:34:34 +02:00
|
|
|
inherit fetchurl;
|
|
|
|
};
|
2006-07-10 17:42:19 +02:00
|
|
|
};
|
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
# Build a dummy stdenv with no GCC or working fetchurl. This is
|
|
|
|
# because we need a stdenv to build the GCC wrapper and fetchurl.
|
|
|
|
stdenvLinuxBoot0 = stdenvBootFun {
|
|
|
|
gcc = "/no-such-path";
|
|
|
|
fetchurl = null;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
fetchurl = import ../../build-support/fetchurl {
|
|
|
|
stdenv = stdenvLinuxBoot0;
|
|
|
|
curl = bootstrapTools;
|
|
|
|
};
|
2004-11-04 13:19:32 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
bootstrapGlibc = stdenvLinuxBoot0.mkDerivation {
|
|
|
|
name = "bootstrap-glibc";
|
|
|
|
buildCommand = ''
|
2012-01-18 21:16:00 +01:00
|
|
|
mkdir -p $out
|
2009-02-01 22:44:56 +01:00
|
|
|
ln -s ${bootstrapTools}/lib $out/lib
|
|
|
|
ln -s ${bootstrapTools}/include-glibc $out/include
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# A helper function to call gcc-wrapper.
|
|
|
|
wrapGCC =
|
2014-02-04 16:58:12 +01:00
|
|
|
{ gcc ? bootstrapTools, libc, binutils, coreutils, shell ? "", name ? "bootstrap-gcc-wrapper" }:
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-02-04 16:58:12 +01:00
|
|
|
lib.makeOverridable (import ../../build-support/gcc-wrapper) {
|
2009-02-01 22:44:56 +01:00
|
|
|
nativeTools = false;
|
|
|
|
nativeLibc = false;
|
2009-11-08 01:32:12 +01:00
|
|
|
inherit gcc binutils coreutils libc shell name;
|
2009-02-01 22:44:56 +01:00
|
|
|
stdenv = stdenvLinuxBoot0;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
2005-02-21 21:42:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Create the first "real" standard environment. This one consists
|
2009-02-01 22:44:56 +01:00
|
|
|
# of bootstrap tools only, and a minimal Glibc to keep the GCC
|
|
|
|
# configure script happy.
|
2005-02-21 21:42:07 +01:00
|
|
|
stdenvLinuxBoot1 = stdenvBootFun {
|
2010-01-19 12:25:33 +01:00
|
|
|
gcc = wrapGCC {
|
|
|
|
libc = bootstrapGlibc;
|
|
|
|
binutils = bootstrapTools;
|
|
|
|
coreutils = bootstrapTools;
|
|
|
|
};
|
2009-02-01 22:44:56 +01:00
|
|
|
inherit fetchurl;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
|
|
|
|
# 2) These are the packages that we can build with the first
|
2011-12-14 15:31:56 +01:00
|
|
|
# stdenv. We only need binutils, because recent Glibcs
|
|
|
|
# require recent Binutils, and those in bootstrap-tools may
|
|
|
|
# be too old.
|
2005-02-21 21:42:07 +01:00
|
|
|
stdenvLinuxBoot1Pkgs = allPackages {
|
2010-08-21 23:08:57 +02:00
|
|
|
inherit system platform;
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot1;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2014-01-07 17:46:47 +01:00
|
|
|
binutils1 = stdenvLinuxBoot1Pkgs.binutils.override { gold = false; };
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-01-07 17:46:47 +01:00
|
|
|
|
|
|
|
# 3) 2nd stdenv that we will use to build only Glibc.
|
2010-08-25 21:15:16 +02:00
|
|
|
stdenvLinuxBoot2 = stdenvBootFun {
|
2010-08-25 15:22:48 +02:00
|
|
|
gcc = wrapGCC {
|
|
|
|
libc = bootstrapGlibc;
|
2014-01-07 17:46:47 +01:00
|
|
|
binutils = binutils1;
|
2010-08-25 15:22:48 +02:00
|
|
|
coreutils = bootstrapTools;
|
|
|
|
};
|
2011-12-14 15:31:56 +01:00
|
|
|
overrides = pkgs: {
|
|
|
|
inherit (stdenvLinuxBoot1Pkgs) perl;
|
|
|
|
};
|
2010-08-25 15:22:48 +02:00
|
|
|
inherit fetchurl;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# 4) These are the packages that we can build with the 2nd
|
2014-01-07 17:46:47 +01:00
|
|
|
# stdenv.
|
2010-08-25 21:15:16 +02:00
|
|
|
stdenvLinuxBoot2Pkgs = allPackages {
|
2010-08-25 15:22:48 +02:00
|
|
|
inherit system platform;
|
2010-08-25 21:15:16 +02:00
|
|
|
bootStdenv = stdenvLinuxBoot2;
|
2010-08-25 15:22:48 +02:00
|
|
|
};
|
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2010-08-25 15:22:48 +02:00
|
|
|
# 5) Build Glibc with the bootstrap tools. The result is the full,
|
2009-02-01 22:44:56 +01:00
|
|
|
# dynamically linked, final Glibc.
|
2010-08-25 21:15:16 +02:00
|
|
|
stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
|
2005-02-21 21:42:07 +01:00
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-01-07 17:46:47 +01:00
|
|
|
# 6) Construct a third stdenv identical to the 2nd, except that this
|
2013-06-12 16:11:14 +02:00
|
|
|
# one uses the Glibc built in step 3. It still uses the recent
|
|
|
|
# binutils and the rest of the bootstrap tools, including GCC.
|
2010-11-21 15:29:20 +01:00
|
|
|
stdenvLinuxBoot3 = stdenvBootFun {
|
2010-01-19 12:25:33 +01:00
|
|
|
gcc = wrapGCC {
|
2014-01-07 17:46:47 +01:00
|
|
|
binutils = binutils1;
|
2010-01-19 12:25:33 +01:00
|
|
|
coreutils = bootstrapTools;
|
|
|
|
libc = stdenvLinuxGlibc;
|
|
|
|
};
|
2011-12-14 15:31:56 +01:00
|
|
|
overrides = pkgs: {
|
2010-01-19 12:25:33 +01:00
|
|
|
glibc = stdenvLinuxGlibc;
|
2010-08-23 21:59:06 +02:00
|
|
|
inherit (stdenvLinuxBoot1Pkgs) perl;
|
2011-12-14 15:31:56 +01:00
|
|
|
# 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 = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
|
|
|
mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
|
|
|
mpc = pkgs.mpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
|
|
|
isl = pkgs.isl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
|
|
|
cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
|
|
|
ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
|
2010-01-19 12:25:33 +01:00
|
|
|
};
|
2012-12-31 10:13:55 +01:00
|
|
|
extraAttrs = {
|
2014-06-27 11:15:28 +02:00
|
|
|
glibc = stdenvLinuxGlibc; # Required by gcc47 build
|
2012-12-31 10:13:55 +01:00
|
|
|
};
|
2014-06-27 11:15:28 +02:00
|
|
|
extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot1Pkgs.paxctl ];
|
2009-02-01 22:44:56 +01:00
|
|
|
inherit fetchurl;
|
2010-11-21 15:29:20 +01:00
|
|
|
};
|
2005-02-21 21:42:07 +01:00
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2010-08-25 15:22:48 +02:00
|
|
|
# 7) The packages that can be built using the third stdenv.
|
2010-08-25 21:15:16 +02:00
|
|
|
stdenvLinuxBoot3Pkgs = allPackages {
|
2010-08-21 23:08:57 +02:00
|
|
|
inherit system platform;
|
2010-08-25 21:15:16 +02:00
|
|
|
bootStdenv = stdenvLinuxBoot3;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2010-08-25 15:22:48 +02:00
|
|
|
# 8) Construct a fourth stdenv identical to the second, except that
|
2014-01-07 17:46:47 +01:00
|
|
|
# this one uses the new GCC from step 7. The other tools
|
|
|
|
# (e.g. coreutils) are still from the bootstrap tools.
|
2010-08-25 21:15:16 +02:00
|
|
|
stdenvLinuxBoot4 = stdenvBootFun {
|
2009-02-01 22:44:56 +01:00
|
|
|
gcc = wrapGCC rec {
|
2014-01-07 17:46:47 +01:00
|
|
|
binutils = binutils1;
|
2009-11-08 01:32:12 +01:00
|
|
|
coreutils = bootstrapTools;
|
2006-10-24 22:57:06 +02:00
|
|
|
libc = stdenvLinuxGlibc;
|
2011-12-14 15:31:56 +01:00
|
|
|
gcc = stdenvLinuxBoot3Pkgs.gcc.gcc;
|
2009-04-09 17:25:29 +02:00
|
|
|
name = "";
|
2006-07-10 17:42:19 +02:00
|
|
|
};
|
2014-06-27 11:15:28 +02:00
|
|
|
extraBuildInputs = [ stdenvLinuxBoot2Pkgs.patchelf stdenvLinuxBoot3Pkgs.xz ];
|
2011-12-14 15:31:56 +01:00
|
|
|
overrides = pkgs: {
|
2010-08-23 21:59:06 +02:00
|
|
|
inherit (stdenvLinuxBoot1Pkgs) perl;
|
2013-01-29 23:39:27 +01:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 gmp;
|
2010-01-19 12:25:33 +01:00
|
|
|
};
|
2009-02-01 22:44:56 +01:00
|
|
|
inherit fetchurl;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2010-08-25 15:22:48 +02:00
|
|
|
# 9) The packages that can be built using the fourth stdenv.
|
2010-08-25 21:15:16 +02:00
|
|
|
stdenvLinuxBoot4Pkgs = allPackages {
|
2010-08-21 23:08:57 +02:00
|
|
|
inherit system platform;
|
2010-08-25 21:15:16 +02:00
|
|
|
bootStdenv = stdenvLinuxBoot4;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-01-07 17:46:47 +01:00
|
|
|
# 10) 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.
|
2009-02-01 22:44:56 +01:00
|
|
|
#
|
2010-08-25 15:22:48 +02:00
|
|
|
# When updating stdenvLinux, make sure that the result has no
|
|
|
|
# dependency (`nix-store -qR') on bootstrapTools or the
|
|
|
|
# first binutils built.
|
2010-08-06 12:34:34 +02:00
|
|
|
stdenvLinux = import ../generic rec {
|
2012-12-28 16:36:09 +01:00
|
|
|
inherit system config;
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2014-01-07 13:57:42 +01:00
|
|
|
preHook =
|
|
|
|
''
|
|
|
|
# Make "strip" produce deterministic output, by setting
|
|
|
|
# timestamps etc. to a fixed value.
|
|
|
|
commonStripFlags="--enable-deterministic-archives"
|
|
|
|
${commonPreHook}
|
|
|
|
'';
|
2012-12-28 16:41:56 +01:00
|
|
|
|
|
|
|
initialPath =
|
2014-06-27 11:15:28 +02:00
|
|
|
((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;});
|
|
|
|
|
|
|
|
extraBuildInputs =
|
|
|
|
[ stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ];
|
2009-11-15 17:48:36 +01:00
|
|
|
|
2009-02-01 22:44:56 +01:00
|
|
|
gcc = wrapGCC rec {
|
2014-01-07 17:46:47 +01:00
|
|
|
inherit (stdenvLinuxBoot4Pkgs) binutils coreutils;
|
2006-10-24 22:57:06 +02:00
|
|
|
libc = stdenvLinuxGlibc;
|
2012-12-07 16:13:39 +01:00
|
|
|
gcc = stdenvLinuxBoot4.gcc.gcc;
|
2010-08-25 21:15:16 +02:00
|
|
|
shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
|
2009-04-09 17:25:29 +02:00
|
|
|
name = "";
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2010-08-25 21:15:16 +02:00
|
|
|
shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
fetchurlBoot = fetchurl;
|
2012-12-28 16:41:56 +01:00
|
|
|
|
2006-02-09 18:04:18 +01:00
|
|
|
extraAttrs = {
|
2014-06-27 11:15:28 +02:00
|
|
|
glibc = stdenvLinuxGlibc;
|
2012-12-30 12:29:02 +01:00
|
|
|
inherit platform bootstrapTools;
|
2014-01-28 15:22:51 +01:00
|
|
|
shellPackage = stdenvLinuxBoot4Pkgs.bash;
|
2010-08-06 12:34:34 +02:00
|
|
|
};
|
|
|
|
|
2011-12-14 15:31:56 +01:00
|
|
|
overrides = pkgs: {
|
2010-08-06 12:34:34 +02:00
|
|
|
inherit gcc;
|
2014-01-28 15:22:51 +01:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) glibc;
|
|
|
|
inherit (stdenvLinuxBoot4Pkgs) binutils;
|
2010-08-25 21:15:16 +02:00
|
|
|
inherit (stdenvLinuxBoot4Pkgs)
|
2011-10-14 23:56:11 +02:00
|
|
|
gzip bzip2 xz bash coreutils diffutils findutils gawk
|
2010-08-06 12:34:34 +02:00
|
|
|
gnumake gnused gnutar gnugrep gnupatch patchelf
|
2014-08-23 16:04:53 +02:00
|
|
|
attr acl pcre paxctl;
|
2006-02-09 18:04:18 +01:00
|
|
|
};
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2004-10-19 17:16:14 +02:00
|
|
|
}
|