3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/build-support/gcc-cross-wrapper/default.nix
Lluís Batlle i Rossell ae3383e001 Making the cross-built packages not depend on the gcc cross compiler directly,
but on a nix-store path only having the cross-built gcc libraries.
This trims down a lot the runtime dependency tree for cross-built packages.

I also remove the glibc dependency on the native bash.

svn path=/nixpkgs/branches/stdenv-updates/; revision=23040
2010-08-08 18:47:48 +00:00

53 lines
1.8 KiB
Nix

# 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".
{ name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? ""
, gcc ? null, libc ? null, binutils ? null, shell ? "", cross
}:
assert nativeTools -> nativePrefix != "";
assert !nativeTools -> gcc != null && binutils != null;
assert !noLibc -> (!nativeLibc -> libc != null);
let
chosenName = if name == "" then gcc.name else name;
gccLibs = stdenv.mkDerivation {
name = chosenName + "-libs";
phases = [ "installPhase" ];
installPhase = ''
ensureDir $out
cp -Rd ${gcc}/lib $out/lib
if [ -d ${gcc}/lib64 ]; then
cp -Rd ${gcc}/lib64 $out/lib64
fi
'';
};
in
stdenv.mkDerivation {
builder = ./builder.sh;
setupHook = ./setup-hook.sh;
gccWrapper = ./gcc-wrapper.sh;
ldWrapper = ./ld-wrapper.sh;
utils = ./utils.sh;
addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
crossConfig = if (cross != null) then cross.config else null;
gccLibs = if gcc != null then gccLibs else null;
name = chosenName;
langC = if nativeTools then true else gcc.langC;
langCC = if nativeTools then true else gcc.langCC;
langF77 = if nativeTools then false else gcc ? langFortran;
shell = if shell == "" then stdenv.shell else shell;
meta = if gcc != null then gcc.meta else
{ description = "System C compiler wrapper";
};
passthru = {
target = cross;
};
}