2005-02-21 20:42:07 +00: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 15:12:03 +00:00
|
|
|
# The function defaults are for easy testing.
|
2011-12-12 14:02:12 +00:00
|
|
|
{ system ? "i686-linux"
|
|
|
|
, allPackages ? import ../../top-level/all-packages.nix
|
|
|
|
, platform ? null }:
|
2005-02-21 20:42:07 +00:00
|
|
|
|
2004-11-04 12:19:32 +00:00
|
|
|
rec {
|
2004-10-19 15:16:14 +00:00
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
bootstrapFiles =
|
2006-10-24 20:57:06 +00:00
|
|
|
if system == "i686-linux" then import ./bootstrap/i686
|
|
|
|
else if system == "x86_64-linux" then import ./bootstrap/x86_64
|
2006-10-26 20:07:49 +00:00
|
|
|
else if system == "powerpc-linux" then import ./bootstrap/powerpc
|
2009-11-08 00:32:12 +00:00
|
|
|
else if system == "armv5tel-linux" then import ./bootstrap/armv5tel
|
2010-09-01 09:50:12 +00:00
|
|
|
else if system == "mips64-linux" then import ./bootstrap/loongson2f
|
2006-10-24 20:57:06 +00:00
|
|
|
else abort "unsupported platform for the pure Linux stdenv";
|
2006-08-23 16:18:02 +00:00
|
|
|
|
|
|
|
|
2009-03-25 17:34:38 +00:00
|
|
|
commonPreHook =
|
|
|
|
''
|
|
|
|
export NIX_ENFORCE_PURITY=1
|
|
|
|
havePatchELF=1
|
|
|
|
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
|
2010-09-01 09:50:12 +00:00
|
|
|
${if system == "mips64-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
|
2009-03-25 17:34:38 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
2005-02-21 20:42:07 +00:00
|
|
|
# The bootstrap process proceeds in several steps.
|
|
|
|
|
2006-10-24 20:57:06 +00:00
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
# 1) Create a standard environment by downloading pre-built binaries
|
|
|
|
# of coreutils, GCC, etc.
|
2005-02-22 09:55:03 +00:00
|
|
|
|
2009-02-02 15:03:38 +00:00
|
|
|
|
2005-02-22 09:55:03 +00:00
|
|
|
# This function downloads a file.
|
2009-02-01 21:44:56 +00:00
|
|
|
download = {url, sha256}: derivation {
|
2005-02-22 09:55:03 +00:00
|
|
|
name = baseNameOf (toString url);
|
2009-02-01 21:44:56 +00:00
|
|
|
builder = bootstrapFiles.sh;
|
|
|
|
inherit system url;
|
|
|
|
inherit (bootstrapFiles) bzip2 mkdir curl cpio ln;
|
2006-10-24 20:57:51 +00:00
|
|
|
args = [ ./scripts/download.sh ];
|
2009-02-01 21:44:56 +00:00
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHash = sha256;
|
2008-11-14 10:51:17 +00:00
|
|
|
impureEnvVars = [ "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" ];
|
2004-11-04 12:19:32 +00:00
|
|
|
};
|
|
|
|
|
2009-02-02 15:03:38 +00:00
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
|
|
|
|
bootstrapTools = derivation {
|
|
|
|
name = "bootstrap-tools";
|
|
|
|
|
|
|
|
builder = bootstrapFiles.sh;
|
|
|
|
|
2009-11-08 00:32:12 +00:00
|
|
|
args = if (system == "armv5tel-linux") then
|
|
|
|
([ ./scripts/unpack-bootstrap-tools-arm.sh ])
|
|
|
|
else
|
|
|
|
([ ./scripts/unpack-bootstrap-tools.sh ]);
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
inherit (bootstrapFiles) bzip2 mkdir curl cpio;
|
|
|
|
|
|
|
|
tarball = download {
|
|
|
|
inherit (bootstrapFiles.bootstrapTools) url sha256;
|
|
|
|
};
|
|
|
|
|
2006-10-24 20:57:06 +00:00
|
|
|
inherit system;
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
# Needed by the GCC wrapper.
|
|
|
|
langC = true;
|
|
|
|
langCC = true;
|
2004-11-04 12:19:32 +00:00
|
|
|
};
|
2009-02-01 21:44:56 +00:00
|
|
|
|
2004-11-04 12:19:32 +00:00
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
# This function builds the various standard environments used during
|
|
|
|
# the bootstrap.
|
|
|
|
stdenvBootFun =
|
2010-08-06 10:34:34 +00:00
|
|
|
{gcc, extraAttrs ? {}, overrides ? {}, extraPath ? [], fetchurl}:
|
2004-11-04 12:19:32 +00:00
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
import ../generic {
|
|
|
|
inherit system;
|
|
|
|
name = "stdenv-linux-boot";
|
|
|
|
param1 = bootstrapTools;
|
|
|
|
preHook = builtins.toFile "prehook.sh"
|
|
|
|
''
|
|
|
|
# Don't patch #!/interpreter because it leads to retained
|
|
|
|
# dependencies on the bootstrapTools in the final stdenv.
|
|
|
|
dontPatchShebangs=1
|
2009-03-25 17:34:38 +00:00
|
|
|
${commonPreHook}
|
2009-02-01 21:44:56 +00:00
|
|
|
'';
|
|
|
|
shell = "${bootstrapTools}/bin/sh";
|
|
|
|
initialPath = [bootstrapTools] ++ extraPath;
|
|
|
|
fetchurlBoot = fetchurl;
|
2010-08-21 21:08:57 +00:00
|
|
|
inherit gcc;
|
|
|
|
# Having the proper 'platform' in all the stdenvs allows getting proper
|
|
|
|
# linuxHeaders for example.
|
|
|
|
extraAttrs = extraAttrs // { inherit platform; };
|
2010-08-06 10:34:34 +00:00
|
|
|
overrides = overrides // {
|
|
|
|
inherit fetchurl;
|
|
|
|
};
|
2006-07-10 15:42:19 +00:00
|
|
|
};
|
|
|
|
|
2009-02-01 21:44:56 +00: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 12:19:32 +00:00
|
|
|
};
|
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
fetchurl = import ../../build-support/fetchurl {
|
|
|
|
stdenv = stdenvLinuxBoot0;
|
|
|
|
curl = bootstrapTools;
|
|
|
|
};
|
2004-11-04 12:19:32 +00:00
|
|
|
|
2009-02-01 21:44:56 +00: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 = ''
|
|
|
|
ensureDir $out
|
|
|
|
ln -s ${bootstrapTools}/lib $out/lib
|
|
|
|
ln -s ${bootstrapTools}/include-glibc $out/include
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# A helper function to call gcc-wrapper.
|
|
|
|
wrapGCC =
|
2009-11-08 00:32:12 +00:00
|
|
|
{gcc ? bootstrapTools, libc, binutils, coreutils, shell ? "", name ? "bootstrap-gcc-wrapper"}:
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
import ../../build-support/gcc-wrapper {
|
|
|
|
nativeTools = false;
|
|
|
|
nativeLibc = false;
|
2009-11-08 00:32:12 +00:00
|
|
|
inherit gcc binutils coreutils libc shell name;
|
2009-02-01 21:44:56 +00:00
|
|
|
stdenv = stdenvLinuxBoot0;
|
2004-11-04 12:19:32 +00:00
|
|
|
};
|
2005-02-21 20:42:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Create the first "real" standard environment. This one consists
|
2009-02-01 21:44:56 +00:00
|
|
|
# of bootstrap tools only, and a minimal Glibc to keep the GCC
|
|
|
|
# configure script happy.
|
2005-02-21 20:42:07 +00:00
|
|
|
stdenvLinuxBoot1 = stdenvBootFun {
|
2010-01-19 11:25:33 +00:00
|
|
|
gcc = wrapGCC {
|
|
|
|
libc = bootstrapGlibc;
|
|
|
|
binutils = bootstrapTools;
|
|
|
|
coreutils = bootstrapTools;
|
|
|
|
};
|
2009-02-01 21:44:56 +00:00
|
|
|
inherit fetchurl;
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
2006-10-24 20:57:06 +00:00
|
|
|
|
2005-02-21 20:42:07 +00:00
|
|
|
|
|
|
|
# 2) These are the packages that we can build with the first
|
2010-08-25 13:22:48 +00:00
|
|
|
# stdenv. We only need binutils, because recent glibcs
|
|
|
|
# require recent binutils, and those in bootstrap-tools may
|
|
|
|
# be too old. (in step 3).
|
2005-02-21 20:42:07 +00:00
|
|
|
stdenvLinuxBoot1Pkgs = allPackages {
|
2010-08-21 21:08:57 +00:00
|
|
|
inherit system platform;
|
2006-02-08 17:37:45 +00:00
|
|
|
bootStdenv = stdenvLinuxBoot1;
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
firstBinutils = stdenvLinuxBoot1Pkgs.binutils;
|
|
|
|
|
|
|
|
# 3) 2nd stdenv that we will use to build only the glibc.
|
2010-08-25 19:15:16 +00:00
|
|
|
stdenvLinuxBoot2 = stdenvBootFun {
|
2010-08-25 13:22:48 +00:00
|
|
|
gcc = wrapGCC {
|
|
|
|
libc = bootstrapGlibc;
|
|
|
|
binutils = firstBinutils;
|
|
|
|
coreutils = bootstrapTools;
|
|
|
|
};
|
|
|
|
inherit fetchurl;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# 4) These are the packages that we can build with the 2nd
|
|
|
|
# stdenv. We only need Glibc (in step 5).
|
2010-08-25 19:15:16 +00:00
|
|
|
stdenvLinuxBoot2Pkgs = allPackages {
|
2010-08-25 13:22:48 +00:00
|
|
|
inherit system platform;
|
2010-08-25 19:15:16 +00:00
|
|
|
bootStdenv = stdenvLinuxBoot2;
|
2010-08-25 13:22:48 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 20:57:06 +00:00
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
# 5) Build Glibc with the bootstrap tools. The result is the full,
|
2009-02-01 21:44:56 +00:00
|
|
|
# dynamically linked, final Glibc.
|
2010-08-25 19:15:16 +00:00
|
|
|
stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
|
2005-02-21 20:42:07 +00:00
|
|
|
|
2006-10-24 20:57:06 +00:00
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
# 6) Construct a third stdenv identical to the 2nd, except that
|
2005-02-21 20:42:07 +00:00
|
|
|
# this one uses the Glibc built in step 3. It still uses
|
2010-08-25 13:22:48 +00:00
|
|
|
# the recent binutils and rest of the bootstrap tools, including GCC.
|
2010-11-21 14:29:20 +00:00
|
|
|
stdenvLinuxBoot3 = stdenvBootFun {
|
2010-01-19 11:25:33 +00:00
|
|
|
gcc = wrapGCC {
|
2010-08-25 13:22:48 +00:00
|
|
|
binutils = stdenvLinuxBoot1Pkgs.binutils;
|
2010-01-19 11:25:33 +00:00
|
|
|
coreutils = bootstrapTools;
|
|
|
|
libc = stdenvLinuxGlibc;
|
|
|
|
};
|
2010-08-06 10:34:34 +00:00
|
|
|
overrides = {
|
2010-01-19 11:25:33 +00:00
|
|
|
glibc = stdenvLinuxGlibc;
|
2010-08-23 19:59:06 +00:00
|
|
|
inherit (stdenvLinuxBoot1Pkgs) perl;
|
2010-01-19 11:25:33 +00:00
|
|
|
};
|
2009-02-01 21:44:56 +00:00
|
|
|
inherit fetchurl;
|
2010-11-21 14:29:20 +00:00
|
|
|
};
|
2005-02-21 20:42:07 +00:00
|
|
|
|
2006-10-24 20:57:06 +00:00
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
# 7) The packages that can be built using the third stdenv.
|
2010-08-25 19:15:16 +00:00
|
|
|
stdenvLinuxBoot3Pkgs = allPackages {
|
2010-08-21 21:08:57 +00:00
|
|
|
inherit system platform;
|
2010-08-25 19:15:16 +00:00
|
|
|
bootStdenv = stdenvLinuxBoot3;
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
|
|
|
|
2010-08-25 19:15:16 +00:00
|
|
|
gccWithStaticLibs = stdenvLinuxBoot3Pkgs.gcc.gcc.override (rec {
|
2011-04-04 13:47:04 +00:00
|
|
|
ppl = stdenvLinuxBoot3Pkgs.ppl.override {
|
|
|
|
static = true;
|
|
|
|
gmpxx = stdenvLinuxBoot3Pkgs.gmpxx.override {
|
|
|
|
static = true;
|
|
|
|
};
|
|
|
|
};
|
2011-09-01 14:28:13 +00:00
|
|
|
cloog = stdenvLinuxBoot3Pkgs.cloog.override {
|
|
|
|
isl = stdenvLinuxBoot3Pkgs.isl.override {
|
|
|
|
static = true;
|
|
|
|
};
|
2011-04-04 13:47:04 +00:00
|
|
|
static = true;
|
|
|
|
};
|
2011-09-01 14:28:13 +00:00
|
|
|
cloogppl = null;
|
2011-04-04 13:47:04 +00:00
|
|
|
});
|
2008-05-19 15:12:03 +00:00
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
# 8) Construct a fourth stdenv identical to the second, except that
|
2005-02-21 20:42:07 +00:00
|
|
|
# this one uses the dynamically linked GCC and Binutils from step
|
2009-02-01 21:44:56 +00:00
|
|
|
# 5. The other tools (e.g. coreutils) are still from the
|
|
|
|
# bootstrap tools.
|
2010-08-25 19:15:16 +00:00
|
|
|
stdenvLinuxBoot4 = stdenvBootFun {
|
2009-02-01 21:44:56 +00:00
|
|
|
gcc = wrapGCC rec {
|
2010-08-25 19:15:16 +00:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) binutils;
|
2009-11-08 00:32:12 +00:00
|
|
|
coreutils = bootstrapTools;
|
2006-10-24 20:57:06 +00:00
|
|
|
libc = stdenvLinuxGlibc;
|
2010-08-04 12:36:35 +00:00
|
|
|
gcc = gccWithStaticLibs;
|
2009-04-09 15:25:29 +00:00
|
|
|
name = "";
|
2006-07-10 15:42:19 +00:00
|
|
|
};
|
2010-08-06 10:34:34 +00:00
|
|
|
overrides = {
|
2010-08-23 19:59:06 +00:00
|
|
|
inherit (stdenvLinuxBoot1Pkgs) perl;
|
2010-01-19 11:25:33 +00:00
|
|
|
};
|
2009-02-01 21:44:56 +00:00
|
|
|
inherit fetchurl;
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
|
|
|
|
2006-10-24 20:57:06 +00:00
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
# 9) The packages that can be built using the fourth stdenv.
|
2010-08-25 19:15:16 +00:00
|
|
|
stdenvLinuxBoot4Pkgs = allPackages {
|
2010-08-21 21:08:57 +00:00
|
|
|
inherit system platform;
|
2010-08-25 19:15:16 +00:00
|
|
|
bootStdenv = stdenvLinuxBoot4;
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
|
|
|
|
2010-01-19 11:25:33 +00:00
|
|
|
|
2010-08-25 13:22:48 +00:00
|
|
|
# 10) Construct the final stdenv. It uses the Glibc, GCC and
|
|
|
|
# Binutils built above, and adds in dynamically linked versions
|
|
|
|
# of all other tools.
|
2009-02-01 21:44:56 +00:00
|
|
|
#
|
2010-08-25 13:22:48 +00: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 10:34:34 +00:00
|
|
|
stdenvLinux = import ../generic rec {
|
2009-11-17 21:14:57 +00:00
|
|
|
name = "stdenv-linux";
|
2009-02-01 21:44:56 +00:00
|
|
|
|
2009-11-17 21:14:57 +00:00
|
|
|
inherit system;
|
2009-02-01 21:44:56 +00:00
|
|
|
|
2009-03-25 17:34:38 +00:00
|
|
|
preHook = builtins.toFile "prehook.sh" commonPreHook;
|
2009-02-01 21:44:56 +00:00
|
|
|
|
2009-04-25 14:08:29 +00:00
|
|
|
initialPath =
|
2010-08-25 19:15:16 +00:00
|
|
|
((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;})
|
|
|
|
++ [stdenvLinuxBoot4Pkgs.patchelf];
|
2009-11-15 16:48:36 +00:00
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
gcc = wrapGCC rec {
|
2010-08-25 19:15:16 +00:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) binutils;
|
|
|
|
inherit (stdenvLinuxBoot4Pkgs) coreutils;
|
2006-10-24 20:57:06 +00:00
|
|
|
libc = stdenvLinuxGlibc;
|
2010-08-04 12:36:35 +00:00
|
|
|
gcc = gccWithStaticLibs;
|
2010-08-25 19:15:16 +00:00
|
|
|
shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
|
2009-04-09 15:25:29 +00:00
|
|
|
name = "";
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
|
|
|
|
2010-08-25 19:15:16 +00:00
|
|
|
shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
|
2006-02-09 17:04:18 +00:00
|
|
|
|
2009-02-02 15:03:38 +00:00
|
|
|
fetchurlBoot = fetchurl;
|
2008-05-27 07:49:55 +00:00
|
|
|
|
2006-02-09 17:04:18 +00:00
|
|
|
extraAttrs = {
|
2010-08-25 19:15:16 +00:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) glibc;
|
2010-08-21 21:08:57 +00:00
|
|
|
inherit platform;
|
2010-08-06 10:34:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
overrides = {
|
|
|
|
inherit gcc;
|
2010-08-25 19:15:16 +00:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) binutils glibc;
|
|
|
|
inherit (stdenvLinuxBoot4Pkgs)
|
2011-10-14 21:56:11 +00:00
|
|
|
gzip bzip2 xz bash coreutils diffutils findutils gawk
|
2010-08-06 10:34:34 +00:00
|
|
|
gnumake gnused gnutar gnugrep gnupatch patchelf
|
2008-05-19 15:12:03 +00:00
|
|
|
attr acl;
|
2006-02-09 17:04:18 +00:00
|
|
|
};
|
2005-02-21 20:42:07 +00:00
|
|
|
};
|
|
|
|
|
2004-10-19 15:16:14 +00:00
|
|
|
}
|