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.
|
|
|
|
{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix}:
|
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
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
bootstrapTools =
|
|
|
|
if system == "i686-linux" then import ./bootstrap/i686
|
|
|
|
else if system == "x86_64-linux" then import ./bootstrap/x86_64
|
2006-10-26 22:07:49 +02:00
|
|
|
else if system == "powerpc-linux" then import ./bootstrap/powerpc
|
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
|
|
|
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The bootstrap process proceeds in several steps.
|
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 1) Create a standard environment by downloading pre-built
|
|
|
|
# statically linked binaries of coreutils, gcc, etc.
|
|
|
|
|
|
|
|
# To fetch the pre-built binaries, we use a statically linked `curl'
|
|
|
|
# binary which is unpacked here.
|
2004-11-04 13:19:32 +01:00
|
|
|
curl = derivation {
|
2006-08-23 18:18:02 +02:00
|
|
|
inherit system;
|
2006-10-24 22:57:06 +02:00
|
|
|
name = "curl";
|
|
|
|
builder = bootstrapTools.bash;
|
2007-12-03 18:56:44 +01:00
|
|
|
inherit (bootstrapTools) bzip2 cp curl;
|
2006-10-24 22:57:51 +02:00
|
|
|
args = [ ./scripts/unpack-curl.sh ];
|
2005-02-22 10:55:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# This function downloads a file.
|
2006-10-24 22:57:06 +02:00
|
|
|
download = {url, sha1, pkgname}: derivation {
|
2005-02-22 10:55:03 +01:00
|
|
|
name = baseNameOf (toString url);
|
2006-10-24 22:57:06 +02:00
|
|
|
builder = bootstrapTools.bash;
|
2006-08-23 18:18:02 +02:00
|
|
|
inherit system curl url;
|
2006-10-24 22:57:51 +02:00
|
|
|
args = [ ./scripts/download.sh ];
|
2006-10-24 22:57:06 +02:00
|
|
|
outputHashAlgo = "sha1";
|
|
|
|
outputHash = sha1;
|
2008-11-14 11:51:17 +01:00
|
|
|
impureEnvVars = [ "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" ];
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# This function downloads and unpacks a file.
|
2006-10-24 22:57:06 +02:00
|
|
|
downloadAndUnpack = pkgname: {url, sha1}: derivation {
|
2004-11-04 13:19:32 +01:00
|
|
|
name = pkgname;
|
2006-10-24 22:57:06 +02:00
|
|
|
builder = bootstrapTools.bash;
|
2007-12-03 18:56:44 +01:00
|
|
|
inherit (bootstrapTools) bzip2 tar cp;
|
2006-10-24 22:57:51 +02:00
|
|
|
args = [ ./scripts/unpack.sh ];
|
2006-10-24 22:57:06 +02:00
|
|
|
tarball = download {inherit url sha1 pkgname;};
|
|
|
|
inherit system;
|
|
|
|
allowedReferences = [];
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The various statically linked components that make up the standard
|
|
|
|
# environment.
|
2006-10-24 22:57:06 +02:00
|
|
|
staticTools = downloadAndUnpack "static-tools" bootstrapTools.staticToolsURL;
|
|
|
|
staticBinutils = downloadAndUnpack "static-binutils" bootstrapTools.binutilsURL;
|
|
|
|
staticGCC = (downloadAndUnpack "static-gcc" bootstrapTools.gccURL)
|
|
|
|
// { langC = true; langCC = false; langF77 = false; };
|
|
|
|
staticGlibc = downloadAndUnpack "static-glibc" bootstrapTools.glibcURL;
|
2004-11-04 13:19:32 +01:00
|
|
|
|
|
|
|
|
2006-07-10 17:42:19 +02:00
|
|
|
# A helper function to call gcc-wrapper.
|
|
|
|
wrapGCC =
|
2006-10-24 22:57:06 +02:00
|
|
|
{gcc ? staticGCC, libc, binutils, shell ? ""}:
|
2006-07-10 17:42:19 +02:00
|
|
|
(import ../../build-support/gcc-wrapper) {
|
|
|
|
nativeTools = false;
|
2006-10-24 22:57:06 +02:00
|
|
|
nativeLibc = false;
|
|
|
|
inherit gcc binutils libc shell;
|
2006-07-10 17:42:19 +02:00
|
|
|
stdenv = stdenvInitial;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The "fake" standard environment used to build "real" standard
|
2005-02-22 08:59:15 +01:00
|
|
|
# environments. It consists of just the basic statically linked
|
|
|
|
# tools.
|
2005-02-21 21:42:07 +01:00
|
|
|
stdenvInitial = let {
|
2005-02-21 17:03:34 +01:00
|
|
|
body = derivation {
|
2005-02-22 08:59:15 +01:00
|
|
|
name = "stdenv-linux-initial";
|
2006-10-24 22:57:06 +02:00
|
|
|
builder = bootstrapTools.bash;
|
2006-10-24 22:57:51 +02:00
|
|
|
args = [ ./scripts/builder-stdenv-initial.sh ];
|
2006-12-27 19:14:57 +01:00
|
|
|
stdenvScript = ../generic/setup.sh;
|
2006-10-24 22:57:06 +02:00
|
|
|
inherit system staticTools curl;
|
2006-10-12 12:53:16 +02:00
|
|
|
} // {
|
|
|
|
# !!! too much duplication with stdenv/generic/default.nix
|
|
|
|
mkDerivation = attrs: (derivation ((removeAttrs attrs ["meta"]) // {
|
2006-10-24 22:57:06 +02:00
|
|
|
builder = bootstrapTools.bash;
|
2004-11-04 13:19:32 +01:00
|
|
|
args = ["-e" attrs.builder];
|
|
|
|
stdenv = body;
|
|
|
|
system = body.system;
|
2006-10-12 12:53:16 +02:00
|
|
|
})) // { meta = if attrs ? meta then attrs.meta else {}; };
|
2006-10-24 22:57:06 +02:00
|
|
|
shell = bootstrapTools.bash;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# This function builds the various standard environments used during
|
|
|
|
# the bootstrap.
|
2006-02-09 18:04:18 +01:00
|
|
|
stdenvBootFun =
|
2008-05-19 17:12:03 +02:00
|
|
|
{gcc, staticGlibc, extraAttrs ? {}, extraPath ? []}:
|
2008-05-27 09:49:55 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
fetchurlBoot = import ../../build-support/fetchurl {
|
|
|
|
stdenv = stdenvInitial;
|
|
|
|
inherit curl;
|
|
|
|
};
|
|
|
|
in import ../generic {
|
2006-02-09 18:04:18 +01:00
|
|
|
name = "stdenv-linux-boot";
|
2006-10-25 13:06:44 +02:00
|
|
|
param1 = if staticGlibc then "static" else "dynamic";
|
2006-10-24 22:57:51 +02:00
|
|
|
preHook = ./scripts/prehook.sh;
|
2004-11-04 13:19:32 +01:00
|
|
|
stdenv = stdenvInitial;
|
2006-10-24 22:57:06 +02:00
|
|
|
shell = bootstrapTools.bash;
|
2008-05-19 17:12:03 +02:00
|
|
|
initialPath = [staticTools] ++ extraPath;
|
2008-05-27 09:49:55 +02:00
|
|
|
inherit fetchurlBoot;
|
2008-06-18 17:09:13 +02:00
|
|
|
forceFetchurlBoot = true;
|
2008-06-27 16:33:09 +02:00
|
|
|
inherit gcc extraAttrs;
|
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
|
|
|
|
# of statically linked components only, and a minimal glibc to keep
|
|
|
|
# the gcc configure script happy.
|
|
|
|
stdenvLinuxBoot1 = stdenvBootFun {
|
|
|
|
# Use the statically linked, downloaded glibc/gcc/binutils.
|
2006-10-24 22:57:06 +02:00
|
|
|
gcc = wrapGCC {libc = staticGlibc; binutils = staticBinutils;};
|
2005-02-21 21:42:07 +01:00
|
|
|
staticGlibc = true;
|
|
|
|
};
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
|
|
|
|
# 2) These are the packages that we can build with the first
|
|
|
|
# stdenv. We only need Glibc (in step 3).
|
|
|
|
stdenvLinuxBoot1Pkgs = allPackages {
|
2006-08-23 18:18:02 +02:00
|
|
|
inherit system;
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot1;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 3) Build Glibc with the statically linked tools. The result is the
|
|
|
|
# full, dynamically linked, final Glibc.
|
2006-10-25 00:23:20 +02:00
|
|
|
stdenvLinuxGlibc = stdenvLinuxBoot1Pkgs.glibc;
|
2005-02-21 21:42:07 +01:00
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 4) Construct a second stdenv identical to the first, except that
|
|
|
|
# this one uses the Glibc built in step 3. It still uses
|
|
|
|
# statically linked tools.
|
2006-07-10 17:42:19 +02:00
|
|
|
stdenvLinuxBoot2 = removeAttrs (stdenvBootFun {
|
2005-02-21 21:42:07 +01:00
|
|
|
staticGlibc = false;
|
2006-10-24 22:57:06 +02:00
|
|
|
gcc = wrapGCC {binutils = staticBinutils; libc = stdenvLinuxGlibc;};
|
2008-05-27 09:49:55 +02:00
|
|
|
extraAttrs = {glibc = stdenvLinuxGlibc;};
|
2006-07-10 17:42:19 +02:00
|
|
|
}) ["gcc" "binutils"];
|
2005-02-21 21:42:07 +01:00
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 5) The packages that can be built using the second stdenv.
|
|
|
|
stdenvLinuxBoot2Pkgs = allPackages {
|
2006-08-23 18:18:02 +02:00
|
|
|
inherit system;
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot2;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2008-05-19 17:12:03 +02:00
|
|
|
|
|
|
|
# Ugh, some packages in stdenvLinuxBoot3Pkgs need "sh", so create a
|
|
|
|
# package that contains just a symlink to bash.
|
|
|
|
shSymlink = stdenvLinuxBoot2Pkgs.runCommand "sh-symlink" {} ''
|
|
|
|
ensureDir $out/bin
|
|
|
|
ln -s $shell $out/bin/sh
|
|
|
|
'';
|
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 6) Construct a third stdenv identical to the second, except that
|
|
|
|
# this one uses the dynamically linked GCC and Binutils from step
|
|
|
|
# 5. The other tools (e.g. coreutils) are still static.
|
|
|
|
stdenvLinuxBoot3 = stdenvBootFun {
|
|
|
|
staticGlibc = false;
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = wrapGCC {
|
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
2006-10-24 22:57:06 +02:00
|
|
|
libc = stdenvLinuxGlibc;
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
|
|
|
|
};
|
2008-05-19 17:12:03 +02:00
|
|
|
extraPath = [stdenvLinuxBoot2Pkgs.replace shSymlink];
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 7) The packages that can be built using the third stdenv.
|
|
|
|
stdenvLinuxBoot3Pkgs = allPackages {
|
2006-08-23 18:18:02 +02:00
|
|
|
inherit system;
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot3;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2006-10-24 22:57:06 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# 8) Construct the final stdenv. It uses the Glibc, GCC and
|
|
|
|
# Binutils built above, and adds in dynamically linked versions
|
|
|
|
# of all other tools.
|
2008-05-19 17:12:03 +02:00
|
|
|
stdenvLinux = import ../generic {
|
2005-02-22 08:59:15 +01:00
|
|
|
name = "stdenv-linux";
|
2006-10-24 22:57:51 +02:00
|
|
|
preHook = ./scripts/prehook.sh;
|
2005-02-21 21:42:07 +01:00
|
|
|
initialPath = [
|
2006-07-14 10:35:59 +02:00
|
|
|
((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;})
|
2005-02-21 21:42:07 +01:00
|
|
|
stdenvLinuxBoot3Pkgs.patchelf
|
|
|
|
];
|
|
|
|
|
|
|
|
stdenv = stdenvInitial;
|
|
|
|
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = wrapGCC {
|
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
2006-10-24 22:57:06 +02:00
|
|
|
libc = stdenvLinuxGlibc;
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
|
2006-10-17 16:06:18 +02:00
|
|
|
shell = stdenvLinuxBoot3Pkgs.bash + "/bin/sh";
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2006-10-17 16:06:18 +02:00
|
|
|
shell = stdenvLinuxBoot3Pkgs.bash + "/bin/sh";
|
2006-02-09 18:04:18 +01:00
|
|
|
|
2008-05-27 09:49:55 +02:00
|
|
|
fetchurlBoot = stdenvLinuxBoot3.fetchurlBoot;
|
2008-06-18 17:09:13 +02:00
|
|
|
forceFetchurlBoot = false;
|
2008-05-27 09:49:55 +02:00
|
|
|
|
2006-02-09 18:04:18 +01:00
|
|
|
extraAttrs = {
|
2006-07-10 17:42:19 +02:00
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */ glibc;
|
2006-02-09 18:04:18 +01:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs)
|
|
|
|
gzip bzip2 bash coreutils diffutils findutils gawk
|
2008-05-19 17:12:03 +02:00
|
|
|
gnumake gnused gnutar gnugrep patch patchelf
|
|
|
|
attr acl;
|
2006-02-09 18:04:18 +01:00
|
|
|
};
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2004-10-19 17:16:14 +02:00
|
|
|
}
|