2005-11-29 01:40:33 +00:00
|
|
|
# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
|
|
|
|
# know where the C library and standard header files are. Therefore
|
|
|
|
# the compiler produced by that package cannot be installed directly
|
|
|
|
# in a user environment and used from the command line. This
|
|
|
|
# stdenv.mkDerivation provides a wrapper that sets up the right environment
|
|
|
|
# variables so that the compiler and the linker just "work".
|
|
|
|
|
2006-10-27 14:44:17 +01:00
|
|
|
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
|
|
|
|
, gcc ? null, libc ? null, binutils ? null, shell ? "", cross ? ""
|
2005-11-29 01:40:33 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert nativeTools -> nativePrefix != "";
|
|
|
|
assert !nativeTools -> gcc != null && binutils != null;
|
2006-10-27 14:44:17 +01:00
|
|
|
assert !nativeLibc -> libc != null;
|
2005-11-29 01:40:33 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
builder = ./builder.sh;
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
gccWrapper = ./gcc-wrapper.sh;
|
|
|
|
ldWrapper = ./ld-wrapper.sh;
|
|
|
|
utils = ./utils.sh;
|
|
|
|
addFlags = ./add-flags;
|
2009-11-16 23:21:13 +00:00
|
|
|
inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
|
|
|
|
crossConfig = if (cross != null) then cross.config else null;
|
2005-11-29 01:40:33 +00:00
|
|
|
name = if name == "" then gcc.name else name;
|
|
|
|
langC = if nativeTools then true else gcc.langC;
|
|
|
|
langCC = if nativeTools then true else gcc.langCC;
|
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 08:11:30 +00:00
|
|
|
langF77 = if nativeTools then false else gcc ? langFortran;
|
2005-11-29 01:40:33 +00:00
|
|
|
shell = if shell == "" then stdenv.shell else shell;
|
2006-03-10 16:12:46 +00:00
|
|
|
meta = if gcc != null then gcc.meta else
|
|
|
|
{ description = "System C compiler wrapper";
|
|
|
|
};
|
2009-11-17 21:14:57 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit cross;
|
|
|
|
};
|
2005-11-29 01:40:33 +00:00
|
|
|
}
|