2aba922d30
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
110 lines
3.4 KiB
Nix
110 lines
3.4 KiB
Nix
{ stdenv, fetchurl, noSysDirs
|
|
, langC ? true, langCC ? true, langFortran ? false, langTreelang ? false
|
|
, langJava ? false
|
|
, profiledCompiler ? false
|
|
, staticCompiler ? false
|
|
, enableShared ? true
|
|
, texinfo ? null
|
|
, gmp, mpfr
|
|
, bison ? null, flex ? null
|
|
, zlib ? null, boehmgc ? null
|
|
, enableMultilib ? false
|
|
, name ? "gcc"
|
|
, cross ? null
|
|
, binutilsCross ? null
|
|
, glibcHeadersCross ? null
|
|
}:
|
|
|
|
assert langTreelang -> bison != null && flex != null;
|
|
|
|
assert cross != null -> profiledCompiler == false && enableMultilib == true;
|
|
|
|
with stdenv.lib;
|
|
|
|
let version = "4.3.4"; in
|
|
|
|
stdenv.mkDerivation ({
|
|
name = "${name}-${version}" +
|
|
stdenv.lib.optionalString (cross != null) "-${cross}";
|
|
|
|
builder = ./builder.sh;
|
|
|
|
src =
|
|
optional /*langC*/ true (fetchurl {
|
|
url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
|
|
sha256 = "1yk80nwyw8vkpw8d3x7lkg3zrv3ngjqlvj0i8zslzgj7a27q729i";
|
|
}) ++
|
|
optional langCC (fetchurl {
|
|
url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
|
|
sha256 = "0d8pyk5c9zmph25f4fl63vd8vhljj6ildbxpz2hr594g5i6pplpq";
|
|
}) ++
|
|
optional langFortran (fetchurl {
|
|
url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
|
|
sha256 = "1xf2njykv1qcgxiqwj693dxjf77ss1rcxirylvnsp5hs89mdlj12";
|
|
}) ++
|
|
optional langJava (fetchurl {
|
|
url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
|
|
sha256 = "1v3krhxi3zyaqfj0x8dbxvg67fjp29cr1psyf71r9zf757p3vqsw";
|
|
});
|
|
|
|
patches =
|
|
[./pass-cxxcpp.patch]
|
|
++ optional noSysDirs ./no-sys-dirs.patch
|
|
++ optional (noSysDirs && langFortran) ./no-sys-dirs-fortran.patch
|
|
++ optional langJava ./java-jvgenmain-link.patch;
|
|
|
|
inherit noSysDirs profiledCompiler staticCompiler;
|
|
|
|
buildInputs = [texinfo gmp mpfr]
|
|
++ (optionals langTreelang [bison flex])
|
|
++ (optional (zlib != null) zlib)
|
|
++ (optional (boehmgc != null) boehmgc)
|
|
++ (optionals (cross != null) [binutilsCross])
|
|
;
|
|
|
|
configureFlags = "
|
|
${if enableMultilib then "" else "--disable-multilib"}
|
|
${if enableShared then "" else "--disable-shared"}
|
|
--disable-libstdcxx-pch
|
|
--with-system-zlib
|
|
--enable-languages=${
|
|
concatStrings (intersperse ","
|
|
( optional langC "c"
|
|
++ optional langCC "c++"
|
|
++ optional langFortran "fortran"
|
|
++ optional langJava "java"
|
|
++ optional langTreelang "treelang"
|
|
)
|
|
)
|
|
}
|
|
${if stdenv.isi686 then "--with-arch=i686" else ""}
|
|
${if cross != null then "--disable-libssp --disable-nls" +
|
|
" --with-headers=${glibcHeadersCross}/include --target=${cross}" +
|
|
" --disable-shared" else ""}
|
|
";
|
|
#Above I added a hack on making the build different than the host.
|
|
|
|
# Needed for the cross compilation to work
|
|
AR = "ar";
|
|
LD = "ld";
|
|
CC = "gcc";
|
|
|
|
NIX_EXTRA_LDFLAGS = if staticCompiler then "-static" else "";
|
|
|
|
inherit gmp mpfr;
|
|
|
|
passthru = { inherit langC langCC langFortran langTreelang enableMultilib; };
|
|
|
|
meta = {
|
|
homepage = "http://gcc.gnu.org/";
|
|
license = "GPL/LGPL";
|
|
description = "GNU Compiler Collection, 4.3.x";
|
|
};
|
|
} // (if langJava then {
|
|
postConfigure = ''
|
|
make configure-gcc
|
|
sed -i gcc/Makefile -e 's@^CFLAGS = .*@& -I${zlib}/include@ ; s@^LDFLAGS = .*@& -L${zlib}/lib@'
|
|
sed -i gcc/Makefile -e 's@^CFLAGS = .*@& -I${boehmgc}/include@ ; s@^LDFLAGS = .*@& -L${boehmgc}/lib -lgc@'
|
|
'';
|
|
} else {}))
|