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".
|
|
|
|
|
2009-11-21 02:42:52 +00:00
|
|
|
{ name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? ""
|
Big fixes in the cross build:
- Before this changes, cflags and ldflags for the native and the cross compiler
got mixed. Not all the gcc-wrapper/gcc-cross-wrapper variables are
independant now, but enough, I think.
- Fixed the generic stdenv expression, which did a big mess on buildInputs and
buildNativeInputs. Now it distinguishes when there is a stdenvCross or not.
Maybe we should have a single stdenv and forget about the stdenvCross
adapter - this could end in a stdenv a bit complex, but simpler than the
generic stdenv + adapter.
- Added basic support in pkgconfig for cross-builds: a single PKG_CONFIG_PATH
now works for both the cross and the native compilers, but I think this
should work well for most cases I can think of.
- I tried to fix the guile expression to cross-biuld; guile is built, but not
its manual, so the derivation still fails. Guile requires patching to
cross-build, as far as I understnad.
- Made the glibcCross build to be done through the usage of a
gcc-cross-wrapper over the gcc-cross-stage-static, instead of using it
directly.
- Trying to make physfs (a neverball dependency) cross build.
- Updated the gcc expression to support building a cross compiler without getting
derivation variables mixed with those of the stdenvCross.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18534
2009-11-22 19:51:45 +00:00
|
|
|
, 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;
|
2009-11-21 02:42:52 +00:00
|
|
|
assert !noLibc -> (!nativeLibc -> libc != null);
|
2005-11-29 01:40:33 +00:00
|
|
|
|
2010-08-08 19:47:48 +01:00
|
|
|
let
|
|
|
|
chosenName = if name == "" then gcc.name else name;
|
|
|
|
gccLibs = stdenv.mkDerivation {
|
|
|
|
name = chosenName + "-libs";
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
installPhase = ''
|
2010-08-09 22:37:31 +01:00
|
|
|
echo $out
|
2012-03-12 09:45:14 +00:00
|
|
|
mkdir -p "$out"
|
|
|
|
|
|
|
|
if [ -d "${gcc}/${cross.config}/lib" ]
|
|
|
|
then
|
|
|
|
cp -Rd "${gcc}/${cross.config}/lib" "$out/lib"
|
|
|
|
chmod -R +w "$out/lib"
|
|
|
|
for a in "$out/lib/"*.la; do
|
|
|
|
sed -i -e "s,${gcc}/${cross.config}/lib,$out/lib,g" $a
|
|
|
|
done
|
|
|
|
rm -f "$out/lib/"*.py
|
|
|
|
else
|
|
|
|
# The MinGW cross-compiler falls into this category.
|
|
|
|
mkdir "$out/lib"
|
|
|
|
fi
|
2010-08-08 19:47:48 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
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;
|
2012-12-28 18:54:15 +00:00
|
|
|
crossConfig = if cross != null then cross.config else null;
|
2010-08-08 19:47:48 +01:00
|
|
|
gccLibs = if gcc != null then gccLibs else null;
|
|
|
|
name = chosenName;
|
2005-11-29 01:40:33 +00:00
|
|
|
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 = {
|
Big fixes in the cross build:
- Before this changes, cflags and ldflags for the native and the cross compiler
got mixed. Not all the gcc-wrapper/gcc-cross-wrapper variables are
independant now, but enough, I think.
- Fixed the generic stdenv expression, which did a big mess on buildInputs and
buildNativeInputs. Now it distinguishes when there is a stdenvCross or not.
Maybe we should have a single stdenv and forget about the stdenvCross
adapter - this could end in a stdenv a bit complex, but simpler than the
generic stdenv + adapter.
- Added basic support in pkgconfig for cross-builds: a single PKG_CONFIG_PATH
now works for both the cross and the native compilers, but I think this
should work well for most cases I can think of.
- I tried to fix the guile expression to cross-biuld; guile is built, but not
its manual, so the derivation still fails. Guile requires patching to
cross-build, as far as I understnad.
- Made the glibcCross build to be done through the usage of a
gcc-cross-wrapper over the gcc-cross-stage-static, instead of using it
directly.
- Trying to make physfs (a neverball dependency) cross build.
- Updated the gcc expression to support building a cross compiler without getting
derivation variables mixed with those of the stdenvCross.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18534
2009-11-22 19:51:45 +00:00
|
|
|
target = cross;
|
2009-11-17 21:14:57 +00:00
|
|
|
};
|
2005-11-29 01:40:33 +00:00
|
|
|
}
|