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

+201 -17
+8 -1
pkgs/development/compilers/gcc-4.5/builder.sh
··· 56 56 # gcj in. 57 57 unset LIBRARY_PATH 58 58 unset CPATH 59 - if test -z "$crossStageStatic"; then 59 + if test -z "$crossStageStatic" -o -n "$crossMingw"; then 60 60 EXTRA_FLAGS_TARGET="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include" 61 61 EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib" 62 62 fi ··· 121 121 # the target libgcc as target libraries. 122 122 # See 'configure:5370' 123 123 rm -Rf zlib 124 + fi 125 + 126 + if test -n "$crossMingw" -a -n "$crossStageStatic"; then 127 + mkdir -p ../mingw 128 + # --with-build-sysroot expects that: 129 + cp -R $libcCross/include ../mingw 130 + configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." 124 131 fi 125 132 126 133 # Perform the build in a different directory.
+32 -6
pkgs/development/compilers/gcc-4.5/default.nix
··· 68 68 withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; 69 69 withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; 70 70 withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; 71 + crossMingw = (cross != null && cross.libc == "msvcrt"); 71 72 72 73 crossConfigureFlags = 73 74 "--target=${cross.config}" + 74 75 withArch + 75 76 withCpu + 76 77 withAbi + 77 - (if crossStageStatic then 78 + (if (crossMingw && crossStageStatic) then 79 + " --with-headers=${libcCross}/include" + 80 + " --with-gcc" + 81 + " --with-gnu-as" + 82 + " --with-gnu-ld" + 83 + " --with-gnu-ld" + 84 + " --disable-shared" + 85 + " --disable-nls" + 86 + " --disable-debug" + 87 + " --enable-sjlj-exceptions" + 88 + " --enable-threads=win32" + 89 + " --disable-win32-registry" 90 + else if crossStageStatic then 78 91 " --disable-libssp --disable-nls" + 79 92 " --without-headers" + 80 93 " --disable-threads " + ··· 86 99 " --with-headers=${libcCross}/include" + 87 100 " --enable-__cxa_atexit" + 88 101 " --enable-long-long" + 89 - " --enable-threads=posix" + 90 - " --enable-nls" + 91 - " --disable-decimal-float" # No final libdecnumber (it may work only in 386) 102 + (if crossMingw then 103 + " --enable-threads=win32" + 104 + " --enable-sjlj-exceptions" + 105 + " --enable-hash-synchronization" + 106 + " --enable-version-specific-runtime-libs" + 107 + " --disable-libssp" + 108 + " --disable-nls" + 109 + " --with-dwarf2" 110 + else 111 + " --enable-threads=posix" + 112 + " --enable-nls" + 113 + " --disable-decimal-float") # No final libdecnumber (it may work only in 386) 92 114 ); 93 115 stageNameAddon = if (crossStageStatic) then "-stage-static" else 94 116 "-stage-final"; ··· 110 132 }; 111 133 112 134 patches = 113 - [ ] 135 + [ ./libstdc++-target.patch ] 114 136 ++ optional noSysDirs ./no-sys-dirs.patch 115 137 # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its 116 138 # target libraries and tools. ··· 119 141 ++ optional (cross != null && cross.arch == "sparc64") ./pr41818.patch; 120 142 121 143 inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic 122 - libcCross; 144 + libcCross crossMingw; 123 145 124 146 buildInputs = [ texinfo gmp mpfr mpc libelf gettext which ] 125 147 ++ (optional (ppl != null) ppl) ··· 227 249 platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false) [ "i686-darwin" ]; 228 250 }; 229 251 } 252 + // (if cross != null && cross.libc == "msvcrt" && crossStageStatic then rec { 253 + makeFlags = [ "all-gcc" "all-target-libgcc" ]; 254 + installTargets = "install-gcc install-target-libgcc"; 255 + } else {}) 230 256 // (if langVhdl then rec { 231 257 name = "ghdl-0.29"; 232 258
+32
pkgs/development/compilers/gcc-4.5/libstdc++-target.patch
··· 1 + Patch to make the target libraries 'configure' scripts find the proper CPP. 2 + I noticed that building the mingw32 cross compiler. 3 + Looking at the build script for mingw in archlinux, I think that only nixos 4 + needs this patch. I don't know why. 5 + diff --git a/Makefile.in b/Makefile.in 6 + index 93f66b6..d691917 100644 7 + --- a/Makefile.in 8 + +++ b/Makefile.in 9 + @@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \ 10 + AR="$(AR_FOR_TARGET)"; export AR; \ 11 + AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \ 12 + CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \ 13 + + CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \ 14 + CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ 15 + CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ 16 + CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \ 17 + @@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \ 18 + RAW_CXX_TARGET_EXPORTS = \ 19 + $(BASE_TARGET_EXPORTS) \ 20 + CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ 21 + - CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; 22 + + CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ 23 + + CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; 24 + 25 + NORMAL_TARGET_EXPORTS = \ 26 + $(BASE_TARGET_EXPORTS) \ 27 + - CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; 28 + + CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ 29 + + CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; 30 + 31 + # Where to find GMP 32 + HOST_GMPLIBS = @gmplibs@
+13
pkgs/os-specific/windows/mingw-headers/default.nix
··· 1 + {stdenv, mingw_runtime_headers, w32api_headers}: 2 + 3 + stdenv.mkDerivation { 4 + name = "mingw-headers"; 5 + 6 + phases = [ "installPhase" ]; 7 + 8 + installPhase = '' 9 + ensureDir $out/include 10 + cp -R ${mingw_runtime_headers}/include/* $out/include 11 + cp -R ${w32api_headers}/include/* $out/include 12 + ''; 13 + }
+29
pkgs/os-specific/windows/mingwrt/default.nix
··· 1 + {stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}: 2 + 3 + let 4 + name = "mingwrt-3.18"; 5 + in 6 + stdenv.mkDerivation (rec { 7 + inherit name; 8 + 9 + src = fetchurl { 10 + url = "mirror://sourceforge/mingw/${name}-mingw32-src.tar.gz"; 11 + sha256 = "0hmxgkxnf6an70g07gmyik46sw1qm204izh6sp923szddvypjjfy"; 12 + }; 13 + 14 + } // 15 + (if onlyHeaders then { 16 + name = name + "-headers"; 17 + phases = [ "unpackPhase" "installPhase" ]; 18 + installPhase = '' 19 + ensureDir $out 20 + cp -R include $out 21 + ''; 22 + } else { 23 + buildInputs = [ gccCross binutilsCross ]; 24 + 25 + crossConfig = gccCross.crossConfig; 26 + 27 + dontStrip = true; 28 + }) 29 + )
+29
pkgs/os-specific/windows/w32api/default.nix
··· 1 + {stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}: 2 + 3 + let 4 + name = "w32api-3.14"; 5 + in 6 + stdenv.mkDerivation ({ 7 + inherit name; 8 + 9 + src = fetchurl { 10 + url = "mirror://sourceforge/mingw/${name}-mingw32-src.tar.gz"; 11 + sha256 = "128ax8a4dlspxsi5fi7bi1aslppqx3kczr1ibzj1z1az48bvwp21"; 12 + }; 13 + 14 + } // 15 + (if onlyHeaders then { 16 + name = name + "-headers"; 17 + phases = [ "unpackPhase" "installPhase" ]; 18 + installPhase = '' 19 + ensureDir $out 20 + cp -R include $out 21 + ''; 22 + } else { 23 + buildInputs = [ gccCross binutilsCross ]; 24 + 25 + crossConfig = gccCross.crossConfig; 26 + 27 + dontStrip = true; 28 + }) 29 + )
+58 -10
pkgs/top-level/all-packages.nix
··· 2066 2066 cross = assert crossSystem != null; crossSystem; 2067 2067 }); 2068 2068 2069 - gcc_realCross = gcc44_realCross; 2069 + gcc_realCross = gcc45_realCross; 2070 2070 2071 - gccCrossStageStatic = wrapGCCCross { 2072 - gcc = forceBuildDrv (lib.addMetaAttrs { platforms = []; } ( 2073 - gcc_realCross.override { 2074 - crossStageStatic = true; 2075 - langCC = false; 2076 - libcCross = null; 2077 - enableShared = true; 2078 - })); 2079 - libc = null; 2071 + gccCrossStageStatic = let 2072 + isMingw = (stdenv.cross.libc == "msvcrt"); 2073 + libcCross1 = if isMingw then mingw_headers1 else null; 2074 + in 2075 + wrapGCCCross { 2076 + gcc = forceBuildDrv (lib.addMetaAttrs { platforms = []; } ( 2077 + gcc_realCross.override { 2078 + crossStageStatic = true; 2079 + langCC = false; 2080 + libcCross = libcCross1; 2081 + enableShared = false; 2082 + })); 2083 + libc = libcCross1; 2084 + binutils = binutilsCross; 2085 + cross = assert crossSystem != null; crossSystem; 2086 + }; 2087 + 2088 + # Only needed for mingw builds 2089 + gccCrossMingw2 = wrapGCCCross { 2090 + gcc = gccCrossStageStatic.gcc; 2091 + libc = mingw_headers2; 2080 2092 binutils = binutilsCross; 2081 2093 cross = assert crossSystem != null; crossSystem; 2082 2094 }; ··· 3884 3896 # We can choose: 3885 3897 libcCrossChooser = name : if (name == "glibc") then glibcCross 3886 3898 else if (name == "uclibc") then uclibcCross 3899 + else if (name == "msvcrt") then mingw_headers3 3887 3900 else throw "Unknown libc"; 3888 3901 3889 3902 libcCross = assert crossSystem != null; libcCrossChooser crossSystem.libc; ··· 6688 6701 6689 6702 utillinuxngCurses = utillinuxng.override { 6690 6703 inherit ncurses; 6704 + }; 6705 + 6706 + w32api = makeOverridable (import ../os-specific/windows/w32api) { 6707 + inherit fetchurl stdenv; 6708 + gccCross = gccCrossStageStatic; 6709 + binutilsCross = binutilsCross; 6710 + }; 6711 + 6712 + w32api_headers = w32api.override { 6713 + onlyHeaders = true; 6714 + }; 6715 + 6716 + mingw_runtime = makeOverridable (import ../os-specific/windows/mingwrt) { 6717 + inherit fetchurl stdenv; 6718 + gccCross = gccCrossMingw2; 6719 + binutilsCross = binutilsCross; 6720 + }; 6721 + 6722 + mingw_runtime_headers = mingw_runtime.override { 6723 + onlyHeaders = true; 6724 + }; 6725 + 6726 + mingw_headers1 = buildEnv { 6727 + name = "mingw-headers-1"; 6728 + paths = [ w32api_headers mingw_runtime_headers ]; 6729 + }; 6730 + 6731 + mingw_headers2 = buildEnv { 6732 + name = "mingw-headers-2"; 6733 + paths = [ w32api mingw_runtime_headers ]; 6734 + }; 6735 + 6736 + mingw_headers3 = buildEnv { 6737 + name = "mingw-headers-3"; 6738 + paths = [ w32api mingw_runtime ]; 6691 6739 }; 6692 6740 6693 6741 wesnoth = import ../games/wesnoth {