Commit c548c084 authored by Lluís Batlle i Rossell's avatar Lluís Batlle i Rossell
Browse files

Making gcc-4.5 cross-build to mingw32 too (set by the proper config and libc = "msvcrt"

in the crossSystem)

svn path=/nixpkgs/trunk/; revision=21630
parent 3b2d0133
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ if test "$noSysDirs" = "1"; then
        # gcj in.
        unset LIBRARY_PATH
        unset CPATH
        if test -z "$crossStageStatic"; then
        if test -z "$crossStageStatic" -o -n "$crossMingw"; then
            EXTRA_FLAGS_TARGET="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include"
            EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib"
        fi
@@ -123,6 +123,13 @@ preConfigure() {
        rm -Rf zlib
    fi

    if test -n "$crossMingw" -a -n "$crossStageStatic"; then
        mkdir -p ../mingw
        # --with-build-sysroot expects that:
        cp -R $libcCross/include ../mingw
        configureFlags="$configureFlags --with-build-sysroot=`pwd`/.."
    fi

    # Perform the build in a different directory.
    mkdir ../build
    cd ../build
+32 −6
Original line number Diff line number Diff line
@@ -68,13 +68,26 @@ let version = "4.5.0";
    withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
    withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
    withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
    crossMingw = (cross != null && cross.libc == "msvcrt");

    crossConfigureFlags =
      "--target=${cross.config}" +
      withArch +
      withCpu +
      withAbi +
      (if crossStageStatic then
      (if (crossMingw && crossStageStatic) then
        " --with-headers=${libcCross}/include" +
        " --with-gcc" +
        " --with-gnu-as" +
        " --with-gnu-ld" +
        " --with-gnu-ld" +
        " --disable-shared" +
        " --disable-nls" +
        " --disable-debug" +
        " --enable-sjlj-exceptions" +
        " --enable-threads=win32" +
        " --disable-win32-registry"
        else if crossStageStatic then
        " --disable-libssp --disable-nls" +
        " --without-headers" +
        " --disable-threads " +
@@ -86,9 +99,18 @@ let version = "4.5.0";
        " --with-headers=${libcCross}/include" +
        " --enable-__cxa_atexit" +
        " --enable-long-long" +
        (if crossMingw then
          " --enable-threads=win32" +
          " --enable-sjlj-exceptions" +
          " --enable-hash-synchronization" +
          " --enable-version-specific-runtime-libs" +
          " --disable-libssp" +
          " --disable-nls" +
          " --with-dwarf2"
          else
          " --enable-threads=posix" +
          " --enable-nls" +
        " --disable-decimal-float" # No final libdecnumber (it may work only in 386)
          " --disable-decimal-float") # No final libdecnumber (it may work only in 386)
        );
    stageNameAddon = if (crossStageStatic) then "-stage-static" else
      "-stage-final";
@@ -110,7 +132,7 @@ stdenv.mkDerivation ({
  };

  patches =
    [ ]
    [ ./libstdc++-target.patch ]
    ++ optional noSysDirs ./no-sys-dirs.patch
    # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
    # target libraries and tools.
@@ -119,7 +141,7 @@ stdenv.mkDerivation ({
    ++ optional (cross != null && cross.arch == "sparc64") ./pr41818.patch;

  inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic
    libcCross;
    libcCross crossMingw;

  buildInputs = [ texinfo gmp mpfr mpc libelf gettext which ]
    ++ (optional (ppl != null) ppl)
@@ -227,6 +249,10 @@ stdenv.mkDerivation ({
    platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false) [ "i686-darwin" ];
  };
}
// (if cross != null && cross.libc == "msvcrt" && crossStageStatic then rec {
  makeFlags = [ "all-gcc" "all-target-libgcc" ];
  installTargets = "install-gcc install-target-libgcc";
} else {})
// (if langVhdl then rec {
  name = "ghdl-0.29";

+32 −0
Original line number Diff line number Diff line
Patch to make the target libraries 'configure' scripts find the proper CPP.
I noticed that building the mingw32 cross compiler.
Looking at the build script for mingw in archlinux, I think that only nixos
needs this patch. I don't know why.
diff --git a/Makefile.in b/Makefile.in
index 93f66b6..d691917 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
 	AR="$(AR_FOR_TARGET)"; export AR; \
 	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
 	CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+	CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
 	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
 	CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
 RAW_CXX_TARGET_EXPORTS = \
 	$(BASE_TARGET_EXPORTS) \
 	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
-	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+	CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
 
 NORMAL_TARGET_EXPORTS = \
 	$(BASE_TARGET_EXPORTS) \
-	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+	CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
 
 # Where to find GMP
 HOST_GMPLIBS = @gmplibs@
+13 −0
Original line number Diff line number Diff line
{stdenv, mingw_runtime_headers, w32api_headers}:

stdenv.mkDerivation {
  name = "mingw-headers";

  phases = [ "installPhase" ];

  installPhase = ''
    ensureDir $out/include
    cp -R ${mingw_runtime_headers}/include/* $out/include
    cp -R ${w32api_headers}/include/* $out/include
  '';
}
+29 −0
Original line number Diff line number Diff line
{stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}:

let
  name = "mingwrt-3.18";
in
stdenv.mkDerivation (rec {
  inherit name;

  src = fetchurl {
    url = "mirror://sourceforge/mingw/${name}-mingw32-src.tar.gz";
    sha256 = "0hmxgkxnf6an70g07gmyik46sw1qm204izh6sp923szddvypjjfy";
  };

} //
(if onlyHeaders then {
  name = name + "-headers";
  phases = [ "unpackPhase" "installPhase" ];
  installPhase = ''
    ensureDir $out
    cp -R include $out
  '';
} else {
  buildInputs = [ gccCross binutilsCross ];

  crossConfig = gccCross.crossConfig;

  dontStrip = true;
})
)
Loading