summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-10 18:13:00 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-10 18:13:00 -0400
commitf18ddabee7812fbf409759280e1e95df2019d2d2 (patch)
tree766cd52b598ae9eb0f30a2571032b000193a19a8 /pkgs/development/compilers/gcc
parente98814461d40c2907a46bbd7a81f8e0b7053019e (diff)
parent938ff5401adc7ae43bd185d8fa610f1fd4f6ead1 (diff)
downloadnixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.tar
nixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.tar.gz
nixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.tar.bz2
nixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.tar.lz
nixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.tar.xz
nixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.tar.zst
nixlib-f18ddabee7812fbf409759280e1e95df2019d2d2.zip
Merge remote-tracking branch 'upstream/master' into lib-float
Diffstat (limited to 'pkgs/development/compilers/gcc')
-rw-r--r--pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch111
-rw-r--r--pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch54
-rw-r--r--pkgs/development/compilers/gcc/4.5/sources.nix26
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix22
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix41
-rw-r--r--pkgs/development/compilers/gcc/5/default.nix22
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix22
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix37
-rw-r--r--pkgs/development/compilers/gcc/7/riscv-no-relax.patch109
-rw-r--r--pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch13
-rw-r--r--pkgs/development/compilers/gcc/8/default.nix (renamed from pkgs/development/compilers/gcc/4.5/default.nix)358
-rw-r--r--pkgs/development/compilers/gcc/builder.sh2
-rw-r--r--pkgs/development/compilers/gcc/gnat-cflags.patch33
-rw-r--r--pkgs/development/compilers/gcc/libstdc++-hook.sh2
-rw-r--r--pkgs/development/compilers/gcc/snapshot/default.nix22
15 files changed, 333 insertions, 541 deletions
diff --git a/pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch b/pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch
deleted file mode 100644
index 901534591c8f..000000000000
--- a/pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-diff --git a/gcc/vhdl/Make-lang.in b/gcc/vhdl/Make-lang.in
-index 8f481df..681ac59 100644
---- a/gcc/vhdl/Make-lang.in
-+++ b/gcc/vhdl/Make-lang.in
-@@ -96,7 +96,7 @@ AGCC_GCCOBJ_DIR=../
- AGCC_INC_FLAGS=-I$(AGCC_GCCOBJ_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/include \
-  -I$(AGCC_GCCSRC_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/gcc/config \
-  -I$(AGCC_GCCSRC_DIR)/libcpp/include
--AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS)
-+AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS) $(CFLAGS) $(INCLUDES)
- 
- AGCC_LOCAL_OBJS=ortho-lang.o
- 
-@@ -140,7 +140,7 @@ ghdl$(exeext): force
- 
- # Ghdl libraries.
- ghdllib: ghdl$(exeext) $(GCC_PASSES) force
--	$(MAKE_IN_VHDL) GRT_FLAGS="-O -g" ghdllib
-+	$(MAKE_IN_VHDL) GRT_FLAGS="-O -g $(CFLAGS)" ghdllib
- 
- # Build hooks:
- 
-diff --git a/gcc/vhdl/Makefile.in b/gcc/vhdl/Makefile.in
-index d754c6c..07abc4a 100644
---- a/gcc/vhdl/Makefile.in
-+++ b/gcc/vhdl/Makefile.in
-@@ -80,7 +80,8 @@ T_CPPFLAGS =
- X_ADAFLAGS =
- T_ADAFLAGS =
- 
--ADAC = $(CC)
-+# Never use the bootstrapped compiler, as it may not be built for ada
-+ADAC = gcc
- 
- ECHO = echo
- CHMOD = chmod
-diff --git a/gcc/vhdl/ortho-lang.c b/gcc/vhdl/ortho-lang.c
-index 84aeb92..8eddd42 100644
---- a/gcc/vhdl/ortho-lang.c
-+++ b/gcc/vhdl/ortho-lang.c
-@@ -16,6 +16,7 @@
- #include "options.h"
- #include "real.h"
--#include "tree-gimple.h"
-+#include "gimple.h"
-+#include "tree.h"
- #include "function.h"
- #include "cgraph.h"
- #include "target.h"
-@@ -680,38 +681,10 @@ type_for_mode (enum machine_mode mode, int unsignedp)
- 
- const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
- 
--/* Tree code classes.  */
--
--#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
--
--const enum tree_code_class tree_code_type[] = {
--#include "tree.def"
--  'x'
--};
--#undef DEFTREECODE
--
--/* Table indexed by tree code giving number of expression
--   operands beyond the fixed part of the node structure.
--   Not used for types or decls.  */
--
--#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
--
--const unsigned char tree_code_length[] = {
--#include "tree.def"
--  0
--};
--#undef DEFTREECODE
--
--#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) NAME,
--const char * const tree_code_name[] = {
--#include "tree.def"
--  "@@dummy"
--};
--#undef DEFTREECODE
- 
- union lang_tree_node 
-   GTY((desc ("0"),
--       chain_next ("(union lang_tree_node *) GENERIC_NEXT (&%h.generic)")))
-+       chain_next ("(union lang_tree_node *) TREE_CHAIN (&%h.generic)")))
- {
-   union tree_node GTY ((tag ("0"))) generic;
- };
-@@ -1162,7 +1135,7 @@ new_access_type (tree dtype)
-       res = make_node (POINTER_TYPE);
-       TREE_TYPE (res) = NULL_TREE;
-       /* Seems necessary.  */
--      TYPE_MODE (res) = Pmode;
-+      SET_TYPE_MODE (res, Pmode);
-       layout_type (res);
-       return res;
-     }
-diff --git a/gcc/vhdl/Make-lang.in b/gcc/vhdl/Make-lang.in
-index e201f64..f36fb97 100644
---- a/gcc/vhdl/Make-lang.in
-+++ b/gcc/vhdl/Make-lang.in
-@@ -132,7 +132,7 @@ ghdl1$(exeext): $(AGCC_OBJS) $(AGCC_DEPS) force
- 	 -cargs $(CFLAGS) $(GHDL_ADAFLAGS)
- 	$(GNATMAKE) -o $@ -aI$(srcdir)/vhdl -aOvhdl ortho_gcc-main \
- 	 -bargs -E -cargs $(CFLAGS) $(GHDL_ADAFLAGS) \
--	 -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS)
-+	 -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS) $(CLOOGLIBS) $(PPLLIBS)
- 
- # The driver for ghdl.
- ghdl$(exeext): force
diff --git a/pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch
deleted file mode 100644
index 8128fa87da5f..000000000000
--- a/pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-diff -ru gcc-4.3.1-orig/gcc/cppdefault.c gcc-4.3.1/gcc/cppdefault.c
---- gcc-4.3.1-orig/gcc/cppdefault.c	2007-07-26 10:37:01.000000000 +0200
-+++ gcc-4.3.1/gcc/cppdefault.c	2008-06-25 17:48:23.000000000 +0200
-@@ -41,6 +41,10 @@
- # 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 -ru gcc-4.3.1-orig/gcc/gcc.c gcc-4.3.1/gcc/gcc.c
---- gcc-4.3.1-orig/gcc/gcc.c	2008-03-02 23:55:19.000000000 +0100
-+++ gcc-4.3.1/gcc/gcc.c	2008-06-25 17:52:53.000000000 +0200
-@@ -1478,10 +1478,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.  */
---- gcc-4.3.1-orig/gcc/Makefile.in	2008-05-11 20:54:15.000000000 +0200
-+++ gcc-4.3.1/gcc/Makefile.in	2008-06-25 17:48:23.000000000 +0200
-@@ -378,7 +378,11 @@
- MD5_H	    = $(srcdir)/../include/md5.h
- 
- # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
--NATIVE_SYSTEM_HEADER_DIR = /usr/include
-+# 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@
- 
-@@ -3277,7 +3281,7 @@
-   -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)\" \
-+  -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
-   -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
-   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
-   -DPREFIX=\"$(prefix)/\" \
diff --git a/pkgs/development/compilers/gcc/4.5/sources.nix b/pkgs/development/compilers/gcc/4.5/sources.nix
deleted file mode 100644
index 71e1e483cacd..000000000000
--- a/pkgs/development/compilers/gcc/4.5/sources.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Automatically generated by `update-gcc.sh', do not edit.
-   For GCC 4.5.4.  */
-{ fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }:
-
-assert version == "4.5.4";
-optional /* langC */ true (fetchurl {
-  url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-  sha256 = "894d90f72cbfc8707e330fa2b1847c443fa97cf9b7f26e86be554709510e624a";
-}) ++
-optional langCC (fetchurl {
-  url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-  sha256 = "f7e3bab5e22713fbce46c2acb35fb727748473a34a942ce00393d75e1b09b6b9";
-}) ++
-optional langFortran (fetchurl {
-  url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-  sha256 = "cf0803b4f5334a526dd8da1b2171d6724f50c17346b2d5c509b6abc973d2ef34";
-}) ++
-optional langJava (fetchurl {
-  url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-  sha256 = "c98398da6f8c4c7d1758e291089d99853fdd27112cd3f146b7a8c26e6d762a23";
-}) ++
-optional langAda (fetchurl {
-  url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2";
-  sha256 = "8abddae15be65572b4d639bd9818057019bb4a45da4decfc6451511c8d580c5e";
-}) ++
-[]
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index dea8b912b272..fbeb649f96ac 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -3,8 +3,6 @@
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
 , langJava ? false
-, langAda ? false
-, langVhdl ? false
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -21,13 +19,11 @@
 , libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
-, gnatboot ? null
 , enableMultilib ? false
 , enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
@@ -39,8 +35,6 @@
 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;
@@ -68,9 +62,6 @@ let version = "4.8.5";
       ++ optional enableParallelBuilding ../parallel-bconfig.patch
       ++ optional (targetPlatform != hostPlatform) ../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
       ++ optional hostPlatform.isDarwin ../gfortran-darwin-NXConstStr.patch
       ++ [(fetchpatch {
@@ -263,8 +254,6 @@ stdenv.mkDerivation ({
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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.
@@ -314,8 +303,6 @@ stdenv.mkDerivation ({
           ++ 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++"
@@ -353,9 +340,6 @@ stdenv.mkDerivation ({
     optional javaAwtGtk "--enable-java-awt=gtk" ++
     optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
 
-    # Ada
-    optional langAda "--enable-libada" ++
-
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -448,7 +432,7 @@ stdenv.mkDerivation ({
     ]);
 
   passthru = {
-    inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version;
+    inherit langC langCC langObjC langObjCpp langFortran langGo version;
     isGNU = true;
     hardeningUnsupportedFlags = [ "stackprotector" ];
   };
@@ -474,13 +458,11 @@ stdenv.mkDerivation ({
 
     maintainers = with stdenv.lib.maintainers; [ viric peti ];
 
-    # 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 ++
       stdenv.lib.platforms.illumos ++
-      optionals (langAda == false) stdenv.lib.platforms.darwin;
+      stdenv.lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 343d820fa236..b8aebe6ed094 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -1,10 +1,8 @@
-{ stdenv, targetPackages, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs, fetchpatch
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
 , langJava ? false
-, langAda ? false
-, langVhdl ? false
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -21,13 +19,11 @@
 , libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
-, gnatboot ? null
 , enableMultilib ? false
 , enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
@@ -39,8 +35,6 @@
 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;
@@ -69,12 +63,23 @@ let version = "4.9.4";
       ++ optionals enableParallelBuilding [ ../parallel-bconfig.patch ./parallel-strsignal.patch ]
       ++ optional (targetPlatform != hostPlatform) ../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
       ++ [ ../struct-ucontext.patch ../struct-sigaltstack-4.9.patch ] # glibc-2.26
-      ;
+      # Retpoline patches pulled from the branch hjl/indirect/gcc-4_9-branch (by H.J. Lu, the author of GCC upstream retpoline commits)
+      ++ builtins.map ({commit, sha256}: fetchpatch {url = "https://github.com/hjl-tools/gcc/commit/${commit}.patch"; inherit sha256;})
+         [{ commit = "e623d21608e96ecd6b65f0d06312117d20488a38"; sha256 = "1ix8i4d2r3ygbv7npmsdj790rhxqrnfwcqzv48b090r9c3ij8ay3"; }
+          { commit = "2015a09e332309f12de1dadfe179afa6a29368b8"; sha256 = "0xcfs0cbb63llj2gbcdrvxim79ax4k4aswn0a3yjavxsj71s1n91"; }
+          { commit = "6b11591f4494f705e8746e7d58b7f423191f4e92"; sha256 = "0aydyhsm2ig0khgbp27am7vq7liyqrq6kfhfi2ki0ij0ab1hfbga"; }
+          { commit = "203c7d9c3e9cb0f88816b481ef8e7e87b3ecc373"; sha256 = "0wqn16y7wy5kg8ngfcni5qdwfphl01axczibbk49bxclwnzvldqa"; }
+          { commit = "f039c6f284b2c9ce97c8353d6034978795c4872e"; sha256 = "13fkgdb17lpyxfksz1zanxhgpsm0jrss9w61nbl7an4im22hz7ci"; }
+          { commit = "ed42606bdab1c5d9e5ad828cd6fe1a0557f193b7"; sha256 = "0gdnn8v3p03imj3qga2mzdhpgbmjcklkxdl97jvz5xia2ikzknxm"; }
+          { commit = "5278e062ef292fd2fbf987d25389785f4c5c0f99"; sha256 = "0j81x758wf8v7j4rx5wc1cy7yhkvhlhv3wmnarwakxiwsspq0vrs"; }
+          { commit = "76f1ffbbb6cd9f6ecde6c82cd16e20a27242e890"; sha256 = "1py56y6gp7fjf4f8bbsfwh5bs1gnmlqda1ycsmnwlzfm0cshdp0c"; }
+          { commit = "4ca48b2b688b135c0390f54ea9077ef10aedd52c"; sha256 = "15r019pzr3k0lpgyvdc92c8fayw8b5lrzncna4bqmamcsdz7vsaw"; }
+          { commit = "98c7bf9ddc80db965d69d61521b1c7a1cec32d9a"; sha256 = "1d7pfdv1q23nf0wadw7jbp6d6r7pnzjpbyxgbdfv7j1vr9l1bp60"; }
+          { commit = "3dc76b53ad896494ca62550a7a752fecbca3f7a2"; sha256 = "0jvdzfpvfdmklfcjwqblwq1i22iqis7ljpvm7adra5d7zf2xk7xz"; }
+          { commit = "1e961ed49b18e176c7457f53df2433421387c23b"; sha256 = "04dnqqs4qsvz4g8cq6db5id41kzys7hzhcaycwmc9rpqygs2ajwz"; }
+          { commit = "e137c72d099f9b3b47f4cc718aa11eab14df1a9c"; sha256 = "1ms0dmz74yf6kwgjfs4d2fhj8y6mcp2n184r3jk44wx2xc24vgb2"; }];
 
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
@@ -268,8 +273,6 @@ stdenv.mkDerivation ({
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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.
@@ -322,8 +325,6 @@ stdenv.mkDerivation ({
           ++ 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++"
@@ -361,9 +362,6 @@ stdenv.mkDerivation ({
     optional javaAwtGtk "--enable-java-awt=gtk" ++
     optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
 
-    # Ada
-    optional langAda "--enable-libada" ++
-
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -456,7 +454,7 @@ stdenv.mkDerivation ({
     ]);
 
   passthru =
-    { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
+    { inherit langC langCC langObjC langObjCpp langFortran langGo version; isGNU = true; };
 
   inherit enableParallelBuilding enableMultilib;
 
@@ -479,13 +477,10 @@ stdenv.mkDerivation ({
 
     maintainers = with stdenv.lib.maintainers; [ viric peti ];
 
-    # 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 ++
-      stdenv.lib.platforms.illumos ++
-      optionals (langAda == false) stdenv.lib.platforms.darwin;
+      stdenv.lib.platforms.illumos;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix
index 0d9565de0a77..8cbd85d9d198 100644
--- a/pkgs/development/compilers/gcc/5/default.nix
+++ b/pkgs/development/compilers/gcc/5/default.nix
@@ -3,8 +3,6 @@
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
 , langJava ? false
-, langAda ? false
-, langVhdl ? false
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -21,13 +19,11 @@
 , libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
-, gnatboot ? null
 , enableMultilib ? false
 , enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
@@ -40,8 +36,6 @@
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null
                        && perl != null;  # for `--enable-java-home'
-assert langAda      -> gnatboot != null;
-assert langVhdl     -> gnat != null;
 
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
@@ -67,9 +61,6 @@ let version = "5.5.0";
       [ ../use-source-date-epoch.patch ]
       ++ optional (targetPlatform != hostPlatform) ../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
 
       # This could be applied unconditionally but I don't want to cause a full
@@ -290,8 +281,6 @@ stdenv.mkDerivation ({
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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.
@@ -343,8 +332,6 @@ stdenv.mkDerivation ({
           ++ 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++"
@@ -377,9 +364,6 @@ stdenv.mkDerivation ({
     optional javaAwtGtk "--enable-java-awt=gtk" ++
     optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
 
-    # Ada
-    optional langAda "--enable-libada" ++
-
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -473,7 +457,7 @@ stdenv.mkDerivation ({
     ]);
 
   passthru =
-    { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
+    { inherit langC langCC langObjC langObjCpp langFortran langGo version; isGNU = true; };
 
   inherit enableParallelBuilding enableMultilib;
 
@@ -496,12 +480,10 @@ stdenv.mkDerivation ({
 
     maintainers = with stdenv.lib.maintainers; [ viric peti ];
 
-    # 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;
+      stdenv.lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index 29f2bad7eac1..8985879977d3 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -3,8 +3,6 @@
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
 , langJava ? false
-, langAda ? false
-, langVhdl ? false
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -21,13 +19,11 @@
 , libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
-, gnatboot ? null
 , enableMultilib ? false
 , enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
@@ -40,8 +36,6 @@
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null
                        && perl != null;  # for `--enable-java-home'
-assert langAda      -> gnatboot != null;
-assert langVhdl     -> gnat != null;
 
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
@@ -66,9 +60,6 @@ let version = "6.4.0";
       [ ../use-source-date-epoch.patch ]
       ++ optional (targetPlatform != hostPlatform) ../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
       ++ [ ../struct-ucontext.patch ../struct-sigaltstack.patch ] # glibc-2.26
       ++ optional langJava [ ../struct-ucontext-libjava.patch ] # glibc-2.26
@@ -290,8 +281,6 @@ stdenv.mkDerivation ({
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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.
@@ -347,8 +336,6 @@ stdenv.mkDerivation ({
           ++ 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++"
@@ -381,9 +368,6 @@ stdenv.mkDerivation ({
     optional javaAwtGtk "--enable-java-awt=gtk" ++
     optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
 
-    # Ada
-    optional langAda "--enable-libada" ++
-
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -476,7 +460,7 @@ stdenv.mkDerivation ({
     ]);
 
   passthru =
-    { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
+    { inherit langC langCC langObjC langObjCpp langFortran langGo version; isGNU = true; };
 
   inherit enableParallelBuilding enableMultilib;
 
@@ -499,12 +483,10 @@ stdenv.mkDerivation ({
 
     maintainers = with stdenv.lib.maintainers; [ viric peti ];
 
-    # 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;
+      stdenv.lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index e75e22efce1f..d2fc25dad588 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -3,8 +3,6 @@
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
 , langJava ? false
-, langAda ? false
-, langVhdl ? false
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -21,13 +19,11 @@
 , libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
-, gnatboot ? null
 , enableMultilib ? false
 , enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
@@ -40,8 +36,6 @@
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null
                        && perl != null;  # for `--enable-java-home'
-assert langAda      -> gnatboot != null;
-assert langVhdl     -> gnat != null;
 
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
@@ -63,16 +57,17 @@ let version = "7.3.0";
     enableParallelBuilding = true;
 
     patches =
-      [ ]
+      [ # https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00633.html
+        ./riscv-pthread-reentrant.patch
+        # https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00297.html
+        ./riscv-no-relax.patch
+      ]
       ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
       ++ optional noSysDirs ../no-sys-dirs.patch
       ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied
         url = "https://git.busybox.net/buildroot/plain/package/gcc/7.1.0/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
         sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs";
       })
-      # 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 {
@@ -203,7 +198,12 @@ stdenv.mkDerivation ({
       --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname"
   '';
 
-  postPatch =
+  postPatch = ''
+    configureScripts=$(find . -name configure)
+    for configureScript in $configureScripts; do
+      patchShebangs $configureScript
+    done
+  '' + (
     if (hostPlatform.isHurd
         || (libcCross != null                  # e.g., building `gcc.crossDrv'
             && libcCross ? crossConfig
@@ -262,7 +262,7 @@ stdenv.mkDerivation ({
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
         )
-    else null;
+    else "");
 
   # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
   crossStageStatic = targetPlatform == hostPlatform || crossStageStatic;
@@ -290,8 +290,6 @@ stdenv.mkDerivation ({
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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.
@@ -343,8 +341,6 @@ stdenv.mkDerivation ({
           ++ 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++"
@@ -377,9 +373,6 @@ stdenv.mkDerivation ({
     optional javaAwtGtk "--enable-java-awt=gtk" ++
     optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
 
-    # Ada
-    optional langAda "--enable-libada" ++
-
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -472,7 +465,7 @@ stdenv.mkDerivation ({
     ]);
 
   passthru =
-    { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
+    { inherit langC langCC langObjC langObjCpp langFortran langGo version; isGNU = true; };
 
   inherit enableParallelBuilding enableMultilib;
 
@@ -495,12 +488,10 @@ stdenv.mkDerivation ({
 
     maintainers = with stdenv.lib.maintainers; [ ];
 
-    # 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;
+      stdenv.lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/7/riscv-no-relax.patch b/pkgs/development/compilers/gcc/7/riscv-no-relax.patch
new file mode 100644
index 000000000000..93d9cd1d60f5
--- /dev/null
+++ b/pkgs/development/compilers/gcc/7/riscv-no-relax.patch
@@ -0,0 +1,109 @@
+commit e7c570f37384d824cb9725f237920e9691e57269
+gpg: Signature made Tue 06 Mar 2018 04:52:46 PM PST
+gpg:                using RSA key 00CE76D1834960DFCE886DF8EF4CA1502CCBAB41
+gpg:                issuer "palmer@dabbelt.com"
+gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>" [ultimate]
+gpg:                 aka "Palmer Dabbelt <palmer@sifive.com>" [ultimate]
+Author: Palmer Dabbelt <palmer@sifive.com>
+Date:   Thu Mar 1 12:01:06 2018 -0800
+
+    RISC-V: Add and document the "-mno-relax" option
+
+    RISC-V relies on aggressive linker relaxation to get good code size.  As
+    a result no text symbol addresses can be known until link time, which
+    means that alignment must be handled during the link.  This alignment
+    pass is essentially just another linker relaxation, so this has the
+    unfortunate side effect that linker relaxation is required for
+    correctness on many RISC-V targets.
+
+    The RISC-V assembler has supported an ".option norelax" for a long time
+    because there are situations in which linker relaxation is a bad idea --
+    the canonical example is when trying to materialize the initial value of
+    the global pointer into a register, which would otherwise be relaxed to
+    a NOP.  We've been relying on users who want to disable relaxation for
+    an entire link to pass "-Wl,--no-relax", but that still relies on the
+    linker relaxing R_RISCV_ALIGN to handle alignment despite it not being
+    strictly necessary.
+
+    This patch adds a GCC option, "-mno-relax", that disable linker
+    relaxation by adding ".option norelax" to the top of every generated
+    assembly file.  The assembler is smart enough to handle alignment at
+    assemble time for files that have never emitted a relaxable relocation,
+    so this is sufficient to really disable all relaxations in the linker,
+    which results in significantly faster link times for large objects.
+
+    This also has the side effect of allowing toolchains that don't support
+    linker relaxation (LLVM and the Linux module loader) to function
+    correctly.  Toolchains that don't support linker relaxation should
+    default to "-mno-relax" and error when presented with any R_RISCV_ALIGN
+    relocation as those need to be handled for correctness.
+
+    gcc/ChangeLog
+
+    2018-03-01  Palmer Dabbelt  <palmer@sifive.com>
+
+            * config/riscv/riscv.opt (mrelax): New option.
+            * config/riscv/riscv.c (riscv_file_start): Emit ".option
+            "norelax" when riscv_mrelax is disabled.
+            * doc/invoke.texi (RISC-V): Document "-mrelax" and "-mno-relax".
+
+diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c
+index c38f6c394d54..3e81874de232 100644
+--- a/gcc/config/riscv/riscv.c
++++ b/gcc/config/riscv/riscv.c
+@@ -3979,6 +3979,11 @@ riscv_file_start (void)
+
+   /* Instruct GAS to generate position-[in]dependent code.  */
+   fprintf (asm_out_file, "\t.option %spic\n", (flag_pic ? "" : "no"));
++
++  /* If the user specifies "-mno-relax" on the command line then disable linker
++     relaxation in the assembler.  */
++  if (! riscv_mrelax)
++    fprintf (asm_out_file, "\t.option norelax\n");
+ }
+
+ /* Implement TARGET_ASM_OUTPUT_MI_THUNK.  Generate rtl rather than asm text
+diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
+index 581a26bb5c1e..b37ac75d9bb4 100644
+--- a/gcc/config/riscv/riscv.opt
++++ b/gcc/config/riscv/riscv.opt
+@@ -106,6 +106,11 @@ mexplicit-relocs
+ Target Report Mask(EXPLICIT_RELOCS)
+ Use %reloc() operators, rather than assembly macros, to load addresses.
+
++mrelax
++Target Bool Var(riscv_mrelax) Init(1)
++Take advantage of linker relaxations to reduce the number of instructions
++required to materialize symbol addresses.
++
+ Mask(64BIT)
+
+ Mask(MUL)
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 8d366c626bae..deb48af2ecad 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -1042,7 +1042,8 @@ See RS/6000 and PowerPC Options.
+ -msave-restore  -mno-save-restore @gol
+ -mstrict-align -mno-strict-align @gol
+ -mcmodel=medlow -mcmodel=medany @gol
+--mexplicit-relocs  -mno-explicit-relocs @gol}
++-mexplicit-relocs  -mno-explicit-relocs @gol
++-mrelax -mno-relax @gol}
+
+ @emph{RL78 Options}
+ @gccoptlist{-msim  -mmul=none  -mmul=g13  -mmul=g14  -mallregs @gol
+@@ -23102,6 +23103,12 @@ Use or do not use assembler relocation operators when dealing with symbolic
+ addresses.  The alternative is to use assembler macros instead, which may
+ limit optimization.
+
++@item -mrelax
++@itemx -mno-relax
++Take advantage of linker relaxations to reduce the number of instructions
++required to materialize symbol addresses. The default is to take advantage of
++linker relaxations.
++
+ @end table
+
+ @node RL78 Options
+
diff --git a/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch b/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch
new file mode 100644
index 000000000000..c7527ffb2b16
--- /dev/null
+++ b/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch
@@ -0,0 +1,13 @@
+Index: gcc/config/riscv/linux.h
+===================================================================
+--- a/gcc/config/riscv/linux.h	(revision 257620)
++++ b/gcc/config/riscv/linux.h	(revision 257621)
+@@ -47,6 +47,8 @@
+ 
+ #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
+ 
++#define CPP_SPEC "%{pthread:-D_REENTRANT}"
++
+ #define LINK_SPEC "\
+ -melf" XLEN_SPEC "lriscv \
+ %{shared} \
diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/8/default.nix
index 36b48b880211..b7e209ebc0c8 100644
--- a/pkgs/development/compilers/gcc/4.5/default.nix
+++ b/pkgs/development/compilers/gcc/8/default.nix
@@ -1,72 +1,62 @@
-{ stdenv, targetPackages, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langJava ? false
-, langAda ? false
-, langVhdl ? false
+, langObjC ? targetPlatform.isDarwin
+, langObjCpp ? targetPlatform.isDarwin
+, langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
 , enableShared ? true
 , texinfo ? null
-, perl ? null # optional, for texi2pod (then pod2man); required for Java
+, perl ? null # optional, for texi2pod (then pod2man)
 , gmp, mpfr, libmpc, gettext, which
 , libelf                      # optional, for link-time optimizations (LTO)
-, ppl ? null, cloogppl ? null # optional, for the Graphite optimization framework
-, zlib ? null, boehmgc ? null
-, zip ? null, unzip ? null, pkgconfig ? null, gtk2 ? 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
+, isl ? null # optional, for the Graphite optimization framework.
+, zlib ? null
 , enableMultilib ? false
+, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
+, gnused ? null
+, cloog # unused; just for compat with gcc4, as we override the parameter on some places
+, darwin ? null
 , buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
-assert langJava     -> zip != null && unzip != null
-                       && zlib != null && boehmgc != null
-                       && perl != null;  # for `--enable-java-home'
-assert langAda      -> gnatboot != null;
-assert langVhdl     -> gnat != null;
-
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
 
+# Make sure we get GNU sed.
+assert hostPlatform.isDarwin -> gnused != null;
+
+# The go frontend is written in c++
+assert langGo -> langCC;
+
 with stdenv.lib;
 with builtins;
 
-let version = "4.5.4";
-    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
-    ];
+let version = "8.1.0";
+
+    # Whether building a cross-compiler for GNU/Hurd.
+    crossGNU = targetPlatform != hostPlatform && targetPlatform.config == "i586-pc-gnu";
 
-    javaAwtGtk = langJava && gtk2 != null;
+    enableParallelBuilding = true;
 
-    /* Cross-gcc settings */
-    crossMingw = (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt");
+    patches =
+         optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
+      ++ optional noSysDirs ../no-sys-dirs.patch
+      /* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied
+        url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
+        sha256 = ""; # TODO: uncomment and check hash when available.
+      }) */
+      ++ optional langFortran ../gfortran-driving.patch;
 
+    /* Cross-gcc settings (build == host != target) */
+    crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
+    crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
     crossConfigureFlags =
       # Ensure that -print-prog-name is able to find the correct programs.
       [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
@@ -88,12 +78,17 @@ let version = "4.5.4";
         "--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
+        # maybe only needed on musl, PATH_MAX
+        # https://github.com/richfelker/musl-cross-make/blob/0867cdf300618d1e3e87a0a939fa4427207ad9d7/litecross/Makefile#L62
+        "--disable-libmpx"
       ] else [
-        "--with-headers=${libcCross}/include"
+        (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot"
+         else                "--with-headers=${getDev libcCross}/include")
         "--enable-__cxa_atexit"
         "--enable-long-long"
       ] ++
@@ -101,62 +96,77 @@ let version = "4.5.4";
           "--enable-threads=win32"
           "--enable-sjlj-exceptions"
           "--enable-hash-synchronization"
-          "--enable-version-specific-runtime-libs"
           "--enable-libssp"
           "--disable-nls"
           "--with-dwarf2"
-        ] else [
+          # To keep ABI compatibility with upstream mingw-w64
+          "--enable-fully-dynamic-string"
+        ] else
+          optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
+            # libsanitizer requires netrom/netrom.h which is not
+            # available in uclibc.
+            "--disable-libsanitizer"
+            # In uclibc cases, libgomp needs an additional '-ldl'
+            # and as I don't know how to pass it, I disable libgomp.
+            "--disable-libgomp"
+            # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865
+            "--disable-libmpx"
+          ] ++ [
           "--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";
+    stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
     crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
 
-in
+    bootstrap = targetPlatform == hostPlatform;
 
-# We need all these X libraries when building AWT with GTK+.
-assert gtk2 != null -> (filter (x: x == null) xlibs) == [];
+in
 
 stdenv.mkDerivation ({
-  name = "${name}-${version}" + crossNameAddon;
+  name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
 
   builder = ../builder.sh;
 
-  src = (import ./sources.nix) {
-    inherit fetchurl optional version;
-    inherit langC langCC langFortran langJava langAda;
+  src = fetchurl {
+    url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+    sha256 = "0lxil8x0jjx7zbf90cy1rli650akaa6hpk8wk8s62vk2jbwnc60x";
   };
 
-  hardeningDisable = [ "format" ] ++ optional (name != "gnat") "all";
-
-  outputs = [ "out" "man" "info" ]
-    ++ optional (!(hostPlatform.is64bit && langAda)) "lib";
+  inherit patches;
 
+  outputs = [ "out" "lib" "man" "info" ];
   setOutputFlags = false;
   NIX_NO_SELF_RPATH = true;
 
   libc_dev = stdenv.cc.libc_dev;
 
-  patches =
-    [ ]
-    ++ optional (targetPlatform != hostPlatform) ../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 langVhdl ./ghdl-ortho-cflags.patch
-    ++ [ ../struct-ucontext-4.5.patch ] # glibc-2.26
-    ;
+  hardeningDisable = [ "format" ];
+
+  # This should kill all the stdinc frameworks that gcc and friends like to
+  # insert into default search paths.
+  prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+    substituteInPlace gcc/config/darwin-c.c \
+      --replace 'if (stdinc)' 'if (0)'
+
+    substituteInPlace libgcc/config/t-slibgcc-darwin \
+      --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)"
 
-  postPatch =
-    if (stdenv.system == "i586-pc-gnu"
+    substituteInPlace libgfortran/configure \
+      --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname"
+  '';
+
+  postPatch = ''
+    configureScripts=$(find . -name configure)
+    for configureScript in $configureScripts; do
+      patchShebangs $configureScript
+    done
+  '' + (
+    if (hostPlatform.isHurd
         || (libcCross != null                  # e.g., building `gcc.crossDrv'
             && libcCross ? crossConfig
             && libcCross.crossConfig == "i586-pc-gnu")
-        || (targetPlatform != hostPlatform && targetPlatform.config == "i586-pc-gnu"
-            && libcCross != null))
+        || (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.
@@ -164,7 +174,6 @@ stdenv.mkDerivation ({
       let
         libc = if libcCross != null then libcCross else stdenv.glibc;
         gnu_h = "gcc/config/gnu.h";
-        i386_gnu_h = "gcc/config/i386/gnu.h";
         extraCPPDeps =
              libc.propagatedBuildInputs
           ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
@@ -177,8 +186,8 @@ stdenv.mkDerivation ({
           then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
           else "-L${libpthread}/lib";
       in
-        '' echo "augmenting \`CPP_SPEC' in \`${i386_gnu_h}' with \`${extraCPPSpec}'..."
-           sed -i "${i386_gnu_h}" \
+        '' 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}'..."
@@ -188,8 +197,6 @@ stdenv.mkDerivation ({
            echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
            sed -i "${gnu_h}" \
                -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
-           sed -i gcc/config/t-gnu \
-               -es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc.dev}/include|g'
         ''
     else if targetPlatform != hostPlatform || stdenv.cc.libc != null then
       # On NixOS, use the right path to the dynamic linker instead of
@@ -197,25 +204,32 @@ stdenv.mkDerivation ({
       let
         libc = if libcCross != null then libcCross else stdenv.cc.libc;
       in
-        '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
+        (
+        '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..."
            for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
            do
-             grep -q LIBC_DYNAMIC_LINKER "$header" || continue
+             grep -q _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.out}\3"|g'
+                 -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \
+                 -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
            done
         ''
-    else null;
+        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        ''
+            sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
+        ''
+        )
+    else "");
 
   # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
   crossStageStatic = targetPlatform == hostPlatform || crossStageStatic;
-  inherit noSysDirs profiledCompiler staticCompiler langJava
+  inherit noSysDirs staticCompiler
     libcCross crossMingw;
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [ texinfo which gettext ]
-    ++ optional (perl != null) perl;
+    ++ (optional (perl != null) perl);
 
   # For building runtime libs
   depsBuildTarget =
@@ -228,17 +242,27 @@ stdenv.mkDerivation ({
   buildInputs = [
     gmp mpfr libmpc libelf
     targetPackages.stdenv.cc.bintools # For linking code at run-time
-  ] ++ (optional (ppl != null) ppl)
-    ++ (optional (cloogppl != null) cloogppl)
+  ] ++ (optional (isl != null) isl)
     ++ (optional (zlib != null) zlib)
-    ++ (optional langJava boehmgc)
-    ++ (optionals langJava [zip unzip])
-    ++ (optionals javaAwtGtk ([gtk2 pkgconfig libart_lgpl] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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 hostPlatform.isDarwin gnused)
+    ++ (optional hostPlatform.isDarwin targetPackages.stdenv.cc.bintools)
     ;
 
+  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+
+  preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.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"
+  '';
+
+  dontDisableStatic = true;
+
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms =
     # TODO(@Ericson2314): Figure out what's going wrong with Arm
@@ -249,8 +273,10 @@ stdenv.mkDerivation ({
   configureFlags =
     # Basic dependencies
     [
-      "--with-gmp=${gmp.dev}"
-      "--with-mpfr=${mpfr.dev}"
+      "--with-gmp-include=${gmp.dev}/include"
+      "--with-gmp-lib=${gmp.out}/lib"
+      "--with-mpfr-include=${mpfr.dev}/include"
+      "--with-mpfr-lib=${mpfr.out}/lib"
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
@@ -259,67 +285,72 @@ stdenv.mkDerivation ({
 
     # Basic configuration
     [
+      "--enable-lto"
       "--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++" ]
           )
         )
       }"
     ] ++
-    optional (!enableMultilib) "--disable-multilib" ++
+
+    (if enableMultilib
+      then ["--enable-multilib" "--disable-libquadmath"]
+      else ["--disable-multilib"]) ++
     optional (!enableShared) "--disable-shared" ++
+    (if enablePlugin
+      then ["--enable-plugin"]
+      else ["--disable-plugin"]) ++
 
     # Optional features
-    optional (cloogppl != null) "--with-cloog=${cloogppl}" ++
-    optional (ppl != null) "--with-ppl=${ppl}" ++
-
-    # Java options
-    optionals langJava [
-      "--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"
-    ] ++
-    optional javaAwtGtk "--enable-java-awt=gtk" ++
-    optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
-
-    # Ada
-    optional langAda "--enable-libada" ++
+    optional (isl != null) "--with-isl=${isl}" ++
 
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
+    optional (!bootstrap) "--disable-bootstrap" ++
 
     # Platform-specific flags
     optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
-    # Trick that should be taken out once we have a mipsel-linux not loongson2f
-    optional (targetPlatform == hostPlatform && stdenv.system == "mipsel-linux") "--with-arch=loongson2f"
+    optionals hostPlatform.isSunOS [
+      "--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"
+    ]
+    ++ optional (targetPlatform == hostPlatform && targetPlatform.libc == "musl") "--disable-libsanitizer"
   ;
 
   targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
 
+  buildFlags =
+    optional bootstrap (if profiledCompiler then "profiledbootstrap" else "bootstrap");
+
+  installTargets =
+    if stripped
+    then "install-strip"
+    else "install";
+
   /* For cross-built gcc (build != host == target) */
   crossAttrs = {
     dontStrip = true;
+    buildFlags = "";
   };
 
+  # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
+
   # 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.
   #
   # Cross-compiling, we need gcc not to read ./specs in order to build the g++
@@ -328,9 +359,6 @@ stdenv.mkDerivation ({
 
   CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
-    ++ optional langJava boehmgc
-    ++ optionals javaAwtGtk xlibs
-    ++ optionals javaAwtGtk [ gmp mpfr ]
     ++ optional (libpthread != null) libpthread
     ++ optional (libpthreadCross != null) libpthreadCross
 
@@ -342,16 +370,13 @@ stdenv.mkDerivation ({
 
   LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
-    ++ optional langJava boehmgc
-    ++ optionals javaAwtGtk xlibs
-    ++ optionals javaAwtGtk [ gmp mpfr ]
     ++ optional (libpthread != null) libpthread)
   );
 
   EXTRA_TARGET_FLAGS = optionals
     (targetPlatform != hostPlatform && libcCross != null)
     ([
-      "-idirafter ${libcCross.dev}/include"
+      "-idirafter ${getDev libcCross}/include"
     ] ++ optionals (! crossStageStatic) [
       "-B${libcCross.out}/lib"
     ]);
@@ -370,13 +395,12 @@ stdenv.mkDerivation ({
       "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
     ]);
 
-  passthru = {
-    inherit langC langCC langAda langFortran langVhdl enableMultilib version;
-    isGNU = true;
-    hardeningUnsupportedFlags = [ "stackprotector" ];
-  };
+  passthru =
+    { inherit langC langCC langObjC langObjCpp langFortran langGo version; isGNU = true; };
 
-  enableParallelBuilding = !langAda;
+  inherit enableParallelBuilding enableMultilib;
+
+  inherit (stdenv) is64bit;
 
   meta = {
     homepage = http://gcc.gnu.org/;
@@ -386,71 +410,29 @@ stdenv.mkDerivation ({
 
     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,...).
+      Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as
+      libraries for these languages (libstdc++, 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 = [
-      stdenv.lib.maintainers.viric
-    ];
+    maintainers = with stdenv.lib.maintainers; [ synthetica ];
 
-    # 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) [ "i686-darwin" ];
+    platforms =
+      stdenv.lib.platforms.linux ++
+      stdenv.lib.platforms.freebsd ++
+      stdenv.lib.platforms.darwin;
   };
 }
 
-// optionalAttrs (targetPlatform != hostPlatform || libcCross != null) {
-  # `builder.sh' sets $CPP, which leads configure to use "gcc -E" instead of,
-  # say, "i586-pc-gnu-gcc -E" when building `gcc.crossDrv'.
-  # FIXME: Fix `builder.sh' directly in the next stdenv-update.
-  postUnpack = "unset CPP";
-}
-
 // optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
   makeFlags = [ "all-gcc" "all-target-libgcc" ];
   installTargets = "install-gcc install-target-libgcc";
 }
 
-# GCC 4.5.2 doesn't support the `install-strip' target, so let `stdenv' do
-# the stripping by default.
-// optionalAttrs (!stripped) { dontStrip = true; }
-
-// optionalAttrs langVhdl rec {
-  name = "ghdl-0.29";
-
-  ghdlSrc = fetchurl {
-    url = "http://ghdl.free.fr/ghdl-0.29.tar.bz2";
-    sha256 = "15mlinr1lwljwll9ampzcfcrk9bk0qpdks1kxlvb70xf9zhh2jva";
-  };
-
-  # Ghdl has some timestamps checks, storing file timestamps in '.cf' files.
-  # As we will change the timestamps to 1970-01-01 00:00:01, we also set the
-  # content of that .cf to that value. This way ghdl does not complain on
-  # the installed object files from the basic libraries (ieee, ...)
-  postInstallGhdl = ''
-    pushd $out
-    find . -name "*.cf" -exec \
-        sed 's/[0-9]*\.000" /19700101000001.000" /g' -i {} \;
-    popd
-  '';
-
-  postUnpack = ''
-    tar xvf ${ghdlSrc}
-    mv ghdl-*/vhdl gcc*/gcc
-    rm -Rf ghdl-*
-  '';
-
-  meta = {
-    homepage = http://ghdl.free.fr/;
-    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;
-  };
+# Strip kills static libs of other archs (hence targetPlatform != hostPlatform)
+// optionalAttrs (!stripped || targetPlatform != hostPlatform) { dontStrip = true; }
 
-})
+// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
+)
diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh
index 1796c83385e5..a3250f4021a5 100644
--- a/pkgs/development/compilers/gcc/builder.sh
+++ b/pkgs/development/compilers/gcc/builder.sh
@@ -287,8 +287,6 @@ postInstall() {
     # See https://bugs.gentoo.org/show_bug.cgi?id=301299#c31
     paxmark r $out/libexec/gcc/*/*/{cc1,cc1plus}
 
-    eval "$postInstallGhdl"
-
     # Two identical man pages are shipped (moving and compressing is done later)
     ln -sf gcc.1 "$out"/share/man/man1/g++.1
 }
diff --git a/pkgs/development/compilers/gcc/gnat-cflags.patch b/pkgs/development/compilers/gcc/gnat-cflags.patch
deleted file mode 100644
index bf2acf065e9b..000000000000
--- a/pkgs/development/compilers/gcc/gnat-cflags.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-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/libstdc++-hook.sh b/pkgs/development/compilers/gcc/libstdc++-hook.sh
index 2d30c845b5a3..893bbbc0c2dc 100644
--- a/pkgs/development/compilers/gcc/libstdc++-hook.sh
+++ b/pkgs/development/compilers/gcc/libstdc++-hook.sh
@@ -1,2 +1,2 @@
-export NIX_CXXSTDLIB_COMPILE+="-isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)"
+export NIX_CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)"
 export NIX_CXXSTDLIB_LINK=" -stdlib=libstdc++"
diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix
index 609d418693d7..06e44d2868a1 100644
--- a/pkgs/development/compilers/gcc/snapshot/default.nix
+++ b/pkgs/development/compilers/gcc/snapshot/default.nix
@@ -3,8 +3,6 @@
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
 , langJava ? false
-, langAda ? false
-, langVhdl ? false
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -21,13 +19,11 @@
 , libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
-, gnatboot ? null
 , enableMultilib ? false
 , enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
-, gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
@@ -41,8 +37,6 @@
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null
                        && perl != null;  # for `--enable-java-home'
-assert langAda      -> gnatboot != null;
-assert langVhdl     -> gnat != null;
 
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
@@ -67,9 +61,6 @@ let version = "7-20170409";
       [ ]
       ++ optional (targetPlatform != hostPlatform) ../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 {
@@ -262,8 +253,6 @@ stdenv.mkDerivation ({
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
     ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
-    ++ (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.
@@ -315,8 +304,6 @@ stdenv.mkDerivation ({
           ++ 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++"
@@ -349,9 +336,6 @@ stdenv.mkDerivation ({
     optional javaAwtGtk "--enable-java-awt=gtk" ++
     optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
 
-    # Ada
-    optional langAda "--enable-libada" ++
-
     (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -444,7 +428,7 @@ stdenv.mkDerivation ({
     ]);
 
   passthru =
-    { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
+    { inherit langC langCC langObjC langObjCpp langFortran langGo version; isGNU = true; };
 
   inherit enableParallelBuilding enableMultilib;
 
@@ -467,12 +451,10 @@ stdenv.mkDerivation ({
 
     maintainers = with stdenv.lib.maintainers; [ ];
 
-    # 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;
+      stdenv.lib.platforms.darwin;
 
     broken = true;
   };