diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc-4.5/builder.sh index b9724e7ad50e..3be8e7951627 100644 --- a/pkgs/development/compilers/gcc-4.5/builder.sh +++ b/pkgs/development/compilers/gcc-4.5/builder.sh @@ -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 diff --git a/pkgs/development/compilers/gcc-4.5/default.nix b/pkgs/development/compilers/gcc-4.5/default.nix index d9b1a8ebe7c1..8d088be0f8fa 100644 --- a/pkgs/development/compilers/gcc-4.5/default.nix +++ b/pkgs/development/compilers/gcc-4.5/default.nix @@ -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" + - " --enable-threads=posix" + - " --enable-nls" + - " --disable-decimal-float" # No final libdecnumber (it may work only in 386) + (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) ); 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"; diff --git a/pkgs/development/compilers/gcc-4.5/libstdc++-target.patch b/pkgs/development/compilers/gcc-4.5/libstdc++-target.patch new file mode 100644 index 000000000000..fb622b395806 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.5/libstdc++-target.patch @@ -0,0 +1,32 @@ +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@ diff --git a/pkgs/os-specific/windows/mingw-headers/default.nix b/pkgs/os-specific/windows/mingw-headers/default.nix new file mode 100644 index 000000000000..c4e0063feecb --- /dev/null +++ b/pkgs/os-specific/windows/mingw-headers/default.nix @@ -0,0 +1,13 @@ +{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 + ''; +} diff --git a/pkgs/os-specific/windows/mingwrt/default.nix b/pkgs/os-specific/windows/mingwrt/default.nix new file mode 100644 index 000000000000..aecf43c9123b --- /dev/null +++ b/pkgs/os-specific/windows/mingwrt/default.nix @@ -0,0 +1,29 @@ +{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; +}) +) diff --git a/pkgs/os-specific/windows/w32api/default.nix b/pkgs/os-specific/windows/w32api/default.nix new file mode 100644 index 000000000000..570b83f671e5 --- /dev/null +++ b/pkgs/os-specific/windows/w32api/default.nix @@ -0,0 +1,29 @@ +{stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}: + +let + name = "w32api-3.14"; +in +stdenv.mkDerivation ({ + inherit name; + + src = fetchurl { + url = "mirror://sourceforge/mingw/${name}-mingw32-src.tar.gz"; + sha256 = "128ax8a4dlspxsi5fi7bi1aslppqx3kczr1ibzj1z1az48bvwp21"; + }; + +} // +(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; +}) +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b3346b9165a2..23bb6bddb7a0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2066,17 +2066,29 @@ let cross = assert crossSystem != null; crossSystem; }); - gcc_realCross = gcc44_realCross; + gcc_realCross = gcc45_realCross; - gccCrossStageStatic = wrapGCCCross { - gcc = forceBuildDrv (lib.addMetaAttrs { platforms = []; } ( - gcc_realCross.override { - crossStageStatic = true; - langCC = false; - libcCross = null; - enableShared = true; - })); - libc = null; + gccCrossStageStatic = let + isMingw = (stdenv.cross.libc == "msvcrt"); + libcCross1 = if isMingw then mingw_headers1 else null; + in + wrapGCCCross { + gcc = forceBuildDrv (lib.addMetaAttrs { platforms = []; } ( + gcc_realCross.override { + crossStageStatic = true; + langCC = false; + libcCross = libcCross1; + enableShared = false; + })); + libc = libcCross1; + binutils = binutilsCross; + cross = assert crossSystem != null; crossSystem; + }; + + # Only needed for mingw builds + gccCrossMingw2 = wrapGCCCross { + gcc = gccCrossStageStatic.gcc; + libc = mingw_headers2; binutils = binutilsCross; cross = assert crossSystem != null; crossSystem; }; @@ -3884,6 +3896,7 @@ let # We can choose: libcCrossChooser = name : if (name == "glibc") then glibcCross else if (name == "uclibc") then uclibcCross + else if (name == "msvcrt") then mingw_headers3 else throw "Unknown libc"; libcCross = assert crossSystem != null; libcCrossChooser crossSystem.libc; @@ -6690,6 +6703,41 @@ let inherit ncurses; }; + w32api = makeOverridable (import ../os-specific/windows/w32api) { + inherit fetchurl stdenv; + gccCross = gccCrossStageStatic; + binutilsCross = binutilsCross; + }; + + w32api_headers = w32api.override { + onlyHeaders = true; + }; + + mingw_runtime = makeOverridable (import ../os-specific/windows/mingwrt) { + inherit fetchurl stdenv; + gccCross = gccCrossMingw2; + binutilsCross = binutilsCross; + }; + + mingw_runtime_headers = mingw_runtime.override { + onlyHeaders = true; + }; + + mingw_headers1 = buildEnv { + name = "mingw-headers-1"; + paths = [ w32api_headers mingw_runtime_headers ]; + }; + + mingw_headers2 = buildEnv { + name = "mingw-headers-2"; + paths = [ w32api mingw_runtime_headers ]; + }; + + mingw_headers3 = buildEnv { + name = "mingw-headers-3"; + paths = [ w32api mingw_runtime ]; + }; + wesnoth = import ../games/wesnoth { inherit fetchurl stdenv SDL SDL_image SDL_mixer SDL_net SDL_ttf gettext zlib boost freetype libpng pkgconfig;