I made the whole nixpkgs dependencies available to the cross compiler, no

needing to keep a new tree of expressions apart for the expressions to get
cross-compiled.

I changed the whole way of using cross compilation with nixpkgs, which before
was done through a simple adapter.

Now the adapter became complex, and I've tried to avoid the most obvious
recursivities. For example, the fetchurl expression should
never be cross-compiled, as the gmp, mpfr, and some others, like
some ncurses, perl, ... I made overrided copies of those necessary as
perlNoCross, ncursesNoCross, as stdenvNoCross, keeping in mind that
the stdenv (capable of cross compilation) is built upon stdenvNoCross using
an adapter.

So, to cross compile, instead of building using "nixpkgs/default.nix",
you should build with your
own "myarchiteture.nix", which should have contents like these, for example:

import /etc/nixos/nixpkgs/default.nix
{
    crossSystem = {
        config = "armv5tel-unknown-linux-gnueabi";
        bigEndian = false;
        arch = "arm";
        float = "soft";
    };
}


svn path=/nixpkgs/branches/stdenv-updates/; revision=18398
This commit is contained in:
Lluís Batlle i Rossell 2009-11-17 22:58:48 +00:00
parent 0c631f6181
commit e7c8e8da4f
3 changed files with 105 additions and 46 deletions

View File

@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
sha256 = "1pn13j6f9376kwki69050x3zh62yb1w31l37rws5nwr5q02xk68i";
};
propagatedBuildInputs = [ncurses];
propagatedHostInputs = [ncurses];
patchFlags = "-p0";
patches =

View File

@ -109,16 +109,38 @@ rec {
# Return a modified stdenv that adds a cross compiler to the
# builds.
makeStdenvCross = stdenv: binutilsCross : gccCross: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // {
buildInputs =
(if args ? buildInputs then args.buildInputs else [])
++ [ gccCross binutilsCross ];
makeStdenvCross = stdenv: cross: binutilsCross: gccCross: stdenv //
{ mkDerivation = {name, buildInputs ? null, hostInputs ? null,
propagatedBuildInputs ? null, propagatedHostInputs ? null, ...}@args: let
buildInputsList = if (buildInputs != null) then
buildInputs else [];
hostInputsList = if (hostInputs != null) then
hostInputs else [];
propagatedBuildInputsList = if (propagatedBuildInputs != null) then
propagatedBuildInputs else [];
propagatedHostInputsList = if (propagatedHostInputs != null) then
propagatedHostInputs else [];
buildInputsDrvs = map (drv: drv.buildDrv) buildInputsList;
hostInputsDrvs = map (drv: drv.hostDrv) hostInputsList;
propagatedBuildInputsDrvs = map (drv: drv.buildDrv) propagatedBuildInputsList;
propagatedHostInputsDrvs = map (drv: drv.buildDrv) propagatedHostInputsList;
buildDrv = stdenv.mkDerivation (args // {
buildInputs = buildInputsDrvs ++ hostInputsDrvs;
propagatedBuildInputs = propagatedBuildInputsDrvs ++
propagatedHostInputsDrvs;
});
hostDrv = if (cross == null) then buildDrv else
stdenv.mkDerivation (args // {
name = name + "-" + cross.config;
buildInputs = buildInputsDrvs
++ [ gccCross binutilsCross ];
crossConfig = gccCross.cross.config;
});
};
crossConfig = cross.config;
});
in hostDrv // {
inherit hostDrv buildDrv;
};
} // { inherit cross; };
/* Modify a stdenv so that the specified attributes are added to
every derivation returned by its mkDerivation function.

View File

@ -33,6 +33,7 @@
# argument. Otherwise, it's read from $NIXPKGS_CONFIG or
# ~/.nixpkgs/config.nix.
config ? null
, crossSystem ? null
}:
@ -215,7 +216,7 @@ let
defaultStdenv = allStdenvs.stdenv;
stdenv =
stdenvNoCross =
if bootStdenv != null then bootStdenv else
let changer = getConfig ["replaceStdenv"] null;
in if changer != null then
@ -225,6 +226,10 @@ let
}
else defaultStdenv;
stdenv = if (bootStdenv != null || crossSystem == null) then stdenvNoCross else
makeStdenvCross stdenvNoCross crossSystem (binutilsCross crossSystem)
(gccCrossStageFinal crossSystem);
# A stdenv capable of building 32-bit binaries. On x86_64-linux,
# it uses GCC compiled with multilib support; on i686-linux, it's
# just the plain stdenv.
@ -239,9 +244,6 @@ let
useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
keepBuildTree cleanupBuildTree addCoverageInstrumentation makeStdenvCross;
stdenvCross = cross : makeStdenvCross stdenv (binutilsCross cross)
(gccCrossStageFinal cross);
### BUILD SUPPORT
@ -304,7 +306,8 @@ let
# from being built.
fetchurl = useFromStdenv "fetchurl"
(import ../build-support/fetchurl {
inherit curl stdenv;
curl = curlNoCross;
stdenv = stdenvNoCross;
});
# fetchurlBoot is used for curl and its dependencies in order to
@ -638,13 +641,19 @@ let
inherit fetchurl stdenv;
};
curl = import ../tools/networking/curl {
curl = makeOverridable (import ../tools/networking/curl) {
fetchurl = fetchurlBoot;
inherit stdenv zlib openssl;
zlibSupport = ! ((stdenv ? isDietLibC) || (stdenv ? isStatic));
sslSupport = ! ((stdenv ? isDietLibC) || (stdenv ? isStatic));
};
curlNoCross = curl.override {
stdenv = stdenvNoCross;
zlib = zlib.override { stdenv = stdenvNoCross; };
openssl = opensslNoCross;
};
curlftpfs = import ../tools/networking/curlftpfs {
inherit fetchurl stdenv fuse curl pkgconfig zlib glib;
};
@ -1066,10 +1075,14 @@ let
readline nettools lsof procps;
};
lzma = import ../tools/compression/lzma {
lzma = makeOverridable (import ../tools/compression/lzma) {
inherit fetchurl stdenv;
};
lzmaNoCross = lzma.override {
stdenv = stdenvNoCross;
};
xz = import ../tools/compression/xz {
inherit fetchurl stdenv lib;
};
@ -1883,13 +1896,17 @@ let
gcc43 = useFromStdenv "gcc" gcc43_real;
gcc43_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.3) {
inherit fetchurl stdenv texinfo gmp mpfr noSysDirs;
inherit fetchurl gmp mpfr noSysDirs;
stdenv = stdenvNoCross;
texinfo = texinfoNoCross;
profiledCompiler = true;
}));
gcc43_realCross = cross : makeOverridable (import ../development/compilers/gcc-4.3) {
#stdenv = overrideGCC stdenv (wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi gcc);
inherit stdenv fetchurl texinfo gmp mpfr noSysDirs cross;
inherit fetchurl gmp mpfr noSysDirs cross;
stdenv = stdenvNoCross;
texinfo = texinfoNoCross;
binutilsCross = binutilsCross cross;
glibcCross = glibcCross cross;
profiledCompiler = false;
@ -2326,7 +2343,8 @@ let
import ../build-support/gcc-cross-wrapper {
nativeTools = false;
nativeLibc = false;
inherit stdenv gcc binutils libc shell name cross;
inherit gcc binutils libc shell name cross;
stdenv = stdenvNoCross;
};
# FIXME: This is a specific hack for GCC-UPC. Eventually, we may
@ -2428,7 +2446,7 @@ let
impureLibcPath = if stdenv.isLinux then null else "/usr";
};
perl510 = import ../development/interpreters/perl-5.10 {
perl510 = makeOverridable (import ../development/interpreters/perl-5.10) {
inherit stdenv;
fetchurl = fetchurlBoot;
impureLibcPath = if stdenv.isLinux then null else "/usr";
@ -2436,6 +2454,11 @@ let
perl = if system != "i686-cygwin" then perl510 else sysPerl;
perlNoCross = perl.override
{
stdenv = stdenvNoCross;
};
# FIXME: unixODBC needs patching on Darwin (see darwinports)
phpOld = import ../development/interpreters/php {
inherit stdenv fetchurl flex bison libxml2 apacheHttpd;
@ -2708,22 +2731,13 @@ let
});
binutilsCross = cross : import ../development/tools/misc/binutils {
inherit stdenv fetchurl cross;
inherit fetchurl cross;
stdenv = stdenvNoCross;
noSysDirs = true;
};
bison = bison23;
bisonArm = import ../development/tools/parsing/bison/bison-2.3.nix {
inherit fetchurl m4;
stdenv = stdenvCross {
config = "armv5tel-unknown-linux-gnueabi";
bigEndian = false;
arch = "arm";
float = "soft";
};
};
bison1875 = import ../development/tools/parsing/bison/bison-1.875.nix {
inherit fetchurl stdenv m4;
};
@ -2859,11 +2873,15 @@ let
m4 = gnum4;
m4NoCross = m4.override {
stdenv = stdenvNoCross;
};
global = import ../development/tools/misc/global {
inherit fetchurl stdenv;
};
gnum4 = import ../development/tools/misc/gnum4 {
gnum4 = makeOverridable (import ../development/tools/misc/gnum4) {
inherit fetchurl stdenv;
};
@ -3055,10 +3073,16 @@ let
inherit fetchurl stdenv ncurses;
};
texinfo = import ../development/tools/misc/texinfo {
texinfo = makeOverridable (import ../development/tools/misc/texinfo) {
inherit fetchurl stdenv ncurses lzma;
};
texinfoNoCross = texinfo.override {
stdenv = stdenvNoCross;
ncurses = ncursesNoCross;
lzma = lzmaNoCross;
};
texi2html = import ../development/tools/misc/texi2html {
inherit fetchurl stdenv perl;
};
@ -3534,7 +3558,8 @@ let
};
glibc29Cross = cross : makeOverridable (import ../development/libraries/glibc-2.9) {
inherit fetchurl stdenv cross;
inherit fetchurl cross;
stdenv = stdenvNoCross;
binutilsCross = binutilsCross cross;
gccCross = gccCrossStageStatic cross;
kernelHeaders = kernelHeadersCross cross;
@ -3587,7 +3612,9 @@ let
};
gmp = import ../development/libraries/gmp {
inherit fetchurl stdenv m4;
inherit fetchurl;
stdenv = stdenvNoCross;
m4 = m4NoCross;
};
# `gmpxx' used to mean "GMP with C++ bindings". Now `gmp' has C++ bindings
@ -3609,7 +3636,8 @@ let
#GMP ex-satellite, so better keep it near gmp
mpfr = import ../development/libraries/mpfr {
inherit fetchurl stdenv gmp;
inherit fetchurl gmp;
stdenv = stdenvNoCross;
};
gst_all = recurseIntoAttrs (import ../development/libraries/gstreamer {
@ -4320,9 +4348,15 @@ let
inherit fetchurl stdenv;
};
ncurses = composedArgsAndFun (import ../development/libraries/ncurses) {
ncurses = makeOverridable (composedArgsAndFun (import ../development/libraries/ncurses)) {
inherit fetchurl stdenv;
unicode = (system != "i686-cygwin");
# The "! (stdenv ? cross)" is for the cross-built arm ncurses, which
# don't build for me in unicode.
unicode = (system != "i686-cygwin" && ! (stdenv ? cross));
};
ncursesNoCross = ncurses.override {
stdenv = stdenvNoCross;
};
neon = neon026;
@ -4404,11 +4438,16 @@ let
pkgconfig;
};
openssl = import ../development/libraries/openssl {
openssl = makeOverridable (import ../development/libraries/openssl) {
fetchurl = fetchurlBoot;
inherit stdenv perl;
};
opensslNoCross = openssl.override {
stdenv = stdenvNoCross;
perl = perlNoCross;
};
ortp = import ../development/libraries/ortp {
inherit fetchurl stdenv;
};
@ -4757,7 +4796,7 @@ let
inherit ncurses flex bison autoconf automake m4 coreutils;
};
zlib = import ../development/libraries/zlib {
zlib = makeOverridable (import ../development/libraries/zlib) {
fetchurl = fetchurlBoot;
inherit stdenv;
};
@ -5508,7 +5547,9 @@ let
kernelHeaders = kernelHeaders_2_6_28;
kernelHeadersCross = cross : import ../os-specific/linux/kernel-headers/2.6.28.nix {
inherit fetchurl stdenv perl cross;
inherit fetchurl cross;
stdenv = stdenvNoCross;
perl = perlNoCross;
};
kernelHeaders_2_6_18 = import ../os-specific/linux/kernel-headers/2.6.18.5.nix {
@ -6101,10 +6142,6 @@ let
inherit fetchurl stdenv unzip;
};
ubootArm = uboot.override {
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
};
uclibc = import ../os-specific/linux/uclibc {
inherit fetchurl stdenv kernelHeaders;
};