2005-02-21 23:42:07 +03: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 19:12:03 +04:00
|
|
|
# The function defaults are for easy testing.
|
My first attempt at getting cross compilers in nixpkgs.
My idea is to provide special stdenv expressions that will contain in the path
additional cross compilers. As most expressions for programs accept a stdenv parameter,
we could substitute this parameter with the special stdenv, which will have a
generic builder that attempts the usual "--target=..." and can additionally
have an env variable like "cross" with the target architecture set.
So, finally we could have additional expressions like this:
bashRealArm = makeOverridable (import ../shells/bash) {
inherit fetchurl bison;
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
};
Meanwhile it does not work - I still cannot get the cross-gcc to build.
I think it does not fill the previous expressions with a lot of noise, so I
think it may be a good path to follow.
I only touched some files of the current stdenv: gcc-4.3, kernel headers
2.6.28, glibc 2.9, ...
I tried to use the gcc-cross-wrapper, that may be very outdated. Maybe I will
update it, or update the gcc-wrapper expression to make it fit the cross tools,
but meanwhile I even cannot build gcc, so I have not tested the wrapper.
This new idea on cross compiling is not similar to that of the
nixpkgs/branches/cross-compilation, which mostly added bare new expressions for
anything to be cross compiled, if I understood it correctly.
I cared not to break anything of the usual stdenv in all this work.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18343
2009-11-14 11:11:30 +03:00
|
|
|
{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix,
|
|
|
|
cross ? null}:
|
2005-02-21 23:42:07 +03:00
|
|
|
|
2004-11-04 15:19:32 +03:00
|
|
|
rec {
|
2004-10-19 19:16:14 +04:00
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
bootstrapFiles =
|
2006-10-25 00:57:06 +04:00
|
|
|
if system == "i686-linux" then import ./bootstrap/i686
|
|
|
|
else if system == "x86_64-linux" then import ./bootstrap/x86_64
|
2006-10-27 00:07:49 +04:00
|
|
|
else if system == "powerpc-linux" then import ./bootstrap/powerpc
|
2009-11-08 03:32:12 +03:00
|
|
|
else if system == "armv5tel-linux" then import ./bootstrap/armv5tel
|
2006-10-25 00:57:06 +04:00
|
|
|
else abort "unsupported platform for the pure Linux stdenv";
|
2006-08-23 20:18:02 +04:00
|
|
|
|
|
|
|
|
2009-03-25 20:34:38 +03:00
|
|
|
commonPreHook =
|
|
|
|
''
|
|
|
|
export NIX_ENFORCE_PURITY=1
|
|
|
|
havePatchELF=1
|
|
|
|
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2005-02-21 23:42:07 +03:00
|
|
|
# The bootstrap process proceeds in several steps.
|
|
|
|
|
2006-10-25 00:57:06 +04:00
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
# 1) Create a standard environment by downloading pre-built binaries
|
|
|
|
# of coreutils, GCC, etc.
|
2005-02-22 12:55:03 +03:00
|
|
|
|
2009-02-02 18:03:38 +03:00
|
|
|
|
2005-02-22 12:55:03 +03:00
|
|
|
# This function downloads a file.
|
2009-02-02 00:44:56 +03:00
|
|
|
download = {url, sha256}: derivation {
|
2005-02-22 12:55:03 +03:00
|
|
|
name = baseNameOf (toString url);
|
2009-02-02 00:44:56 +03:00
|
|
|
builder = bootstrapFiles.sh;
|
|
|
|
inherit system url;
|
|
|
|
inherit (bootstrapFiles) bzip2 mkdir curl cpio ln;
|
2006-10-25 00:57:51 +04:00
|
|
|
args = [ ./scripts/download.sh ];
|
2009-02-02 00:44:56 +03:00
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHash = sha256;
|
2008-11-14 13:51:17 +03:00
|
|
|
impureEnvVars = [ "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" ];
|
2004-11-04 15:19:32 +03:00
|
|
|
};
|
|
|
|
|
2009-02-02 18:03:38 +03:00
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
|
|
|
|
bootstrapTools = derivation {
|
|
|
|
name = "bootstrap-tools";
|
|
|
|
|
|
|
|
builder = bootstrapFiles.sh;
|
|
|
|
|
2009-11-08 03:32:12 +03:00
|
|
|
args = if (system == "armv5tel-linux") then
|
|
|
|
([ ./scripts/unpack-bootstrap-tools-arm.sh ])
|
|
|
|
else
|
|
|
|
([ ./scripts/unpack-bootstrap-tools.sh ]);
|
2009-02-02 00:44:56 +03:00
|
|
|
|
|
|
|
inherit (bootstrapFiles) bzip2 mkdir curl cpio;
|
|
|
|
|
|
|
|
tarball = download {
|
|
|
|
inherit (bootstrapFiles.bootstrapTools) url sha256;
|
|
|
|
};
|
|
|
|
|
2006-10-25 00:57:06 +04:00
|
|
|
inherit system;
|
2009-02-02 00:44:56 +03:00
|
|
|
|
|
|
|
# Needed by the GCC wrapper.
|
|
|
|
langC = true;
|
|
|
|
langCC = true;
|
2004-11-04 15:19:32 +03:00
|
|
|
};
|
2009-02-02 00:44:56 +03:00
|
|
|
|
2004-11-04 15:19:32 +03:00
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
# This function builds the various standard environments used during
|
|
|
|
# the bootstrap.
|
|
|
|
stdenvBootFun =
|
|
|
|
{gcc, extraAttrs ? {}, extraPath ? [], fetchurl}:
|
2004-11-04 15:19:32 +03:00
|
|
|
|
2009-02-02 00:44:56 +03: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 20:34:38 +03:00
|
|
|
${commonPreHook}
|
2009-02-02 00:44:56 +03:00
|
|
|
'';
|
|
|
|
shell = "${bootstrapTools}/bin/sh";
|
|
|
|
initialPath = [bootstrapTools] ++ extraPath;
|
|
|
|
fetchurlBoot = fetchurl;
|
2009-02-02 18:03:38 +03:00
|
|
|
inherit gcc;
|
|
|
|
extraAttrs = extraAttrs // {inherit fetchurl;};
|
2006-07-10 19:42:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-02-02 00:44:56 +03: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 15:19:32 +03:00
|
|
|
};
|
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
|
|
|
|
fetchurl = import ../../build-support/fetchurl {
|
|
|
|
stdenv = stdenvLinuxBoot0;
|
|
|
|
curl = bootstrapTools;
|
|
|
|
};
|
2004-11-04 15:19:32 +03:00
|
|
|
|
2009-02-02 00:44:56 +03: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 03:32:12 +03:00
|
|
|
{gcc ? bootstrapTools, libc, binutils, coreutils, shell ? "", name ? "bootstrap-gcc-wrapper"}:
|
2009-02-02 00:44:56 +03:00
|
|
|
|
|
|
|
import ../../build-support/gcc-wrapper {
|
|
|
|
nativeTools = false;
|
|
|
|
nativeLibc = false;
|
2009-11-08 03:32:12 +03:00
|
|
|
inherit gcc binutils coreutils libc shell name;
|
2009-02-02 00:44:56 +03:00
|
|
|
stdenv = stdenvLinuxBoot0;
|
2004-11-04 15:19:32 +03:00
|
|
|
};
|
2005-02-21 23:42:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Create the first "real" standard environment. This one consists
|
2009-02-02 00:44:56 +03:00
|
|
|
# of bootstrap tools only, and a minimal Glibc to keep the GCC
|
|
|
|
# configure script happy.
|
2005-02-21 23:42:07 +03:00
|
|
|
stdenvLinuxBoot1 = stdenvBootFun {
|
2009-11-08 03:32:12 +03:00
|
|
|
gcc = wrapGCC {libc = bootstrapGlibc; binutils = bootstrapTools;
|
|
|
|
coreutils = bootstrapTools; };
|
2009-02-02 00:44:56 +03:00
|
|
|
inherit fetchurl;
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
2006-10-25 00:57:06 +04:00
|
|
|
|
2005-02-21 23:42:07 +03: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 20:18:02 +04:00
|
|
|
inherit system;
|
2006-02-08 20:37:45 +03:00
|
|
|
bootStdenv = stdenvLinuxBoot1;
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
|
|
|
|
2006-10-25 00:57:06 +04:00
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
# 3) Build Glibc with the bootstrap tools. The result is the full,
|
|
|
|
# dynamically linked, final Glibc.
|
2006-10-25 02:23:20 +04:00
|
|
|
stdenvLinuxGlibc = stdenvLinuxBoot1Pkgs.glibc;
|
2005-02-21 23:42:07 +03:00
|
|
|
|
2006-10-25 00:57:06 +04:00
|
|
|
|
2005-02-21 23:42:07 +03:00
|
|
|
# 4) Construct a second stdenv identical to the first, except that
|
|
|
|
# this one uses the Glibc built in step 3. It still uses
|
2009-02-02 00:44:56 +03:00
|
|
|
# the rest of the bootstrap tools, including GCC.
|
2006-07-10 19:42:19 +04:00
|
|
|
stdenvLinuxBoot2 = removeAttrs (stdenvBootFun {
|
2009-11-08 03:32:12 +03:00
|
|
|
gcc = wrapGCC {binutils = bootstrapTools; coreutils = bootstrapTools;
|
|
|
|
libc = stdenvLinuxGlibc;};
|
2008-05-27 11:49:55 +04:00
|
|
|
extraAttrs = {glibc = stdenvLinuxGlibc;};
|
2009-02-02 00:44:56 +03:00
|
|
|
inherit fetchurl;
|
2006-07-10 19:42:19 +04:00
|
|
|
}) ["gcc" "binutils"];
|
2005-02-21 23:42:07 +03:00
|
|
|
|
2006-10-25 00:57:06 +04:00
|
|
|
|
2005-02-21 23:42:07 +03:00
|
|
|
# 5) The packages that can be built using the second stdenv.
|
|
|
|
stdenvLinuxBoot2Pkgs = allPackages {
|
2006-08-23 20:18:02 +04:00
|
|
|
inherit system;
|
2006-02-08 20:37:45 +03:00
|
|
|
bootStdenv = stdenvLinuxBoot2;
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
|
|
|
|
2008-05-19 19:12:03 +04:00
|
|
|
|
2005-02-21 23:42:07 +03:00
|
|
|
# 6) Construct a third stdenv identical to the second, except that
|
|
|
|
# this one uses the dynamically linked GCC and Binutils from step
|
2009-02-02 00:44:56 +03:00
|
|
|
# 5. The other tools (e.g. coreutils) are still from the
|
|
|
|
# bootstrap tools.
|
2005-02-21 23:42:07 +03:00
|
|
|
stdenvLinuxBoot3 = stdenvBootFun {
|
2009-02-02 00:44:56 +03:00
|
|
|
gcc = wrapGCC rec {
|
2006-07-10 19:42:19 +04:00
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
2009-11-08 03:32:12 +03:00
|
|
|
coreutils = bootstrapTools;
|
2006-10-25 00:57:06 +04:00
|
|
|
libc = stdenvLinuxGlibc;
|
2006-07-10 19:42:19 +04:00
|
|
|
gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
|
2009-04-09 19:25:29 +04:00
|
|
|
name = "";
|
2006-07-10 19:42:19 +04:00
|
|
|
};
|
2009-02-02 00:44:56 +03:00
|
|
|
inherit fetchurl;
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
|
|
|
|
2006-10-25 00:57:06 +04:00
|
|
|
|
2005-02-21 23:42:07 +03:00
|
|
|
# 7) The packages that can be built using the third stdenv.
|
|
|
|
stdenvLinuxBoot3Pkgs = allPackages {
|
2006-08-23 20:18:02 +04:00
|
|
|
inherit system;
|
2006-02-08 20:37:45 +03:00
|
|
|
bootStdenv = stdenvLinuxBoot3;
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
|
|
|
|
My first attempt at getting cross compilers in nixpkgs.
My idea is to provide special stdenv expressions that will contain in the path
additional cross compilers. As most expressions for programs accept a stdenv parameter,
we could substitute this parameter with the special stdenv, which will have a
generic builder that attempts the usual "--target=..." and can additionally
have an env variable like "cross" with the target architecture set.
So, finally we could have additional expressions like this:
bashRealArm = makeOverridable (import ../shells/bash) {
inherit fetchurl bison;
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
};
Meanwhile it does not work - I still cannot get the cross-gcc to build.
I think it does not fill the previous expressions with a lot of noise, so I
think it may be a good path to follow.
I only touched some files of the current stdenv: gcc-4.3, kernel headers
2.6.28, glibc 2.9, ...
I tried to use the gcc-cross-wrapper, that may be very outdated. Maybe I will
update it, or update the gcc-wrapper expression to make it fit the cross tools,
but meanwhile I even cannot build gcc, so I have not tested the wrapper.
This new idea on cross compiling is not similar to that of the
nixpkgs/branches/cross-compilation, which mostly added bare new expressions for
anything to be cross compiled, if I understood it correctly.
I cared not to break anything of the usual stdenv in all this work.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18343
2009-11-14 11:11:30 +03:00
|
|
|
wrapGCCCross =
|
|
|
|
{gcc, libc, binutils, shell ? "", name ? "bootstrap-gcc-wrapper"}:
|
|
|
|
|
|
|
|
import ../../build-support/gcc-cross-wrapper {
|
|
|
|
nativeTools = false;
|
|
|
|
nativeLibc = false;
|
|
|
|
inherit gcc binutils libc shell name cross;
|
|
|
|
stdenv = stdenvLinuxBoot3;
|
|
|
|
};
|
|
|
|
|
|
|
|
gccCross = wrapGCCCross rec {
|
|
|
|
gcc = stdenvLinuxBoot3Pkgs.gccCross cross;
|
|
|
|
binutils = stdenvLinuxBoot3Pkgs.gccCross cross;
|
|
|
|
libc = stdenvLinuxBoot3Pkgs.glibcCross cross;
|
|
|
|
};
|
|
|
|
|
2005-02-21 23:42:07 +03: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.
|
2009-02-02 00:44:56 +03:00
|
|
|
#
|
|
|
|
# When updating stdenvLinux, make sure that the result has no
|
|
|
|
# dependency (`nix-store -qR') on bootstrapTools.
|
2008-05-19 19:12:03 +04:00
|
|
|
stdenvLinux = import ../generic {
|
My first attempt at getting cross compilers in nixpkgs.
My idea is to provide special stdenv expressions that will contain in the path
additional cross compilers. As most expressions for programs accept a stdenv parameter,
we could substitute this parameter with the special stdenv, which will have a
generic builder that attempts the usual "--target=..." and can additionally
have an env variable like "cross" with the target architecture set.
So, finally we could have additional expressions like this:
bashRealArm = makeOverridable (import ../shells/bash) {
inherit fetchurl bison;
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
};
Meanwhile it does not work - I still cannot get the cross-gcc to build.
I think it does not fill the previous expressions with a lot of noise, so I
think it may be a good path to follow.
I only touched some files of the current stdenv: gcc-4.3, kernel headers
2.6.28, glibc 2.9, ...
I tried to use the gcc-cross-wrapper, that may be very outdated. Maybe I will
update it, or update the gcc-wrapper expression to make it fit the cross tools,
but meanwhile I even cannot build gcc, so I have not tested the wrapper.
This new idea on cross compiling is not similar to that of the
nixpkgs/branches/cross-compilation, which mostly added bare new expressions for
anything to be cross compiled, if I understood it correctly.
I cared not to break anything of the usual stdenv in all this work.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18343
2009-11-14 11:11:30 +03:00
|
|
|
name = "stdenv-linux" +
|
|
|
|
stdenvLinuxBoot3Pkgs.lib.optionalString (cross != null) "-${cross}";
|
2009-02-02 00:44:56 +03:00
|
|
|
|
|
|
|
inherit system;
|
|
|
|
|
2009-03-25 20:34:38 +03:00
|
|
|
preHook = builtins.toFile "prehook.sh" commonPreHook;
|
2009-02-02 00:44:56 +03:00
|
|
|
|
2009-04-25 18:08:29 +04:00
|
|
|
initialPath =
|
2006-07-14 12:35:59 +04:00
|
|
|
((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;})
|
My first attempt at getting cross compilers in nixpkgs.
My idea is to provide special stdenv expressions that will contain in the path
additional cross compilers. As most expressions for programs accept a stdenv parameter,
we could substitute this parameter with the special stdenv, which will have a
generic builder that attempts the usual "--target=..." and can additionally
have an env variable like "cross" with the target architecture set.
So, finally we could have additional expressions like this:
bashRealArm = makeOverridable (import ../shells/bash) {
inherit fetchurl bison;
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
};
Meanwhile it does not work - I still cannot get the cross-gcc to build.
I think it does not fill the previous expressions with a lot of noise, so I
think it may be a good path to follow.
I only touched some files of the current stdenv: gcc-4.3, kernel headers
2.6.28, glibc 2.9, ...
I tried to use the gcc-cross-wrapper, that may be very outdated. Maybe I will
update it, or update the gcc-wrapper expression to make it fit the cross tools,
but meanwhile I even cannot build gcc, so I have not tested the wrapper.
This new idea on cross compiling is not similar to that of the
nixpkgs/branches/cross-compilation, which mostly added bare new expressions for
anything to be cross compiled, if I understood it correctly.
I cared not to break anything of the usual stdenv in all this work.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18343
2009-11-14 11:11:30 +03:00
|
|
|
++ [stdenvLinuxBoot3Pkgs.patchelf]
|
|
|
|
++ stdenvLinuxBoot3Pkgs.lib.optionals (cross != null)
|
|
|
|
[ (stdenvLinuxBoot3Pkgs.binutilsCross cross)
|
|
|
|
gccCross ];
|
2005-02-21 23:42:07 +03:00
|
|
|
|
2009-02-02 00:44:56 +03:00
|
|
|
gcc = wrapGCC rec {
|
2006-07-10 19:42:19 +04:00
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
2009-11-08 03:32:12 +03:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs) coreutils;
|
2006-10-25 00:57:06 +04:00
|
|
|
libc = stdenvLinuxGlibc;
|
2006-07-10 19:42:19 +04:00
|
|
|
gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
|
2009-03-25 20:34:38 +03:00
|
|
|
shell = stdenvLinuxBoot3Pkgs.bash + "/bin/bash";
|
2009-04-09 19:25:29 +04:00
|
|
|
name = "";
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
|
|
|
|
2009-03-25 20:34:38 +03:00
|
|
|
shell = stdenvLinuxBoot3Pkgs.bash + "/bin/bash";
|
2006-02-09 20:04:18 +03:00
|
|
|
|
2009-02-02 18:03:38 +03:00
|
|
|
fetchurlBoot = fetchurl;
|
2008-05-27 11:49:55 +04:00
|
|
|
|
2006-02-09 20:04:18 +03:00
|
|
|
extraAttrs = {
|
2006-07-10 19:42:19 +04:00
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */ glibc;
|
2006-02-09 20:04:18 +03:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs)
|
|
|
|
gzip bzip2 bash coreutils diffutils findutils gawk
|
2009-01-19 21:49:58 +03:00
|
|
|
gnumake gnused gnutar gnugrep patch patchelf
|
2008-05-19 19:12:03 +04:00
|
|
|
attr acl;
|
2006-02-09 20:04:18 +03:00
|
|
|
};
|
2005-02-21 23:42:07 +03:00
|
|
|
};
|
|
|
|
|
2004-10-19 19:16:14 +04:00
|
|
|
}
|