mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-18 19:03:28 +00:00
Fixing many things related to the cross compilation in stdenvCross.
It still does not work, but I think I already get glibc cross compiled. Next: gcc and g++, and set some setup script hooks on stdenvCross. It took quite enough hours for this commit. svn path=/nixpkgs/branches/stdenv-updates/; revision=18351
This commit is contained in:
parent
2aba922d30
commit
9b977f5c60
@ -43,13 +43,30 @@ if test "$noSysDirs" = "1"; then
|
||||
"${makeFlagsArray[@]}" \
|
||||
NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
|
||||
SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
|
||||
LIMITS_H_TEST=true \
|
||||
X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
|
||||
LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
|
||||
LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
|
||||
)
|
||||
|
||||
if test -n "$cross" -a "$crossStageStatic" == 1; then
|
||||
# We don't want the gcc build to assume there will be a libc providing
|
||||
# limits.h in this stagae
|
||||
makeFlagsArray=( \
|
||||
"${makeFlagsArray[@]}" \
|
||||
LIMITS_H_TEST=false \
|
||||
)
|
||||
else
|
||||
makeFlagsArray=( \
|
||||
"${makeFlagsArray[@]}" \
|
||||
LIMITS_H_TEST=true \
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$cross"; then
|
||||
# The host stripp will destroy everything in the target binaries otherwise
|
||||
dontStrip=1
|
||||
fi
|
||||
|
||||
preConfigure() {
|
||||
# Perform the build in a different directory.
|
||||
@ -84,15 +101,24 @@ postInstall() {
|
||||
ln -sfn g++ $i
|
||||
fi
|
||||
done
|
||||
|
||||
# gcc will look for the binutils there, called through collect2
|
||||
if test -n "$cross"; then
|
||||
ln -s $binutilsCross/$cross/bin $out/$cross/bin
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if test -n "$cross"; then
|
||||
if test -z "$cross"; then
|
||||
if test -z "$profiledCompiler"; then
|
||||
buildFlags="bootstrap $buildFlags"
|
||||
else
|
||||
buildFlags="profiledbootstrap $buildFlags"
|
||||
fi
|
||||
else
|
||||
:
|
||||
# buildFlags="all-gcc all-target-libgcc $buildFlags"
|
||||
# installTargets="install-gcc install-target-libgcc"
|
||||
fi
|
||||
|
||||
genericBuild
|
||||
|
@ -13,19 +13,38 @@
|
||||
, cross ? null
|
||||
, binutilsCross ? null
|
||||
, glibcHeadersCross ? null
|
||||
, crossStageStatic ? true
|
||||
}:
|
||||
|
||||
assert langTreelang -> bison != null && flex != null;
|
||||
|
||||
assert cross != null -> profiledCompiler == false && enableMultilib == true;
|
||||
assert (cross != null && crossStageStatic) -> (langCC == false && langFortran
|
||||
== false && langTreelang == false);
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let version = "4.3.4"; in
|
||||
let
|
||||
version = "4.3.4";
|
||||
crossConfigureFlags =
|
||||
"--target=${cross}" +
|
||||
(if crossStageStatic then
|
||||
" --disable-libssp --disable-nls" +
|
||||
" --without-headers" +
|
||||
" --disable-threads " +
|
||||
" --disable-libmudflap " +
|
||||
" --disable-libgomp " +
|
||||
" --disable-shared" else
|
||||
" --with-headers=${glibcHeadersCross}"
|
||||
);
|
||||
stageNameAddon = if (crossStageStatic) then "-stage-static" else
|
||||
"-stage-final";
|
||||
crossNameAddon = if (cross != null) then "-${cross}" + stageNameAddon else "";
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation ({
|
||||
name = "${name}-${version}" +
|
||||
stdenv.lib.optionalString (cross != null) "-${cross}";
|
||||
name = "${name}-${version}" + crossNameAddon;
|
||||
|
||||
builder = ./builder.sh;
|
||||
|
||||
@ -53,7 +72,7 @@ stdenv.mkDerivation ({
|
||||
++ optional (noSysDirs && langFortran) ./no-sys-dirs-fortran.patch
|
||||
++ optional langJava ./java-jvgenmain-link.patch;
|
||||
|
||||
inherit noSysDirs profiledCompiler staticCompiler;
|
||||
inherit noSysDirs profiledCompiler staticCompiler cross crossStageStatic binutilsCross;
|
||||
|
||||
buildInputs = [texinfo gmp mpfr]
|
||||
++ (optionals langTreelang [bison flex])
|
||||
@ -78,9 +97,7 @@ stdenv.mkDerivation ({
|
||||
)
|
||||
}
|
||||
${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 ""}
|
||||
${if cross != null then crossConfigureFlags else ""}
|
||||
";
|
||||
#Above I added a hack on making the build different than the host.
|
||||
|
||||
|
33
pkgs/development/libraries/glibc-2.9/binutils-ld.patch
Normal file
33
pkgs/development/libraries/glibc-2.9/binutils-ld.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 7c8a67320e26b8c11108bf0a3410d3aef9cf3486 Mon Sep 17 00:00:00 2001
|
||||
From: Ulrich Drepper <drepper@redhat.com>
|
||||
Date: Sat, 31 Jan 2009 00:21:15 +0000
|
||||
Subject: [PATCH] * elf/Makefile (ld.so): Adjust the sed script to insert _begin in to
|
||||
|
||||
newer linker scripts.
|
||||
---
|
||||
ChangeLog | 5 +++++
|
||||
elf/Makefile | 4 ++--
|
||||
2 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/elf/Makefile b/elf/Makefile
|
||||
index 8079fe9..e44ff1d 100644
|
||||
--- a/elf/Makefile
|
||||
+++ b/elf/Makefile
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Copyright (C) 1995-2007, 2008 Free Software Foundation, Inc.
|
||||
+# Copyright (C) 1995-2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
# This file is part of the GNU C Library.
|
||||
|
||||
# The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -304,7 +304,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
|
||||
$(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \
|
||||
LC_ALL=C \
|
||||
sed -e '/^=========/,/^=========/!d;/^=========/d' \
|
||||
- -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
|
||||
+ -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
|
||||
> $@.lds
|
||||
$(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
|
||||
$(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \
|
||||
--
|
||||
1.6.4
|
||||
|
@ -29,10 +29,29 @@ preConfigure() {
|
||||
|
||||
tar xvjf "$srcPorts"
|
||||
|
||||
if test -n "$cross"; then
|
||||
sed -i s/-lgcc_eh//g Makeconfig
|
||||
fi
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
configureScript=../configure
|
||||
if test -n "$cross"; then
|
||||
cat > config.cache << "EOF"
|
||||
libc_cv_forced_unwind=yes
|
||||
libc_cv_c_cleanup=yes
|
||||
libc_cv_gnu89_inline=yes
|
||||
EOF
|
||||
export BUILD_CC=gcc
|
||||
export CC="${cross}-gcc"
|
||||
export AR="${cross}-ar"
|
||||
export RANLIB="${cross}-ranlib"
|
||||
configureFlags="${configureFlags} --cache-file=config.cache"
|
||||
|
||||
# The host stripp will destroy everything in the target binaries otherwise
|
||||
dontStrip=1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +71,7 @@ postInstall() {
|
||||
if test -n "$installLocales"; then
|
||||
make localedata/install-locales
|
||||
fi
|
||||
rm $out/etc/ld.so.cache
|
||||
test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache
|
||||
(cd $out/include && ln -s $kernelHeaders/include/* .) || exit 1
|
||||
|
||||
# Fix for NIXOS-54 (ldd not working on x86_64). Make a symlink
|
||||
|
@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "0r2sn527wxqifi63di7ns9wbjh1cainxn978w178khhy7yw9fk42";
|
||||
};
|
||||
|
||||
inherit kernelHeaders installLocales;
|
||||
inherit kernelHeaders installLocales cross;
|
||||
|
||||
inherit (stdenv) is64bit;
|
||||
|
||||
@ -58,6 +58,8 @@ stdenv.mkDerivation rec {
|
||||
|
||||
/* Support GNU Binutils 2.20 and above. */
|
||||
./binutils-2.20.patch
|
||||
|
||||
./binutils-ld.patch
|
||||
];
|
||||
|
||||
configureFlags = [
|
||||
@ -65,7 +67,12 @@ stdenv.mkDerivation rec {
|
||||
"--with-headers=${kernelHeaders}/include"
|
||||
(if profilingLibraries then "--enable-profile" else "--disable-profile")
|
||||
] ++ stdenv.lib.optionals (cross != null) [
|
||||
"--target=${cross}"
|
||||
"--host=${cross}"
|
||||
"--build=${stdenv.system}"
|
||||
"--with-tls"
|
||||
"--enable-kernel=2.6.0"
|
||||
"--without-fp"
|
||||
"--with-__thread"
|
||||
] ++ (if (stdenv.system == "armv5tel-linux") then [
|
||||
"--host=arm-linux-gnueabi"
|
||||
"--build=arm-linux-gnueabi"
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
assert stdenv.isLinux;
|
||||
|
||||
let version = "2.6.28.5"; in
|
||||
let
|
||||
version = "2.6.28.5";
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "linux-headers-${version}";
|
||||
@ -12,14 +14,17 @@ stdenv.mkDerivation {
|
||||
sha256 = "0hifjh75sinifr5138v22zwbpqln6lhn65k8b57a1dyzlqca7cl9";
|
||||
};
|
||||
|
||||
inherit cross;
|
||||
|
||||
platform =
|
||||
if cross == "armv5tel-unknown-linux-gnueabi" then "arm" else
|
||||
assert(cross == null);
|
||||
if stdenv.system == "i686-linux" then "i386" else
|
||||
if stdenv.system == "x86_64-linux" then "x86_64" else
|
||||
if stdenv.system == "powerpc-linux" then "powerpc" else
|
||||
if stdenv.system == "armv5tel-linux" then "arm" else
|
||||
abort "don't know what the kernel include directory is called for this platform";
|
||||
abort "don't know what the kernel include directory is called for this
|
||||
platform";
|
||||
|
||||
buildInputs = [perl];
|
||||
|
||||
@ -31,6 +36,9 @@ stdenv.mkDerivation {
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
if test -n "$cross"; then
|
||||
export ARCH=$platform
|
||||
fi
|
||||
make mrproper headers_check
|
||||
'';
|
||||
|
||||
|
@ -198,22 +198,6 @@ rec {
|
||||
bootStdenv = stdenvLinuxBoot3;
|
||||
};
|
||||
|
||||
wrapGCCCross =
|
||||
{gcc, libc, binutils, shell ? "", name ? "bootstrap-gcc-wrapper"}:
|
||||
|
||||
import ../../build-support/gcc-cross-wrapper {
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
inherit gcc binutils libc shell name cross;
|
||||
stdenv = stdenvLinuxBoot3;
|
||||
};
|
||||
|
||||
gccCross = wrapGCCCross rec {
|
||||
gcc = stdenvLinuxBoot3Pkgs.gccCross cross;
|
||||
binutils = stdenvLinuxBoot3Pkgs.gccCross cross;
|
||||
libc = stdenvLinuxBoot3Pkgs.glibcCross cross;
|
||||
};
|
||||
|
||||
# 8) Construct the final stdenv. It uses the Glibc, GCC and
|
||||
# Binutils built above, and adds in dynamically linked versions
|
||||
# of all other tools.
|
||||
@ -233,7 +217,7 @@ rec {
|
||||
++ [stdenvLinuxBoot3Pkgs.patchelf]
|
||||
++ stdenvLinuxBoot3Pkgs.lib.optionals (cross != null)
|
||||
[ (stdenvLinuxBoot3Pkgs.binutilsCross cross)
|
||||
gccCross ];
|
||||
(stdenvLinuxBoot3Pkgs.gccCrossStageFinal cross) ];
|
||||
|
||||
gcc = wrapGCC rec {
|
||||
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
||||
|
@ -1792,11 +1792,6 @@ let
|
||||
inherit fetchurl stdenv bison;
|
||||
};
|
||||
|
||||
bashRealArm = makeOverridable (import ../shells/bash) {
|
||||
inherit fetchurl bison;
|
||||
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
|
||||
};
|
||||
|
||||
bashInteractive = appendToName "interactive" (bashReal.override {
|
||||
inherit readline texinfo;
|
||||
interactive = true;
|
||||
@ -1897,14 +1892,39 @@ let
|
||||
}));
|
||||
|
||||
gcc43_realCross = cross : makeOverridable (import ../development/compilers/gcc-4.3) {
|
||||
inherit fetchurl stdenv texinfo gmp mpfr noSysDirs cross;
|
||||
#stdenv = overrideGCC stdenv (wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi gcc);
|
||||
inherit stdenv fetchurl texinfo gmp mpfr noSysDirs cross;
|
||||
binutilsCross = binutilsCross cross;
|
||||
glibcHeadersCross = glibcHeadersCross cross;
|
||||
glibcHeadersCross = glibcCross cross;
|
||||
profiledCompiler = false;
|
||||
enableMultilib = true;
|
||||
langCC = false;
|
||||
};
|
||||
|
||||
gccCross = cross: gcc43_realCross cross;
|
||||
gccCrossStageStatic = cross: (gcc43_realCross cross).override {
|
||||
crossStageStatic = true;
|
||||
};
|
||||
|
||||
/*
|
||||
gccCrossStageStatic = cross: wrapGCCCross {
|
||||
gcc = (gcc43_realCross cross).override {
|
||||
crossStageStatic = true;
|
||||
};
|
||||
#libc = glibc;
|
||||
libc = stdenv.gcc.libc;
|
||||
binutils = binutilsCross cross;
|
||||
inherit cross;
|
||||
};
|
||||
*/
|
||||
|
||||
gccCrossStageFinal = cross: wrapGCCCross {
|
||||
gcc = (gcc43_realCross cross).override {
|
||||
crossStageStatic = false;
|
||||
};
|
||||
libc = glibcCross cross;
|
||||
binutils = binutilsCross cross;
|
||||
inherit cross;
|
||||
};
|
||||
|
||||
gcc43_multi = lowPrio (wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi (gcc43_real.gcc.override {
|
||||
stdenv = overrideGCC stdenv (wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi gcc);
|
||||
@ -2316,6 +2336,15 @@ let
|
||||
|
||||
wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc;
|
||||
|
||||
wrapGCCCross =
|
||||
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
|
||||
|
||||
import ../build-support/gcc-cross-wrapper {
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
inherit stdenv gcc binutils libc shell name cross;
|
||||
};
|
||||
|
||||
# FIXME: This is a specific hack for GCC-UPC. Eventually, we may
|
||||
# want to merge `gcc-upc-wrapper' and `gcc-wrapper'.
|
||||
wrapGCCUPC = baseGCC: import ../build-support/gcc-upc-wrapper {
|
||||
@ -2701,6 +2730,11 @@ let
|
||||
|
||||
bison = bison23;
|
||||
|
||||
bisonArm = import ../development/tools/parsing/bison/bison-2.3.nix {
|
||||
inherit fetchurl m4;
|
||||
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
|
||||
};
|
||||
|
||||
bison1875 = import ../development/tools/parsing/bison/bison-1.875.nix {
|
||||
inherit fetchurl stdenv m4;
|
||||
};
|
||||
@ -3510,17 +3544,10 @@ let
|
||||
installLocales = getPkgConfig "glibc" "locales" false;
|
||||
};
|
||||
|
||||
glibc29HeadersCross = cross: import ../development/libraries/glibc-2.9/headers.nix {
|
||||
inherit fetchurl stdenv;
|
||||
kernelHeaders = kernelHeadersCross cross;
|
||||
};
|
||||
|
||||
glibcHeadersCross = cross: glibc29HeadersCross cross;
|
||||
|
||||
glibc29Cross = cross : makeOverridable (import ../development/libraries/glibc-2.9) {
|
||||
inherit fetchurl stdenv cross;
|
||||
binutilsCross = binutilsCross cross;
|
||||
gccCross = gccCross cross;
|
||||
gccCross = gccCrossStageStatic cross;
|
||||
kernelHeaders = kernelHeadersCross cross;
|
||||
installLocales = getPkgConfig "glibc" "locales" false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user