summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/gcc')
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/default.nix8
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch54
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/floor_log2_patch.diff62
-rw-r--r--pkgs/development/compilers/gcc/4.2/builder.sh96
-rw-r--r--pkgs/development/compilers/gcc/4.2/default.nix66
-rw-r--r--pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch139
-rw-r--r--pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch21
-rw-r--r--pkgs/development/compilers/gcc/4.3/default.nix18
-rw-r--r--pkgs/development/compilers/gcc/4.4/default.nix9
-rw-r--r--pkgs/development/compilers/gcc/4.4/sources.nix14
-rwxr-xr-xpkgs/development/compilers/gcc/4.4/update-gcc.sh4
-rw-r--r--pkgs/development/compilers/gcc/4.5/default.nix8
-rw-r--r--pkgs/development/compilers/gcc/4.6/builder.sh5
-rw-r--r--pkgs/development/compilers/gcc/4.6/default.nix20
-rw-r--r--pkgs/development/compilers/gcc/4.7/arm-eabi.patch230
-rw-r--r--pkgs/development/compilers/gcc/4.8/builder.sh255
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix541
-rw-r--r--pkgs/development/compilers/gcc/4.8/gfortran-driving.patch (renamed from pkgs/development/compilers/gcc/4.7/gfortran-driving.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.8/gnat-cflags.patch (renamed from pkgs/development/compilers/gcc/4.7/gnat-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch (renamed from pkgs/development/compilers/gcc/4.7/java-jvgenmain-link.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.8/libstdc++-target.patch (renamed from pkgs/development/compilers/gcc/4.7/libstdc++-target.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch28
-rw-r--r--pkgs/development/compilers/gcc/4.8/parallel-bconfig.patch32
-rw-r--r--pkgs/development/compilers/gcc/4.9/builder.sh (renamed from pkgs/development/compilers/gcc/4.7/builder.sh)15
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix (renamed from pkgs/development/compilers/gcc/4.7/default.nix)149
-rw-r--r--pkgs/development/compilers/gcc/4.9/gfortran-driving.patch20
-rw-r--r--pkgs/development/compilers/gcc/4.9/gnat-cflags.patch33
-rw-r--r--pkgs/development/compilers/gcc/4.9/java-jvgenmain-link.patch17
-rw-r--r--pkgs/development/compilers/gcc/4.9/libstdc++-target.patch32
-rw-r--r--pkgs/development/compilers/gcc/4.9/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc/4.7/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.9/parallel-bconfig.patch32
31 files changed, 1250 insertions, 658 deletions
diff --git a/pkgs/development/compilers/gcc/4.2-apple64/default.nix b/pkgs/development/compilers/gcc/4.2-apple64/default.nix
index 011086164adf..b2444ebb9bff 100644
--- a/pkgs/development/compilers/gcc/4.2-apple64/default.nix
+++ b/pkgs/development/compilers/gcc/4.2-apple64/default.nix
@@ -12,7 +12,7 @@ let
   revision = "5666.3";  # Apple's fork revision number.
 in
 
-stdenv.mkDerivation {
+stdenv.mkDerivation rec {
   name = "gcc-apple-${version}.${revision}";
 
   builder = ./builder.sh;
@@ -33,8 +33,10 @@ stdenv.mkDerivation {
 
   sourceRoot = "gcc-${revision}/";
 
+  # The floor_log2_patch is from a Gentoo fix for the same issue:
+  #   https://bugs.gentoo.org/attachment.cgi?id=363174&action=diff
   patches =
-    [ ./pass-cxxcpp.patch ]
+    [ ./pass-cxxcpp.patch ./floor_log2_patch.diff ]
     ++ stdenv.lib.optional noSysDirs ./no-sys-dirs.patch
     ++ stdenv.lib.optional langCC ./fix-libstdc++-link.patch;
 
@@ -42,4 +44,6 @@ stdenv.mkDerivation {
   langC = true;
 
   buildInputs = stdenv.lib.optionals langF77 [ gmp mpfr bison flex ];
+
+  #meta.broken = true;
 }
diff --git a/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch b/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch
index e7b8a55a29af..5a417f8151b5 100644
--- a/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch
@@ -3,6 +3,9 @@ Prevent our libstdc++.dylib from having a runtime dependency on
 passed by g++ when it links libstdc++.dylib.  Adding "-nostdlib" to
 the g++ invocation prevents this.
 
+jww (2014-06-21): I've added several more patches to this, for building on
+Mavericks.
+
 diff -ru -x '*~' libstdcxx-39-orig/libstdcxx/libstdc++-v3/src/Makefile.in libstdcxx-39/libstdcxx/libstdc++-v3/src/Makefile.in
 --- x/libstdcxx/libstdc++-v3/src/Makefile.in	2006-10-16 21:08:22.000000000 +0200
 +++ y/libstdcxx/libstdc++-v3/src/Makefile.in	2012-02-17 18:44:05.210570590 +0100
@@ -15,3 +18,54 @@ diff -ru -x '*~' libstdcxx-39-orig/libstdcxx/libstdc++-v3/src/Makefile.in libstd
  
  
  # Use special rules for the deprecated source files so that they find
+--- x/libstdcxx/libstdc++-v3/libsupc++/unwind-cxx.h
++++ y/libstdcxx/libstdc++-v3/libsupc++/unwind-cxx.h
+@@ -38,7 +38,7 @@
+ #include <typeinfo>
+ #include <exception>
+ #include <cstddef>
+-#include "unwind.h"
++#include "unwind-generic.h"
+ 
+ #pragma GCC visibility push(default)
+ 
+@@ -133,7 +133,7 @@ extern "C" void __cxa_bad_typeid ();
+ // throws, and if bad_exception needs to be thrown.  Called from the
+ // compiler.
+ extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn));
+-extern "C" void __cxa_call_terminate (void*) __attribute__((noreturn));
++extern "C" void __cxa_call_terminate(_Unwind_Exception* ue_header);
+ 
+ #ifdef __ARM_EABI_UNWINDER__
+ // Arm EABI specified routines.
+--- x/libstdcxx/libstdc++-v3/include/ext/bitmap_allocator.h
++++ y/libstdcxx/libstdc++-v3/include/ext/bitmap_allocator.h
+@@ -549,6 +549,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+    */
+   class free_list
+   {
++  public:
+     typedef size_t* 				value_type;
+     typedef __detail::__mini_vector<value_type> vector_type;
+     typedef vector_type::iterator 		iterator;
+--- x/libstdcxx/libstdc++-v3/include/ext/ropeimpl.h
++++ y/libstdcxx/libstdc++-v3/include/ext/ropeimpl.h
+@@ -433,7 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+     {
+       size_t __old_len = __r->_M_size;
+       _CharT* __new_data = (_CharT*)
+-	_Data_allocate(_S_rounded_up_size(__old_len + __len));
++	_Base::_Data_allocate(_S_rounded_up_size(__old_len + __len));
+       _RopeLeaf* __result;
+ 
+       uninitialized_copy_n(__r->_M_data, __old_len, __new_data);
+@@ -817,7 +817,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+ 	    if (__result_len > __lazy_threshold)
+ 	      goto lazy;
+ 	    __section = (_CharT*)
+-	      _Data_allocate(_S_rounded_up_size(__result_len));
++	      _Base::_Data_allocate(_S_rounded_up_size(__result_len));
+ 	    try
+ 	      {	(*(__f->_M_fn))(__start, __result_len, __section); }
+ 	    catch(...)
+
diff --git a/pkgs/development/compilers/gcc/4.2-apple64/floor_log2_patch.diff b/pkgs/development/compilers/gcc/4.2-apple64/floor_log2_patch.diff
new file mode 100644
index 000000000000..f37e6c4990e2
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.2-apple64/floor_log2_patch.diff
@@ -0,0 +1,62 @@
+--- gcc-5666.3/gcc/toplev.h
++++ gcc-5666.3/gcc/toplev.h
+@@ -151,6 +151,8 @@ 
+ /* Return true iff flags are set as if -ffast-math.  */
+ extern bool fast_math_flags_set_p	(void);
+ 
++#if GCC_VERSION < 3004
++
+ /* Return log2, or -1 if not exact.  */
+ extern int exact_log2                  (unsigned HOST_WIDE_INT);
+ 
+@@ -158,7 +160,7 @@ 
+ extern int floor_log2                  (unsigned HOST_WIDE_INT);
+ 
+ /* Inline versions of the above for speed.  */
+-#if GCC_VERSION >= 3004
++#else /* GCC_VERSION < 3004 */
+ # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+ #  define CLZ_HWI __builtin_clzl
+ #  define CTZ_HWI __builtin_ctzl
+@@ -172,18 +172,18 @@ 
+ #  define CTZ_HWI __builtin_ctz
+ # endif
+ 
+-extern inline int
++static inline int
+ floor_log2 (unsigned HOST_WIDE_INT x)
+ {
+   return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1;
+ }
+ 
+-extern inline int
++static inline int
+ exact_log2 (unsigned HOST_WIDE_INT x)
+ {
+   return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1;
+ }
+-#endif /* GCC_VERSION >= 3004 */
++#endif /* GCC_VERSION < 3004 */
+ 
+ /* Functions used to get and set GCC's notion of in what directory
+    compilation was started.  */
+--- gcc-5666.3/gcc/toplev.c
++++ gcc-5666.3/gcc/toplev.c
+@@ -555,7 +555,7 @@ 
+    for floor_log2 and exact_log2; see toplev.h.  That construct, however,
+    conflicts with the ISO C++ One Definition Rule.   */
+ 
+-#if GCC_VERSION < 3004 || !defined (__cplusplus)
++#if GCC_VERSION < 3004
+ 
+ /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
+    If X is 0, return -1.  */
+@@ -607,7 +607,7 @@ 
+ #endif
+ }
+ 
+-#endif /*  GCC_VERSION < 3004 || !defined (__cplusplus)  */
++#endif /*  GCC_VERSION < 3004 */
+ 
+ /* Handler for fatal signals, such as SIGSEGV.  These are transformed
+    into ICE messages, which is much more user friendly.  In case the
diff --git a/pkgs/development/compilers/gcc/4.2/builder.sh b/pkgs/development/compilers/gcc/4.2/builder.sh
deleted file mode 100644
index d749fc08d2a0..000000000000
--- a/pkgs/development/compilers/gcc/4.2/builder.sh
+++ /dev/null
@@ -1,96 +0,0 @@
-source $stdenv/setup
-
-
-export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
-mkdir $NIX_FIXINC_DUMMY
-
-
-# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
-# Thing.
-export CPP="gcc -E"
-
-
-if test "$noSysDirs" = "1"; then
-
-    if test -e $NIX_GCC/nix-support/orig-libc; then
-
-        # Figure out what extra flags to pass to the gcc compilers
-        # being generated to make sure that they use our glibc.
-        extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
-        extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
-
-        # Use *real* header files, otherwise a limits.h is generated
-        # that does not include Glibc's limits.h (notably missing
-        # SSIZE_MAX, which breaks the build).
-        export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
-        
-    else
-        # Hack: support impure environments.
-        extraCFlags="-isystem /usr/include"
-        extraLDFlags="-L/usr/lib64 -L/usr/lib"
-        export NIX_FIXINC_DUMMY=/usr/include
-    fi
-
-    extraCFlags="-g0 $extraCFlags"
-    extraLDFlags="--strip-debug $extraLDFlags"
-
-    export NIX_EXTRA_CFLAGS=$extraCFlags
-    for i in $extraLDFlags; do
-        export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
-    done
-
-    makeFlagsArray=( \
-        "${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" \
-        )
-fi
-
-
-preConfigure() {
-    # Perform the build in a different directory.
-    mkdir ../build
-    cd ../build
-    configureScript=../$sourceRoot/configure
-}
-
-
-postInstall() {
-    # Remove precompiled headers for now.  They are very big and
-    # probably not very useful yet.
-    find $out/include -name "*.gch" -exec rm -rf {} \; -prune
-
-    # Remove `fixincl' to prevent a retained dependency on the
-    # previous gcc.
-    rm -rf $out/libexec/gcc/*/*/install-tools
-    rm -rf $out/lib/gcc/*/*/install-tools
-
-    # Get rid of some "fixed" header files
-    rm -rf $out/lib/gcc/*/*/include/root
-
-    # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
-    for i in $out/bin/*-gcc*; do
-        if cmp -s $out/bin/gcc $i; then
-            ln -sfn gcc $i
-        fi
-    done
-
-    for i in $out/bin/*-c++* $out/bin/*-g++*; do
-        if cmp -s $out/bin/g++ $i; then
-            ln -sfn g++ $i
-        fi
-    done
-}
-
-
-if test -z "$profiledCompiler"; then
-    buildFlags="bootstrap $buildFlags"
-else    
-    buildFlags="profiledbootstrap $buildFlags"
-fi
-
-genericBuild
diff --git a/pkgs/development/compilers/gcc/4.2/default.nix b/pkgs/development/compilers/gcc/4.2/default.nix
deleted file mode 100644
index 68a174cc5797..000000000000
--- a/pkgs/development/compilers/gcc/4.2/default.nix
+++ /dev/null
@@ -1,66 +0,0 @@
-{ stdenv, fetchurl, noSysDirs
-, langC ? true, langCC ? true, langFortran ? false
-, profiledCompiler ? false
-, staticCompiler ? false
-, gmp ? null
-, mpfr ? null
-, texinfo ? null
-, name ? "gcc"
-}:
-
-with stdenv.lib;
-
-let version = "4.2.4"; in
-
-stdenv.mkDerivation {
-  name = "${name}-${version}";
-  
-  builder = ./builder.sh;
-  
-  src =
-    optional /*langC*/ true (fetchurl {
-      url = "mirror://gnu/gcc/gcc-${version}/gcc-core-${version}.tar.bz2";
-      sha256 = "0cm5yzhqhgdfk03aayakmdj793sya42xkkqhslj7s2b697hygjfg";
-    }) ++
-    optional langCC (fetchurl {
-      url = "mirror://gnu/gcc/gcc-${version}/gcc-g++-${version}.tar.bz2";
-      sha256 = "0gq8ikci0qqgck71qqlhfld6zkwn9179x6z15vdd9blkdig55nxg";
-    }) ++
-    optional langFortran (fetchurl {
-      url = "mirror://gnu/gcc/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-      sha256 = "013yqiqhdavgxzjryvylgf3lcnknmw89fx41jf2v4899srn0bhkg";
-    });
-    
-  patches =
-    [./pass-cxxcpp.patch]
-    ++ optional noSysDirs [./no-sys-dirs.patch];
-    
-  inherit noSysDirs profiledCompiler staticCompiler;
-
-  buildInputs = [gmp mpfr texinfo];
-
-  configureFlags = "
-    --disable-multilib
-    --disable-libstdcxx-pch
-    --with-system-zlib
-    --enable-languages=${
-      concatStrings (intersperse ","
-        (  optional langC       "c"
-        ++ optional langCC      "c++"
-        ++ optional langFortran "fortran"
-        )
-      )
-    }
-    ${if stdenv.isi686 then "--with-arch=i686" else ""}
-  ";
-
-  NIX_EXTRA_LDFLAGS = if staticCompiler then "-static" else "";
-
-  passthru = { inherit langC langCC langFortran; };
-
-  meta = {
-    homepage = "http://gcc.gnu.org/";
-    license = "GPL/LGPL";
-    description = "GNU Compiler Collection, 4.2.x";
-  };
-}
diff --git a/pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch
deleted file mode 100644
index f1d429e274a0..000000000000
--- a/pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch
+++ /dev/null
@@ -1,139 +0,0 @@
-diff -rc gcc-4.2.0-orig/Makefile.in gcc-4.2.0/Makefile.in
-*** gcc-4.2.0-orig/Makefile.in	2006-12-29 18:47:06.000000000 +0100
---- gcc-4.2.0/Makefile.in	2007-05-20 21:06:42.000000000 +0200
-***************
-*** 364,369 ****
---- 364,377 ----
-  @host_makefile_frag@
-  ###
-  
-+ CFLAGS += $(NIX_EXTRA_CFLAGS)
-+ CPPFLAGS_FOR_TARGET += $(NIX_EXTRA_CFLAGS)
-+ CXXFLAGS += $(NIX_EXTRA_CFLAGS)
-+ LDFLAGS += $(NIX_EXTRA_LDFLAGS)
-+ LDFLAGS_FOR_TARGET += $(NIX_EXTRA_LDFLAGS)
-+ BOOT_CFLAGS += $(NIX_EXTRA_CFLAGS)
-+ BOOT_LDFLAGS += $(NIX_EXTRA_LDFLAGS)
-+ 
-  # This is the list of directories that may be needed in RPATH_ENVVAR
-  # so that prorgams built for the target machine work.
-  TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(HOST_LIB_PATH_gcc)
-diff -rc gcc-4.2.0-orig/gcc/Makefile.in gcc-4.2.0/gcc/Makefile.in
-*** gcc-4.2.0-orig/gcc/Makefile.in	2007-03-12 05:40:09.000000000 +0100
---- gcc-4.2.0/gcc/Makefile.in	2007-05-20 19:35:13.000000000 +0200
-***************
-*** 396,402 ****
-  MD5_H	    = $(srcdir)/../include/md5.h
-  
-  # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
-! NATIVE_SYSTEM_HEADER_DIR = /usr/include
-  # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
-  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
-  
---- 396,406 ----
-  MD5_H	    = $(srcdir)/../include/md5.h
-  
-  # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
-! # Nix: we override NATIVE_SYSTEM_HEADER_DIR in order to prevent
-! # `fixinc' from fixing header files in /usr/include.  However,
-! # NATIVE_SYSTEM_HEADER_DIR must point to an existing directory, so set
-! # it to some dummy directory.
-! NATIVE_SYSTEM_HEADER_DIR = $(NIX_FIXINC_DUMMY)
-  # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
-  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
-  
-***************
-*** 3066,3072 ****
-    -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-    -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
-    -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
-!   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
-    -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
-    -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
-    @TARGET_SYSTEM_ROOT_DEFINE@
---- 3070,3076 ----
-    -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-    -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
-    -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
-!   -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
-    -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
-    -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
-    @TARGET_SYSTEM_ROOT_DEFINE@
-diff -rc gcc-4.2.0-orig/gcc/cppdefault.c gcc-4.2.0/gcc/cppdefault.c
-*** gcc-4.2.0-orig/gcc/cppdefault.c	2006-01-20 22:00:03.000000000 +0100
---- gcc-4.2.0/gcc/cppdefault.c	2007-05-20 17:16:44.000000000 +0200
-***************
-*** 41,46 ****
---- 41,50 ----
-  # undef CROSS_INCLUDE_DIR
-  #endif
-  
-+ #undef LOCAL_INCLUDE_DIR
-+ #undef SYSTEM_INCLUDE_DIR
-+ #undef STANDARD_INCLUDE_DIR
-+ 
-  const struct default_include cpp_include_defaults[]
-  #ifdef INCLUDE_DEFAULTS
-  = INCLUDE_DEFAULTS;
-diff -rc gcc-4.2.0-orig/gcc/gcc.c gcc-4.2.0/gcc/gcc.c
-*** gcc-4.2.0-orig/gcc/gcc.c	2007-03-05 21:37:05.000000000 +0100
---- gcc-4.2.0/gcc/gcc.c	2007-05-20 17:49:48.000000000 +0200
-***************
-*** 1449,1458 ****
-  /* Default prefixes to attach to command names.  */
-  
-  #ifndef STANDARD_STARTFILE_PREFIX_1
-! #define STANDARD_STARTFILE_PREFIX_1 "/lib/"
-  #endif
-  #ifndef STANDARD_STARTFILE_PREFIX_2
-! #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
-  #endif
-  
-  #ifdef CROSS_COMPILE  /* Don't use these prefixes for a cross compiler.  */
---- 1449,1458 ----
-  /* Default prefixes to attach to command names.  */
-  
-  #ifndef STANDARD_STARTFILE_PREFIX_1
-! #define STANDARD_STARTFILE_PREFIX_1 ""
-  #endif
-  #ifndef STANDARD_STARTFILE_PREFIX_2
-! #define STANDARD_STARTFILE_PREFIX_2 ""
-  #endif
-  
-  #ifdef CROSS_COMPILE  /* Don't use these prefixes for a cross compiler.  */
-***************
-*** 1473,1480 ****
-  #endif
-  
-  static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
-! static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/";
-! static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/";
-  static const char *md_exec_prefix = MD_EXEC_PREFIX;
-  
-  static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
---- 1473,1480 ----
-  #endif
-  
-  static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
-! static const char *const standard_exec_prefix_1 = "/no-such-path/";
-! static const char *const standard_exec_prefix_2 = "/no-such-path/";
-  static const char *md_exec_prefix = MD_EXEC_PREFIX;
-  
-  static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
-diff -rc gcc-4.2.0-orig/ltconfig gcc-4.2.0/ltconfig
-*** gcc-4.2.0-orig/ltconfig	2007-02-14 18:08:35.000000000 +0100
---- gcc-4.2.0/ltconfig	2007-05-20 22:16:24.000000000 +0200
-***************
-*** 2322,2327 ****
---- 2322,2332 ----
-  # A language-specific compiler.
-  CC=$CC
-  
-+ # Ugly hack to get libmudflap (and possibly other libraries) to build.
-+ # Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
-+ # to Glibc gets lost.  Here we forcibly add it to any invocation.
-+ CC="\$CC $NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS"
-+ 
-  # Is the compiler the GNU C compiler?
-  with_gcc=$with_gcc
-  
diff --git a/pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch b/pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch
deleted file mode 100644
index 9b0676d4fdc9..000000000000
--- a/pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -rc gcc-orig/Makefile.in gcc-4.1.1/Makefile.in
-*** gcc-orig/Makefile.in	Wed Jun 21 13:40:23 2006
---- gcc-4.1.1/Makefile.in	Wed Jun 21 14:19:44 2006
-***************
-*** 213,219 ****
-  RAW_CXX_TARGET_EXPORTS = \
-  	$(BASE_TARGET_EXPORTS) \
-  	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
-! 	CXX="$(RAW_CXX_FOR_TARGET)"; export CXX;
-  
-  NORMAL_TARGET_EXPORTS = \
-  	$(BASE_TARGET_EXPORTS) \
---- 213,220 ----
-  RAW_CXX_TARGET_EXPORTS = \
-  	$(BASE_TARGET_EXPORTS) \
-  	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
-! 	CXX="$(RAW_CXX_FOR_TARGET) $(CFLAGS_FOR_BUILD)"; export CXX; \
-! 	CXXCPP="$(RAW_CXX_FOR_TARGET) $(CFLAGS_FOR_BUILD) -E"; export CXXCPP;
-  
-  NORMAL_TARGET_EXPORTS = \
-  	$(BASE_TARGET_EXPORTS) \
diff --git a/pkgs/development/compilers/gcc/4.3/default.nix b/pkgs/development/compilers/gcc/4.3/default.nix
index 7dd5be781859..45040c2f3753 100644
--- a/pkgs/development/compilers/gcc/4.3/default.nix
+++ b/pkgs/development/compilers/gcc/4.3/default.nix
@@ -29,7 +29,7 @@ assert langVhdl -> gnat != null;
 with stdenv.lib;
 
 let
-  version = "4.3.4";
+  version = "4.3.6";
 
   crossConfigureFlags =
     "--target=${cross.config}" +
@@ -54,27 +54,27 @@ in
 
 stdenv.mkDerivation ({
   name = "${name}-${version}" + crossNameAddon;
-  
+
   builder = ./builder.sh;
-  
+
   src =
     optional /*langC*/ true (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-      sha256 = "1yk80nwyw8vkpw8d3x7lkg3zrv3ngjqlvj0i8zslzgj7a27q729i";
+      sha256 = "0ygrfw3hgp48hkqipbl9lw38f27npigc2sm6f01g9iswpq1igbw6";
     }) ++
     optional langCC (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-      sha256 = "0d8pyk5c9zmph25f4fl63vd8vhljj6ildbxpz2hr594g5i6pplpq";
+      sha256 = "105xz3991b57zx3146xwlpchdb2sjmlknclvi1iac2gawm4mhxhf";
     }) ++
     optional langFortran (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-      sha256 = "1xf2njykv1qcgxiqwj693dxjf77ss1rcxirylvnsp5hs89mdlj12";
+      sha256 = "12bqvf53hvhrwjnh101vn9frb5g8cr98cra4f11dzhzs4ppydpi1";
     }) ++
     optional langJava (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-      sha256 = "1v3krhxi3zyaqfj0x8dbxvg67fjp29cr1psyf71r9zf757p3vqsw";
+      sha256 = "03w6jln9gmdv149s774rlw4rzi2zhbqna54r86cd6mql8flmy7fs";
     });
-    
+
   patches =
     [ ./pass-cxxcpp.patch ./libmudflap-cpp.patch ./siginfo_t_fix.patch ]
     ++ optional noSysDirs ./no-sys-dirs.patch
@@ -173,7 +173,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "http://ghdl.free.fr/";
-    license = "GPLv2+";
+    license = stdenv.lib.licenses.gpl2Plus;
     description = "Complete VHDL simulator, using the GCC technology";
     maintainers = with stdenv.lib.maintainers; [viric];
     platforms = with stdenv.lib.platforms; linux;
diff --git a/pkgs/development/compilers/gcc/4.4/default.nix b/pkgs/development/compilers/gcc/4.4/default.nix
index 60e7baa77812..be2f323fde1c 100644
--- a/pkgs/development/compilers/gcc/4.4/default.nix
+++ b/pkgs/development/compilers/gcc/4.4/default.nix
@@ -31,7 +31,7 @@ assert langVhdl     -> gnat != null;
 
 with stdenv.lib;
 
-let version = "4.4.6";
+let version = "4.4.7";
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
       # `configure' time.
@@ -246,11 +246,12 @@ stdenv.mkDerivation ({
       enableMultilib version; };
 
   # ghdl does not build fine with parallel building
-  enableParallelBuilding = !langVhdl;
+  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46173
+  #enableParallelBuilding = !langVhdl && !langAda;
 
   meta = {
     homepage = http://gcc.gnu.org/;
-    license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
+    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}";
 
     longDescription = ''
@@ -301,7 +302,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "http://ghdl.free.fr/";
-    license = "GPLv2+";
+    license = stdenv.lib.licenses.gpl2Plus;
     description = "Complete VHDL simulator, using the GCC technology (gcc ${version})";
     maintainers = with stdenv.lib.maintainers; [viric];
     platforms = with stdenv.lib.platforms; linux;
diff --git a/pkgs/development/compilers/gcc/4.4/sources.nix b/pkgs/development/compilers/gcc/4.4/sources.nix
index 357cc2634edc..5517e7c3b922 100644
--- a/pkgs/development/compilers/gcc/4.4/sources.nix
+++ b/pkgs/development/compilers/gcc/4.4/sources.nix
@@ -1,26 +1,26 @@
 /* Automatically generated by `update-gcc.sh', do not edit.
-   For GCC 4.4.6.  */
+   For GCC 4.4.7.  */
 { fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }:
 
-assert version == "4.4.6";
+assert version == "4.4.7";
 optional /* langC */ true (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-  sha256 = "c2959820de3e42eee6b1d381586992f26430f0083b9a51db31d706080fc9b44a";
+  sha256 = "c4663b7023909a4a075d3c2b2e17f6e082a9625aebfd0ce7f1d7817e44bf5542";
 }) ++
 optional langCC (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-  sha256 = "6d5d2dacab9569472e4caa291abe94017a9b19574b9b0d866de7b04702634ddf";
+  sha256 = "1882ff29be51eeb3fb349cbcda9df200a5c3cd20c97dd1d593101e0998b3c469";
 }) ++
 optional langFortran (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-  sha256 = "2b9998716a16b80f4cf843ce81da1cf58ce116e0b85422e3004ce4454e8ff923";
+  sha256 = "545a1e8e97d9364de4408c6a91830f9051ce24b4fbfbfdc56e72c7b4be17ebdd";
 }) ++
 optional langJava (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-  sha256 = "7c8c12eac21d2a5c605ea4d9b7aa52e482354205b801bc93d62603b6f0956b35";
+  sha256 = "3c31ddd80f945b797d8d4ed7761426c26343781c361ec1b33bcea9874cc4c6c0";
 }) ++
 optional langAda (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2";
-  sha256 = "771ef0e90abf61208ce84689bed15391ad249287e36a28e816d6a044035af0c6";
+  sha256 = "fb9f30b85d48838390554b948d137487f0db09ad5f8ba73ca4d7ca35765c6ed8";
 }) ++
 []
diff --git a/pkgs/development/compilers/gcc/4.4/update-gcc.sh b/pkgs/development/compilers/gcc/4.4/update-gcc.sh
index 6b0bbb993309..03297fbadd64 100755
--- a/pkgs/development/compilers/gcc/4.4/update-gcc.sh
+++ b/pkgs/development/compilers/gcc/4.4/update-gcc.sh
@@ -21,7 +21,7 @@ options["g++"]="langCC"
 options["fortran"]="langFortran"
 options["java"]="langJava"
 options["ada"]="langAda"
-options["go"]="langGo"
+#options["go"]="langGo"
 
 cat > "$out"<<EOF
 /* Automatically generated by \`$(basename $0)', do not edit.
@@ -32,7 +32,7 @@ cat > "$out"<<EOF
 assert version == "${version}";
 EOF
 
-for component in core g++ fortran java ada go
+for component in core g++ fortran java ada #go
 do
     dir="ftp.gnu.org/gnu/gcc/gcc-${version}"
     file="gcc-${component}-${version}.tar.bz2"
diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix
index cb0432b66728..fbeea0768ad3 100644
--- a/pkgs/development/compilers/gcc/4.5/default.nix
+++ b/pkgs/development/compilers/gcc/4.5/default.nix
@@ -212,7 +212,7 @@ stdenv.mkDerivation ({
     ++ (optional (ppl != null) ppl)
     ++ (optional (cloogppl != null) cloogppl)
     ++ (optional (zlib != null) zlib)
-    ++ (optional (boehmgc != null) boehmgc)
+    ++ (optional langJava boehmgc)
     ++ (optionals langJava [zip unzip])
     ++ (optionals javaAwtGtk ([gtk pkgconfig libart_lgpl] ++ xlibs))
     ++ (optionals (cross != null) [binutilsCross])
@@ -360,11 +360,11 @@ stdenv.mkDerivation ({
   passthru = { inherit langC langCC langAda langFortran langVhdl
       enableMultilib version; };
 
-  enableParallelBuilding = true;
+  enableParallelBuilding = !langAda;
 
   meta = {
     homepage = http://gcc.gnu.org/;
-    license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
+    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -432,7 +432,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "http://ghdl.free.fr/";
-    license = "GPLv2+";
+    license = stdenv.lib.licenses.gpl2Plus;
     description = "Complete VHDL simulator, using the GCC technology (gcc ${version})";
     maintainers = with stdenv.lib.maintainers; [viric];
     platforms = with stdenv.lib.platforms; linux;
diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh
index 6aa0ae440c8b..cc58162deeff 100644
--- a/pkgs/development/compilers/gcc/4.6/builder.sh
+++ b/pkgs/development/compilers/gcc/4.6/builder.sh
@@ -249,6 +249,11 @@ postInstall() {
         fi
     done
 
+    # Disable RANDMMAP on grsec, which causes segfaults when using
+    # precompiled headers.
+    # See https://bugs.gentoo.org/show_bug.cgi?id=301299#c31
+    paxmark r $out/libexec/gcc/*/*/{cc1,cc1plus}
+
     eval "$postInstallGhdl"
 }
 
diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix
index 476ddaa84091..23a67d8d5333 100644
--- a/pkgs/development/compilers/gcc/4.6/default.nix
+++ b/pkgs/development/compilers/gcc/4.6/default.nix
@@ -99,7 +99,7 @@ let version = "4.6.3";
         withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
         withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
         withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
-      in 
+      in
         (withArch +
         withCpu +
         withAbi +
@@ -159,10 +159,8 @@ let version = "4.6.3";
             # In any case, mingw32 g++ linking is broken by default with shared libs,
             # unless adding "-lsupc++" to any linking command. I don't know why.
             " --disable-shared" +
-            (if cross.config == "x86_64-w64-mingw32" then
-              # To keep ABI compatibility with upstream mingw-w64
-              " --enable-fully-dynamic-string"
-              else "")
+            # To keep ABI compatibility with upstream mingw-w64
+            " --enable-fully-dynamic-string"
             else (if cross.libc == "uclibc" then
               # In uclibc cases, libgomp needs an additional '-ldl'
               # and as I don't know how to pass it, I disable libgomp.
@@ -440,13 +438,13 @@ stdenv.mkDerivation ({
   passthru = { inherit langC langCC langAda langFortran langVhdl
       langGo version; };
 
-  enableParallelBuilding = true;
+  enableParallelBuilding = false;
 
   inherit (stdenv) is64bit;
 
   meta = {
     homepage = http://gcc.gnu.org/;
-    license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
+    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -462,13 +460,15 @@ stdenv.mkDerivation ({
     maintainers = [
       stdenv.lib.maintainers.ludo
       stdenv.lib.maintainers.viric
-      stdenv.lib.maintainers.shlevy
     ];
 
     # Volunteers needed for the {Cyg,Dar}win ports of *PPL.
     # gnatboot is not available out of linux platforms, so we disable the darwin build
     # for the gnat (ada compiler).
-    platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false && libelf == null) [ "i686-darwin" ];
+    platforms =
+      stdenv.lib.platforms.linux ++
+      stdenv.lib.platforms.freebsd ++
+      optionals (langAda == false) stdenv.lib.platforms.darwin;
   };
 }
 
@@ -507,7 +507,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "http://ghdl.free.fr/";
-    license = "GPLv2+";
+    license = stdenv.lib.licenses.gpl2Plus;
     description = "Complete VHDL simulator, using the GCC technology (gcc ${version})";
     maintainers = with stdenv.lib.maintainers; [viric];
     platforms = with stdenv.lib.platforms; linux;
diff --git a/pkgs/development/compilers/gcc/4.7/arm-eabi.patch b/pkgs/development/compilers/gcc/4.7/arm-eabi.patch
deleted file mode 100644
index 63b017062b5b..000000000000
--- a/pkgs/development/compilers/gcc/4.7/arm-eabi.patch
+++ /dev/null
@@ -1,230 +0,0 @@
-Index: gcc-4_7-branch/libstdc++-v3/configure.host
-===================================================================
---- gcc-4_7-branch/libstdc++-v3/configure.host	(revision 194579)
-+++ gcc-4_7-branch/libstdc++-v3/configure.host	(revision 194580)
-@@ -340,7 +340,7 @@
-         fi
-     esac
-     case "${host}" in
--      arm*-*-linux-*eabi)
-+      arm*-*-linux-*eabi*)
- 	port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
- 	;;
-     esac
-Index: gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc
-===================================================================
---- gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 194579)
-+++ gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 194580)
-@@ -1,5 +1,5 @@
- // { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" }
--// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- 
- // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
- //
-Index: gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc
-===================================================================
---- gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 194579)
-+++ gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 194580)
-@@ -1,5 +1,5 @@
- // { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" }
--// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- 
- // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
- //
-Index: gcc-4_7-branch/libjava/configure.ac
-===================================================================
---- gcc-4_7-branch/libjava/configure.ac	(revision 194579)
-+++ gcc-4_7-branch/libjava/configure.ac	(revision 194580)
-@@ -931,7 +931,7 @@
-     # on Darwin -single_module speeds up loading of the dynamic libraries.
-     extra_ldflags_libjava=-Wl,-single_module
-     ;;
--arm*linux*eabi)
-+arm*-*-linux*eabi*)
-     # Some of the ARM unwinder code is actually in libstdc++.  We
-     # could in principle replicate it in libgcj, but it's better to
-     # have a dependency on libstdc++.
-Index: gcc-4_7-branch/libjava/configure
-===================================================================
---- gcc-4_7-branch/libjava/configure	(revision 194579)
-+++ gcc-4_7-branch/libjava/configure	(revision 194580)
-@@ -20542,7 +20542,7 @@
-     # on Darwin -single_module speeds up loading of the dynamic libraries.
-     extra_ldflags_libjava=-Wl,-single_module
-     ;;
--arm*linux*eabi)
-+arm*-*-linux*eabi*)
-     # Some of the ARM unwinder code is actually in libstdc++.  We
-     # could in principle replicate it in libgcj, but it's better to
-     # have a dependency on libstdc++.
-Index: gcc-4_7-branch/libgcc/config.host
-===================================================================
---- gcc-4_7-branch/libgcc/config.host	(revision 194579)
-+++ gcc-4_7-branch/libgcc/config.host	(revision 194580)
-@@ -327,7 +327,7 @@
- arm*-*-linux*)			# ARM GNU/Linux with ELF
- 	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix"
- 	case ${host} in
--	arm*-*-linux-*eabi)
-+	arm*-*-linux-*eabi*)
- 	  tmake_file="${tmake_file} arm/t-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
- 	  tm_file="$tm_file arm/bpabi-lib.h"
- 	  unwind_header=config/arm/unwind-arm.h
-Index: gcc-4_7-branch/gcc/doc/install.texi
-===================================================================
---- gcc-4_7-branch/gcc/doc/install.texi	(revision 194579)
-+++ gcc-4_7-branch/gcc/doc/install.texi	(revision 194580)
-@@ -3222,7 +3222,7 @@
- @heading @anchor{arm-x-eabi}arm-*-eabi
- ARM-family processors.  Subtargets that use the ELF object format
- require GNU binutils 2.13 or newer.  Such subtargets include:
--@code{arm-*-netbsdelf}, @code{arm-*-*linux-gnueabi}
-+@code{arm-*-netbsdelf}, @code{arm-*-*linux-gnueabi*}
- and @code{arm-*-rtemseabi}.
- 
- @html
-Index: gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c	(revision 194580)
-@@ -1,4 +1,4 @@
--/* { dg-final { scan-assembler "__sync_synchronize|dmb|mcr" { target arm*-*-linux-*eabi } } } */
-+/* { dg-final { scan-assembler "__sync_synchronize|dmb|mcr" { target arm*-*-linux-*eabi* } } } */
- 
- void *foo (void)
- {
-Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C	(revision 194580)
-@@ -7,10 +7,10 @@
- // enum-size attributes should only be emitted if there are values of
- // enum type that can escape the compilation unit, gcc cannot currently
- // detect this; if this facility is added then this linker option should
--// not be needed.  arm-*-linux*eabi should be a good approximation to
-+// not be needed.  arm-*-linux*eabi* should be a good approximation to
- // those platforms where the EABI supplement defines enum values to be
- // 32 bits wide.
--// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- 
- #include <limits.h>
- 
-Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C	(revision 194580)
-@@ -9,10 +9,10 @@
- // enum-size attributes should only be emitted if there are values of
- // enum type that can escape the compilation unit, gcc cannot currently
- // detect this; if this facility is added then this linker option should
--// not be needed.  arm-*-linux*eabi should be a good approximation to
-+// not be needed.  arm-*-linux*eabi* should be a good approximation to
- // those platforms where the EABI supplement defines enum values to be
- // 32 bits wide.
--// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- 
- enum E { 
-   a = -312
-Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C	(revision 194580)
-@@ -7,10 +7,10 @@
- // enum-size attributes should only be emitted if there are values of
- // enum type that can escape the compilation unit, gcc cannot currently
- // detect this; if this facility is added then this linker option should
--// not be needed.  arm-*-linux*eabi should be a good approximation to
-+// not be needed.  arm-*-linux*eabi* should be a good approximation to
- // those platforms where the EABI supplement defines enum values to be
- // 32 bits wide.
--// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- 
- // GROUPS passed enums
-   extern "C" int printf (const char *, ...);
-Index: gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp	(revision 194580)
-@@ -3818,7 +3818,7 @@
- 		}
- 	    } ""
- 	}]
--    } elseif { [istarget arm*-*-linux-gnueabi] } {
-+    } elseif { [istarget arm*-*-linux-gnueabi*] } {
- 	return [check_runtime sync_longlong_runtime {
- 	    #include <stdlib.h>
- 	    int main ()
-@@ -3860,7 +3860,7 @@
- 	     || [istarget i?86-*-*]
- 	     || [istarget x86_64-*-*]
- 	     || [istarget alpha*-*-*] 
--	     || [istarget arm*-*-linux-gnueabi] 
-+	     || [istarget arm*-*-linux-gnueabi*] 
- 	     || [istarget bfin*-*linux*]
- 	     || [istarget hppa*-*linux*]
- 	     || [istarget s390*-*-*] 
-@@ -3890,7 +3890,7 @@
- 	     || [istarget i?86-*-*]
- 	     || [istarget x86_64-*-*]
- 	     || [istarget alpha*-*-*] 
--	     || [istarget arm*-*-linux-gnueabi] 
-+	     || [istarget arm*-*-linux-gnueabi*] 
- 	     || [istarget hppa*-*linux*]
- 	     || [istarget s390*-*-*] 
- 	     || [istarget powerpc*-*-*]
-Index: gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90	(revision 194580)
-@@ -1,6 +1,6 @@
- ! { dg-do run }
- ! { dg-options "-fshort-enums" }
--! { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+! { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- ! Program to test enumerations when option -fshort-enums is given
- 
- program main
-Index: gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90
-===================================================================
---- gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90	(revision 194579)
-+++ gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90	(revision 194580)
-@@ -1,7 +1,7 @@
- ! { dg-do run }
- ! { dg-additional-sources enum_10.c }
- ! { dg-options "-fshort-enums -w" }
--! { dg-options "-fshort-enums -w -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
-+! { dg-options "-fshort-enums -w -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
- ! Make sure short enums are indeed interoperable with the
- ! corresponding C type.
- 
-Index: gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in
-===================================================================
---- gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in	(revision 194579)
-+++ gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in	(revision 194580)
-@@ -1866,7 +1866,7 @@
-   LIBRARY_VERSION := $(LIB_VERSION)
- endif
- 
--ifeq ($(strip $(filter-out arm% linux-gnueabi,$(arch) $(osys)-$(word 4,$(targ)))),)
-+ifeq ($(strip $(filter-out arm%-linux,$(arch)-$(osys)) $(if $(findstring eabi,$(word 4,$(targ))),,$(word 4,$(targ)))),)
-   LIBGNAT_TARGET_PAIRS = \
-   a-intnam.ads<a-intnam-linux.ads \
-   s-inmaop.adb<s-inmaop-posix.adb \
-Index: gcc-4_7-branch/gcc/config.gcc
-===================================================================
---- gcc-4_7-branch/gcc/config.gcc	(revision 194579)
-+++ gcc-4_7-branch/gcc/config.gcc	(revision 194580)
-@@ -855,7 +855,7 @@
- 	esac
- 	tmake_file="${tmake_file} arm/t-arm"
- 	case ${target} in
--	arm*-*-linux-*eabi)
-+	arm*-*-linux-*eabi*)
- 	    tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
- 	    tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
- 	    # Define multilib configuration for arm-linux-androideabi.
diff --git a/pkgs/development/compilers/gcc/4.8/builder.sh b/pkgs/development/compilers/gcc/4.8/builder.sh
new file mode 100644
index 000000000000..3d24d34a2f26
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/builder.sh
@@ -0,0 +1,255 @@
+source $stdenv/setup
+
+
+export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
+mkdir $NIX_FIXINC_DUMMY
+
+
+if test "$staticCompiler" = "1"; then
+    EXTRA_LDFLAGS="-static"
+else
+    EXTRA_LDFLAGS=""
+fi
+
+# GCC interprets empty paths as ".", which we don't want.
+if test -z "$CPATH"; then unset CPATH; fi
+if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
+echo "\$CPATH is \`$CPATH'"
+echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'"
+
+if test "$noSysDirs" = "1"; then
+
+    if test -e $NIX_GCC/nix-support/orig-libc; then
+
+        # Figure out what extra flags to pass to the gcc compilers
+        # being generated to make sure that they use our glibc.
+        extraFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
+        extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
+
+        # Use *real* header files, otherwise a limits.h is generated
+        # that does not include Glibc's limits.h (notably missing
+        # SSIZE_MAX, which breaks the build).
+        export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
+
+        # The path to the Glibc binaries such as `crti.o'.
+        glibc_libdir="$(cat $NIX_GCC/nix-support/orig-libc)/lib"
+
+    else
+        # Hack: support impure environments.
+        extraFlags="-isystem /usr/include"
+        extraLDFlags="-L/usr/lib64 -L/usr/lib"
+        glibc_libdir="/usr/lib"
+        export NIX_FIXINC_DUMMY=/usr/include
+    fi
+
+    extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags"
+    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+    # BOOT_CFLAGS defaults to `-g -O2'; since we override it below,
+    # make sure to explictly add them so that files compiled with the
+    # bootstrap compiler are optimized and (optionally) contain
+    # debugging information (info "(gccinstall) Building").
+    if test -n "$dontStrip"; then
+        extraFlags="-O2 -g $extraFlags"
+    else
+        # Don't pass `-g' at all; this saves space while building.
+        extraFlags="-O2 $extraFlags"
+    fi
+
+    EXTRA_FLAGS="$extraFlags"
+    for i in $extraLDFlags; do
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
+    done
+
+    if test -n "$targetConfig"; then
+        # Cross-compiling, we need gcc not to read ./specs in order to build
+        # the g++ compiler (after the specs for the cross-gcc are created).
+        # Having LIBRARY_PATH= makes gcc read the specs from ., and the build
+        # breaks. Having this variable comes from the default.nix code to bring
+        # gcj in.
+        unset LIBRARY_PATH
+        unset CPATH
+        if test -z "$crossStageStatic"; then
+            EXTRA_TARGET_CFLAGS="-B${libcCross}/lib -idirafter ${libcCross}/include"
+            EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib -Wl,-rpath,${libcCross}/lib -Wl,-rpath-link,${libcCross}/lib"
+        fi
+    else
+        if test -z "$NIX_GCC_CROSS"; then
+            EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_CXXFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
+        else
+            # This the case of cross-building the gcc.
+            # We need special flags for the target, different than those of the build
+            # Assertion:
+            test -e $NIX_GCC_CROSS/nix-support/orig-libc
+
+            # Figure out what extra flags to pass to the gcc compilers
+            # being generated to make sure that they use our glibc.
+            extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)"
+            extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)"
+
+            # Use *real* header files, otherwise a limits.h is generated
+            # that does not include Glibc's limits.h (notably missing
+            # SSIZE_MAX, which breaks the build).
+            NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include
+
+            # The path to the Glibc binaries such as `crti.o'.
+            glibc_dir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)"
+            glibc_libdir="$glibc_dir/lib"
+            configureFlags="$configureFlags --with-native-system-header-dir=$glibc_dir/include"
+
+            extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
+            extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+            EXTRA_TARGET_CFLAGS="$extraFlags"
+            for i in $extraLDFlags; do
+                EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i"
+            done
+        fi
+    fi
+
+    # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
+    # the startfiles.
+    # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
+    # for the startfiles.
+    makeFlagsArray+=( \
+        NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        CXXFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \
+        )
+
+    if test -z "$targetConfig"; then
+        makeFlagsArray+=( \
+            BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+            BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+            )
+    fi
+
+    if test -n "$targetConfig" -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+=( \
+            LIMITS_H_TEST=false \
+            )
+    else
+        makeFlagsArray+=( \
+            LIMITS_H_TEST=true \
+            )
+    fi
+fi
+
+if test -n "$targetConfig"; then
+    # The host strip will destroy some important details of the objects
+    dontStrip=1
+fi
+
+providedPreConfigure="$preConfigure";
+preConfigure() {
+    if test -n "$newlibSrc"; then
+        tar xvf "$newlibSrc" -C ..
+        ln -s ../newlib-*/newlib newlib
+        # Patch to get armvt5el working:
+        sed -i -e 's/ arm)/ arm*)/' newlib/configure.host
+    fi
+
+    # Bug - they packaged zlib
+    if test -d "zlib"; then
+        # This breaks the build without-headers, which should build only
+        # the target libgcc as target libraries.
+        # See 'configure:5370'
+        rm -Rf zlib
+    fi
+
+    if test -f "$NIX_GCC/nix-support/orig-libc"; then
+        # Patch the configure script so it finds glibc headers.  It's
+        # important for example in order not to get libssp built,
+        # because its functionality is in glibc already.
+        glibc_headers="$(cat $NIX_GCC/nix-support/orig-libc)/include"
+        sed -i \
+            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
+            gcc/configure
+    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
+
+    # Eval the preConfigure script from nix expression.
+    eval "$providedPreConfigure"
+
+    # Perform the build in a different directory.
+    mkdir ../build
+    cd ../build
+    configureScript=../$sourceRoot/configure
+}
+
+
+postConfigure() {
+    # Don't store the configure flags in the resulting executables.
+    sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
+}
+
+
+preInstall() {
+    # Make ‘lib64’ a symlink to ‘lib’.
+    if [ -n "$is64bit" -a -z "$enableMultilib" ]; then
+        mkdir -p $out/lib
+        ln -s lib $out/lib64
+    fi
+}
+
+
+postInstall() {
+    # Remove precompiled headers for now.  They are very big and
+    # probably not very useful yet.
+    find $out/include -name "*.gch" -exec rm -rf {} \; -prune
+
+    # Remove `fixincl' to prevent a retained dependency on the
+    # previous gcc.
+    rm -rf $out/libexec/gcc/*/*/install-tools
+    rm -rf $out/lib/gcc/*/*/install-tools
+
+    # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
+    rm -rf $out/bin/gccbug
+    # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
+    for i in $out/libexec/gcc/*/*/*; do
+        if PREV_RPATH=`patchelf --print-rpath $i`; then
+            patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i
+        fi
+    done
+
+    # Get rid of some "fixed" header files
+    rm -rf $out/lib/gcc/*/*/include/root
+
+    # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
+    for i in $out/bin/*-gcc*; do
+        if cmp -s $out/bin/gcc $i; then
+            ln -sfn gcc $i
+        fi
+    done
+
+    for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
+        if cmp -s $out/bin/g++ $i; then
+            ln -sfn g++ $i
+        fi
+    done
+
+    # Disable RANDMMAP on grsec, which causes segfaults when using
+    # precompiled headers.
+    # See https://bugs.gentoo.org/show_bug.cgi?id=301299#c31
+    paxmark r $out/libexec/gcc/*/*/{cc1,cc1plus}
+
+    eval "$postInstallGhdl"
+}
+
+genericBuild
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
new file mode 100644
index 000000000000..7985b445ae06
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -0,0 +1,541 @@
+{ stdenv, fetchurl, noSysDirs
+, langC ? true, langCC ? true, langFortran ? false
+, langObjC ? stdenv.isDarwin
+, langObjCpp ? stdenv.isDarwin
+, langJava ? false
+, langAda ? false
+, langVhdl ? false
+, langGo ? false
+, profiledCompiler ? false
+, staticCompiler ? false
+, enableShared ? true
+, texinfo ? null
+, perl ? null # optional, for texi2pod (then pod2man); required for Java
+, gmp, mpfr, mpc, gettext, which
+, libelf                      # optional, for link-time optimizations (LTO)
+, ppl ? null, cloog ? null, isl ? null # optional, for the Graphite optimization framework.
+, zlib ? null, boehmgc ? null
+, zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
+, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
+, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
+, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
+, gnatboot ? null
+, enableMultilib ? false
+, enablePlugin ? true             # whether to support user-supplied plug-ins
+, name ? "gcc"
+, cross ? null
+, binutilsCross ? null
+, libcCross ? null
+, crossStageStatic ? true
+, gnat ? null
+, libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
+, stripped ? true
+, gnused ? null
+}:
+
+assert langJava     -> zip != null && unzip != null
+                       && zlib != null && boehmgc != null
+                       && perl != null;  # for `--enable-java-home'
+assert langAda      -> gnatboot != null;
+assert langVhdl     -> gnat != null;
+
+# We enable the isl cloog backend.
+assert cloog != null -> isl != null;
+
+# LTO needs libelf and zlib.
+assert libelf != null -> zlib != null;
+
+# Make sure we get GNU sed.
+assert stdenv.isDarwin -> gnused != null;
+
+# The go frontend is written in c++
+assert langGo -> langCC;
+
+with stdenv.lib;
+with builtins;
+
+let version = "4.8.3";
+
+    # Whether building a cross-compiler for GNU/Hurd.
+    crossGNU = cross != null && cross.config == "i586-pc-gnu";
+
+    enableParallelBuilding = true;
+
+    patches = []
+      ++ optional enableParallelBuilding ./parallel-bconfig.patch
+      ++ optional (cross != null) ./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.
+      ++ optional langAda ./gnat-cflags.patch
+      ++ optional langFortran ./gfortran-driving.patch;
+
+    javaEcj = fetchurl {
+      # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
+      # `configure' time.
+
+      # XXX: Eventually we might want to take it from upstream.
+      url = "ftp://sourceware.org/pub/java/ecj-4.3.jar";
+      sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx";
+    };
+
+    # Antlr (optional) allows the Java `gjdoc' tool to be built.  We want a
+    # binary distribution here to allow the whole chain to be bootstrapped.
+    javaAntlr = fetchurl {
+      url = http://www.antlr.org/download/antlr-3.1.3.jar;
+      sha256 = "1f41j0y4kjydl71lqlvr73yagrs2jsg1fjymzjz66mjy7al5lh09";
+    };
+
+    xlibs = [
+      libX11 libXt libSM libICE libXtst libXrender libXrandr libXi
+      xproto renderproto xextproto inputproto randrproto
+    ];
+
+    javaAwtGtk = langJava && gtk != null;
+
+    /* Platform flags */
+    platformFlags = let
+        gccArch = stdenv.platform.gcc.arch or null;
+        gccCpu = stdenv.platform.gcc.cpu or null;
+        gccAbi = stdenv.platform.gcc.abi or null;
+        gccFpu = stdenv.platform.gcc.fpu or null;
+        gccFloat = stdenv.platform.gcc.float or null;
+        gccMode = stdenv.platform.gcc.mode or null;
+        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 "";
+        withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
+        withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
+        withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
+      in
+        withArch +
+        withCpu +
+        withAbi +
+        withFpu +
+        withFloat +
+        withMode;
+
+    /* Cross-gcc settings */
+    crossMingw = cross != null && cross.libc == "msvcrt";
+    crossDarwin = cross != null && cross.libc == "libSystem";
+    crossConfigureFlags = let
+        gccArch = stdenv.cross.gcc.arch or null;
+        gccCpu = stdenv.cross.gcc.cpu or null;
+        gccAbi = stdenv.cross.gcc.abi or null;
+        gccFpu = stdenv.cross.gcc.fpu or null;
+        gccFloat = stdenv.cross.gcc.float or null;
+        gccMode = stdenv.cross.gcc.mode or null;
+        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 "";
+        withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
+        withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
+        withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
+      in
+        "--target=${cross.config}" +
+        withArch +
+        withCpu +
+        withAbi +
+        withFpu +
+        withFloat +
+        withMode +
+        (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 " +
+          " --disable-libmudflap " +
+          " --disable-libgomp " +
+          " --disable-libquadmath" +
+          " --disable-shared" +
+          " --disable-libatomic " +  # libatomic requires libc
+          " --disable-decimal-float" # libdecnumber requires libc
+          else
+          (if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
+           else                " --with-headers=${libcCross}/include") +
+          # Ensure that -print-prog-name is able to find the correct programs.
+          (stdenv.lib.optionalString (crossMingw || crossDarwin) (
+            " --with-as=${binutilsCross}/bin/${cross.config}-as" +
+            " --with-ld=${binutilsCross}/bin/${cross.config}-ld"
+          )) +
+          " --enable-__cxa_atexit" +
+          " --enable-long-long" +
+          (if crossMingw then
+            " --enable-threads=win32" +
+            " --enable-sjlj-exceptions" +
+            " --enable-hash-synchronization" +
+            " --disable-libssp" +
+            " --disable-nls" +
+            " --with-dwarf2" +
+            # I think noone uses shared gcc libs in mingw, so we better do the same.
+            # In any case, mingw32 g++ linking is broken by default with shared libs,
+            # unless adding "-lsupc++" to any linking command. I don't know why.
+            " --disable-shared" +
+            # To keep ABI compatibility with upstream mingw-w64
+            " --enable-fully-dynamic-string"
+            else (if cross.libc == "uclibc" then
+              # In uclibc cases, libgomp needs an additional '-ldl'
+              # and as I don't know how to pass it, I disable libgomp.
+              " --disable-libgomp" 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";
+    crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
+
+  bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
+
+in
+
+# We need all these X libraries when building AWT with GTK+.
+assert gtk != null -> (filter (x: x == null) xlibs) == [];
+
+stdenv.mkDerivation ({
+  name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
+
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
+    sha256 = "07hg10zs7gnqz58my10ch0zygizqh0z0bz6pv4pgxx45n48lz3ka";
+  };
+
+  inherit patches;
+
+  postPatch =
+    if (stdenv.isGNU
+        || (libcCross != null                  # e.g., building `gcc.crossDrv'
+            && libcCross ? crossConfig
+            && libcCross.crossConfig == "i586-pc-gnu")
+        || (crossGNU && libcCross != null))
+    then
+      # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
+      # in glibc, so add the right `-I' flags to the default spec string.
+      assert libcCross != null -> libpthreadCross != null;
+      let
+        libc = if libcCross != null then libcCross else stdenv.glibc;
+        gnu_h = "gcc/config/gnu.h";
+        extraCPPDeps =
+             libc.propagatedBuildInputs
+          ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
+          ++ stdenv.lib.optional (libpthread != null) libpthread;
+        extraCPPSpec =
+          concatStrings (intersperse " "
+                          (map (x: "-I${x}/include") extraCPPDeps));
+        extraLibSpec =
+          if libpthreadCross != null
+          then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
+          else "-L${libpthread}/lib";
+      in
+        '' echo "augmenting \`CPP_SPEC' in \`${gnu_h}' with \`${extraCPPSpec}'..."
+           sed -i "${gnu_h}" \
+               -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g'
+
+           echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
+           sed -i "${gnu_h}" \
+               -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
+
+           echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
+           sed -i "${gnu_h}" \
+               -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
+        ''
+    else if cross != null || stdenv.gcc.libc != null then
+      # On NixOS, use the right path to the dynamic linker instead of
+      # `/lib/ld*.so'.
+      let
+        libc = if libcCross != null then libcCross else stdenv.gcc.libc;
+      in
+        '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
+           for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
+           do
+             grep -q LIBC_DYNAMIC_LINKER "$header" || continue
+             echo "  fixing \`$header'..."
+             sed -i "$header" \
+                 -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
+           done
+        ''
+    else null;
+
+  inherit noSysDirs staticCompiler langJava crossStageStatic
+    libcCross crossMingw;
+
+  nativeBuildInputs = [ texinfo which gettext ]
+    ++ (optional (perl != null) perl)
+    ++ (optional javaAwtGtk pkgconfig);
+
+  buildInputs = [ gmp mpfr mpc libelf ]
+    ++ (optional (ppl != null) ppl)
+    ++ (optional (cloog != null) cloog)
+    ++ (optional (isl != null) isl)
+    ++ (optional (zlib != null) zlib)
+    ++ (optionals langJava [ boehmgc zip unzip ])
+    ++ (optionals javaAwtGtk ([ gtk libart_lgpl ] ++ xlibs))
+    ++ (optionals (cross != null) [binutilsCross])
+    ++ (optionals langAda [gnatboot])
+    ++ (optionals langVhdl [gnat])
+
+    # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
+    # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
+    ++ (optional stdenv.isDarwin gnused)
+    ;
+
+  NIX_LDFLAGS = stdenv.lib.optionalString  stdenv.isSunOS "-lm -ldl";
+
+  preConfigure = ''
+    configureFlagsArray=(
+      ${stdenv.lib.optionalString (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
+        "'--with-host-libstdcxx=-lstdc++ -lgcc_s'"}
+      ${stdenv.lib.optionalString (ppl != null && stdenv.isSunOS)
+        "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\"
+         \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""}
+    );
+  '' + stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit) ''
+    export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+    export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+    export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+    export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then
+      configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include)
+      makeFlagsArray+=( \
+       CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \
+       CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
+       FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
+      )
+    fi
+  '';
+
+  dontDisableStatic = true;
+
+  configureFlags = "
+    ${if stdenv.isSunOS then
+      " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
+      # On Illumos/Solaris GNU as is preferred
+      " --with-gnu-as --without-gnu-ld "
+      else ""}
+    --enable-lto
+    ${if enableMultilib then "--disable-libquadmath" else "--disable-multilib"}
+    ${if enableShared then "" else "--disable-shared"}
+    ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
+    ${if ppl != null then "--with-ppl=${ppl} --disable-ppl-version-check" else ""}
+    ${optionalString (isl != null) "--with-isl=${isl}"}
+    ${optionalString (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"}
+    ${if langJava then
+      "--with-ecj-jar=${javaEcj} " +
+
+      # Follow Sun's layout for the convenience of IcedTea/OpenJDK.  See
+      # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
+      "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
+      else ""}
+    ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+    ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""}
+    --with-gmp=${gmp}
+    --with-mpfr=${mpfr}
+    --with-mpc=${mpc}
+    ${if libelf != null then "--with-libelf=${libelf}" else ""}
+    --disable-libstdcxx-pch
+    --without-included-gettext
+    --with-system-zlib
+    --enable-static
+    --enable-languages=${
+      concatStrings (intersperse ","
+        (  optional langC        "c"
+        ++ optional langCC       "c++"
+        ++ optional langFortran  "fortran"
+        ++ optional langJava     "java"
+        ++ optional langAda      "ada"
+        ++ optional langVhdl     "vhdl"
+        ++ optional langGo       "go"
+        ++ optional langObjC     "objc"
+        ++ optional langObjCpp   "obj-c++"
+        ++ optionals crossDarwin [ "objc" "obj-c++" ]
+        )
+      )
+    }
+    ${if (stdenv ? glibc && cross == null)
+      then " --with-native-system-header-dir=${stdenv.glibc}/include"
+      else ""}
+    ${if langAda then " --enable-libada" else ""}
+    ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
+    ${if cross != null then crossConfigureFlags else ""}
+    ${if !bootstrap then "--disable-bootstrap" else ""}
+    ${if cross == null then platformFlags else ""}
+  ";
+
+  targetConfig = if cross != null then cross.config else null;
+
+  buildFlags = if bootstrap then
+    (if profiledCompiler then "profiledbootstrap" else "bootstrap")
+    else "";
+
+  installTargets =
+    if stripped
+    then "install-strip"
+    else "install";
+
+  crossAttrs = let
+    xgccArch = stdenv.cross.gcc.arch or null;
+    xgccCpu = stdenv.cross.gcc.cpu or null;
+    xgccAbi = stdenv.cross.gcc.abi or null;
+    xgccFpu = stdenv.cross.gcc.fpu or null;
+    xgccFloat = stdenv.cross.gcc.float or null;
+    xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
+    xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
+    xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
+    xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
+    xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
+  in {
+    AR = "${stdenv.cross.config}-ar";
+    LD = "${stdenv.cross.config}-ld";
+    CC = "${stdenv.cross.config}-gcc";
+    CXX = "${stdenv.cross.config}-gcc";
+    AR_FOR_TARGET = "${stdenv.cross.config}-ar";
+    LD_FOR_TARGET = "${stdenv.cross.config}-ld";
+    CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
+    NM_FOR_TARGET = "${stdenv.cross.config}-nm";
+    CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
+    # If we are making a cross compiler, cross != null
+    NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else "";
+    dontStrip = true;
+    configureFlags = ''
+      ${if enableMultilib then "" else "--disable-multilib"}
+      ${if enableShared then "" else "--disable-shared"}
+      ${if ppl != null then "--with-ppl=${ppl.crossDrv}" else ""}
+      ${if cloog != null then "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" else ""}
+      ${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""}
+      ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+      ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""}
+      --with-gmp=${gmp.crossDrv}
+      --with-mpfr=${mpfr.crossDrv}
+      --disable-libstdcxx-pch
+      --without-included-gettext
+      --with-system-zlib
+      --enable-languages=${
+        concatStrings (intersperse ","
+          (  optional langC        "c"
+          ++ optional langCC       "c++"
+          ++ optional langFortran  "fortran"
+          ++ optional langJava     "java"
+          ++ optional langAda      "ada"
+          ++ optional langVhdl     "vhdl"
+          ++ optional langGo       "go"
+          )
+        )
+      }
+      ${if langAda then " --enable-libada" else ""}
+      --target=${stdenv.cross.config}
+      ${xwithArch}
+      ${xwithCpu}
+      ${xwithAbi}
+      ${xwithFpu}
+      ${xwithFloat}
+    '';
+    buildFlags = "";
+  };
+
+
+  # Needed for the cross compilation to work
+  AR = "ar";
+  LD = "ld";
+  # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
+
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
+  # the library headers and binaries, regarless of the language being
+  # compiled.
+
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't
+  # honor `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
+  # add them to $CPATH and $LIBRARY_PATH in this case.
+  #
+  # Likewise, the LTO code doesn't find zlib.
+
+  CPATH = concatStrings
+            (intersperse ":" (map (x: x + "/include")
+                                  (optionals (zlib != null) [ zlib ]
+                                   ++ optionals langJava [ boehmgc ]
+                                   ++ optionals javaAwtGtk xlibs
+                                   ++ optionals javaAwtGtk [ gmp mpfr ]
+                                   ++ optional (libpthread != null) libpthread
+                                   ++ optional (libpthreadCross != null) libpthreadCross
+
+                                   # On GNU/Hurd glibc refers to Mach & Hurd
+                                   # headers.
+                                   ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" )
+                                        libcCross.propagatedBuildInputs)));
+
+  LIBRARY_PATH = concatStrings
+                   (intersperse ":" (map (x: x + "/lib")
+                                         (optionals (zlib != null) [ zlib ]
+                                          ++ optionals langJava [ boehmgc ]
+                                          ++ optionals javaAwtGtk xlibs
+                                          ++ optionals javaAwtGtk [ gmp mpfr ]
+                                          ++ optional (libpthread != null) libpthread)));
+
+  EXTRA_TARGET_CFLAGS =
+    if cross != null && libcCross != null
+    then "-idirafter ${libcCross}/include"
+    else null;
+
+  EXTRA_TARGET_LDFLAGS =
+    if cross != null && libcCross != null
+    then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
+         (optionalString (libpthreadCross != null)
+           " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
+    else null;
+
+  passthru =
+    { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; };
+
+  inherit enableParallelBuilding enableMultilib;
+
+  inherit (stdenv) is64bit;
+
+  meta = {
+    homepage = http://gcc.gnu.org/;
+    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    description = "GNU Compiler Collection, version ${version}"
+      + (if stripped then "" else " (with debugging info)");
+
+    longDescription = ''
+      The GNU Compiler Collection includes compiler front ends for C, C++,
+      Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well
+      as libraries for these languages (libstdc++, libgcj, libgomp,...).
+
+      GCC development is a part of the GNU Project, aiming to improve the
+      compiler used in the GNU system including the GNU/Linux variant.
+    '';
+
+    maintainers = with stdenv.lib.maintainers; [ ludo viric shlevy simons ];
+
+    # Volunteers needed for the {Cyg,Dar}win ports of *PPL.
+    # gnatboot is not available out of linux platforms, so we disable the darwin build
+    # for the gnat (ada compiler).
+    platforms =
+      stdenv.lib.platforms.linux ++
+      stdenv.lib.platforms.freebsd ++
+      optionals (langAda == false) stdenv.lib.platforms.darwin;
+  };
+}
+
+// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
+  makeFlags = [ "all-gcc" "all-target-libgcc" ];
+  installTargets = "install-gcc install-target-libgcc";
+}
+
+# Strip kills static libs of other archs (hence cross != null)
+// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
+)
diff --git a/pkgs/development/compilers/gcc/4.7/gfortran-driving.patch b/pkgs/development/compilers/gcc/4.8/gfortran-driving.patch
index 70708886b405..70708886b405 100644
--- a/pkgs/development/compilers/gcc/4.7/gfortran-driving.patch
+++ b/pkgs/development/compilers/gcc/4.8/gfortran-driving.patch
diff --git a/pkgs/development/compilers/gcc/4.7/gnat-cflags.patch b/pkgs/development/compilers/gcc/4.8/gnat-cflags.patch
index bf2acf065e9b..bf2acf065e9b 100644
--- a/pkgs/development/compilers/gcc/4.7/gnat-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.8/gnat-cflags.patch
diff --git a/pkgs/development/compilers/gcc/4.7/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch
index 2612e8bfbbbc..2612e8bfbbbc 100644
--- a/pkgs/development/compilers/gcc/4.7/java-jvgenmain-link.patch
+++ b/pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch
diff --git a/pkgs/development/compilers/gcc/4.7/libstdc++-target.patch b/pkgs/development/compilers/gcc/4.8/libstdc++-target.patch
index fb622b395806..fb622b395806 100644
--- a/pkgs/development/compilers/gcc/4.7/libstdc++-target.patch
+++ b/pkgs/development/compilers/gcc/4.8/libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch
new file mode 100644
index 000000000000..36df51904acf
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch
@@ -0,0 +1,28 @@
+diff -ru -x '*~' gcc-4.8.3-orig/gcc/cppdefault.c gcc-4.8.3/gcc/cppdefault.c
+--- gcc-4.8.3-orig/gcc/cppdefault.c	2013-01-10 21:38:27.000000000 +0100
++++ gcc-4.8.3/gcc/cppdefault.c	2014-08-18 16:20:32.893944536 +0200
+@@ -35,6 +35,8 @@
+ # undef CROSS_INCLUDE_DIR
+ #endif
+ 
++#undef LOCAL_INCLUDE_DIR
++
+ const struct default_include cpp_include_defaults[]
+ #ifdef INCLUDE_DEFAULTS
+ = INCLUDE_DEFAULTS;
+diff -ru -x '*~' gcc-4.8.3-orig/gcc/gcc.c gcc-4.8.3/gcc/gcc.c
+--- gcc-4.8.3-orig/gcc/gcc.c	2014-03-23 12:30:57.000000000 +0100
++++ gcc-4.8.3/gcc/gcc.c	2014-08-18 13:19:32.689201690 +0200
+@@ -1162,10 +1162,10 @@
+ /* Default prefixes to attach to command names.  */
+ 
+ #ifndef STANDARD_STARTFILE_PREFIX_1
+-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
++#define STANDARD_STARTFILE_PREFIX_1 ""
+ #endif
+ #ifndef STANDARD_STARTFILE_PREFIX_2
+-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
++#define STANDARD_STARTFILE_PREFIX_2 ""
+ #endif
+ 
+ #ifdef CROSS_DIRECTORY_STRUCTURE  /* Don't use these prefixes for a cross compiler.  */
diff --git a/pkgs/development/compilers/gcc/4.8/parallel-bconfig.patch b/pkgs/development/compilers/gcc/4.8/parallel-bconfig.patch
new file mode 100644
index 000000000000..bc56ac698f5a
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/parallel-bconfig.patch
@@ -0,0 +1,32 @@
+Hacky work-around for highly parallel builds.
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57125
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index aad927c..182f666 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3908,21 +3908,21 @@ build/gengtype-lex.o: $(BCONFIG_H)
+ 
+ gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \
+   $(SYSTEM_H)
+-gengtype-parse.o: $(CONFIG_H)
++gengtype-parse.o: $(CONFIG_H) $(BCONFIG_H)
+ CFLAGS-gengtype-parse.o += -DGENERATOR_FILE
+ build/gengtype-parse.o: $(BCONFIG_H)
+ 
+ gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \
+   gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \
+   $(XREGEX_H)
+-gengtype-state.o: $(CONFIG_H)
++gengtype-state.o: $(CONFIG_H) $(BCONFIG_H)
+ CFLAGS-gengtype-state.o += -DGENERATOR_FILE
+ build/gengtype-state.o: $(BCONFIG_H)
+ 
+ gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h 	\
+   rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \
+   $(OBSTACK_H) $(XREGEX_H)
+-gengtype.o: $(CONFIG_H)
++gengtype.o: $(CONFIG_H) $(BCONFIG_H)
+ CFLAGS-gengtype.o += -DGENERATOR_FILE
+ build/gengtype.o: $(BCONFIG_H)
+ 
diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.9/builder.sh
index 37400fba5bf5..b781fa6c7ef6 100644
--- a/pkgs/development/compilers/gcc/4.7/builder.sh
+++ b/pkgs/development/compilers/gcc/4.9/builder.sh
@@ -33,7 +33,7 @@ if test "$noSysDirs" = "1"; then
 
         # The path to the Glibc binaries such as `crti.o'.
         glibc_libdir="$(cat $NIX_GCC/nix-support/orig-libc)/lib"
-        
+
     else
         # Hack: support impure environments.
         extraFlags="-isystem /usr/include"
@@ -50,10 +50,10 @@ if test "$noSysDirs" = "1"; then
     # bootstrap compiler are optimized and (optionally) contain
     # debugging information (info "(gccinstall) Building").
     if test -n "$dontStrip"; then
-	extraFlags="-O2 -g $extraFlags"
+        extraFlags="-O2 -g $extraFlags"
     else
-	# Don't pass `-g' at all; this saves space while building.
-	extraFlags="-O2 $extraFlags"
+        # Don't pass `-g' at all; this saves space while building.
+        extraFlags="-O2 $extraFlags"
     fi
 
     EXTRA_FLAGS="$extraFlags"
@@ -155,7 +155,7 @@ if test -n "$targetConfig"; then
     dontStrip=1
 fi
 
-
+providedPreConfigure="$preConfigure";
 preConfigure() {
     if test -n "$newlibSrc"; then
         tar xvf "$newlibSrc" -C ..
@@ -188,6 +188,9 @@ preConfigure() {
         configureFlags="$configureFlags --with-build-sysroot=`pwd`/.."
     fi
 
+    # Eval the preConfigure script from nix expression.
+    eval $providedPreConfigure;
+    env;
     # Perform the build in a different directory.
     mkdir ../build
     cd ../build
@@ -210,7 +213,7 @@ postInstall() {
     # previous gcc.
     rm -rf $out/libexec/gcc/*/*/install-tools
     rm -rf $out/lib/gcc/*/*/install-tools
-    
+
     # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
     rm -rf $out/bin/gccbug
     # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 4f260d75afcc..f61e6b4445a0 100644
--- a/pkgs/development/compilers/gcc/4.7/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -11,7 +11,7 @@
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
 , gmp, mpfr, mpc, gettext, which
 , libelf                      # optional, for link-time optimizations (LTO)
-, ppl ? null, cloog ? null # optional, for the Graphite optimization framework.
+, ppl ? null, cloog ? null, isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null, boehmgc ? null
 , zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
 , libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
@@ -37,6 +37,9 @@ assert langJava     -> zip != null && unzip != null
 assert langAda      -> gnatboot != null;
 assert langVhdl     -> gnat != null;
 
+# We enable the isl cloog backend.
+assert cloog != null -> isl != null;
+
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
 
@@ -49,13 +52,15 @@ assert langGo -> langCC;
 with stdenv.lib;
 with builtins;
 
-let version = "4.7.3";
+let version = "4.9.1";
 
     # Whether building a cross-compiler for GNU/Hurd.
     crossGNU = cross != null && cross.config == "i586-pc-gnu";
 
-    patches = []
-      ++ optional stdenv.isArm [ ./arm-eabi.patch ]
+    enableParallelBuilding = true;
+
+    patches = [ ]
+      ++ optional enableParallelBuilding ./parallel-bconfig.patch
       ++ optional (cross != null) ./libstdc++-target.patch
       # ++ optional noSysDirs ./no-sys-dirs.patch
       # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
@@ -88,35 +93,36 @@ let version = "4.7.3";
 
     /* Platform flags */
     platformFlags = let
-        gccArch = stdenv.lib.attrByPath [ "platform" "gcc" "arch" ] null stdenv;
-        gccCpu = stdenv.lib.attrByPath [ "platform" "gcc" "cpu" ] null stdenv;
-        gccAbi = stdenv.lib.attrByPath [ "platform" "gcc" "abi" ] null stdenv;
-        gccFpu = stdenv.lib.attrByPath [ "platform" "gcc" "fpu" ] null stdenv;
-        gccFloat = stdenv.lib.attrByPath [ "platform" "gcc" "float" ] null stdenv;
-        gccMode = stdenv.lib.attrByPath [ "platform" "gcc" "mode" ] null stdenv;
+        gccArch = stdenv.platform.gcc.arch or null;
+        gccCpu = stdenv.platform.gcc.cpu or null;
+        gccAbi = stdenv.platform.gcc.abi or null;
+        gccFpu = stdenv.platform.gcc.fpu or null;
+        gccFloat = stdenv.platform.gcc.float or null;
+        gccMode = stdenv.platform.gcc.mode or null;
         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 "";
         withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
         withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
         withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
-      in 
-        (withArch +
+      in
+        withArch +
         withCpu +
         withAbi +
         withFpu +
         withFloat +
-        withMode);
+        withMode;
 
     /* Cross-gcc settings */
-    crossMingw = (cross != null && cross.libc == "msvcrt");
+    crossMingw = cross != null && cross.libc == "msvcrt";
+    crossDarwin = cross != null && cross.libc == "libSystem";
     crossConfigureFlags = let
-        gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross;
-        gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross;
-        gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross;
-        gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross;
-        gccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null cross;
-        gccMode = stdenv.lib.attrByPath [ "gcc" "mode" ] null cross;
+        gccArch = stdenv.cross.gcc.arch or null;
+        gccCpu = stdenv.cross.gcc.cpu or null;
+        gccAbi = stdenv.cross.gcc.abi or null;
+        gccFpu = stdenv.cross.gcc.fpu or null;
+        gccFloat = stdenv.cross.gcc.float or null;
+        gccMode = stdenv.cross.gcc.mode or null;
         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 "";
@@ -153,7 +159,13 @@ let version = "4.7.3";
           " --disable-shared" +
           " --disable-decimal-float" # libdecnumber requires libc
           else
-          " --with-headers=${libcCross}/include" +
+          (if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
+           else                " --with-headers=${libcCross}/include") +
+          # Ensure that -print-prog-name is able to find the correct programs.
+          (stdenv.lib.optionalString (crossMingw || crossDarwin) (
+            " --with-as=${binutilsCross}/bin/${cross.config}-as" +
+            " --with-ld=${binutilsCross}/bin/${cross.config}-ld"
+          )) +
           " --enable-__cxa_atexit" +
           " --enable-long-long" +
           (if crossMingw then
@@ -167,10 +179,8 @@ let version = "4.7.3";
             # In any case, mingw32 g++ linking is broken by default with shared libs,
             # unless adding "-lsupc++" to any linking command. I don't know why.
             " --disable-shared" +
-            (if cross.config == "x86_64-w64-mingw32" then
-              # To keep ABI compatibility with upstream mingw-w64
-              " --enable-fully-dynamic-string"
-              else "")
+            # To keep ABI compatibility with upstream mingw-w64
+            " --enable-fully-dynamic-string"
             else (if cross.libc == "uclibc" then
               # In uclibc cases, libgomp needs an additional '-ldl'
               # and as I don't know how to pass it, I disable libgomp.
@@ -179,8 +189,7 @@ let version = "4.7.3";
             " --enable-nls" +
             " --disable-decimal-float") # No final libdecnumber (it may work only in 386)
           );
-    stageNameAddon = if crossStageStatic then "-stage-static" else
-      "-stage-final";
+    stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
     crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
 
   bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
@@ -197,7 +206,7 @@ stdenv.mkDerivation ({
 
   src = fetchurl {
     url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
-    sha256 = "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g";
+    sha256 = "0zki3ngi0gsidnmsp88mjl2868cc7cm5wm1vwqw6znja28d7hd6k";
   };
 
   inherit patches;
@@ -266,6 +275,7 @@ stdenv.mkDerivation ({
   buildInputs = [ gmp mpfr mpc libelf ]
     ++ (optional (ppl != null) ppl)
     ++ (optional (cloog != null) cloog)
+    ++ (optional (isl != null) isl)
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk libart_lgpl ] ++ xlibs))
@@ -278,22 +288,40 @@ stdenv.mkDerivation ({
     ++ (optional stdenv.isDarwin gnused)
     ;
 
-  configureFlagsArray = stdenv.lib.optionals
-    (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
-        [ "--with-host-libstdcxx=-lstdc++ -lgcc_s" ];
+  NIX_LDFLAGS = stdenv.lib.optionalString  stdenv.isSunOS "-lm -ldl";
+
+  preConfigure = ''
+    configureFlagsArray=(
+      ${stdenv.lib.optionalString (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
+        "'--with-host-libstdcxx=-lstdc++ -lgcc_s'"}
+      ${stdenv.lib.optionalString (ppl != null && stdenv.isSunOS)
+        "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\"
+         \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""}
+    );
+    ${stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit)
+      ''
+        export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+        export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+        export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+        export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+      ''}
+    '';
 
-  # 'iant' at #go-nuts@freenode, gccgo maintainer, said that
-  # they have a bug in 4.7.1 if adding "--disable-static"
-  dontDisableStatic = langGo;
+  dontDisableStatic = true;
 
   configureFlags = "
-    ${if enableMultilib then "" else "--disable-multilib"}
-    ${if enableShared then "" else "--disable-shared"}
-    ${if enablePlugin then "--enable-plugin" else ""}
-    ${if ppl != null then "--with-ppl=${ppl}" else ""}
-    ${if cloog != null then
-      "--with-cloog=${cloog} --enable-cloog-backend=isl"
+    ${if stdenv.isSunOS then
+      " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
+      # On Illumos/Solaris GNU as is preferred
+      " --with-gnu-as --without-gnu-ld "
       else ""}
+    --enable-lto
+    ${if enableMultilib then "--disable-libquadmath" else "--disable-multilib"}
+    ${if enableShared then "" else "--disable-shared"}
+    ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
+    ${if ppl != null then "--with-ppl=${ppl} --disable-ppl-version-check" else ""}
+    ${optionalString (isl != null) "--with-isl=${isl}"}
+    ${optionalString (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"}
     ${if langJava then
       "--with-ecj-jar=${javaEcj} " +
 
@@ -310,6 +338,7 @@ stdenv.mkDerivation ({
     --disable-libstdcxx-pch
     --without-included-gettext
     --with-system-zlib
+    --enable-static
     --enable-languages=${
       concatStrings (intersperse ","
         (  optional langC        "c"
@@ -319,6 +348,7 @@ stdenv.mkDerivation ({
         ++ optional langAda      "ada"
         ++ optional langVhdl     "vhdl"
         ++ optional langGo       "go"
+        ++ optionals crossDarwin [ "objc" "obj-c++" ]
         )
       )
     }
@@ -344,11 +374,11 @@ stdenv.mkDerivation ({
     else "install";
 
   crossAttrs = let
-    xgccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null stdenv.cross;
-    xgccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null stdenv.cross;
-    xgccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null stdenv.cross;
-    xgccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null stdenv.cross;
-    xgccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null stdenv.cross;
+    xgccArch = stdenv.cross.gcc.arch or null;
+    xgccCpu = stdenv.cross.gcc.cpu or null;
+    xgccAbi = stdenv.cross.gcc.abi or null;
+    xgccFpu = stdenv.cross.gcc.fpu or null;
+    xgccFloat = stdenv.cross.gcc.float or null;
     xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
     xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
     xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
@@ -407,7 +437,8 @@ stdenv.mkDerivation ({
   # Needed for the cross compilation to work
   AR = "ar";
   LD = "ld";
-  CC = "gcc";
+  # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
   # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
   # the library headers and binaries, regarless of the language being
@@ -431,8 +462,7 @@ stdenv.mkDerivation ({
 
                                    # On GNU/Hurd glibc refers to Mach & Hurd
                                    # headers.
-                                   ++ optionals (libcCross != null &&
-                                                 hasAttr "propagatedBuildInputs" libcCross)
+                                   ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" )
                                         libcCross.propagatedBuildInputs)));
 
   LIBRARY_PATH = concatStrings
@@ -455,18 +485,14 @@ stdenv.mkDerivation ({
            " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
     else null;
 
-  passthru = { inherit langC langCC langAda langFortran langVhdl
-      langGo enableMultilib version; };
+  passthru =
+    { inherit langC langCC langAda langFortran langVhdl langGo enableMultilib version; };
 
-  /* From gccinstall.info:
-     "parallel make is currently not supported since collisions in profile
-     collecting may occur"
-  */
-  enableParallelBuilding = !profiledCompiler;
+  inherit enableParallelBuilding;
 
   meta = {
     homepage = http://gcc.gnu.org/;
-    license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
+    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -479,16 +505,15 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = [
-      stdenv.lib.maintainers.ludo
-      stdenv.lib.maintainers.viric
-      stdenv.lib.maintainers.shlevy
-    ];
+    maintainers = with stdenv.lib.maintainers; [ ludo viric shlevy simons ];
 
     # Volunteers needed for the {Cyg,Dar}win ports of *PPL.
     # gnatboot is not available out of linux platforms, so we disable the darwin build
     # for the gnat (ada compiler).
-    platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false && libelf == null) [ "i686-darwin" ];
+    platforms =
+      stdenv.lib.platforms.linux ++
+      stdenv.lib.platforms.freebsd ++
+      optionals (langAda == false) stdenv.lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/4.9/gfortran-driving.patch b/pkgs/development/compilers/gcc/4.9/gfortran-driving.patch
new file mode 100644
index 000000000000..70708886b405
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.9/gfortran-driving.patch
@@ -0,0 +1,20 @@
+This patch fixes interaction with Libtool.
+See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details.
+
+--- a/gcc/fortran/gfortranspec.c
++++ b/gcc/fortran/gfortranspec.c
+@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n"));
+     {
+       fprintf (stderr, _("Driving:"));
+       for (i = 0; i < g77_newargc; i++)
++	{
++	  if (g77_new_decoded_options[i].opt_index == OPT_l)
++	    /* Make sure no white space is inserted after `-l'.  */
++	    fprintf (stderr, " -l%s",
++		     g77_new_decoded_options[i].canonical_option[1]);
++	  else
+ 	fprintf (stderr, " %s",
+ 		 g77_new_decoded_options[i].orig_option_with_args_text);
++	}
+       fprintf (stderr, "\n");
+     }
diff --git a/pkgs/development/compilers/gcc/4.9/gnat-cflags.patch b/pkgs/development/compilers/gcc/4.9/gnat-cflags.patch
new file mode 100644
index 000000000000..bf2acf065e9b
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.9/gnat-cflags.patch
@@ -0,0 +1,33 @@
+diff --git a/libada/Makefile.in b/libada/Makefile.in
+index f5057a0..337e0c6 100644
+--- a/libada/Makefile.in
++++ b/libada/Makefile.in
+@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN)
+ WARN_CFLAGS = @warn_cflags@
+ 
+ TARGET_LIBGCC2_CFLAGS=
+-GNATLIBCFLAGS= -g -O2
++GNATLIBCFLAGS= -g -O2 $(CFLAGS)
+ GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
+ 	-DIN_RTS @have_getipinfo@
+ 
+--- a/gcc/ada/gcc-interface/Makefile.in
++++ b/gcc/ada/gcc-interface/Makefile.in
+@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata
+ SOME_ADAFLAGS =-gnata
+ FORCE_DEBUG_ADAFLAGS = -g
+ GNATLIBFLAGS = -gnatpg -nostdinc
+-GNATLIBCFLAGS = -g -O2
++GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
+ # Pretend that _Unwind_GetIPInfo is available for the target by default.  This
+ # should be autodetected during the configuration of libada and passed down to
+ # here, but we need something for --disable-libada and hope for the best.
+@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
+ # Link flags used to build gnat tools.  By default we prefer to statically
+ # link with libgcc to avoid a dependency on shared libgcc (which is tricky
+ # to deal with as it may conflict with the libgcc provided by the system).
+-GCC_LINK_FLAGS=-static-libgcc
++GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET)
+ 
+ # End of variables for you to override.
+ 
diff --git a/pkgs/development/compilers/gcc/4.9/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.9/java-jvgenmain-link.patch
new file mode 100644
index 000000000000..2612e8bfbbbc
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.9/java-jvgenmain-link.patch
@@ -0,0 +1,17 @@
+The `jvgenmain' executable must be linked against `vec.o', among others,
+since it uses its vector API.
+
+--- gcc-4.3.3/gcc/java/Make-lang.in	2008-12-05 00:00:19.000000000 +0100
++++ gcc-4.3.3/gcc/java/Make-lang.in	2009-07-03 16:11:41.000000000 +0200
+@@ -109,9 +109,9 @@ jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIB
+ 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \
+ 		$(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS)
+ 
+-jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS)
++jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) $(BUILD_RTL)
+ 	rm -f $@
+-	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(LIBS)
++	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(BUILD_RTL) $(LIBS)
+ 
+ #
+ # Build hooks:
diff --git a/pkgs/development/compilers/gcc/4.9/libstdc++-target.patch b/pkgs/development/compilers/gcc/4.9/libstdc++-target.patch
new file mode 100644
index 000000000000..fb622b395806
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.9/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/development/compilers/gcc/4.7/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.9/no-sys-dirs.patch
index 79901703cb82..79901703cb82 100644
--- a/pkgs/development/compilers/gcc/4.7/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.9/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc/4.9/parallel-bconfig.patch b/pkgs/development/compilers/gcc/4.9/parallel-bconfig.patch
new file mode 100644
index 000000000000..bc56ac698f5a
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.9/parallel-bconfig.patch
@@ -0,0 +1,32 @@
+Hacky work-around for highly parallel builds.
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57125
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index aad927c..182f666 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3908,21 +3908,21 @@ build/gengtype-lex.o: $(BCONFIG_H)
+ 
+ gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \
+   $(SYSTEM_H)
+-gengtype-parse.o: $(CONFIG_H)
++gengtype-parse.o: $(CONFIG_H) $(BCONFIG_H)
+ CFLAGS-gengtype-parse.o += -DGENERATOR_FILE
+ build/gengtype-parse.o: $(BCONFIG_H)
+ 
+ gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \
+   gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \
+   $(XREGEX_H)
+-gengtype-state.o: $(CONFIG_H)
++gengtype-state.o: $(CONFIG_H) $(BCONFIG_H)
+ CFLAGS-gengtype-state.o += -DGENERATOR_FILE
+ build/gengtype-state.o: $(BCONFIG_H)
+ 
+ gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h 	\
+   rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \
+   $(OBSTACK_H) $(XREGEX_H)
+-gengtype.o: $(CONFIG_H)
++gengtype.o: $(CONFIG_H) $(BCONFIG_H)
+ CFLAGS-gengtype.o += -DGENERATOR_FILE
+ build/gengtype.o: $(BCONFIG_H)
+