summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-14 13:15:06 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-14 13:15:06 -0400
commitbf7d1bae20070e635b8ce05f7b6ca760acf0eb0f (patch)
tree05ad73d84da469154fade30bcd87cb4649ebc752 /pkgs/development/compilers
parent3a9654bfe29ebd987b7426faa25f00af1fab02c5 (diff)
parent4edfc0e93d679a809a0db0c953096726fcb97a28 (diff)
downloadnixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.tar
nixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.tar.gz
nixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.tar.bz2
nixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.tar.lz
nixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.tar.xz
nixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.tar.zst
nixlib-bf7d1bae20070e635b8ce05f7b6ca760acf0eb0f.zip
Merge remote-tracking branch 'upstream/master' into gcc-hurd-condition
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/adobe-flex-sdk/default.nix2
-rw-r--r--pkgs/development/compilers/arachne-pnr/default.nix6
-rwxr-xr-xpkgs/development/compilers/arm-frc-linux-gnueabi-gcc/default.nix98
-rwxr-xr-xpkgs/development/compilers/arm-frc-linux-gnueabi-gcc/minorSOname.patch49
-rwxr-xr-xpkgs/development/compilers/arm-frc-linux-gnueabi-gcc/no-nested-deprecated-warnings.patch22
-rw-r--r--pkgs/development/compilers/as31/default.nix3
-rw-r--r--pkgs/development/compilers/ats2/default.nix6
-rw-r--r--pkgs/development/compilers/avian/default.nix16
-rw-r--r--pkgs/development/compilers/binaryen/default.nix25
-rw-r--r--pkgs/development/compilers/ccl/default.nix15
-rw-r--r--pkgs/development/compilers/closure/default.nix4
-rw-r--r--pkgs/development/compilers/coreclr/default.nix17
-rw-r--r--pkgs/development/compilers/dtc/default.nix2
-rw-r--r--pkgs/development/compilers/ecl/16.1.2.nix20
-rw-r--r--pkgs/development/compilers/ecl/default.nix6
-rw-r--r--pkgs/development/compilers/edk2/default.nix23
-rw-r--r--pkgs/development/compilers/eli/default.nix91
-rw-r--r--pkgs/development/compilers/elm/default.nix21
-rw-r--r--pkgs/development/compilers/elm/packages/elm-package.nix6
-rw-r--r--pkgs/development/compilers/emscripten/default.nix27
-rw-r--r--pkgs/development/compilers/emscripten/fastcomp/default.nix (renamed from pkgs/development/compilers/emscripten-fastcomp/default.nix)4
-rw-r--r--pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix (renamed from pkgs/development/compilers/emscripten-fastcomp/emscripten-fastcomp.nix)17
-rw-r--r--pkgs/development/compilers/fpc/lazarus.nix4
-rw-r--r--pkgs/development/compilers/gambit/bootstrap.nix2
-rw-r--r--pkgs/development/compilers/gambit/build.nix70
-rw-r--r--pkgs/development/compilers/gambit/default.nix72
-rw-r--r--pkgs/development/compilers/gambit/unstable.nix11
-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)353
-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
-rw-r--r--pkgs/development/compilers/gerbil/build.nix88
-rw-r--r--pkgs/development/compilers/gerbil/default.nix94
-rw-r--r--pkgs/development/compilers/gerbil/unstable.nix12
-rw-r--r--pkgs/development/compilers/ghc/7.0.4-binary.nix146
-rw-r--r--pkgs/development/compilers/ghc/7.0.4.nix67
-rw-r--r--pkgs/development/compilers/ghc/7.4.2-binary.nix148
-rw-r--r--pkgs/development/compilers/ghc/7.4.2.nix77
-rw-r--r--pkgs/development/compilers/ghc/7.6.3.nix103
-rw-r--r--pkgs/development/compilers/ghc/7.8.4-binary.nix156
-rw-r--r--pkgs/development/compilers/ghc/7.8.4.nix91
-rw-r--r--pkgs/development/compilers/ghc/8.2.1-binary.nix3
-rw-r--r--pkgs/development/compilers/ghc/8.2.2.nix2
-rw-r--r--pkgs/development/compilers/ghc/8.4.2.nix (renamed from pkgs/development/compilers/ghc/8.4.1.nix)40
-rw-r--r--pkgs/development/compilers/ghc/abi-depends-determinism.nix12
-rw-r--r--pkgs/development/compilers/ghc/fix-7.0.4-clang.patch74
-rw-r--r--pkgs/development/compilers/ghc/fix-7.2.2-clang.patch74
-rw-r--r--pkgs/development/compilers/ghc/fix-7.4.2-clang.patch57
-rw-r--r--pkgs/development/compilers/ghc/fix-7.6.3-clang.patch71
-rw-r--r--pkgs/development/compilers/ghc/head.nix4
-rw-r--r--pkgs/development/compilers/ghc/hpc-7.8.4.patch13
-rw-r--r--pkgs/development/compilers/ghcjs/base.nix2
-rw-r--r--pkgs/development/compilers/ghcjs/default.nix1
-rw-r--r--pkgs/development/compilers/ghdl/default.nix44
-rw-r--r--pkgs/development/compilers/glslang/default.nix24
-rw-r--r--pkgs/development/compilers/gnatboot/default.nix48
-rw-r--r--pkgs/development/compilers/go/1.10.nix11
-rw-r--r--pkgs/development/compilers/go/1.9.nix11
-rw-r--r--pkgs/development/compilers/gprolog/default.nix2
-rw-r--r--pkgs/development/compilers/graalvm/default.nix2
-rw-r--r--pkgs/development/compilers/haxe/default.nix20
-rw-r--r--pkgs/development/compilers/hhvm/default.nix2
-rw-r--r--pkgs/development/compilers/iasl/default.nix4
-rw-r--r--pkgs/development/compilers/icedtea-web/default.nix4
-rw-r--r--pkgs/development/compilers/jetbrains-jdk/default.nix4
-rw-r--r--pkgs/development/compilers/jsonnet/default.nix4
-rw-r--r--pkgs/development/compilers/julia/0.5.nix2
-rw-r--r--pkgs/development/compilers/julia/0.6.nix14
-rw-r--r--pkgs/development/compilers/julia/default.nix5
-rw-r--r--pkgs/development/compilers/julia/git.nix2
-rw-r--r--pkgs/development/compilers/kotlin/default.nix9
-rw-r--r--pkgs/development/compilers/ldc/default.nix26
-rw-r--r--pkgs/development/compilers/llvm/3.4/llvm.nix2
-rw-r--r--pkgs/development/compilers/llvm/3.5/llvm.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/cmdline-help.patch39
-rw-r--r--pkgs/development/compilers/llvm/4/lldb.nix5
-rw-r--r--pkgs/development/compilers/llvm/4/llvm.nix7
-rw-r--r--pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch368
-rw-r--r--pkgs/development/compilers/llvm/5/llvm.nix4
-rw-r--r--pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch370
-rw-r--r--pkgs/development/compilers/llvm/6/clang/default.nix108
-rw-r--r--pkgs/development/compilers/llvm/6/clang/purity.patch30
-rw-r--r--pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch155
-rw-r--r--pkgs/development/compilers/llvm/6/default.nix78
-rw-r--r--pkgs/development/compilers/llvm/6/libc++/default.nix51
-rw-r--r--pkgs/development/compilers/llvm/6/libc++/setup-hook.sh3
-rw-r--r--pkgs/development/compilers/llvm/6/libc++abi.nix49
-rw-r--r--pkgs/development/compilers/llvm/6/lld.nix33
-rw-r--r--pkgs/development/compilers/llvm/6/lldb.nix56
-rw-r--r--pkgs/development/compilers/llvm/6/llvm-outputs.patch26
-rw-r--r--pkgs/development/compilers/llvm/6/llvm.nix185
-rw-r--r--pkgs/development/compilers/llvm/6/openmp.nix26
-rw-r--r--pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch377
-rw-r--r--pkgs/development/compilers/manticore/default.nix12
-rw-r--r--pkgs/development/compilers/mit-scheme/default.nix2
-rw-r--r--pkgs/development/compilers/mono/4.0.nix3
-rw-r--r--pkgs/development/compilers/mono/generic-cmake.nix10
-rw-r--r--pkgs/development/compilers/mono/generic.nix8
-rw-r--r--pkgs/development/compilers/nasm/default.nix4
-rw-r--r--pkgs/development/compilers/neko/default.nix2
-rw-r--r--pkgs/development/compilers/ocaml/4.07.nix9
-rw-r--r--pkgs/development/compilers/ocaml/generic.nix3
-rw-r--r--pkgs/development/compilers/opendylan/bin.nix4
-rw-r--r--pkgs/development/compilers/opendylan/default.nix8
-rw-r--r--pkgs/development/compilers/openjdk/10.nix (renamed from pkgs/development/compilers/openjdk/9.nix)102
-rw-r--r--pkgs/development/compilers/openjdk/7.nix244
-rw-r--r--pkgs/development/compilers/openjdk/8.nix24
-rw-r--r--pkgs/development/compilers/openjdk/bootstrap.nix60
-rw-r--r--pkgs/development/compilers/openjdk/cppflags-include-fix.patch16
-rw-r--r--pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch (renamed from pkgs/development/compilers/openjdk/currency-date-range.patch)5
-rw-r--r--pkgs/development/compilers/openjdk/darwin/8.nix (renamed from pkgs/development/compilers/openjdk-darwin/8.nix)5
-rw-r--r--pkgs/development/compilers/openjdk/darwin/default.nix (renamed from pkgs/development/compilers/openjdk-darwin/default.nix)5
-rw-r--r--pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch (renamed from pkgs/development/compilers/openjdk/fix-java-home-jdk9.patch)10
-rw-r--r--pkgs/development/compilers/openjdk/fix-java-home.patch17
-rw-r--r--pkgs/development/compilers/openjdk/paxctl.patch28
-rw-r--r--pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch (renamed from pkgs/development/compilers/openjdk/read-truststore-from-env-jdk9.patch)4
-rw-r--r--pkgs/development/compilers/openjdk/read-truststore-from-env.patch21
-rw-r--r--pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch (renamed from pkgs/development/compilers/openjdk/swing-use-gtk-jdk9.patch)6
-rw-r--r--pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch (renamed from pkgs/development/compilers/openjdk/swing-use-gtk.patch)0
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk10-linux.nix (renamed from pkgs/development/compilers/oraclejdk/jdk9-linux.nix)15
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix10
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix10
-rw-r--r--pkgs/development/compilers/owl-lisp/default.nix10
-rw-r--r--pkgs/development/compilers/polyml/default.nix4
-rw-r--r--pkgs/development/compilers/purescript/psc-package/default.nix4
-rw-r--r--pkgs/development/compilers/rust/bootstrap.nix16
-rw-r--r--pkgs/development/compilers/rust/default.nix16
-rw-r--r--pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch12
-rw-r--r--pkgs/development/compilers/rust/rustc.nix17
-rw-r--r--pkgs/development/compilers/sbcl/default.nix4
-rw-r--r--pkgs/development/compilers/scala/default.nix4
-rw-r--r--pkgs/development/compilers/sdcc/default.nix4
-rw-r--r--pkgs/development/compilers/solc/default.nix40
-rw-r--r--pkgs/development/compilers/solc/patches/boost-shared-libs.patch24
-rw-r--r--pkgs/development/compilers/solc/patches/shared-libs-install.patch64
-rw-r--r--pkgs/development/compilers/souffle/default.nix27
-rw-r--r--pkgs/development/compilers/swi-prolog/default.nix8
-rw-r--r--pkgs/development/compilers/swift/default.nix66
-rw-r--r--pkgs/development/compilers/swift/patches/0003-build-presets-linux-disable-tests.patch38
-rw-r--r--pkgs/development/compilers/swift/patches/icu59.patch113
-rw-r--r--pkgs/development/compilers/swift/patches/remove_xlocale.patch54
-rw-r--r--pkgs/development/compilers/swift/patches/sigaltstack.patch11
-rw-r--r--pkgs/development/compilers/swift/patches/sigunused.patch11
-rw-r--r--pkgs/development/compilers/swift/purity.patch20
-rw-r--r--pkgs/development/compilers/teyjus/default.nix10
-rw-r--r--pkgs/development/compilers/teyjus/fix-lex-to-flex.patch10
-rw-r--r--pkgs/development/compilers/vala/default.nix24
-rw-r--r--pkgs/development/compilers/yosys/default.nix24
-rw-r--r--pkgs/development/compilers/zig/default.nix11
-rw-r--r--pkgs/development/compilers/zulu/8.nix8
-rw-r--r--pkgs/development/compilers/zulu/default.nix8
162 files changed, 3274 insertions, 3090 deletions
diff --git a/pkgs/development/compilers/adobe-flex-sdk/default.nix b/pkgs/development/compilers/adobe-flex-sdk/default.nix
index ccb366ffe1cb..63dd315e8e4e 100644
--- a/pkgs/development/compilers/adobe-flex-sdk/default.nix
+++ b/pkgs/development/compilers/adobe-flex-sdk/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "Flex SDK for Adobe Flash / ActionScript";
-    homepage = "http://www.adobe.com/products/flex.html";
+    homepage = "https://www.adobe.com/products/flex.html";
     license = stdenv.lib.licenses.mpl11;
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/compilers/arachne-pnr/default.nix b/pkgs/development/compilers/arachne-pnr/default.nix
index 97eb8e8b6421..bf8511704f80 100644
--- a/pkgs/development/compilers/arachne-pnr/default.nix
+++ b/pkgs/development/compilers/arachne-pnr/default.nix
@@ -4,13 +4,13 @@ with builtins;
 
 stdenv.mkDerivation rec {
   name = "arachne-pnr-${version}";
-  version = "2018.02.14";
+  version = "2018.05.03";
 
   src = fetchFromGitHub {
     owner  = "cseed";
     repo   = "arachne-pnr";
-    rev    = "b54675413f9aac1d9a1fb0a8e9354bec2a2a8f3c";
-    sha256 = "06slsb239qk1r2g96n1g37yp8314cy7yi4g1yf86fr87fr11ml8l";
+    rev    = "ea2d04215bc0fd6072cda244caeb6670892033b3";
+    sha256 = "0qhf5djyh0pzmgv33rjnnqq6asmmwxjdadvr18a83iy9pll6gg5k";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/default.nix b/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/default.nix
deleted file mode 100755
index 6fa25df5e033..000000000000
--- a/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/default.nix
+++ /dev/null
@@ -1,98 +0,0 @@
-{stdenv, fetchurl
-, arm-frc-linux-gnueabi-binutils, arm-frc-linux-gnueabi-eglibc, arm-frc-linux-gnueabi-linux-api-headers
-, elfutils
-, libmpc, gmp, mpfr, zlib, isl_0_15, cloog}:
-
-stdenv.mkDerivation rec {
-  _target = "arm-frc-linux-gnueabi";
-
-  version = "4.9.4";
-  name = "${_target}-gcc-${version}";
-
-  src = fetchurl {
-    url = "ftp://gcc.gnu.org/pub/gcc/releases/gcc-${version}/gcc-${version}.tar.bz2";
-    sha256 = "6c11d292cd01b294f9f84c9a59c230d80e9e4a47e5c6355f046bb36d4f358092";
-  };
-
-  patches = [
-    ./minorSOname.patch
-    ./no-nested-deprecated-warnings.patch
-  ];
-
-  hardeningDisable = [ "format" ];
-
-  buildInputs = [
-    arm-frc-linux-gnueabi-binutils
-    arm-frc-linux-gnueabi-eglibc
-    arm-frc-linux-gnueabi-linux-api-headers
-    elfutils
-    libmpc
-    gmp
-    mpfr
-    zlib
-    isl_0_15
-    cloog
-  ];
-
-
-  configurePhase = ''
-    mkdir gcc-build
-    cd gcc-build
-    ../configure \
-      --prefix=$out \
-      --host=$CHOST \
-      --build=$CHOST \
-      --program-prefix=${_target}- \
-      --target=${_target} \
-      --enable-shared \
-      --disable-nls \
-      --enable-threads=posix \
-      --enable-languages=c,c++ \
-      --disable-multilib \
-      --disable-multiarch \
-      --with-sysroot=${arm-frc-linux-gnueabi-eglibc}/${_target} \
-      --with-build-sysroot=${arm-frc-linux-gnueabi-eglibc}/${_target} \
-      --with-as=${arm-frc-linux-gnueabi-binutils}/${_target}/bin/as \
-      --with-ld=${arm-frc-linux-gnueabi-binutils}/${_target}/bin/ld \
-      --with-cpu=cortex-a9 \
-      --with-float=softfp \
-      --with-fpu=vfp \
-      --with-specs='%{save-temps:-fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' \
-      --enable-lto \
-      --with-pkgversion='GCC-for-FRC' \
-      --with-cloog \
-      --enable-poison-system-directories \
-      --enable-plugin \
-      --with-system-zlib \
-      --disable-libmudflap \
-      --disable-libsanitizer
-  '';
-
-  makeFlags = [
-    "all-gcc"
-    "all-target-libgcc"
-    "all-target-libstdc++-v3"
-  ];
-
-  installPhase = ''
-    make install-gcc install-target-libgcc install-target-libstdc++-v3
-  '';
-
-  postInstall = ''
-    rm -rf $out/share/{man/man7,info}/ "$out/share/gcc-${version}/python"
-  '';
-
-  meta = with stdenv.lib; {
-    description = "FRC cross compiler";
-    longDescription = ''
-      arm-frc-linux-gnueabi-gcc is a cross compiler for building
-      code for FIRST Robotics Competition. Used as a cross compiler
-      for the NI RoboRio.
-    '';
-    license = licenses.gpl2;
-    maintainers = [ maintainers.colescott ];
-    platforms = platforms.linux;
-
-    priority = 4;
-  };
-}
diff --git a/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/minorSOname.patch b/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/minorSOname.patch
deleted file mode 100755
index d97d12bc629a..000000000000
--- a/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/minorSOname.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-Description: Make the default SONAME include minor numbers (c++)

- This patch adds .0.20 to the end of the SONAME for libstdc++ to support

- independent side-by-side usage of .17 and .20.

- .

- gcc-armel (4.9.1-0frc2) trusty; urgency=low

- .

-   * Fixing dependency ambiguity yet again...

-Author: Patrick Plenefisch <phplenefisch@wpi.edu>

-

----

-

---- gcc-armel-4.9.1.orig/libstdc++-v3/configure

-+++ gcc-armel-4.9.1/libstdc++-v3/configure

-@@ -10698,7 +10698,7 @@ gnu*)

-   need_lib_prefix=no

-   need_version=no

-   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'

--  soname_spec='${libname}${release}${shared_ext}$major'

-+  soname_spec='${libname}${release}${shared_ext}$versuffix'

-   shlibpath_var=LD_LIBRARY_PATH

-   hardcode_into_libs=yes

-   ;;

-@@ -10824,7 +10824,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)

-   need_lib_prefix=no

-   need_version=no

-   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'

--  soname_spec='${libname}${release}${shared_ext}$major'

-+  soname_spec='${libname}${release}${shared_ext}$versuffix'

-   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'

-   shlibpath_var=LD_LIBRARY_PATH

-   shlibpath_overrides_runpath=no

-@@ -14382,7 +14382,7 @@ gnu*)

-   need_lib_prefix=no

-   need_version=no

-   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'

--  soname_spec='${libname}${release}${shared_ext}$major'

-+  soname_spec='${libname}${release}${shared_ext}$versuffix'

-   shlibpath_var=LD_LIBRARY_PATH

-   hardcode_into_libs=yes

-   ;;

-@@ -14508,7 +14508,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)

-   need_lib_prefix=no

-   need_version=no

-   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'

--  soname_spec='${libname}${release}${shared_ext}$major'

-+  soname_spec='${libname}${release}${shared_ext}$versuffix'

-   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'

-   shlibpath_var=LD_LIBRARY_PATH

-   shlibpath_overrides_runpath=no

diff --git a/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/no-nested-deprecated-warnings.patch b/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/no-nested-deprecated-warnings.patch
deleted file mode 100755
index 050a63e92fd6..000000000000
--- a/pkgs/development/compilers/arm-frc-linux-gnueabi-gcc/no-nested-deprecated-warnings.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Description: Get rid of recursive deprecated warnings.

- As is, gcc gives warnings when a function with the

- deprecated attribute calls another function with

- the deprecated attribute.

- See http://stackoverflow.com/questions/13459602/how-can-i-get-rid-of-deprecated-warnings-in-deprecated-functions-in-gcc

-

-Author: James Kuszmaul <jbkuszmaul@wpi.edu>

-

---

-

---- gcc-armel-4.9.1.orig/gcc/tree.c

-+++ gcc-armel-4.9.1/gcc/tree.c

-@@ -12063,6 +12063,9 @@ warn_deprecated_use (tree node, tree attr)

-   if (node == 0 || !warn_deprecated_decl)

-     return;

-

-+  if (current_function_decl && TREE_DEPRECATED(current_function_decl))

-+    return;

-+

-   if (!attr)

-     {

-       if (DECL_P (node))

diff --git a/pkgs/development/compilers/as31/default.nix b/pkgs/development/compilers/as31/default.nix
index 93b251707e80..519992fd8c26 100644
--- a/pkgs/development/compilers/as31/default.nix
+++ b/pkgs/development/compilers/as31/default.nix
@@ -15,9 +15,8 @@ in stdenv.mkDerivation {
   buildInputs = [ yacc ];
 
   patches = [
-    # CVE-2012-0808
     (fetchpatch {
-       name = "as31-mkstemps.patch";
+       name = "CVE-2012-0808.patch";
        url = "https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=655496;filename=as31-mkstemps.patch;msg=5";
        sha256 = "0iia4wa8m141bwz4588yxb1dp2qwhapcii382sncm6jvwyngwh21";
      })
diff --git a/pkgs/development/compilers/ats2/default.nix b/pkgs/development/compilers/ats2/default.nix
index 6c523ebb4f14..579af7a8d232 100644
--- a/pkgs/development/compilers/ats2/default.nix
+++ b/pkgs/development/compilers/ats2/default.nix
@@ -3,11 +3,11 @@
 , withContrib ? true }:
 
 let
-  versionPkg = "0.3.7" ;
+  versionPkg = "0.3.9" ;
 
   contrib = fetchurl {
     url = "mirror://sourceforge/ats2-lang/ATS2-Postiats-contrib-${versionPkg}.tgz" ;
-    sha256 = "1w59ir9ij5bvvnxj6fb1rvzycfqa57i31wmpwawxbsb10bqwzyr6";
+    sha256 = "627bb99ecf2e3d5976f95f2faa13c7c330726601e8bb05a2113c9b69c98749b5";
   };
 
   postInstallContrib = stdenv.lib.optionalString withContrib
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://sourceforge/ats2-lang/ATS2-Postiats-${version}.tgz";
-    sha256 = "19nxyi39fn42sp38kl14a6pvbxq9wr8y405wx0zz7mqb77r0m0h5";
+    sha256 = "c69a7c58964df26227e77656659129ca4c05205d2ebcacc7084edba818fb6e81";
   };
 
   buildInputs = [ gmp ];
diff --git a/pkgs/development/compilers/avian/default.nix b/pkgs/development/compilers/avian/default.nix
index 3d58e75200c8..4dc384f70a34 100644
--- a/pkgs/development/compilers/avian/default.nix
+++ b/pkgs/development/compilers/avian/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, zlib, jdk }:
+{ stdenv, fetchFromGitHub, zlib, jdk, CoreServices, Foundation }:
 
 stdenv.mkDerivation rec {
   name = "avian-${version}";
@@ -11,10 +11,16 @@ stdenv.mkDerivation rec {
     sha256 = "1j2y45cpqk3x6a743mgpg7z3ivwm7qc9jy6xirvay7ah1qyxmm48";
   };
 
-  buildInputs = [
-    zlib
-    jdk
-  ];
+  buildInputs = [ zlib jdk ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Foundation ];
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-Wno-error";
+
+  postPatch = ''
+    substituteInPlace makefile \
+        --replace 'g++' 'c++' \
+        --replace 'gcc' 'cc'
+  '';
 
   installPhase = ''
     mkdir -p $out/bin
diff --git a/pkgs/development/compilers/binaryen/default.nix b/pkgs/development/compilers/binaryen/default.nix
index 3f9ee17ca279..fc75fe92c730 100644
--- a/pkgs/development/compilers/binaryen/default.nix
+++ b/pkgs/development/compilers/binaryen/default.nix
@@ -1,14 +1,31 @@
-{ stdenv, cmake, fetchFromGitHub }:
+{ stdenv, cmake, fetchFromGitHub, emscriptenRev ? null }:
+
+let
+  defaultVersion = "45";
+
+  # Map from git revs to SHA256 hashes
+  sha256s = {
+    "version_45" = "1wgzfzjjzkiaz0rf2lnwrcvlcsjvjhyvbyh58jxhqq43vi34zyjc";
+    "1.37.36" = "1wgzfzjjzkiaz0rf2lnwrcvlcsjvjhyvbyh58jxhqq43vi34zyjc";
+  };
+in
 
 stdenv.mkDerivation rec {
-  version = "42";
-  rev = "version_${version}";
+  version = if emscriptenRev == null
+            then defaultVersion
+            else "emscripten-${emscriptenRev}";
+  rev = if emscriptenRev == null
+        then "version_${version}"
+        else emscriptenRev;
   name = "binaryen-${version}";
 
   src = fetchFromGitHub {
     owner = "WebAssembly";
     repo = "binaryen";
-    sha256 = "0b8qc9cd7ncshgfjwv4hfapmwa81gmniaycnxmdkihq9bpm26x2k";
+    sha256 =
+      if builtins.hasAttr rev sha256s
+      then builtins.getAttr rev sha256s
+      else null;
     inherit rev;
   };
 
diff --git a/pkgs/development/compilers/ccl/default.nix b/pkgs/development/compilers/ccl/default.nix
index 087f74700214..f3a4ff74aa05 100644
--- a/pkgs/development/compilers/ccl/default.nix
+++ b/pkgs/development/compilers/ccl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gcc, glibc, m4, coreutils }:
+{ stdenv, fetchurl, bootstrap_cmds, coreutils, glibc, m4 }:
 
 let
   options = rec {
@@ -27,19 +27,11 @@ let
       runtime = "dx86cl64";
       kernel = "darwinx8664";
     };
-    i686-darwin = {
-      arch = "darwinx86";
-      sha256 = x86_64-darwin.sha256;
-      runtime = "dx86cl";
-      kernel = "darwinx8632";
-    };
     armv6l-linux = armv7l-linux;
   };
-  cfg = options.${stdenv.system};
+  cfg = options."${stdenv.system}" or (throw "missing source url for platform ${stdenv.system}");
 in
 
-assert builtins.hasAttr stdenv.system options;
-
 stdenv.mkDerivation rec {
   name     = "ccl-${version}";
   version  = "1.11.5";
@@ -49,7 +41,7 @@ stdenv.mkDerivation rec {
     sha256 = cfg.sha256;
   };
 
-  buildInputs = if stdenv.isDarwin then [ m4 ] else [ gcc glibc m4 ];
+  buildInputs = if stdenv.isDarwin then [ bootstrap_cmds m4 ] else [ glibc m4 ];
 
   CCL_RUNTIME = cfg.runtime;
   CCL_KERNEL = cfg.kernel;
@@ -58,7 +50,6 @@ stdenv.mkDerivation rec {
     substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \
       --replace "M4 = gm4"   "M4 = m4" \
       --replace "dtrace"     "/usr/sbin/dtrace" \
-      --replace "mig"        "/usr/bin/mig" \
       --replace "/bin/rm"    "${coreutils}/bin/rm" \
       --replace "/bin/echo"  "${coreutils}/bin/echo"
 
diff --git a/pkgs/development/compilers/closure/default.nix b/pkgs/development/compilers/closure/default.nix
index 8d1b06f52b70..0dfa10f28a12 100644
--- a/pkgs/development/compilers/closure/default.nix
+++ b/pkgs/development/compilers/closure/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "closure-compiler-${version}";
-  version = "20170910";
+  version = "20180506";
 
   src = fetchurl {
     url = "https://dl.google.com/closure-compiler/compiler-${version}.tar.gz";
-    sha256 = "0znzsks8ql9qajhcjzfkhmnpz8zs6b8cji04fhivyq973jpxxrak";
+    sha256 = "10w9vs61fs14k8g3wlng0ifj0knfm0xfc4rsnd2c75464hkdxvr9";
   };
 
   sourceRoot = ".";
diff --git a/pkgs/development/compilers/coreclr/default.nix b/pkgs/development/compilers/coreclr/default.nix
index 0681e8210a6a..3861501d3996 100644
--- a/pkgs/development/compilers/coreclr/default.nix
+++ b/pkgs/development/compilers/coreclr/default.nix
@@ -19,13 +19,13 @@
 
 stdenv.mkDerivation rec {
   name = "coreclr-${version}";
-  version = "2.0.0";
+  version = "2.0.7";
 
   src = fetchFromGitHub {
     owner  = "dotnet";
     repo   = "coreclr";
     rev    = "v${version}";
-    sha256 = "16z58ix8kmk8csfy5qsqz8z30czhrap2vb8s8vdflmbcfnq31jcw";
+    sha256 = "0pzkrfgqywhpijbx7j1v4lxa6270h6whymb64jdkp7yj56ipqh2n";
   };
 
   patches = [
@@ -34,12 +34,20 @@ stdenv.mkDerivation rec {
       url = https://github.com/dotnet/coreclr/commit/a8f83b615708c529b112898e7d2fbc3f618b26ee.patch;
       sha256 = "047ph5gip4z2h7liwdxsmpnlaq0sd3hliaw4nyqjp647m80g3ffq";
     })
+    (fetchpatch {
+      # clang 5
+      url = https://github.com/dotnet/coreclr/commit/9b22e1a767dee38f351001c5601f56d78766a43e.patch;
+      sha256 = "1w1lxw5ryvhq8m5m0kv880c4bh6y9xdgypkr76sqbh3v568yghzg";
+    })
   ];
 
-  buildInputs = [
+  nativeBuildInputs = [
     which
     cmake
     clang
+  ];
+
+  buildInputs = [
     llvmPackages.llvm
     llvmPackages.lldb
     libunwind
@@ -68,7 +76,8 @@ stdenv.mkDerivation rec {
 
   buildPhase = ''
     runHook preBuild
-    ./build.sh $BuildArch $BuildType
+    # disable -Werror which can potentially breaks with every compiler upgrade
+    ./build.sh $BuildArch $BuildType cmakeargs "-DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
     runHook postBuild
   '';
 
diff --git a/pkgs/development/compilers/dtc/default.nix b/pkgs/development/compilers/dtc/default.nix
index fd02f779b3cf..b342bd945858 100644
--- a/pkgs/development/compilers/dtc/default.nix
+++ b/pkgs/development/compilers/dtc/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "1.4.5";
 
   src = fetchgit {
-    url = "git://git.kernel.org/pub/scm/utils/dtc/dtc.git";
+    url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git";
     rev = "refs/tags/v${version}";
     sha256 = "10y5pbkcj5gkijcgnlvrh6q2prpnvsgihb9asz3zfp66mcjwzsy3";
   };
diff --git a/pkgs/development/compilers/ecl/16.1.2.nix b/pkgs/development/compilers/ecl/16.1.2.nix
index 30fee77321f5..291b0ed013d6 100644
--- a/pkgs/development/compilers/ecl/16.1.2.nix
+++ b/pkgs/development/compilers/ecl/16.1.2.nix
@@ -1,10 +1,14 @@
-{stdenv, fetchurl
+{ stdenv, fetchurl, fetchpatch
 , libtool, autoconf, automake
 , gmp, mpfr, libffi, makeWrapper
 , noUnicode ? false
 , gcc
-, threadSupport ? true
+, threadSupport ? false
+, useBoehmgc ? true, boehmgc
 }:
+
+assert useBoehmgc -> boehmgc != null;
+
 let
   s = # Generated upstream information
   rec {
@@ -19,6 +23,9 @@ let
   ];
   propagatedBuildInputs = [
     libffi gmp mpfr gcc
+  ] ++ stdenv.lib.optionals useBoehmgc [
+    # replaces ecl's own gc which other packages can depend on, thus propagated
+    boehmgc
   ];
 in
 stdenv.mkDerivation {
@@ -39,6 +46,15 @@ stdenv.mkDerivation {
       "--enable-unicode")
     ;
 
+  patches = [
+    (fetchpatch {
+      # Avoid infinite loop, see https://gitlab.com/embeddable-common-lisp/ecl/issues/43 (fixed upstream)
+      name = "avoid-infinite-loop.patch";
+      url = "https://gitlab.com/embeddable-common-lisp/ecl/commit/caba1989f40ef917e7486f41b9cd5c7e3c5c2d79.patch";
+      sha256 = "07vw91psbc9gdn8grql46ra8lq3bgkzg5v480chnbryna4sv6lbb";
+    })
+  ];
+
   hardeningDisable = [ "format" ];
 
   postInstall = ''
diff --git a/pkgs/development/compilers/ecl/default.nix b/pkgs/development/compilers/ecl/default.nix
index e506e3aace1f..33ed690772ea 100644
--- a/pkgs/development/compilers/ecl/default.nix
+++ b/pkgs/development/compilers/ecl/default.nix
@@ -4,6 +4,7 @@
 , noUnicode ? false
 , gcc
 , threadSupport ? true
+, useBoehmgc ? false, boehmgc
 }:
 let
   s = # Generated upstream information
@@ -20,6 +21,10 @@ let
   ];
   propagatedBuildInputs = [
     libffi gmp mpfr gcc
+    # replaces ecl's own gc which other packages can depend on, thus propagated
+  ] ++ stdenv.lib.optionals useBoehmgc [
+    # replaces ecl's own gc which other packages can depend on, thus propagated
+    boehmgc
   ];
 in
 stdenv.mkDerivation {
@@ -53,6 +58,7 @@ stdenv.mkDerivation {
   meta = {
     inherit (s) version;
     description = "Lisp implementation aiming to be small, fast and easy to embed";
+    homepage = https://common-lisp.net/project/ecl/;
     license = stdenv.lib.licenses.mit ;
     maintainers = [stdenv.lib.maintainers.raskin];
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/development/compilers/edk2/default.nix b/pkgs/development/compilers/edk2/default.nix
index 4b87beb08794..1dc4430dc6a7 100644
--- a/pkgs/development/compilers/edk2/default.nix
+++ b/pkgs/development/compilers/edk2/default.nix
@@ -7,6 +7,8 @@ targetArch = if stdenv.isi686 then
   "IA32"
 else if stdenv.isx86_64 then
   "X64"
+else if stdenv.isAarch64 then
+  "AARCH64"
 else
   throw "Unsupported architecture";
 
@@ -48,7 +50,7 @@ edk2 = stdenv.mkDerivation {
     homepage = https://sourceforge.net/projects/edk2/;
     license = stdenv.lib.licenses.bsd2;
     branch = "UDK2017";
-    platforms = ["x86_64-linux" "i686-linux"];
+    platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"];
   };
 
   passthru = {
@@ -58,13 +60,20 @@ edk2 = stdenv.mkDerivation {
 
       configurePhase = ''
         mkdir -v Conf
-        sed -e 's|Nt32Pkg/Nt32Pkg.dsc|${projectDscPath}|' -e \
-          's|MYTOOLS|GCC49|' -e 's|IA32|${targetArch}|' -e 's|DEBUG|RELEASE|'\
-          < ${edk2}/BaseTools/Conf/target.template > Conf/target.txt
-        sed -e 's|DEFINE GCC48_IA32_PREFIX       = /usr/bin/|DEFINE GCC48_IA32_PREFIX       = ""|' \
+
+        cp ${edk2}/BaseTools/Conf/target.template Conf/target.txt
+        sed -i Conf/target.txt \
+          -e 's|Nt32Pkg/Nt32Pkg.dsc|${projectDscPath}|' \
+          -e 's|MYTOOLS|GCC49|' \
+          -e 's|IA32|${targetArch}|' \
+          -e 's|DEBUG|RELEASE|'\
+
+        cp ${edk2}/BaseTools/Conf/tools_def.template Conf/tools_def.txt
+        sed -i Conf/tools_def.txt \
+          -e 's|DEFINE GCC48_IA32_PREFIX       = /usr/bin/|DEFINE GCC48_IA32_PREFIX       = ""|' \
           -e 's|DEFINE GCC48_X64_PREFIX        = /usr/bin/|DEFINE GCC48_X64_PREFIX        = ""|' \
-          -e 's|DEFINE UNIX_IASL_BIN           = /usr/bin/iasl|DEFINE UNIX_IASL_BIN           = ${iasl}/bin/iasl|' \
-          < ${edk2}/BaseTools/Conf/tools_def.template > Conf/tools_def.txt
+          -e 's|DEFINE UNIX_IASL_BIN           = /usr/bin/iasl|DEFINE UNIX_IASL_BIN           = ${iasl}/bin/iasl|'
+
         export WORKSPACE="$PWD"
         export EFI_SOURCE="$PWD/EdkCompatibilityPkg"
         ln -sv ${edk2}/BaseTools BaseTools
diff --git a/pkgs/development/compilers/eli/default.nix b/pkgs/development/compilers/eli/default.nix
new file mode 100644
index 000000000000..93e53aa30d13
--- /dev/null
+++ b/pkgs/development/compilers/eli/default.nix
@@ -0,0 +1,91 @@
+{ stdenv
+, fetchurl
+, symlinkJoin
+, makeWrapper
+, tcl
+, fontconfig
+, tk
+, ncurses
+, xorg
+, file
+}:
+
+let
+  # eli derives the location of the include folder from the location of the lib folder
+  tk_combined = symlinkJoin {
+    name = "tk_combined";
+    paths = [
+      tk
+      tk.dev
+    ];
+  };
+  curses_combined = symlinkJoin {
+    name = "curses_combined";
+    paths = [
+      ncurses
+      ncurses.dev
+    ];
+  };
+in
+stdenv.mkDerivation rec {
+  name = "eli";
+  version = "4.8.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/eli-project/Eli/Eli%20${version}/eli-${version}.tar.bz2";
+    sha256="1vran8583hbwrr5dciji4zkhz3f88w4mn8n9sdpr6zw0plpf1whj";
+  };
+
+  buildInputs = [
+    ncurses
+    fontconfig
+  ] ++ (with xorg; [
+    libX11.dev
+    libXt.dev
+    libXaw.dev
+    libXext.dev
+  ]);
+
+  nativeBuildInputs = [
+    file
+    makeWrapper
+  ];
+
+  # skip interactive browser check
+  buildFlags = "nobrowsers";
+
+
+  preConfigure=''
+    configureFlagsArray=(
+      --with-tcltk="${tcl} ${tk_combined}"
+      --with-curses="${curses_combined}"
+    )
+    export ODIN_LOCALIPC=1
+  '';
+
+  postInstall = ''
+    wrapProgram "$out/bin/eli" \
+      --set ODIN_LOCALIPC 1
+  '';
+
+  # Test if eli starts
+  doInstallCheck = true;
+  installCheckPhase = ''
+    export HOME="$TMP/home"
+    mkdir -p "$HOME"
+    $out/bin/eli "!ls"
+  '';
+
+  meta = {
+    description = "Translator Construction Made Easy";
+    longDescription = ''
+      Eli is a programming environment that supports all phases of translator
+      construction with extensive libraries implementing common tasks, yet handling
+      arbitrary special cases. Output is the C subset of C++.
+    '';
+    homepage = http://eli-project.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = with stdenv.lib.maintainers; [ timokau ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/development/compilers/elm/default.nix b/pkgs/development/compilers/elm/default.nix
index 4520363a53b2..8ed34cf9d1e0 100644
--- a/pkgs/development/compilers/elm/default.nix
+++ b/pkgs/development/compilers/elm/default.nix
@@ -74,23 +74,26 @@ let
             elm-format = self.callPackage ./packages/elm-format.nix { };
             elm-interface-to-json = self.callPackage ./packages/elm-interface-to-json.nix {
               aeson-pretty = self.aeson-pretty_0_7_2;
+              either = hlib.overrideCabal self.either (drv :{
+                jailbreak = true;
+                version = "4.4.1.1";
+                sha256 = "1lrlwqqnm6ibfcydlv5qvvssw7bm0c6yypy0rayjzv1znq7wp1xh";
+                libraryHaskellDepends = drv.libraryHaskellDepends or [] ++ [
+                  self.exceptions self.free self.mmorph self.monad-control
+                  self.MonadRandom self.profunctors self.transformers
+                  self.transformers-base
+                ];
+              });
             };
           };
       in elmPkgs // {
         inherit elmPkgs;
         elmVersion = elmRelease.version;
-        # needed for elm-package
-        http-client = hlib.overrideCabal super.http-client (drv: {
-          version = "0.4.31.2";
-          sha256 = "12yq2l6bvmxg5w6cw5ravdh39g8smwn1j44mv36pfmkhm5402h8n";
-        });
-        http-client-tls = hlib.overrideCabal super.http-client-tls (drv: {
-          version = "0.2.4.1";
-          sha256 = "18wbca7jg15p0ds3339f435nqv2ng0fqc4bylicjzlsww625ij4d";
-        });
         # https://github.com/elm-lang/elm-compiler/issues/1566
         indents = hlib.overrideCabal super.indents (drv: {
           version = "0.3.3";
+          #test dep tasty has a version mismatch
+          doCheck = false;
           sha256 = "16lz21bp9j14xilnq8yym22p3saxvc9fsgfcf5awn2a6i6n527xn";
           libraryHaskellDepends = drv.libraryHaskellDepends ++ [super.concatenative];
         });
diff --git a/pkgs/development/compilers/elm/packages/elm-package.nix b/pkgs/development/compilers/elm/packages/elm-package.nix
index 4a60b3dfb387..49eddb58a142 100644
--- a/pkgs/development/compilers/elm/packages/elm-package.nix
+++ b/pkgs/development/compilers/elm/packages/elm-package.nix
@@ -1,6 +1,6 @@
 { mkDerivation, aeson, aeson-pretty_0_7_2, ansi-wl-pprint, base, binary
 , bytestring, containers, directory, edit-distance, elm-compiler
-, fetchgit, filepath, HTTP, http-client, http-client-tls
+, fetchgit, fetchurl, filepath, HTTP, http-client, http-client-tls
 , http-types, mtl, network, optparse-applicative, parallel-io
 , pretty, stdenv, text, time, unordered-containers, vector
 , zip-archive
@@ -13,6 +13,10 @@ mkDerivation {
     sha256 = "19krnkjvfk02gmmic5h5i1i0lw7s30927bnd5g57cj8nqbigysv7";
     rev = "8bd150314bacab5b6fc451927aa01deec2276fbf";
   };
+  patches = fetchurl {
+    url = https://github.com/jerith666/elm-package/commit/40bab60c2fbff70812cc24cdd97f5e09db3844ad.patch;
+    sha256 = "0j6pi6cv3h9s6vz68bh0c73fysvk83yhhk56kgshvnrmnpcb3jib";
+  };
   isLibrary = true;
   isExecutable = true;
   libraryHaskellDepends = [
diff --git a/pkgs/development/compilers/emscripten/default.nix b/pkgs/development/compilers/emscripten/default.nix
index ae80ad6fc808..8e268aa7eb74 100644
--- a/pkgs/development/compilers/emscripten/default.nix
+++ b/pkgs/development/compilers/emscripten/default.nix
@@ -1,10 +1,11 @@
-{ stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler
-, jre, binaryen, enableWasm ? true
+{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler, pkgs
+, jre, binaryen, enableWasm ? true ,  python2Packages, cmake
 }:
 
 let
-  rev = "1.37.16";
+  rev = emscriptenVersion;
   appdir = "share/emscripten";
+  binaryenVersioned = binaryen.override { emscriptenRev = rev; };
 in
 
 stdenv.mkDerivation {
@@ -13,10 +14,12 @@ stdenv.mkDerivation {
   src = fetchFromGitHub {
     owner = "kripken";
     repo = "emscripten";
-    sha256 = "1qyhjx5zza01vnwmj6qzxbkagxknn4kzb6gw12fqw5q8pa8fy4zy";
+    sha256 = "02p0cp86vd1mydlpq544xbydggpnrq9dhbxx7h08j235frjm5cdc";
     inherit rev;
   };
 
+  buildInputs = [ nodejs cmake python ];
+
   buildCommand = ''
     mkdir -p $out/${appdir}
     cp -r $src/* $out/${appdir}
@@ -38,9 +41,23 @@ stdenv.mkDerivation {
     echo "COMPILER_ENGINE = NODE_JS" >> $out/${appdir}/config
     echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> $out/${appdir}/config
     echo "JAVA = '${jre}/bin/java'" >> $out/${appdir}/config
+    # to make the test(s) below work
+    echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config
   ''
   + stdenv.lib.optionalString enableWasm ''
-    echo "BINARYEN_ROOT = '${binaryen}'" >> $out/share/emscripten/config
+    echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config
+  ''
+  +
+  ''
+    echo "--------------- running test -----------------"
+    # quick hack to get the test working
+    HOME=$TMPDIR
+    cp $out/${appdir}/config $HOME/.emscripten
+    export PATH=$PATH:$out/bin
+
+    #export EMCC_DEBUG=2  
+    ${python}/bin/python $src/tests/runner.py test_hello_world
+    echo "--------------- /running test -----------------"
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/compilers/emscripten-fastcomp/default.nix b/pkgs/development/compilers/emscripten/fastcomp/default.nix
index 490dace2faaf..10c1107da026 100644
--- a/pkgs/development/compilers/emscripten-fastcomp/default.nix
+++ b/pkgs/development/compilers/emscripten/fastcomp/default.nix
@@ -1,4 +1,4 @@
-{ newScope, stdenv, binutils-raw, wrapCCWith, symlinkJoin }:
+{ newScope, stdenv, binutils, wrapCCWith, symlinkJoin }:
 let
   callPackage = newScope (self // {inherit stdenv;});
 
@@ -7,7 +7,7 @@ let
     emscriptenfastcomp-wrapped = wrapCCWith {
       cc = self.emscriptenfastcomp-unwrapped;
       # Never want Apple's cctools for WASM target
-      bintools = binutils-raw;
+      bintools = binutils;
       libc = stdenv.cc.libc;
       extraBuildCommands = ''
         # hardening flags break WASM support
diff --git a/pkgs/development/compilers/emscripten-fastcomp/emscripten-fastcomp.nix b/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix
index f35ca26584f1..5317cf25d41b 100644
--- a/pkgs/development/compilers/emscripten-fastcomp/emscripten-fastcomp.nix
+++ b/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchFromGitHub, cmake, python, ... }:
+{ emscriptenVersion, stdenv, llvm, fetchFromGitHub, cmake, python, gtest, ... }:
 
 let
-  rev = "1.37.16";
+  rev = emscriptenVersion;
   gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
 in
 stdenv.mkDerivation rec {
@@ -10,18 +10,18 @@ stdenv.mkDerivation rec {
   src = fetchFromGitHub {
     owner = "kripken";
     repo = "emscripten-fastcomp";
-    sha256 = "0wj9sc0gciaiidcjv6wb0qn6ks06xds7q34351masc7qpvd217by";
+    sha256 = "04j698gmp686b5lricjakm5hyh2z2kh28m1ffkghmkyz4zkzmx98";
     inherit rev;
   };
 
   srcFL = fetchFromGitHub {
     owner = "kripken";
     repo = "emscripten-fastcomp-clang";
-    sha256 = "1akdgxzxhzjbhp4d14ajcrp9jrf39x004a726ly2gynqc185l4j7";
+    sha256 = "1ici51mmpgg80xk3y8f376nbbfak6rz27qdy98l8lxkrymklp5g5";
     inherit rev;
   };
 
-  nativeBuildInputs = [ cmake python ];
+  nativeBuildInputs = [ cmake python gtest ];
   preConfigure = ''
     cp -Lr ${srcFL} tools/clang
     chmod +w -R tools/clang
@@ -30,9 +30,10 @@ stdenv.mkDerivation rec {
     "-DCMAKE_BUILD_TYPE=Release"
     "-DLLVM_TARGETS_TO_BUILD='X86;JSBackend'"
     "-DLLVM_INCLUDE_EXAMPLES=OFF"
-    "-DLLVM_INCLUDE_TESTS=OFF"
-    # "-DCLANG_INCLUDE_EXAMPLES=OFF"
-    "-DCLANG_INCLUDE_TESTS=OFF"
+    "-DLLVM_INCLUDE_TESTS=ON"
+    #"-DLLVM_CONFIG=${llvm}/bin/llvm-config"
+    "-DLLVM_BUILD_TESTS=ON"
+    "-DCLANG_INCLUDE_TESTS=ON"
   ] ++ (stdenv.lib.optional stdenv.isLinux
     # necessary for clang to find crtend.o
     "-DGCC_INSTALL_PREFIX=${gcc}"
diff --git a/pkgs/development/compilers/fpc/lazarus.nix b/pkgs/development/compilers/fpc/lazarus.nix
index e646debd9d7e..0793a9d7ed0b 100644
--- a/pkgs/development/compilers/fpc/lazarus.nix
+++ b/pkgs/development/compilers/fpc/lazarus.nix
@@ -8,10 +8,10 @@ stdenv, fetchurl
 let
   s =
   rec {
-    version = "1.8.0";
+    version = "1.8.2";
     versionSuffix = "";
     url = "mirror://sourceforge/lazarus/Lazarus%20Zip%20_%20GZip/Lazarus%20${version}/lazarus-${version}${versionSuffix}.tar.gz";
-    sha256 = "0i58ngrr1vjyazirfmz0cgikglc02z1m0gcrsfw9awpi3ax8h21j";
+    sha256 = "06ajdnyba3v3d37mjq1yim96hsmbx1w5n695m5zlhjbydgw62a15";
     name = "lazarus-${version}";
   };
   buildInputs = [
diff --git a/pkgs/development/compilers/gambit/bootstrap.nix b/pkgs/development/compilers/gambit/bootstrap.nix
index 7376aec27501..05e804a1f740 100644
--- a/pkgs/development/compilers/gambit/bootstrap.nix
+++ b/pkgs/development/compilers/gambit/bootstrap.nix
@@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
     description = "Optimizing Scheme to C compiler, bootstrap step";
     homepage    = "http://gambitscheme.org";
     license     = stdenv.lib.licenses.lgpl2;
-    platforms   = stdenv.lib.platforms.linux;
+    platforms   = stdenv.lib.platforms.unix;
     maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin fare ];
   };
 }
diff --git a/pkgs/development/compilers/gambit/build.nix b/pkgs/development/compilers/gambit/build.nix
new file mode 100644
index 000000000000..202e55254222
--- /dev/null
+++ b/pkgs/development/compilers/gambit/build.nix
@@ -0,0 +1,70 @@
+{ stdenv, git, openssl, autoconf, pkgs, makeStaticLibraries, version, git-version, SRC }:
+
+stdenv.mkDerivation rec {
+  name    = "gambit-${version}";
+  src     = SRC;
+
+  bootstrap = import ./bootstrap.nix ( pkgs );
+
+  # Use makeStaticLibraries to enable creation of statically linked binaries
+  buildInputs = [ git autoconf bootstrap openssl (makeStaticLibraries openssl)];
+
+  configurePhase = ''
+    options=(
+      --prefix=$out
+      --enable-single-host
+      --enable-c-opt=-O2
+      --enable-gcc-opts
+      --enable-shared
+      --enable-absolute-shared-libs # Yes, NixOS will want an absolute path, and fix it.
+      --enable-poll
+      --enable-openssl
+      --enable-default-runtime-options="f8,-8,t8" # Default to UTF-8 for source and all I/O
+      #--enable-debug # Nope: enables plenty of good stuff, but also the costly console.log
+
+      #--enable-multiple-versions # Nope, NixOS already does version multiplexing
+      #--enable-guide
+      #--enable-track-scheme
+      #--enable-high-res-timing
+      #--enable-max-processors=4
+      #--enable-multiple-vms
+      #--enable-dynamic-tls
+      #--enable-multiple-vms
+      #--enable-multiple-threaded-vms  ## when SMP branch is merged in
+      #--enable-thread-system=posix    ## default when --enable-multiple-vms is on.
+      #--enable-profile
+      #--enable-coverage
+      #--enable-inline-jumps
+      #--enable-char-size=1" ; default is 4
+    )
+    ./configure ''${options[@]}
+  '';
+
+  buildPhase = ''
+    # Make bootstrap compiler, from release bootstrap
+    mkdir -p boot &&
+    cp -rp ${bootstrap}/. boot/. &&
+    chmod -R u+w boot &&
+    cd boot &&
+    cp ../gsc/makefile.in ../gsc/*.scm gsc && # */
+    ./configure &&
+    for i in lib gsi gsc ; do (cd $i ; make ) ; done &&
+    cd .. &&
+    cp boot/gsc/gsc gsc-boot &&
+
+    # Now use the bootstrap compiler to build the real thing!
+    make -j2 from-scratch
+  '';
+
+  doCheck = true;
+
+  meta = {
+    description = "Optimizing Scheme to C compiler";
+    homepage    = "http://gambitscheme.org";
+    license     = stdenv.lib.licenses.lgpl2;
+    # NB regarding platforms: only actually tested on Linux, *should* work everywhere,
+    # but *might* need adaptation e.g. on macOS.
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin fare ];
+  };
+}
diff --git a/pkgs/development/compilers/gambit/default.nix b/pkgs/development/compilers/gambit/default.nix
index 95e8dba762a2..0996d0c3078a 100644
--- a/pkgs/development/compilers/gambit/default.nix
+++ b/pkgs/development/compilers/gambit/default.nix
@@ -1,75 +1,13 @@
-{ stdenv, fetchurl, fetchgit, git, openssl, autoconf, pkgs, makeStaticLibraries }:
+{ callPackage, fetchgit }:
 
-# TODO: distinct packages for gambit-release and gambit-devel
-
-stdenv.mkDerivation rec {
-  name    = "gambit-${version}";
+callPackage ./build.nix {
   version = "4.8.9";
-  bootstrap = import ./bootstrap.nix ( pkgs );
+  # TODO: for next version, prefer the unpatched tarball for the stable/default gambit.
+  git-version = "4.8.9-8-g793679bd";
 
-  src = fetchgit {
+  SRC = fetchgit {
     url = "https://github.com/feeley/gambit.git";
     rev = "dd54a71dfc0bd09813592f1645d755867a02195d";
     sha256 = "120kg73k39gshrwas8a3xcrxgnq1c7ww92wgy4d3mmrwy3j9nzzc";
   };
-
-  # Use makeStaticLibraries to enable creation of statically linked binaries
-  buildInputs = [ git autoconf bootstrap openssl (makeStaticLibraries openssl)];
-
-  configurePhase = ''
-    options=(
-      --prefix=$out
-      --enable-single-host
-      --enable-c-opt=-O2
-      --enable-gcc-opts
-      --enable-shared
-      --enable-absolute-shared-libs # Yes, NixOS will want an absolute path, and fix it.
-      --enable-poll
-      --enable-openssl
-      --enable-default-runtime-options="f8,-8,t8" # Default to UTF-8 for source and all I/O
-      #--enable-debug # Nope: enables plenty of good stuff, but also the costly console.log
-
-      #--enable-multiple-versions # Nope, NixOS already does version multiplexing
-      #--enable-guide
-      #--enable-track-scheme
-      #--enable-high-res-timing
-      #--enable-max-processors=4
-      #--enable-multiple-vms
-      #--enable-dynamic-tls
-      #--enable-multiple-vms
-      #--enable-multiple-threaded-vms  ## when SMP branch is merged in
-      #--enable-thread-system=posix    ## default when --enable-multiple-vms is on.
-      #--enable-profile
-      #--enable-coverage
-      #--enable-inline-jumps
-      #--enable-char-size=1" ; default is 4
-    )
-    ./configure ''${options[@]}
-  '';
-
-  buildPhase = ''
-    # Make bootstrap compiler, from release bootstrap
-    mkdir -p boot &&
-    cp -rp ${bootstrap}/. boot/. &&
-    chmod -R u+w boot &&
-    cd boot &&
-    cp ../gsc/makefile.in ../gsc/*.scm gsc && # */
-    ./configure &&
-    for i in lib gsi gsc ; do (cd $i ; make ) ; done &&
-    cd .. &&
-    cp boot/gsc/gsc gsc-boot &&
-
-    # Now use the bootstrap compiler to build the real thing!
-    make -j2 from-scratch
-  '';
-
-  doCheck = true;
-
-  meta = {
-    description = "Optimizing Scheme to C compiler";
-    homepage    = "http://gambitscheme.org";
-    license     = stdenv.lib.licenses.lgpl2;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin fare ];
-  };
 }
diff --git a/pkgs/development/compilers/gambit/unstable.nix b/pkgs/development/compilers/gambit/unstable.nix
new file mode 100644
index 000000000000..f98fd5ca935a
--- /dev/null
+++ b/pkgs/development/compilers/gambit/unstable.nix
@@ -0,0 +1,11 @@
+{ callPackage, fetchgit }:
+
+callPackage ./build.nix {
+  version = "unstable-2018-03-26";
+  git-version = "4.8.9-8-g793679bd";
+  SRC = fetchgit {
+    url = "https://github.com/feeley/gambit.git";
+    rev = "793679bd57eb6275cb06e6570b05f4a78df61bf9";
+    sha256 = "0bippvmrc8vcaa6ka3mhzfgkagb6a1616g7nxk0i0wapxai5cngj";
+  };
+}
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 1fcad756eec1..59ee9cf5e850 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 {
@@ -259,8 +250,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.
@@ -310,8 +299,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;
+    inherit langC langCC langObjC langObjCpp langFortran langGo version;
     isGNU = true;
     hardeningUnsupportedFlags = [ "stackprotector" ];
   };
@@ -470,13 +454,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 009f28dc66b1..ea462099d230 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
@@ -264,8 +269,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.
@@ -318,8 +321,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++"
@@ -357,9 +358,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" ++
@@ -452,7 +450,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;
 
@@ -475,13 +473,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 a695b6819a1a..443f3a7cf0b2 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
@@ -286,8 +277,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.
@@ -339,8 +328,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++"
@@ -373,9 +360,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" ++
@@ -469,7 +453,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;
 
@@ -492,12 +476,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 c5ca1060894b..94e7f8347372 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
@@ -286,8 +277,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" ++
@@ -472,7 +456,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 +479,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 9a0da5dbf6eb..54ac2c45d892 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 targetPlatform.isHurd
     then
       # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
@@ -258,7 +258,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;
@@ -286,8 +286,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.
@@ -339,8 +337,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++"
@@ -373,9 +369,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" ++
@@ -468,7 +461,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;
 
@@ -491,12 +484,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 70fbefb898e8..4ba6acc670f7 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,56 +96,72 @@ 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 =
+    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 targetPlatform.isHurd
     then
       # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
@@ -159,7 +170,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
@@ -172,8 +182,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}'..."
@@ -183,8 +193,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
@@ -192,25 +200,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 =
@@ -223,17 +238,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
@@ -244,8 +269,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}" ++
@@ -254,67 +281,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++
@@ -323,9 +355,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
 
@@ -337,16 +366,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"
     ]);
@@ -365,13 +391,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/;
@@ -381,71 +406,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 fcfc8f15f132..de12a2ba52ac 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 {
@@ -258,8 +249,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.
@@ -311,8 +300,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++"
@@ -345,9 +332,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" ++
@@ -440,7 +424,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;
 
@@ -463,12 +447,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;
   };
diff --git a/pkgs/development/compilers/gerbil/build.nix b/pkgs/development/compilers/gerbil/build.nix
new file mode 100644
index 000000000000..5609de15d4cb
--- /dev/null
+++ b/pkgs/development/compilers/gerbil/build.nix
@@ -0,0 +1,88 @@
+{ stdenv, lib, makeStaticLibraries,
+  coreutils, rsync, bash,
+  openssl, zlib, sqlite, libxml2, libyaml, mysql, lmdb, leveldb, postgresql,
+  version, git-version, GAMBIT, SRC }:
+
+# TODO: distinct packages for gerbil-release and gerbil-devel
+# TODO: make static compilation work
+
+stdenv.mkDerivation rec {
+  name    = "gerbil-${version}";
+  src     = SRC;
+
+  # Use makeStaticLibraries to enable creation of statically linked binaries
+  buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml mysql.connector-c lmdb leveldb postgresql ];
+  buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
+
+  buildInputs = [ GAMBIT coreutils rsync bash ]
+    ++ buildInputs_libraries ++ buildInputs_staticLibraries;
+
+  NIX_CFLAGS_COMPILE = [ "-I${mysql.connector-c}/include/mysql" "-L${mysql.connector-c}/lib/mysql" ];
+
+  postPatch = ''
+    echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm
+
+    patchShebangs .
+
+    find . -type f -executable -print0 | while IFS= read -r -d ''$'\0' f; do
+      substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
+    done
+
+    cat > etc/gerbil_static_libraries.sh <<EOF
+#OPENSSL_LIBCRYPTO=${makeStaticLibraries openssl}/lib/libcrypto.a # MISSING!
+#OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
+ZLIB=${makeStaticLibraries zlib}/lib/libz.a
+# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
+# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING!
+# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING!
+MYSQL=${makeStaticLibraries mysql.connector-c}/lib/mariadb/libmariadb.a
+# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING!
+LEVELDB=${makeStaticLibraries lmdb}/lib/libleveldb.a
+EOF
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+
+    # Enable all optional libraries
+    substituteInPlace "src/std/build-features.ss" --replace '#f' '#t'
+
+    # gxprof testing uses $HOME/.cache/gerbil/gxc
+    export HOME=$$PWD
+
+    # Build, replacing make by build.sh
+    ( cd src && sh build.sh )
+
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/
+    cp -fa bin lib etc doc $out/
+
+    cat > $out/bin/gxi <<EOF
+#!${bash}/bin/bash -e
+export GERBIL_HOME=$out
+case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac
+if [[ \$# = 0 ]] ; then
+  exec ${GAMBIT}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive - ;
+else
+  exec ${GAMBIT}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@"
+fi
+EOF
+    runHook postInstall
+  '';
+
+  dontStrip = true;
+
+  meta = {
+    description = "Gerbil Scheme";
+    homepage    = "https://github.com/vyzo/gerbil";
+    license     = stdenv.lib.licenses.lgpl2;
+    # NB regarding platforms: only actually tested on Linux, *should* work everywhere,
+    # but *might* need adaptation e.g. on macOS. Please report success and/or failure to fare.
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ fare ];
+  };
+}
diff --git a/pkgs/development/compilers/gerbil/default.nix b/pkgs/development/compilers/gerbil/default.nix
index c1a411120d03..eaab0e71d3bd 100644
--- a/pkgs/development/compilers/gerbil/default.nix
+++ b/pkgs/development/compilers/gerbil/default.nix
@@ -1,91 +1,11 @@
-{ stdenv, lib, fetchurl, fetchgit, makeStaticLibraries, gambit,
-  coreutils, rsync, bash,
-  openssl, zlib, sqlite, libxml2, libyaml, mysql, lmdb, leveldb, postgresql }:
-
-# TODO: distinct packages for gerbil-release and gerbil-devel
-# TODO: make static compilation work
-
-stdenv.mkDerivation rec {
-  name    = "gerbil-${version}";
+{ callPackage, fetchurl, gambit }:
 
+callPackage ./build.nix {
   version = "0.12-RELEASE";
-  src = fetchgit {
-    url = "https://github.com/vyzo/gerbil.git";
-    rev = "5618892d7939e1cb4ef5247912e0bc1ec99f6b52";
-    sha256 = "0b2valahf5k81r4sp6y12d44fb286p92s7k6dphij0kmvg0dp818";
-  };
-
-  # Use makeStaticLibraries to enable creation of statically linked binaries
-  buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml mysql.connector-c lmdb leveldb postgresql ];
-  buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
-
-  buildInputs = [ gambit coreutils rsync bash ]
-    ++ buildInputs_libraries ++ buildInputs_staticLibraries;
-
-  NIX_CFLAGS_COMPILE = [ "-I${mysql.connector-c}/include/mysql" "-L${mysql.connector-c}/lib/mysql" ];
-
-  postPatch = ''
-    echo '(define (gerbil-version-string) "v${version}")' > src/gerbil/runtime/gx-version.scm
-
-    patchShebangs .
-
-    find . -type f -executable -print0 | while IFS= read -r -d ''$'\0' f; do
-      substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
-    done
-
-    cat > etc/gerbil_static_libraries.sh <<EOF
-#OPENSSL_LIBCRYPTO=${makeStaticLibraries openssl}/lib/libcrypto.a # MISSING!
-#OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
-ZLIB=${makeStaticLibraries zlib}/lib/libz.a
-# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
-# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING!
-# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING!
-MYSQL=${makeStaticLibraries mysql.connector-c}/lib/mariadb/libmariadb.a
-# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING!
-LEVELDB=${makeStaticLibraries lmdb}/lib/libleveldb.a
-EOF
-  '';
-
-  buildPhase = ''
-    runHook preBuild
-
-    # Enable all optional libraries
-    substituteInPlace "src/std/build-features.ss" --replace '#f' '#t'
-
-    # gxprof testing uses $HOME/.cache/gerbil/gxc
-    export HOME=$$PWD
-
-    # Build, replacing make by build.sh
-    ( cd src && sh build.sh )
-
-    runHook postBuild
-  '';
-
-  installPhase = ''
-    runHook preInstall
-    mkdir -p $out/
-    cp -fa bin lib etc doc $out/
-
-    cat > $out/bin/gxi <<EOF
-#!${bash}/bin/bash -e
-export GERBIL_HOME=$out
-case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac
-if [[ \$# = 0 ]] ; then
-  exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive - ;
-else
-  exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@"
-fi
-EOF
-    runHook postInstall
-  '';
-
-  dontStrip = true;
-
-  meta = {
-    description = "Gerbil Scheme";
-    homepage    = "https://github.com/vyzo/gerbil";
-    license     = stdenv.lib.licenses.lgpl2;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ fare ];
+  git-version = "0.12";
+  GAMBIT = gambit;
+  SRC = fetchurl {
+    url = "https://github.com/vyzo/gerbil/archive/v0.12.tar.gz";
+    sha256 = "0nigr3mgrzai57q2jqac8f39zj8rcmic3277ynyzlgm8hhps71pq";
   };
 }
diff --git a/pkgs/development/compilers/gerbil/unstable.nix b/pkgs/development/compilers/gerbil/unstable.nix
new file mode 100644
index 000000000000..ec36f42d86e6
--- /dev/null
+++ b/pkgs/development/compilers/gerbil/unstable.nix
@@ -0,0 +1,12 @@
+{ callPackage, fetchgit, gambit-unstable }:
+
+callPackage ./build.nix {
+  version = "unstable-2018-04-03";
+  git-version = "0.13-DEV-357-ge61318dc";
+  GAMBIT = gambit-unstable;
+  SRC = fetchgit {
+    url = "https://github.com/vyzo/gerbil.git";
+    rev = "e61318dcaa3a9c843e2cf259e67851f240e4beda";
+    sha256 = "1xd7yxiramifdxgp6b3s24z6nkkmy5h4a6pkchvy4w358qv1vqin";
+  };
+}
diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix
deleted file mode 100644
index 8758ee59d384..000000000000
--- a/pkgs/development/compilers/ghc/7.0.4-binary.nix
+++ /dev/null
@@ -1,146 +0,0 @@
-{ stdenv
-, fetchurl, perl
-, ncurses5, gmp, libiconv
-}:
-
-# Prebuilt only does native
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-let
-  libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
-
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
-    + "LD_LIBRARY_PATH";
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.0.4";
-
-  name = "ghc-${version}-binary";
-
-  src = fetchurl ({
-    "i686-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
-      sha256 = "0mfnihiyjl06f5w1yrjp36sw9g67g2ymg5sdl0g23h1pab99jx63";
-    };
-    "x86_64-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
-      sha256 = "0mc4rhqcxz427wq4zgffmnn0d2yjqvy6af4x9mha283p1gdj5q99";
-    };
-    "i686-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
-      sha256 = "0qj45hslrrr8zfks8m1jcb3awwx9rh35ndnpfmb0gwb6j7azq5n3";
-    };
-    "x86_64-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
-      sha256 = "1m2ml88p1swf4dnv2vq8hz4drcp46n3ahpfi05wh01ajkf8hnn3l";
-    };
-  }.${stdenv.hostPlatform.system}
-    or (throw "cannot bootstrap GHC on this platform"));
-
-  nativeBuildInputs = [ perl ];
-
-  # Cannot patchelf beforehand due to relative RPATHs that anticipate
-  # the final install location/
-  ${libEnvVar} = libPath;
-
-  postUnpack =
-    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
-    # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
-      export NIX_LDFLAGS+=" -no_dtrace_dof"
-    '' +
-
-    # Strip is harmful, see also below. It's important that this happens
-    # first. The GHC Cabal build system makes use of strip by default and
-    # has hardcoded paths to /usr/bin/strip in many places. We replace
-    # those below, making them point to our dummy script.
-    ''
-      mkdir "$TMP/bin"
-      for i in strip; do
-        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
-        chmod +x "$TMP/bin/$i"
-      done
-      PATH="$TMP/bin:$PATH"
-    '' +
-    # We have to patch the GMP paths for the integer-gmp package.
-    ''
-      find . -name integer-gmp.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
-      find . -name base.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
-    '' +
-    # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
-          --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
-
-      paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-
-      sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      sed -i "s|/usr/bin/gcc|gcc\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      for prog in ld ar gcc strip ranlib; do
-        find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
-      done
-    '';
-
-  configurePlatforms = [ ];
-  configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
-
-  # Stripping combined with patchelf breaks the executables (they die
-  # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
-  dontStrip = true;
-
-  # No building is necessary, but calling make without flags ironically
-  # calls install-strip ...
-  dontBuild = true;
-
-  # On Linux, use patchelf to modify the executables so that they can
-  # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
-    find "$out" -type f -executable \
-        -exec patchelf --set-rpath "${libPath}" {} \;
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    # not enough room in the object files for the full path to libiconv :(
-    for exe in $(find "$out" -type f -executable); do
-      isScript $exe && continue
-      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-    done
-
-    for file in $(find "$out" -name setup-config); do
-      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-    done
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    # Sanity check, can ghc create executables?
-    cd $TMP
-    mkdir test-ghc; cd test-ghc
-    cat > main.hs << EOF
-      module Main where
-      main = putStrLn "yes"
-    EOF
-    $out/bin/ghc --make main.hs
-    echo compilation ok
-    [ $(./main) == "yes" ]
-  '';
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.0.4";
-  };
-
-  meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
-}
diff --git a/pkgs/development/compilers/ghc/7.0.4.nix b/pkgs/development/compilers/ghc/7.0.4.nix
deleted file mode 100644
index 5bd05b257ca5..000000000000
--- a/pkgs/development/compilers/ghc/7.0.4.nix
+++ /dev/null
@@ -1,67 +0,0 @@
-{ stdenv, fetchurl, ghc, perl, gmp, ncurses, libiconv }:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-stdenv.mkDerivation rec {
-  version = "7.0.4";
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.bz2";
-    sha256 = "1a9b78d9d66c9c21de6c0932e36bb87406a4856f1611bf83bd44539bdc6ed0ed";
-  };
-
-  patches = [ ./fix-7.0.4-clang.patch ./relocation.patch ];
-
-  buildInputs = [ ghc perl gmp ncurses ];
-
-  buildMK = ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '';
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    find . -name '*.hs'  | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  configureFlags = if stdenv.isDarwin then "--with-gcc=${./gcc-clang-wrapper.sh}"
-                                      else "--with-gcc=${stdenv.cc}/bin/gcc";
-
-  NIX_CFLAGS_COMPILE = "-fomit-frame-pointer";
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags=["-S" "--keep-file-symbols"];
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.0.4";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = [
-      stdenv.lib.maintainers.marcweber
-      stdenv.lib.maintainers.andres
-      stdenv.lib.maintainers.peti
-    ];
-    platforms = ["x86_64-linux" "i686-linux"];  # Darwin is not supported.
-    inherit (ghc.meta) license;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix
deleted file mode 100644
index 988392e74b9e..000000000000
--- a/pkgs/development/compilers/ghc/7.4.2-binary.nix
+++ /dev/null
@@ -1,148 +0,0 @@
-{ stdenv
-, fetchurl, perl
-, ncurses5, gmp, libiconv
-}:
-
-# Prebuilt only does native
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-let
-  libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
-
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
-    + "LD_LIBRARY_PATH";
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.4.2";
-
-  name = "ghc-${version}-binary";
-
-  src = fetchurl ({
-    "i686-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
-      sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi";
-    };
-    "x86_64-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
-      sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns";
-    };
-    "i686-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
-      sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0";
-    };
-    "x86_64-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
-      sha256 = "1imzqc0slpg0r6p40n5a9m18cbcm0m86z8dgyhfxcckksw54mzwf";
-    };
-  }.${stdenv.hostPlatform.system}
-    or (throw "cannot bootstrap GHC on this platform"));
-
-  nativeBuildInputs = [ perl ];
-
-  # Cannot patchelf beforehand due to relative RPATHs that anticipate
-  # the final install location/
-  ${libEnvVar} = libPath;
-
-  postUnpack =
-    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
-    # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
-      export NIX_LDFLAGS+=" -no_dtrace_dof"
-    '' +
-
-    # Strip is harmful, see also below. It's important that this happens
-    # first. The GHC Cabal build system makes use of strip by default and
-    # has hardcoded paths to /usr/bin/strip in many places. We replace
-    # those below, making them point to our dummy script.
-    ''
-      mkdir "$TMP/bin"
-      for i in strip; do
-        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
-        chmod +x "$TMP/bin/$i"
-      done
-      PATH="$TMP/bin:$PATH"
-    '' +
-    # We have to patch the GMP paths for the integer-gmp package.
-    ''
-      find . -name integer-gmp.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
-      find . -name base.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
-    '' +
-    # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
-          --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
-
-      paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-
-      sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      sed -i "s|/usr/bin/gcc|gcc\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      for prog in ld ar gcc strip ranlib; do
-        find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
-      done
-    '';
-
-  configurePlatforms = [ ];
-  configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
-
-  # Stripping combined with patchelf breaks the executables (they die
-  # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
-  dontStrip = true;
-
-  # No building is necessary, but calling make without flags ironically
-  # calls install-strip ...
-  dontBuild = true;
-
-  # On Linux, use patchelf to modify the executables so that they can
-  # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
-    find "$out" -type f -executable \
-        -exec patchelf --set-rpath "${libPath}" {} \;
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    # not enough room in the object files for the full path to libiconv :(
-    for exe in $(find "$out" -type f -executable); do
-      isScript $exe && continue
-      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-    done
-
-    for file in $(find "$out" -name setup-config); do
-      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-    done
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    # Sanity check, can ghc create executables?
-    cd $TMP
-    mkdir test-ghc; cd test-ghc
-    cat > main.hs << EOF
-      {-# LANGUAGE TemplateHaskell #-}
-      module Main where
-      main = putStrLn \$([|"yes"|])
-    EOF
-    $out/bin/ghc --make main.hs || exit 1
-    echo compilation ok
-    [ $(./main) == "yes" ]
-  '';
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.4.2";
-  };
-
-  meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
-}
diff --git a/pkgs/development/compilers/ghc/7.4.2.nix b/pkgs/development/compilers/ghc/7.4.2.nix
deleted file mode 100644
index 86925c406cfc..000000000000
--- a/pkgs/development/compilers/ghc/7.4.2.nix
+++ /dev/null
@@ -1,77 +0,0 @@
-{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
-
-, # If enabled, GHC will be built with the GPL-free but slower integer-simple
-  # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
-}:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-assert !enableIntegerSimple -> gmp != null;
-
-stdenv.mkDerivation rec {
-  version = "7.4.2";
-
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.bz2";
-    sha256 = "0vc3zmxqi4gflssmj35n5c8idbvyrhd88abi50whbirwlf4i5vpj";
-  };
-
-  patches = [ ./fix-7.4.2-clang.patch ./relocation.patch ];
-
-  buildInputs = [ ghc perl ncurses ]
-                ++ stdenv.lib.optional (!enableIntegerSimple) gmp;
-
-  buildMK = ''
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '' + (if enableIntegerSimple then ''
-    INTEGER_LIBRARY = integer-simple
-  '' else ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-  '');
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
-    export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    find . -name '*.hs'  | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  configureFlags = if stdenv.isDarwin then "--with-gcc=${./gcc-clang-wrapper.sh}"
-                                      else "--with-gcc=${stdenv.cc}/bin/gcc";
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.4.2";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = [
-      stdenv.lib.maintainers.marcweber
-      stdenv.lib.maintainers.andres
-      stdenv.lib.maintainers.peti
-    ];
-    inherit (ghc.meta) license platforms;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/7.6.3.nix b/pkgs/development/compilers/ghc/7.6.3.nix
deleted file mode 100644
index 982008563a06..000000000000
--- a/pkgs/development/compilers/ghc/7.6.3.nix
+++ /dev/null
@@ -1,103 +0,0 @@
-{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
-
-, # If enabled, GHC will be built with the GPL-free but slower integer-simple
-  # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
-}:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-assert !enableIntegerSimple -> gmp != null;
-
-let
-  # The "-Wa,--noexecstack" options might be needed only with GNU ld (as opposed
-  # to the gold linker). It prevents binaries' stacks from being marked as
-  # executable, which fails to run on a grsecurity/PaX kernel.
-  ghcFlags = "-optc-Wa,--noexecstack -opta-Wa,--noexecstack";
-  cFlags = "-Wa,--noexecstack";
-
-in stdenv.mkDerivation rec {
-  version = "7.6.3";
-
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.bz2";
-    sha256 = "1669m8k9q72rpd2mzs0bh2q6lcwqiwd1ax3vrard1dgn64yq4hxx";
-  };
-
-  patches = [ ./fix-7.6.3-clang.patch ./relocation.patch ];
-
-  buildInputs = [ ghc perl ncurses ]
-                ++ stdenv.lib.optional (!enableIntegerSimple) gmp;
-
-  buildMK = ''
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '' + stdenv.lib.optionalString stdenv.isLinux ''
-    # Set ghcFlags for building ghc itself
-    SRC_HC_OPTS += ${ghcFlags}
-    SRC_CC_OPTS += ${cFlags}
-  '' + (if enableIntegerSimple then ''
-    INTEGER_LIBRARY = integer-simple
-  '' else ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-  '');
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-
-  '' + stdenv.lib.optionalString stdenv.isLinux ''
-    # Set ghcFlags for binaries that ghc builds
-    sed -i -e 's|"\$topdir"|"\$topdir" ${ghcFlags}|' ghc/ghc.wrapper
-
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
-    export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    find . -name '*.hs'  | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  configureFlags = if stdenv.isDarwin then "--with-gcc=${./gcc-clang-wrapper.sh}"
-                                      else "--with-gcc=${stdenv.cc}/bin/gcc";
-
-  postInstall = ''
-    # ghci uses mmap with rwx protection at it implements dynamic
-    # linking on its own. See:
-    # - https://bugs.gentoo.org/show_bug.cgi?id=299709
-    # - https://ghc.haskell.org/trac/ghc/ticket/4244
-    # Therefore, we have to pax-mark the resulting binary.
-    # Haddock also seems to run with ghci, so mark it as well.
-    paxmark m $out/lib/${name}/{ghc,haddock}
-  '';
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.6.3";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = [
-      stdenv.lib.maintainers.marcweber
-      stdenv.lib.maintainers.andres
-      stdenv.lib.maintainers.peti
-    ];
-    inherit (ghc.meta) license platforms;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/7.8.4-binary.nix b/pkgs/development/compilers/ghc/7.8.4-binary.nix
deleted file mode 100644
index 58a9370b3213..000000000000
--- a/pkgs/development/compilers/ghc/7.8.4-binary.nix
+++ /dev/null
@@ -1,156 +0,0 @@
-{ stdenv
-, fetchurl, perl
-, ncurses5, gmp, libiconv
-}:
-
-# Prebuilt only does native
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-let
-  libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
-
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
-    + "LD_LIBRARY_PATH";
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.8.4";
-
-  name = "ghc-${version}-binary";
-
-  src = fetchurl ({
-    "i686-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux-deb7.tar.bz2";
-      sha256 = "5da2cf45986f33319a92a666f1f0149915334a7b64b41892ab94f4557242b406";
-    };
-    "x86_64-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux-deb7.tar.bz2";
-      sha256 = "20b5731d268613bbf6e977dbb192a3a3b7b78d954c35edbfca4fb36b652e24f7";
-    };
-    "x86_64-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
-      sha256 = "dfa161c2a136ee16214a49d5902e2377407c8292dbbdbb14fa0fa6b17220cae6";
-    };
-  }.${stdenv.hostPlatform.system}
-    or (throw "cannot bootstrap GHC on this platform"));
-
-  nativeBuildInputs = [ perl ];
-
-  # Cannot patchelf beforehand due to relative RPATHs that anticipate
-  # the final install location/
-  ${libEnvVar} = libPath;
-
-  postUnpack =
-    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
-    # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
-      export NIX_LDFLAGS+=" -no_dtrace_dof"
-      # not enough room in the object files for the full path to libiconv :(
-      for exe in $(find . -type f -executable); do
-        isScript $exe && continue
-        ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-        install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-        for file in $(find . -name setup-config); do
-          substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-        done
-      done
-    '' +
-
-    # Some scripts used during the build need to have their shebangs patched
-    ''
-      patchShebangs ghc-${version}/utils/
-    '' +
-
-    # Strip is harmful, see also below. It's important that this happens
-    # first. The GHC Cabal build system makes use of strip by default and
-    # has hardcoded paths to /usr/bin/strip in many places. We replace
-    # those below, making them point to our dummy script.
-    ''
-      mkdir "$TMP/bin"
-      for i in strip; do
-        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
-        chmod +x "$TMP/bin/$i"
-      done
-      PATH="$TMP/bin:$PATH"
-    '' +
-    # We have to patch the GMP paths for the integer-gmp package.
-    ''
-      find . -name integer-gmp.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
-      find . -name base.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
-    '' +
-    # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
-          --replace-needed libtinfo.so libtinfo.so.5 \
-          --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
-
-      paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-
-      sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      sed -i "s|/usr/bin/gcc|gcc\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-    '';
-
-  configurePlatforms = [ ];
-  configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
-
-  # Stripping combined with patchelf breaks the executables (they die
-  # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
-  dontStrip = true;
-
-  # No building is necessary, but calling make without flags ironically
-  # calls install-strip ...
-  dontBuild = true;
-
-  # On Linux, use patchelf to modify the executables so that they can
-  # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
-    for p in $(find "$out" -type f -executable); do
-      if isELF "$p"; then
-        echo "Patchelfing $p"
-        patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
-      fi
-    done
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    # not enough room in the object files for the full path to libiconv :(
-    for exe in $(find "$out" -type f -executable); do
-      isScript $exe && continue
-      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-    done
-
-    for file in $(find "$out" -name setup-config); do
-      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-    done
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    unset ${libEnvVar}
-    # Sanity check, can ghc create executables?
-    cd $TMP
-    mkdir test-ghc; cd test-ghc
-    cat > main.hs << EOF
-      {-# LANGUAGE TemplateHaskell #-}
-      module Main where
-      main = putStrLn \$([|"yes"|])
-    EOF
-    $out/bin/ghc --make main.hs || exit 1
-    echo compilation ok
-    [ $(./main) == "yes" ]
-  '';
-
-  passthru = { targetPrefix = ""; };
-
-  meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
-}
diff --git a/pkgs/development/compilers/ghc/7.8.4.nix b/pkgs/development/compilers/ghc/7.8.4.nix
deleted file mode 100644
index 47fc090c1ff1..000000000000
--- a/pkgs/development/compilers/ghc/7.8.4.nix
+++ /dev/null
@@ -1,91 +0,0 @@
-{ stdenv, targetPackages
-
-, fetchurl, ghc, perl
-, libffi, libiconv ? null, ncurses
-
-, # If enabled, GHC will be built with the GPL-free but slower integer-simple
-  # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
-}:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-assert !enableIntegerSimple -> gmp != null;
-
-let
-  buildMK = ''
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    DYNAMIC_BY_DEFAULT = NO
-    ${stdenv.lib.optionalString (stdenv.hostPlatform.libc != "glibc") ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '' + (if enableIntegerSimple then ''
-    INTEGER_LIBRARY = integer-simple
-  '' else ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-  '');
-
-  # Splicer will pull out correct variations
-  libDeps = [ ncurses ]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc") libiconv;
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.8.4";
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "http://www.haskell.org/ghc/dist/${version}/${name}-src.tar.xz";
-    sha256 = "1i4254akbb4ym437rf469gc0m40bxm31blp6s1z1g15jmnacs6f3";
-  };
-
-  enableParallelBuilding = true;
-
-  patches = [ ./relocation.patch ]
-    ++ stdenv.lib.optional stdenv.isDarwin ./hpc-7.8.4.patch;
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
-    export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ];
-
-  nativeBuildInputs = [ ghc perl ];
-  depsBuildTarget = [ targetPackages.stdenv.cc ];
-
-  buildInputs = libDeps;
-  propagatedBuildInputs = [ targetPackages.stdenv.cc ];
-
-  depsTargetTarget = map stdenv.lib.getDev libDeps;
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") libDeps;
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.8.4";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
-    inherit (ghc.meta) license platforms;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix
index c0bc2a9dd736..c88d2a8685a6 100644
--- a/pkgs/development/compilers/ghc/8.2.1-binary.nix
+++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix
@@ -158,5 +158,6 @@ stdenv.mkDerivation rec {
   passthru = { targetPrefix = ""; };
 
   meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"];
+  # AArch64 should work in theory but eventually some builds start segfaulting
+  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" /* "aarch64-linux" */];
 }
diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix
index b2a1aafe6131..192ff1ba207d 100644
--- a/pkgs/development/compilers/ghc/8.2.2.nix
+++ b/pkgs/development/compilers/ghc/8.2.2.nix
@@ -4,6 +4,7 @@
 # build-tools
 , bootPkgs, alex, happy, hscolour
 , autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx
+, runCommand
 
 , libffi, libiconv ? null, ncurses
 
@@ -89,6 +90,7 @@ stdenv.mkDerivation rec {
       url = "https://git.haskell.org/ghc.git/commitdiff_plain/2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3";
       sha256 = "03253ci40np1v6k0wmi4aypj3nmj3rdyvb1k6rwqipb30nfc719f";
     })
+    (import ./abi-depends-determinism.nix { inherit fetchpatch runCommand; })
   ] ++ stdenv.lib.optional deterministicProfiling
     (fetchpatch { # Backport of https://phabricator.haskell.org/D4388 for more determinism
       url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch";
diff --git a/pkgs/development/compilers/ghc/8.4.1.nix b/pkgs/development/compilers/ghc/8.4.2.nix
index f232e0b47287..94555482d28b 100644
--- a/pkgs/development/compilers/ghc/8.4.1.nix
+++ b/pkgs/development/compilers/ghc/8.4.2.nix
@@ -3,7 +3,7 @@
 
 # build-tools
 , bootPkgs, alex, happy
-, autoconf, automake, coreutils, fetchgit, fetchpatch, perl, python3
+, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3
 
 , libffi, libiconv ? null, ncurses
 
@@ -15,20 +15,16 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
+  enableIntegerSimple ? false, gmp ? null, m4
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? targetPlatform != hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? true
+  enableShared ? !targetPlatform.useAndroidPrebuilt
 
-, version ? "8.4.0.20180224"
-, # Whether to backport https://phabricator.haskell.org/D4388 for
-  # deterministic profiling symbol names, at the cost of a slightly
-  # non-standard GHC API
-  deterministicProfiling ? false
+, version ? "8.4.2"
 }:
 
 assert !enableIntegerSimple -> gmp != null;
@@ -54,6 +50,8 @@ let
   '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
+  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+    EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
@@ -72,24 +70,23 @@ let
 in
 stdenv.mkDerivation rec {
   inherit version;
-  inherit (src) rev;
   name = "${targetPrefix}ghc-${version}";
 
-  src = fetchgit {
-    url = "git://git.haskell.org/ghc.git";
-    rev = "a1e15c8f59092ef2d11be7966bd20688d8dc01e6";
-    sha256 = "1pimf5ryl76r3vwnc2n0qzk4yh7zckp2r2g5rlz8nbddsws2v893";
+  src = fetchurl {
+    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
+    sha256 = "0yq4y0smn92sksnjjva28b8847krxizns6rm50j3pgq69br35k01";
   };
 
   enableParallelBuilding = true;
 
   outputs = [ "out" "doc" ];
 
-  patches = stdenv.lib.optional deterministicProfiling
-    (fetchpatch { # https://phabricator.haskell.org/D4388 for more determinism
-      url = "https://github.com/shlevy/ghc/commit/8b2dbd869d1a64de3e99fa8b1c9bb1140eee7099.patch";
-      sha256 = "0hxpiwhbg64rsyjdr4psh6dwyp58b96mad3adccvfr0x8hc6ba2m";
-    });
+  patches = [(fetchpatch {
+    url = "https://git.haskell.org/hsc2hs.git/patch/738f3666c878ee9e79c3d5e819ef8b3460288edf";
+    sha256 = "0plzsbfaq6vb1023lsarrjglwgr9chld4q3m99rcfzx0yx5mibp3";
+    extraPrefix = "utils/hsc2hs/";
+    stripLen = 1;
+  })];
 
   postPatch = "patchShebangs .";
 
@@ -112,9 +109,6 @@ stdenv.mkDerivation rec {
     export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
 
     echo -n "${buildMK}" > mk/build.mk
-    echo ${version} >VERSION
-    echo ${src.rev} >GIT_COMMIT_ID
-    ./boot
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
   '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
@@ -149,7 +143,7 @@ stdenv.mkDerivation rec {
   # masss-rebuild.
   crossConfig = true;
 
-  nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
+  nativeBuildInputs = [ ghc perl autoconf automake m4 happy alex python3 ];
 
   # For building runtime libs
   depsBuildTarget = toolsForTarget;
@@ -190,7 +184,7 @@ stdenv.mkDerivation rec {
     inherit llvmPackages;
 
     # Our Cabal compiler name
-    haskellCompilerName = "ghc-8.4.1";
+    haskellCompilerName = "ghc-8.4.2";
   };
 
   meta = {
diff --git a/pkgs/development/compilers/ghc/abi-depends-determinism.nix b/pkgs/development/compilers/ghc/abi-depends-determinism.nix
new file mode 100644
index 000000000000..bc803b74617f
--- /dev/null
+++ b/pkgs/development/compilers/ghc/abi-depends-determinism.nix
@@ -0,0 +1,12 @@
+# https://phabricator.haskell.org/D4159 to fix non-determinism in
+# cached abi-depends fields in package databases, modified to only
+# contain hunks that exist in distribution tarballs.
+{ fetchpatch, runCommand }: let
+  base = fetchpatch rec { # Non-determinism in cached abi-depends fields
+    # Originally https://phabricator-files.haskell.org/file/data/4pqrbo5b62sifktfbrls/PHID-FILE-4g4zjiqlfxmmlaos7lz7/D4159.diff
+    url = "http://tarballs.nixos.org/sha256/${sha256}";
+    name = "D4159.diff";
+    sha256 = "0b8a08sisf1swmarm6nh9rgw7cpzi2rwdzvrd6ny49c7wk0f7x4b";
+  };
+in runCommand base.name {}
+  "sed -n '/utils\\/ghc-pkg/,$p' ${base} >$out"
diff --git a/pkgs/development/compilers/ghc/fix-7.0.4-clang.patch b/pkgs/development/compilers/ghc/fix-7.0.4-clang.patch
deleted file mode 100644
index 51323c69c201..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.0.4-clang.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index f704a69..37753fd 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -211,9 +211,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--	ppr binds $$ ppr rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), ppr binds $$ ppr rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
-index 638e1db..0aee4b7 100644
---- a/compiler/main/GHC.hs
-+++ b/compiler/main/GHC.hs
-@@ -788,8 +788,7 @@ load2 how_much mod_graph = do
- 	    -- is stable).
- 	    partial_mg
- 		| LoadDependenciesOf _mod <- how_much
--		= ASSERT( case last partial_mg0 of 
--			    AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
-+		= ASSERT( case last partial_mg0 of AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
- 		  List.init partial_mg0
- 		| otherwise
- 		= partial_mg0
-@@ -879,8 +878,7 @@ load2 how_much mod_graph = do
- 	      liftIO $ cleanTempFilesExcept dflags (ppFilesFromSummaries mods_to_keep)
- 
- 	      -- there should be no Nothings where linkables should be, now
--	      ASSERT(all (isJust.hm_linkable) 
--			(eltsUFM (hsc_HPT hsc_env))) do
-+	      ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
- 	
- 	      -- Link everything together
-               linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index 99a63e4..3268726 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -388,8 +388,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-@@ -1812,4 +1811,4 @@ without getting changed to c1=I# c2.
- I don't think this is worth fixing, even if I knew how. It'll
- all come out in the next pass anyway.
- 
--  
-\ No newline at end of file
-+  
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index d0fbd8d..ef87996 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2071,8 +2071,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
diff --git a/pkgs/development/compilers/ghc/fix-7.2.2-clang.patch b/pkgs/development/compilers/ghc/fix-7.2.2-clang.patch
deleted file mode 100644
index 9592d54188ed..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.2.2-clang.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index dbd22f3..42208f9 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -210,9 +210,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--	ppr binds $$ ppr rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), ppr binds $$ ppr rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
-index dece548..9643f30 100644
---- a/compiler/main/GhcMake.hs
-+++ b/compiler/main/GhcMake.hs
-@@ -236,8 +236,7 @@ load2 how_much mod_graph = do
- 	    -- is stable).
- 	    partial_mg
- 		| LoadDependenciesOf _mod <- how_much
--		= ASSERT( case last partial_mg0 of 
--			    AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
-+		= ASSERT( case last partial_mg0 of AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
- 		  List.init partial_mg0
- 		| otherwise
- 		= partial_mg0
-@@ -331,8 +330,7 @@ load2 how_much mod_graph = do
-               liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1
- 
- 	      -- there should be no Nothings where linkables should be, now
--	      ASSERT(all (isJust.hm_linkable) 
--			(eltsUFM (hsc_HPT hsc_env))) do
-+	      ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
- 	
- 	      -- Link everything together
-               linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index dd0ce4b..9501e73 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -393,8 +393,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-@@ -1845,4 +1844,4 @@ without getting changed to c1=I# c2.
- I don't think this is worth fixing, even if I knew how. It'll
- all come out in the next pass anyway.
- 
--  
-\ No newline at end of file
-+  
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index adcaf13..06d939d 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2185,8 +2185,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
diff --git a/pkgs/development/compilers/ghc/fix-7.4.2-clang.patch b/pkgs/development/compilers/ghc/fix-7.4.2-clang.patch
deleted file mode 100644
index ce1593b3e31d..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.4.2-clang.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index 25ba154..fbb7874 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -178,9 +178,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--        pprPlatform platform binds $$ pprPlatform platform rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), pprPlatform platform binds $$ pprPlatform platform rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
-index 091e1be..23447e4 100644
---- a/compiler/main/GhcMake.hs
-+++ b/compiler/main/GhcMake.hs
-@@ -338,8 +338,7 @@ load2 how_much mod_graph = do
-               liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1
- 
-               -- there should be no Nothings where linkables should be, now
--              ASSERT(all (isJust.hm_linkable) 
--                        (eltsUFM (hsc_HPT hsc_env))) do
-+              ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
-         
-               -- Link everything together
-               linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index 86dc88d..ecde4fd 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -407,8 +407,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index 3bd95a7..4c9ee7c 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2336,8 +2336,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
diff --git a/pkgs/development/compilers/ghc/fix-7.6.3-clang.patch b/pkgs/development/compilers/ghc/fix-7.6.3-clang.patch
deleted file mode 100644
index e83fd252d72c..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.6.3-clang.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index 7cdb1b6..e953507 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -157,9 +157,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--        ppr binds $$ ppr rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), ppr binds $$ ppr rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
-index f563cd9..4ac7812 100644
---- a/compiler/main/GhcMake.hs
-+++ b/compiler/main/GhcMake.hs
-@@ -331,8 +331,7 @@ load how_much = do
-           liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1
- 
-           -- there should be no Nothings where linkables should be, now
--          ASSERT(all (isJust.hm_linkable) 
--                    (eltsUFM (hsc_HPT hsc_env))) do
-+          ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
-     
-           -- Link everything together
-           linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index 87aefba..479d2ef 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -415,8 +415,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index f2ed224..464fad6 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2359,8 +2359,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
-diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs
-index 42e54ba..9b420ae 100644
---- a/compiler/types/Coercion.lhs
-+++ b/compiler/types/Coercion.lhs
-@@ -498,8 +498,7 @@ splitForAllCo_maybe _                = Nothing
- coVarKind :: CoVar -> (Type,Type) 
- coVarKind cv
-  | Just (tc, [_kind,ty1,ty2]) <- splitTyConApp_maybe (varType cv)
-- = ASSERT (tc `hasKey` eqPrimTyConKey)
--   (ty1,ty2)
-+ = ASSERT (tc `hasKey` eqPrimTyConKey) (ty1,ty2)
-  | otherwise = panic "coVarKind, non coercion variable"
- 
- -- | Makes a coercion type from two types: the types whose equality 
diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index 51497e0d9cee..7e1c73d166a2 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -22,7 +22,7 @@
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? true
+  enableShared ? !targetPlatform.useAndroidPrebuilt
 
 , version ? "8.5.20180118"
 }:
@@ -50,6 +50,8 @@ let
   '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
+  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+    EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
diff --git a/pkgs/development/compilers/ghc/hpc-7.8.4.patch b/pkgs/development/compilers/ghc/hpc-7.8.4.patch
deleted file mode 100644
index 212989200bc5..000000000000
--- a/pkgs/development/compilers/ghc/hpc-7.8.4.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
-index 991fc57..0aad221 100644
---- a/compiler/cmm/CLabel.hs
-+++ b/compiler/cmm/CLabel.hs
-@@ -877,7 +877,7 @@ labelDynamic dflags this_pkg this_mod lbl =
- 
-    PlainModuleInitLabel m -> not (gopt Opt_Static dflags) && this_pkg /= (modulePackageId m)
- 
--   HpcTicksLabel m        -> not (gopt Opt_Static dflags) && this_pkg /= (modulePackageId m)
-+   HpcTicksLabel m        -> not (gopt Opt_Static dflags) && this_mod /= m
- 
-    -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
-    _                 -> False
diff --git a/pkgs/development/compilers/ghcjs/base.nix b/pkgs/development/compilers/ghcjs/base.nix
index 3aac2d70e137..07662d32d258 100644
--- a/pkgs/development/compilers/ghcjs/base.nix
+++ b/pkgs/development/compilers/ghcjs/base.nix
@@ -189,7 +189,7 @@ in mkDerivation (rec {
   description = "A Haskell to JavaScript compiler that uses the GHC API";
   license = stdenv.lib.licenses.bsd3;
   platforms = ghc.meta.platforms;
-  maintainers = with stdenv.lib.maintainers; [ jwiegley cstrahan dmjio ];
+  maintainers = with stdenv.lib.maintainers; [ jwiegley cstrahan dmjio elvishjerricco ];
   hydraPlatforms = if broken then [] else ghc.meta.platforms;
   inherit broken;
 })
diff --git a/pkgs/development/compilers/ghcjs/default.nix b/pkgs/development/compilers/ghcjs/default.nix
index b5a7a7f7cfc2..7f3cc9440015 100644
--- a/pkgs/development/compilers/ghcjs/default.nix
+++ b/pkgs/development/compilers/ghcjs/default.nix
@@ -2,5 +2,4 @@
 
 bootPkgs.callPackage ./base.nix {
   inherit bootPkgs cabal-install;
-  broken = true;  # https://hydra.nixos.org/build/70552553
 }
diff --git a/pkgs/development/compilers/ghdl/default.nix b/pkgs/development/compilers/ghdl/default.nix
deleted file mode 100644
index eaf9949b52da..000000000000
--- a/pkgs/development/compilers/ghdl/default.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ stdenv, fetchFromGitHub, gnat, zlib, llvm_35, ncurses, clang, flavour ? "mcode" }:
-
-# mcode only works on x86, while the llvm flavour works on both x86 and x86_64.
-
-
-assert flavour == "llvm" || flavour == "mcode";
-
-let
-  inherit (stdenv.lib) optional;
-  inherit (stdenv.lib) optionals;
-  version = "0.33";
-in
-stdenv.mkDerivation rec {
-  name = "ghdl-${flavour}-${version}";
-
-  src = fetchFromGitHub {
-    owner = "tgingold";
-    repo = "ghdl";
-    rev = "v${version}";
-    sha256 = "0g72rk2yzr0lrpncq2c1qcv71w3mi2hjq84r1yzgjr6d0qm87r2a";
-  };
-
-  buildInputs = [ gnat zlib ] ++ optionals (flavour == "llvm") [ clang ncurses ];
-
-  configureFlags = optional (flavour == "llvm") "--with-llvm=${llvm_35}";
-
-  patchPhase = ''
-    # Disable warnings-as-errors, because there are warnings (unused things)
-    sed -i s/-gnatwae/-gnatwa/ Makefile.in ghdl.gpr.in
-  '';
-
-  hardeningDisable = [ "all" ];
-
-  enableParallelBuilding = true;
-
-  meta = {
-    homepage = https://sourceforge.net/p/ghdl-updates/wiki/Home/;
-    description = "Free VHDL simulator";
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; (if flavour == "llvm" then [ "i686-linux" "x86_64-linux" ]
-      else [ "i686-linux" ]);
-    license = stdenv.lib.licenses.gpl2Plus;
-  };
-}
diff --git a/pkgs/development/compilers/glslang/default.nix b/pkgs/development/compilers/glslang/default.nix
index 151f42a7aa7b..ca1e2f54df93 100644
--- a/pkgs/development/compilers/glslang/default.nix
+++ b/pkgs/development/compilers/glslang/default.nix
@@ -1,21 +1,35 @@
-{ stdenv, fetchFromGitHub, cmake, bison }:
+{ stdenv, fetchFromGitHub, cmake, bison, spirv-tools, jq }:
 
 stdenv.mkDerivation rec {
   name = "glslang-git-${version}";
-  version = "2017-08-31";
+  version = "2018-02-05";
 
   # `vulkan-loader` requires a specific version of `glslang` as specified in
   # `<vulkan-loader-repo>/external_revisions/glslang_revision`.
   src = fetchFromGitHub {
     owner = "KhronosGroup";
     repo = "glslang";
-    rev = "3a21c880500eac21cdf79bef5b80f970a55ac6af";
-    sha256 = "1i15m17r0acmzjrkybris2rgw15il05a4w5h7vhhsiyngcvajcyn";
+    rev = "2651ccaec8";
+    sha256 = "0x5x5i07n9g809rzf5jgw70mmwck31ishdmxnmi0wxx737jjqwaq";
   };
 
-  buildInputs = [ cmake bison ];
+  buildInputs = [ cmake bison jq ] ++ spirv-tools.buildInputs;
   enableParallelBuilding = true;
 
+  patchPhase = ''
+    cp --no-preserve=mode -r "${spirv-tools.src}" External/spirv-tools
+    ln -s "${spirv-tools.headers}" External/spirv-tools/external/spirv-headers
+  '';
+
+  preConfigure = ''
+    HEADERS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools/external/spirv-headers"))[0].commit')
+    TOOLS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools"))[0].commit')
+    if [ "$HEADERS_COMMIT" != "${spirv-tools.headers.rev}" ] || [ "$TOOLS_COMMIT" != "${spirv-tools.src.rev}" ]; then
+      echo "ERROR: spirv-tools commits do not match expected versions";
+      exit 1;
+    fi
+  '';
+
   meta = with stdenv.lib; {
     inherit (src.meta) homepage;
     description = "Khronos reference front-end for GLSL and ESSL";
diff --git a/pkgs/development/compilers/gnatboot/default.nix b/pkgs/development/compilers/gnatboot/default.nix
deleted file mode 100644
index a209e392bc6f..000000000000
--- a/pkgs/development/compilers/gnatboot/default.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{stdenv, fetchurl}:
-
-stdenv.mkDerivation {
-  name = "gentoo-gnatboot-4.1";
-
-  src = if stdenv.system == "i686-linux" then
-    fetchurl {
-      url = "mirror://gentoo/distfiles/gnatboot-4.1-i386.tar.bz2";
-      sha256 = "0665zk71598204bf521vw68i5y6ccqarq9fcxsqp7ccgycb4lysr";
-    }
-    else if stdenv.system == "x86_64-linux" then
-    fetchurl {
-      url = "mirror://gentoo/distfiles/gnatboot-4.1-amd64.tar.bz2";
-      sha256 = "1li4d52lmbnfs6llcshlbqyik2q2q4bvpir0f7n38nagp0h6j0d4";
-    } else throw "Platform not supported";
-
-  dontStrip=1;
-
-  installPhase = ''
-    mkdir -p $out
-    cp -R * $out
-    set +e
-    for a in $out/bin/* ; do
-      patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-        --set-rpath $(cat $NIX_CC/nix-support/orig-libc)/lib:$(cat $NIX_CC/nix-support/orig-cc)/lib64:$(cat $NIX_CC/nix-support/orig-cc)/lib $a
-    done
-    set -e
-    mv $out/bin/gnatgcc_2wrap $out/bin/gnatgcc
-    ln -s $out/bin/gnatgcc $out/bin/gcc
-  '';
-
-  passthru = {
-    langC = true; /* TRICK for gcc-wrapper to wrap it */
-    langCC = false;
-    langFortran = false;
-    langAda = true;
-  };
-
-  meta = {
-    homepage = http://gentoo.org;
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
-    maintainers = [
-      stdenv.lib.maintainers.viric
-    ];
-    
-    platforms = stdenv.lib.platforms.linux;
-  };
-}
diff --git a/pkgs/development/compilers/go/1.10.nix b/pkgs/development/compilers/go/1.10.nix
index b22bfb2bd101..1f7cc9d7740c 100644
--- a/pkgs/development/compilers/go/1.10.nix
+++ b/pkgs/development/compilers/go/1.10.nix
@@ -25,18 +25,17 @@ in
 
 stdenv.mkDerivation rec {
   name = "go-${version}";
-  version = "1.10";
+  version = "1.10.1";
 
   src = fetchFromGitHub {
     owner = "golang";
     repo = "go";
     rev = "go${version}";
-    sha256 = "1dzs1mz3zxgg1qyi2lrlxdz1lsvazxvmj9cb69pgqnwjlh3jpw0l";
+    sha256 = "1wqwy52ibb343a4v7b9q26xa6r5jk4khfxd90wbpcayws8cxly8m";
   };
 
   # perl is used for testing go vet
-  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ]
-    ++ optionals stdenv.isLinux [ procps ];
+  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper procps ];
   buildInputs = [ cacert pcre ]
     ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ]
     ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
@@ -77,6 +76,10 @@ stdenv.mkDerivation rec {
     sed -i '/TestRespectSetgidDir/areturn' src/cmd/go/internal/work/build_test.go
     # Remove cert tests that conflict with NixOS's cert resolution
     sed -i '/TestEnvVars/areturn' src/crypto/x509/root_unix_test.go
+    # TestWritevError hangs sometimes
+    sed -i '/TestWritevError/areturn' src/net/writev_test.go
+    # TestVariousDeadlines fails sometimes
+    sed -i '/TestVariousDeadlines/areturn' src/net/timeout_test.go
 
     sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
     sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go
diff --git a/pkgs/development/compilers/go/1.9.nix b/pkgs/development/compilers/go/1.9.nix
index 955d9029d388..8ef528e2c92a 100644
--- a/pkgs/development/compilers/go/1.9.nix
+++ b/pkgs/development/compilers/go/1.9.nix
@@ -25,18 +25,17 @@ in
 
 stdenv.mkDerivation rec {
   name = "go-${version}";
-  version = "1.9.4";
+  version = "1.9.5";
 
   src = fetchFromGitHub {
     owner = "golang";
     repo = "go";
     rev = "go${version}";
-    sha256 = "15d9lfiy1cjfz6nqnig5884ykqckx58cynd1bva1xna7bwcwwp2r";
+    sha256 = "15dx1b71xv7b265gqk9nv02pirggpw7d83apikhrza2qkj64ydd0";
   };
 
   # perl is used for testing go vet
-  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ]
-    ++ optionals stdenv.isLinux [ procps ];
+  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper procps ];
   buildInputs = [ cacert pcre ]
     ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ]
     ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
@@ -77,6 +76,10 @@ stdenv.mkDerivation rec {
     sed -i '/TestRespectSetgidDir/areturn' src/cmd/go/internal/work/build_test.go
     # Remove cert tests that conflict with NixOS's cert resolution
     sed -i '/TestEnvVars/areturn' src/crypto/x509/root_unix_test.go
+    # TestWritevError hangs sometimes
+    sed -i '/TestWritevError/areturn' src/net/writev_test.go
+    # TestVariousDeadlines fails sometimes
+    sed -i '/TestVariousDeadlines/areturn' src/net/timeout_test.go
 
     sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
     sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go
diff --git a/pkgs/development/compilers/gprolog/default.nix b/pkgs/development/compilers/gprolog/default.nix
index 0e3eb88f537c..b12b055342ca 100644
--- a/pkgs/development/compilers/gprolog/default.nix
+++ b/pkgs/development/compilers/gprolog/default.nix
@@ -63,6 +63,6 @@ stdenv.mkDerivation rec {
     '';
 
     maintainers = [ stdenv.lib.maintainers.peti ];
-    platforms = stdenv.lib.platforms.gnu;
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/graalvm/default.nix b/pkgs/development/compilers/graalvm/default.nix
index ce324b353ec5..2eb9c4a7e835 100644
--- a/pkgs/development/compilers/graalvm/default.nix
+++ b/pkgs/development/compilers/graalvm/default.nix
@@ -116,6 +116,7 @@ in rec {
       mv jdk1.8.0_*/linux-amd64/product $out
       find $out -type f -exec sed -i "s#${oraclejdk8}#$out#g" {} \;
     '';
+    dontFixup = true; # do not nuke path of ffmpeg etc
     dontStrip = true; # why? see in oraclejdk derivation
     inherit (oraclejdk8) meta;
   };
@@ -174,6 +175,7 @@ in rec {
         --replace file:/dev/random    file:/dev/./urandom \
         --replace NativePRNGBlocking  SHA1PRNG
     '';
+    dontFixup = true; # do not nuke path of ffmpeg etc
     dontStrip = true; # why? see in oraclejdk derivation
     doInstallCheck = true;
     installCheckPhase = ''
diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix
index a420949711e0..afeef2b3637c 100644
--- a/pkgs/development/compilers/haxe/default.nix
+++ b/pkgs/development/compilers/haxe/default.nix
@@ -53,6 +53,24 @@ let
 
       dontStrip = true;
 
+      # While it might be a good idea to run the upstream test suite, let's at
+      # least make sure we can actually run the compiler.
+      doInstallCheck = true;
+      installCheckPhase = ''
+        # Get out of the source directory to make sure the stdlib from the
+        # sources doesn't interfere with the installed one.
+        mkdir installcheck
+        pushd installcheck > /dev/null
+        cat >> InstallCheck.hx <<EOF
+        class InstallCheck {
+          public static function main() trace("test");
+        }
+        EOF
+        "$out/bin/haxe" -js installcheck.js -main InstallCheck
+        grep -q 'console\.log.*test' installcheck.js
+        popd > /dev/null
+      '';
+
       meta = with stdenv.lib; {
         description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
         homepage = https://haxe.org;
@@ -75,7 +93,7 @@ in {
     version = "3.4.6";
     sha256 = "1myc4b8fwp0f9vky17wv45n34a583f5sjvajsc93f5gm1wanp4if";
     prePatch = ''
-      sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml
+      sed -i -re 's!(let +prefix_path += +).*( +in)!\1"'"$out/"'"\2!' src/main.ml
       sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx
     '';
   };
diff --git a/pkgs/development/compilers/hhvm/default.nix b/pkgs/development/compilers/hhvm/default.nix
index 1cb28118ccbe..749e4125a0b3 100644
--- a/pkgs/development/compilers/hhvm/default.nix
+++ b/pkgs/development/compilers/hhvm/default.nix
@@ -59,7 +59,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "High-performance JIT compiler for PHP/Hack";
-    homepage    = "http://hhvm.com";
+    homepage    = "https://hhvm.com";
     license     = "PHP/Zend";
     platforms   = [ "x86_64-linux" ];
     maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
diff --git a/pkgs/development/compilers/iasl/default.nix b/pkgs/development/compilers/iasl/default.nix
index 5e0970ea12f4..22f80ae559f7 100644
--- a/pkgs/development/compilers/iasl/default.nix
+++ b/pkgs/development/compilers/iasl/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "iasl-${version}";
-  version = "20170303";
+  version = "20180313";
 
   src = fetchurl {
     url = "https://acpica.org/sites/acpica/files/acpica-unix-${version}.tar.gz";
-    sha256 = "1dc933rr11gv1nlaf5j8ih1chdakbjbjkn34jgbm330zppmck4y0";
+    sha256 = "05ab2xfv9wqwbzjaa9xqgrvvan87rxv29hw48h1gcckpc5smp2wm";
   };
 
   NIX_CFLAGS_COMPILE = "-O3";
diff --git a/pkgs/development/compilers/icedtea-web/default.nix b/pkgs/development/compilers/icedtea-web/default.nix
index fb03d98dbdc0..9390cbde6377 100644
--- a/pkgs/development/compilers/icedtea-web/default.nix
+++ b/pkgs/development/compilers/icedtea-web/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "icedtea-web-${version}";
 
-  version = "1.6.2";
+  version = "1.7.1";
 
   src = fetchurl {
     url = "http://icedtea.wildebeest.org/download/source/${name}.tar.gz";
-    sha256 = "004kwrngyxxlrlzby4vzxjr0xcyngcdc9dfgnvi61ffnjr006ryf";
+    sha256 = "1b9z0i9b1dsc2qpfdzbn2fi4vi3idrhm7ig45g1ny40ymvxcwwn9";
   };
 
   nativeBuildInputs = [ pkgconfig bc perl ];
diff --git a/pkgs/development/compilers/jetbrains-jdk/default.nix b/pkgs/development/compilers/jetbrains-jdk/default.nix
index 604474e01fe9..5ffb7b92b26a 100644
--- a/pkgs/development/compilers/jetbrains-jdk/default.nix
+++ b/pkgs/development/compilers/jetbrains-jdk/default.nix
@@ -7,13 +7,13 @@
 
 let drv = stdenv.mkDerivation rec {
   pname = "jetbrainsjdk";
-  version = "152b1036.1";
+  version = "152b1136.20";
   name = pname + "-" + version;
 
   src = if stdenv.system == "x86_64-linux" then
     fetchurl {
       url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbsdk8u${version}_linux_x64.tar.gz";
-      sha256 = "1768f02i3dxdbxn8n29d522h8v0mkgnhpb8ixzq5p54vwjmfl6md";
+      sha256 = "0sqr8f3z062kwcxh3dxnan45ldas438blbc69z0pypbhc8c2sk2b";
     }
   else
     throw "unsupported system: ${stdenv.system}";
diff --git a/pkgs/development/compilers/jsonnet/default.nix b/pkgs/development/compilers/jsonnet/default.nix
index d46646733064..839e3e71e811 100644
--- a/pkgs/development/compilers/jsonnet/default.nix
+++ b/pkgs/development/compilers/jsonnet/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, fetchFromGitHub, emscripten }:
 
-let version = "0.9.5"; in
+let version = "0.10.0"; in
 
 stdenv.mkDerivation {
   name = "jsonnet-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
     rev = "v${version}";
     owner = "google";
     repo = "jsonnet";
-    sha256 = "193sa4hdhvml0c32nmdkjii41hbyc5l0zisdn699ar0gaq7yiqan";
+    sha256 = "0xj540140r89qrdh3h4kzlz4x8c576ynq9i1x82zzl3d7fxbk5f0";
   };
 
   buildInputs = [ emscripten ];
diff --git a/pkgs/development/compilers/julia/0.5.nix b/pkgs/development/compilers/julia/0.5.nix
index 0cf933ee4d20..cff6c1c446f1 100644
--- a/pkgs/development/compilers/julia/0.5.nix
+++ b/pkgs/development/compilers/julia/0.5.nix
@@ -42,7 +42,7 @@ let
   rmathVersion = "0.1";
   rmath-julia = fetchurl {
     url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
-    sha256 = "0ai5dhjc43zcvangz123ryxmlbm51s21rg13bllwyn98w67arhb4";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
   };
   
   virtualenvVersion = "15.0.0";
diff --git a/pkgs/development/compilers/julia/0.6.nix b/pkgs/development/compilers/julia/0.6.nix
index 6acb192933e6..6fad8e5259c5 100644
--- a/pkgs/development/compilers/julia/0.6.nix
+++ b/pkgs/development/compilers/julia/0.6.nix
@@ -42,7 +42,7 @@ let
   rmathVersion = "0.1";
   rmath-julia = fetchurl {
     url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
-    sha256 = "0ai5dhjc43zcvangz123ryxmlbm51s21rg13bllwyn98w67arhb4";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
   };
   
   virtualenvVersion = "15.0.0";
@@ -172,10 +172,14 @@ stdenv.mkDerivation rec {
   '';
 
   postInstall = ''
-    for prog in "$out/bin/julia" "$out/bin/julia-debug"; do
-        wrapProgram "$prog" \
-            --prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH:$out/lib/julia" \
-            --prefix PATH : "${stdenv.lib.makeBinPath [ curl ]}"
+    # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia,
+    # as using a wrapper with LD_LIBRARY_PATH causes segmentation
+    # faults when program returns an error:
+    #   $ julia -e 'throw(Error())'
+    find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do
+      if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then
+        ln -sv $lib $out/lib/julia/$(basename $lib)
+      fi
     done
   '';
 
diff --git a/pkgs/development/compilers/julia/default.nix b/pkgs/development/compilers/julia/default.nix
index 63252084b5de..b5a3a8c6be2d 100644
--- a/pkgs/development/compilers/julia/default.nix
+++ b/pkgs/development/compilers/julia/default.nix
@@ -42,7 +42,7 @@ let
   rmathVersion = "0.1";
   rmath-julia = fetchurl {
     url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
-    sha256 = "0ai5dhjc43zcvangz123ryxmlbm51s21rg13bllwyn98w67arhb4";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
   };
 in
 
@@ -164,6 +164,7 @@ stdenv.mkDerivation rec {
     license = stdenv.lib.licenses.mit;
     maintainers = with stdenv.lib.maintainers; [ raskin ];
     platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
-    broken = stdenv.isi686;
+    #broken = stdenv.isi686;
+    broken = true; # 2018-04-10
   };
 }
diff --git a/pkgs/development/compilers/julia/git.nix b/pkgs/development/compilers/julia/git.nix
index 19519823f373..4b9a369e8d25 100644
--- a/pkgs/development/compilers/julia/git.nix
+++ b/pkgs/development/compilers/julia/git.nix
@@ -40,7 +40,7 @@ let
   rmathVersion = "0.1";
   rmath-julia = fetchurl {
     url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
-    sha256 = "0ai5dhjc43zcvangz123ryxmlbm51s21rg13bllwyn98w67arhb4";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
   };
   
   virtualenvVersion = "15.0.0";
diff --git a/pkgs/development/compilers/kotlin/default.nix b/pkgs/development/compilers/kotlin/default.nix
index b6374908757c..76f29eeaa0c0 100644
--- a/pkgs/development/compilers/kotlin/default.nix
+++ b/pkgs/development/compilers/kotlin/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchurl, makeWrapper, jre, unzip }:
 
 let
-  version = "1.2.30";
+  version = "1.2.41";
 in stdenv.mkDerivation rec {
   inherit version;
   name = "kotlin-${version}";
 
   src = fetchurl {
     url = "https://github.com/JetBrains/kotlin/releases/download/v${version}/kotlin-compiler-${version}.zip";
-    sha256 = "0wg08cncwfajxfx8860wdf5dr4h92j069qvdr90l5m01ff3nasad";
+    sha256 = "0p16xl2qhm7913abd06vvmsx956ny51jjfr6knkmrnk8y9r2g1xg";
   };
 
   propagatedBuildInputs = [ jre ] ;
@@ -22,6 +22,11 @@ in stdenv.mkDerivation rec {
     for p in $(ls $out/bin/) ; do
       wrapProgram $out/bin/$p --prefix PATH ":" ${jre}/bin ;
     done
+
+    if [ -f $out/LICENSE ]; then
+      install -D $out/LICENSE $out/share/kotlin/LICENSE
+      rm $out/LICENSE
+    fi
   '';
 
   meta = {
diff --git a/pkgs/development/compilers/ldc/default.nix b/pkgs/development/compilers/ldc/default.nix
index bdb74680b134..1fd839180c56 100644
--- a/pkgs/development/compilers/ldc/default.nix
+++ b/pkgs/development/compilers/ldc/default.nix
@@ -2,8 +2,8 @@
 , python, libconfig, lit, gdb, unzip, darwin, bash
 , callPackage
 , bootstrapVersion ? false
-, version ? "1.7.0"
-, ldcSha256 ? "1g8qvmlzvsp030z2rw6lis4kclsd9mlmnbim5kas0k1yr9063m3w"
+, version ? "1.8.0"
+, ldcSha256 ? "0zswjlibj8zcdj06nn09jjhbd99chsa5f4kps8xifzgrpgsa28g4"
 }:
 
 let
@@ -29,16 +29,12 @@ let
       sha256 = ldcSha256;
     };
 
-    sourceRoot = ".";
-
     postUnpack = ''
-        cd ldc-${version}-src/
-
         patchShebangs .
 
         # Remove cppa test for now because it doesn't work.
-        rm tests/d2/dmd-testsuite/runnable/cppa.d
-        rm tests/d2/dmd-testsuite/runnable/extra-files/cppb.cpp
+        rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/cppa.d
+        rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/extra-files/cppb.cpp
     ''
 
     + stdenv.lib.optionalString (bootstrapVersion) ''
@@ -55,12 +51,15 @@ let
         #
         #==============================
         #Test failed: expected rc == 0, exited with rc == 1
-        rm tests/d2/dmd-testsuite/runnable/variadic.d
+        rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/variadic.d
     ''
 
     + stdenv.lib.optionalString (!bootstrapVersion) ''
 	    # http://forum.dlang.org/thread/xtbbqthxutdoyhnxjhxl@forum.dlang.org
-	    rm -r tests/dynamiccompile
+	    rm -r ldc-${version}-src/tests/dynamiccompile
+
+            # https://github.com/NixOS/nixpkgs/issues/34817
+	    rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall
     '';
 
     ROOT_HOME_DIR = "$(echo ~root)";
@@ -190,8 +189,6 @@ let
 
     src = ldcBuild.src;
 
-    sourceRoot = ".";
-
     postUnpack = ldcBuild.postUnpack;
 
     postPatch = ldcBuild.postPatch;
@@ -212,7 +209,7 @@ let
                         "-DLDC_WITH_LLD=OFF"
                         # Xcode 9.0.1 fixes that bug according to ldc release notes
                         "-DRT_ARCHIVE_WITH_LDC=OFF"
-                        "-DD_COMPILER=${ldcBuild}/bin/ldmd2"
+                        "-DD_COMPILER=${ldcBuild.out}/bin/ldmd2"
                       )
     '';
 
@@ -223,7 +220,7 @@ let
     buildCmd = if bootstrapVersion then
       "ctest -V -R \"build-druntime-ldc-unittest|build-phobos2-ldc-unittest\""
     else
-      "make -j$NIX_BUILD_CORES DMD=${ldcBuild}/bin/ldc2 druntime-test-runner druntime-test-runner-debug phobos2-test-runner phobos2-test-runner-debug";
+      "make -j$NIX_BUILD_CORES DMD=${ldcBuild.out}/bin/ldc2 phobos2-test-runner phobos2-test-runner-debug";
 
     testCmd = if bootstrapVersion then
       "ctest -j$NIX_BUILD_CORES --output-on-failure -E \"dmd-testsuite|lit-tests|ldc2-unittest|llvm-ir-testsuite\""
@@ -232,6 +229,7 @@ let
 
     buildPhase = ''
         ${buildCmd}
+        ln -s ${ldcBuild.out}/bin/ldmd2 $PWD/bin/ldmd2
         ${testCmd}
     '';
 
diff --git a/pkgs/development/compilers/llvm/3.4/llvm.nix b/pkgs/development/compilers/llvm/3.4/llvm.nix
index 27047e7d941c..0b29b04825a1 100644
--- a/pkgs/development/compilers/llvm/3.4/llvm.nix
+++ b/pkgs/development/compilers/llvm/3.4/llvm.nix
@@ -90,6 +90,6 @@ in stdenv.mkDerivation rec {
     homepage    = http://llvm.org/;
     license     = stdenv.lib.licenses.ncsa;
     maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric ];
-    platforms   = stdenv.lib.platforms.all;
+    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "armv7l-linux"];
   };
 }
diff --git a/pkgs/development/compilers/llvm/3.5/llvm.nix b/pkgs/development/compilers/llvm/3.5/llvm.nix
index 00b2548d56e6..7dc134b4fcfd 100644
--- a/pkgs/development/compilers/llvm/3.5/llvm.nix
+++ b/pkgs/development/compilers/llvm/3.5/llvm.nix
@@ -98,7 +98,7 @@ in stdenv.mkDerivation rec {
     homepage    = http://llvm.org/;
     license     = stdenv.lib.licenses.ncsa;
     maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric ];
-    platforms   = stdenv.lib.platforms.all;
+    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "armv7l-linux"];
   };
 }
 
diff --git a/pkgs/development/compilers/llvm/4/cmdline-help.patch b/pkgs/development/compilers/llvm/4/cmdline-help.patch
new file mode 100644
index 000000000000..a693719c2cfa
--- /dev/null
+++ b/pkgs/development/compilers/llvm/4/cmdline-help.patch
@@ -0,0 +1,39 @@
+From c7a9aa3a697c81432786a5583bf973771c7be15e Mon Sep 17 00:00:00 2001
+From: Don Hinton <hintonda@gmail.com>
+Date: Wed, 12 Jul 2017 01:15:46 +0000
+Subject: [PATCH] Fix minor typo introduced in r276404
+
+Summary:
+A space was added between '-' and 'help' when emitting help output.
+
+See https://reviews.llvm.org/D22621 for details.
+
+Reviewers: MaggieYi, vsk
+
+Reviewed By: vsk
+
+Subscribers: llvm-commits
+
+Differential Revision: https://reviews.llvm.org/D35283
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307745 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ lib/Support/CommandLine.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
+index 3889902eea5..79defa5c36c 100644
+--- a/lib/Support/CommandLine.cpp
++++ b/lib/Support/CommandLine.cpp
+@@ -1236,7 +1236,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
+              << ": Not enough positional command line arguments specified!\n"
+              << "Must specify at least " << NumPositionalRequired
+              << " positional argument" << (NumPositionalRequired > 1 ? "s" : "")
+-             << ": See: " << argv[0] << " - help\n";
++             << ": See: " << argv[0] << " -help\n";
+     }
+ 
+     ErrorParsing = true;
+-- 
+2.14.0
+
diff --git a/pkgs/development/compilers/llvm/4/lldb.nix b/pkgs/development/compilers/llvm/4/lldb.nix
index 5ffc346a479e..325149fc19be 100644
--- a/pkgs/development/compilers/llvm/4/lldb.nix
+++ b/pkgs/development/compilers/llvm/4/lldb.nix
@@ -41,6 +41,11 @@ stdenv.mkDerivation {
     "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
   ];
 
+  # Add missing include to fix error when using std::bind
+  prePatch = ''
+    sed -i -e '30i#include <functional>' include/lldb/Utility/TaskPool.h
+  '';
+
   enableParallelBuilding = true;
 
   postInstall = ''
diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix
index 7fd94316d738..bc8453f743ad 100644
--- a/pkgs/development/compilers/llvm/4/llvm.nix
+++ b/pkgs/development/compilers/llvm/4/llvm.nix
@@ -78,11 +78,15 @@ in stdenv.mkDerivation (rec {
       substituteInPlace lib/esan/esan_sideline_linux.cpp \
         --replace 'struct sigaltstack' 'stack_t'
     )
+  '' + # Fix extra space printed in commandline help sometimes, "- help"
+  ''
+    patch -p1 -i ${./cmdline-help.patch}
   '' + stdenv.lib.optionalString stdenv.isAarch64 ''
     patch -p0 < ${../aarch64.patch}
   '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -i ${../TLI-musl.patch}
     patch -p1 -i ${./dynamiclibrary-musl.patch}
+    patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
   '';
 
   # hacky fix: created binaries need to be run before installation
@@ -118,9 +122,6 @@ in stdenv.mkDerivation (rec {
     "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
     "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
     "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
-
-    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
-    "-DCOMPILER_RT_BUILD_XRAY=OFF"
   ];
 
   postBuild = ''
diff --git a/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch b/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch
new file mode 100644
index 000000000000..5bd858f8ae79
--- /dev/null
+++ b/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch
@@ -0,0 +1,368 @@
+From dac4d3912378069b44340204e5fc6237aa1baf94 Mon Sep 17 00:00:00 2001
+From: Matthias Maier <tamiko@43-1.org>
+Date: Fri, 5 May 2017 17:47:39 +0000
+Subject: [PATCH] Musl patches
+
+Ported to compiler-rt-sanitizers-4.0.0. Taken from
+
+  https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
+---
+ lib/asan/asan_linux.cc                             |  4 +--
+ lib/interception/interception_linux.cc             |  2 +-
+ lib/interception/interception_linux.h              |  2 +-
+ lib/msan/msan_linux.cc                             |  2 +-
+ .../sanitizer_common_interceptors_ioctl.inc        |  4 +--
+ lib/sanitizer_common/sanitizer_common_syscalls.inc |  2 +-
+ lib/sanitizer_common/sanitizer_linux_libcdep.cc    | 12 +++----
+ lib/sanitizer_common/sanitizer_platform.h          |  7 ++++
+ .../sanitizer_platform_interceptors.h              |  2 +-
+ .../sanitizer_platform_limits_posix.cc             | 39 +++++++++++++---------
+ lib/tsan/rtl/tsan_platform_linux.cc                |  2 +-
+ 11 files changed, 46 insertions(+), 32 deletions(-)
+
+diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
+index c051573dd..e295f6004 100644
+--- a/lib/asan/asan_linux.cc
++++ b/lib/asan/asan_linux.cc
+@@ -39,7 +39,7 @@
+ #include <sys/link_elf.h>
+ #endif
+ 
+-#if SANITIZER_ANDROID || SANITIZER_FREEBSD
++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU
+ #include <ucontext.h>
+ extern "C" void* _DYNAMIC;
+ #else
+@@ -80,7 +80,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
+   UNIMPLEMENTED();
+ }
+ 
+-#if SANITIZER_ANDROID
++#if SANITIZER_ANDROID || SANITIZER_NONGNU
+ // FIXME: should we do anything for Android?
+ void AsanCheckDynamicRTPrereqs() {}
+ void AsanCheckIncompatibleRT() {}
+diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
+index 6e908ac01..8f23d9adc 100644
+--- a/lib/interception/interception_linux.cc
++++ b/lib/interception/interception_linux.cc
+@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+   return real == wrapper;
+ }
+ 
+-#if !defined(__ANDROID__)  // android does not have dlvsym
++#if !defined(__ANDROID__) && !SANITIZER_NONGNU  // android does not have dlvsym
+ void *GetFuncAddrVer(const char *func_name, const char *ver) {
+   return dlvsym(RTLD_NEXT, func_name, ver);
+ }
+diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
+index 27a66c882..3b559a303 100644
+--- a/lib/interception/interception_linux.h
++++ b/lib/interception/interception_linux.h
+@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
+       (::__interception::uptr) & (func),                                   \
+       (::__interception::uptr) & WRAP(func))
+ 
+-#if !defined(__ANDROID__)  // android does not have dlvsym
++#if !defined(__ANDROID__) && !SANITIZER_NONGNU  // android does not have dlvsym
+ #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
+   (::__interception::real_##func = (func##_f)(                \
+        unsigned long)::__interception::GetFuncAddrVer(#func, symver))
+diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
+index 0a687f620..0852d97d7 100644
+--- a/lib/msan/msan_linux.cc
++++ b/lib/msan/msan_linux.cc
+@@ -13,7 +13,7 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "sanitizer_common/sanitizer_platform.h"
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
++#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU
+ 
+ #include "msan.h"
+ #include "msan_thread.h"
+diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+index 4ed9afedf..64f584e93 100644
+--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+@@ -100,7 +100,7 @@ static void ioctl_table_fill() {
+   _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
+ #endif
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+   // Conflicting request ids.
+   // _(CDROMAUDIOBUFSIZ, NONE, 0);
+   // _(SNDCTL_TMR_CONTINUE, NONE, 0);
+@@ -361,7 +361,7 @@ static void ioctl_table_fill() {
+   _(VT_WAITACTIVE, NONE, 0);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
+   _(CYGETDEFTHRESH, WRITE, sizeof(int));
+   _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
+diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+index 469c8eb7e..24f87867d 100644
+--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
+   }
+ }
+ 
+-#if !SANITIZER_ANDROID
++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
+                        void *old_rlim) {
+   if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
+diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+index f99f0b594..3a773a94e 100644
+--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+@@ -152,7 +152,7 @@ bool SanitizerGetThreadName(char *name, int max_len) {
+ #endif
+ }
+ 
+-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
+ static uptr g_tls_size;
+ 
+ #ifdef __i386__
+@@ -180,11 +180,11 @@ void InitTlsSize() {
+ }
+ #else
+ void InitTlsSize() { }
+-#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
++#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
+ 
+ #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
+     || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__)) \
+-    && SANITIZER_LINUX && !SANITIZER_ANDROID
++    && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ // sizeof(struct pthread) from glibc.
+ static atomic_uintptr_t kThreadDescriptorSize;
+ 
+@@ -338,7 +338,7 @@ uptr ThreadSelf() {
+ 
+ #if !SANITIZER_GO
+ static void GetTls(uptr *addr, uptr *size) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
+   *addr = ThreadSelf();
+   *size = GetTlsSize();
+@@ -364,7 +364,7 @@ static void GetTls(uptr *addr, uptr *size) {
+     *addr = (uptr) dtv[2];
+     *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
+   }
+-#elif SANITIZER_ANDROID
++#elif SANITIZER_ANDROID || SANITIZER_NONGNU
+   *addr = 0;
+   *size = 0;
+ #else
+@@ -375,7 +375,7 @@ static void GetTls(uptr *addr, uptr *size) {
+ 
+ #if !SANITIZER_GO
+ uptr GetTlsSize() {
+-#if SANITIZER_FREEBSD || SANITIZER_ANDROID
++#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU
+   uptr addr, size;
+   GetTls(&addr, &size);
+   return size;
+diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
+index d9a8e8df1..fe01c5744 100644
+--- a/lib/sanitizer_common/sanitizer_platform.h
++++ b/lib/sanitizer_common/sanitizer_platform.h
+@@ -162,6 +162,13 @@
+ # define SANITIZER_PPC64V2 0
+ #endif
+ 
++
++#if defined(__linux__) && !defined(__GLIBC__)
++# define SANITIZER_NONGNU 1
++#else
++# define SANITIZER_NONGNU 0
++#endif
++
+ // By default we allow to use SizeClassAllocator64 on 64-bit platform.
+ // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
+ // does not work well and we need to fallback to SizeClassAllocator32.
+diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+index 62875d11a..212e6e882 100644
+--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -23,7 +23,7 @@
+ # define SI_NOT_WINDOWS 0
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # define SI_LINUX_NOT_ANDROID 1
+ #else
+ # define SI_LINUX_NOT_ANDROID 0
+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+index 683f019d7..fd4880962 100644
+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -14,6 +14,8 @@
+ 
+ #include "sanitizer_platform.h"
+ 
++#define _LINUX_SYSINFO_H
++
+ #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
+ // Tests in this file assume that off_t-dependent data structures match the
+ // libc ABI. For example, struct dirent here is what readdir() function (as
+@@ -139,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
+ 
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ #include <glob.h>
+-#include <obstack.h>
++#  if !SANITIZER_NONGNU
++#    include <obstack.h>
++#  endif
+ #include <mqueue.h>
+-#include <net/if_ppp.h>
+-#include <netax25/ax25.h>
+-#include <netipx/ipx.h>
+-#include <netrom/netrom.h>
++#include <linux/if_ppp.h>
++#include <linux/ax25.h>
++#include <linux/ipx.h>
++#include <linux/netrom.h>
+ #if HAVE_RPC_XDR_H
+ # include <rpc/xdr.h>
+ #elif HAVE_TIRPC_RPC_XDR_H
+@@ -160,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t;
+ # include <sys/procfs.h>
+ #endif
+ #include <sys/user.h>
+-#include <sys/ustat.h>
++// #include <sys/ustat.h>
++#include <sys/statfs.h>
+ #include <linux/cyclades.h>
+ #include <linux/if_eql.h>
+ #include <linux/if_plip.h>
+@@ -252,7 +257,7 @@ namespace __sanitizer {
+   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned struct_ustat_sz = sizeof(struct ustat);
+   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+@@ -310,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ #endif
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   int glob_nomatch = GLOB_NOMATCH;
+   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+ #endif
+@@ -404,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned struct_termios_sz = sizeof(struct termios);
+   unsigned struct_winsize_sz = sizeof(struct winsize);
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+   unsigned struct_arpreq_sz = sizeof(struct arpreq);
+   unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
+   unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
+@@ -454,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+   unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+ #if EV_VERSION > (0x010000)
+@@ -822,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
+   unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
+   unsigned IOCTL_CYGETMON = CYGETMON;
+@@ -985,7 +990,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(glob_t);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
+@@ -1019,6 +1024,7 @@ CHECK_TYPE_SIZE(iovec);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_base);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_len);
+ 
++#if !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(msghdr);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
+@@ -1032,6 +1038,7 @@ CHECK_TYPE_SIZE(cmsghdr);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
++#endif
+ 
+ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
+ CHECK_SIZE_AND_OFFSET(dirent, d_ino);
+@@ -1134,7 +1141,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
+ 
+ CHECK_TYPE_SIZE(ether_addr);
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(ipc_perm);
+ # if SANITIZER_FREEBSD
+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
+@@ -1195,7 +1202,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
+ #endif
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
+ #endif
+ 
+@@ -1245,7 +1252,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
+ COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
+ CHECK_SIZE_AND_OFFSET(FILE, _flags);
+ CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
+@@ -1264,7 +1271,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
+ CHECK_SIZE_AND_OFFSET(FILE, _fileno);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
+diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
+index 3313288a7..103c7b6b9 100644
+--- a/lib/tsan/rtl/tsan_platform_linux.cc
++++ b/lib/tsan/rtl/tsan_platform_linux.cc
+@@ -287,7 +287,7 @@ void InitializePlatform() {
+ // This is required to properly "close" the fds, because we do not see internal
+ // closes within glibc. The code is a pure hack.
+ int ExtractResolvFDs(void *state, int *fds, int nfd) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   int cnt = 0;
+   __res_state *statp = (__res_state*)state;
+   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
+-- 
+2.16.2
+
diff --git a/pkgs/development/compilers/llvm/5/llvm.nix b/pkgs/development/compilers/llvm/5/llvm.nix
index f574eb05f92b..ac575a0bf7aa 100644
--- a/pkgs/development/compilers/llvm/5/llvm.nix
+++ b/pkgs/development/compilers/llvm/5/llvm.nix
@@ -79,6 +79,7 @@ in stdenv.mkDerivation (rec {
     substituteInPlace unittests/Support/CMakeLists.txt \
       --replace "add_subdirectory(DynamicLibrary)" ""
     rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+    patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
   '';
 
   # hacky fix: created binaries need to be run before installation
@@ -114,9 +115,6 @@ in stdenv.mkDerivation (rec {
     "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
     "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
     "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
-
-    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
-    "-DCOMPILER_RT_BUILD_XRAY=OFF"
   ];
 
   postBuild = ''
diff --git a/pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch b/pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch
new file mode 100644
index 000000000000..c9ddfe45c898
--- /dev/null
+++ b/pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch
@@ -0,0 +1,370 @@
+From 3e1fcb7d4909db8f0f7dd0109b2eee20115c8be3 Mon Sep 17 00:00:00 2001
+From: "Jory A. Pratt" <anarchy@gentoo.org>
+Date: Sat, 9 Sep 2017 08:31:15 -0500
+Subject: [PATCH] Ported to compiler-rt-sanitizers-5.0.0. Taken from
+
+https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
+Signed-off-by: Jory A. Pratt <anarchy@gentoo.org>
+
+Taken from gentoo-musl project, with a few additional minor fixes.
+---
+ lib/asan/asan_linux.cc                             |  4 +--
+ lib/interception/interception_linux.cc             |  2 +-
+ lib/interception/interception_linux.h              |  2 +-
+ lib/msan/msan_linux.cc                             |  2 +-
+ .../sanitizer_common_interceptors_ioctl.inc        |  4 +--
+ lib/sanitizer_common/sanitizer_common_syscalls.inc |  2 +-
+ lib/sanitizer_common/sanitizer_linux_libcdep.cc    | 12 +++----
+ lib/sanitizer_common/sanitizer_platform.h          |  7 ++++
+ .../sanitizer_platform_interceptors.h              |  2 +-
+ .../sanitizer_platform_limits_posix.cc             | 40 +++++++++++++---------
+ lib/tsan/rtl/tsan_platform_linux.cc                |  2 +-
+ 11 files changed, 47 insertions(+), 32 deletions(-)
+
+diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
+index 6d47ba432..c58dd4864 100644
+--- a/lib/asan/asan_linux.cc
++++ b/lib/asan/asan_linux.cc
+@@ -39,7 +39,7 @@
+ #include <sys/link_elf.h>
+ #endif
+ 
+-#if SANITIZER_ANDROID || SANITIZER_FREEBSD
++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU
+ #include <ucontext.h>
+ extern "C" void* _DYNAMIC;
+ #else
+@@ -86,7 +86,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
+   UNIMPLEMENTED();
+ }
+ 
+-#if SANITIZER_ANDROID
++#if SANITIZER_ANDROID || SANITIZER_NONGNU
+ // FIXME: should we do anything for Android?
+ void AsanCheckDynamicRTPrereqs() {}
+ void AsanCheckIncompatibleRT() {}
+diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
+index 6e908ac01..76c1688ce 100644
+--- a/lib/interception/interception_linux.cc
++++ b/lib/interception/interception_linux.cc
+@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+   return real == wrapper;
+ }
+ 
+-#if !defined(__ANDROID__)  // android does not have dlvsym
++#if !defined(__ANDROID__) && defined(__GLIBC__)  // android does not have dlvsym
+ void *GetFuncAddrVer(const char *func_name, const char *ver) {
+   return dlvsym(RTLD_NEXT, func_name, ver);
+ }
+diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
+index 27a66c882..f60c38991 100644
+--- a/lib/interception/interception_linux.h
++++ b/lib/interception/interception_linux.h
+@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
+       (::__interception::uptr) & (func),                                   \
+       (::__interception::uptr) & WRAP(func))
+ 
+-#if !defined(__ANDROID__)  // android does not have dlvsym
++#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym
+ #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
+   (::__interception::real_##func = (func##_f)(                \
+        unsigned long)::__interception::GetFuncAddrVer(#func, symver))
+diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
+index 0a687f620..0852d97d7 100644
+--- a/lib/msan/msan_linux.cc
++++ b/lib/msan/msan_linux.cc
+@@ -13,7 +13,7 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "sanitizer_common/sanitizer_platform.h"
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
++#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU
+ 
+ #include "msan.h"
+ #include "msan_thread.h"
+diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+index 4ed9afedf..64f584e93 100644
+--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+@@ -100,7 +100,7 @@ static void ioctl_table_fill() {
+   _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
+ #endif
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+   // Conflicting request ids.
+   // _(CDROMAUDIOBUFSIZ, NONE, 0);
+   // _(SNDCTL_TMR_CONTINUE, NONE, 0);
+@@ -361,7 +361,7 @@ static void ioctl_table_fill() {
+   _(VT_WAITACTIVE, NONE, 0);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
+   _(CYGETDEFTHRESH, WRITE, sizeof(int));
+   _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
+diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+index 469c8eb7e..24f87867d 100644
+--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
+   }
+ }
+ 
+-#if !SANITIZER_ANDROID
++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
+                        void *old_rlim) {
+   if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
+diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+index 52196db12..045d9331f 100644
+--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+@@ -148,7 +148,7 @@ bool SanitizerGetThreadName(char *name, int max_len) {
+ #endif
+ }
+ 
+-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
+ static uptr g_tls_size;
+ 
+ #ifdef __i386__
+@@ -176,11 +176,11 @@ void InitTlsSize() {
+ }
+ #else
+ void InitTlsSize() { }
+-#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
++#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
+ 
+ #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
+     || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \
+-    || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID
++    || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ // sizeof(struct pthread) from glibc.
+ static atomic_uintptr_t kThreadDescriptorSize;
+ 
+@@ -335,7 +335,7 @@ uptr ThreadSelf() {
+ 
+ #if !SANITIZER_GO
+ static void GetTls(uptr *addr, uptr *size) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
+   *addr = ThreadSelf();
+   *size = GetTlsSize();
+@@ -362,7 +362,7 @@ static void GetTls(uptr *addr, uptr *size) {
+     *addr = (uptr) dtv[2];
+     *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
+   }
+-#elif SANITIZER_ANDROID
++#elif SANITIZER_ANDROID || SANITIZER_NONGNU
+   *addr = 0;
+   *size = 0;
+ #else
+@@ -373,7 +373,7 @@ static void GetTls(uptr *addr, uptr *size) {
+ 
+ #if !SANITIZER_GO
+ uptr GetTlsSize() {
+-#if SANITIZER_FREEBSD || SANITIZER_ANDROID
++#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU
+   uptr addr, size;
+   GetTls(&addr, &size);
+   return size;
+diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
+index 396f7c934..5af6f1ed5 100644
+--- a/lib/sanitizer_common/sanitizer_platform.h
++++ b/lib/sanitizer_common/sanitizer_platform.h
+@@ -175,6 +175,13 @@
+ # define SANITIZER_ARM 0
+ #endif
+ 
++
++#if defined(__linux__) && !defined(__GLIBC__)
++# define SANITIZER_NONGNU 1
++#else
++# define SANITIZER_NONGNU 0
++#endif
++
+ // By default we allow to use SizeClassAllocator64 on 64-bit platform.
+ // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
+ // does not work well and we need to fallback to SizeClassAllocator32.
+diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+index 0380cee92..0a39abbd0 100644
+--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -31,7 +31,7 @@
+ # define SI_POSIX 0
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # define SI_LINUX_NOT_ANDROID 1
+ #else
+ # define SI_LINUX_NOT_ANDROID 0
+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+index 83f4fd22f..fa8c1b8bd 100644
+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -14,6 +14,9 @@
+ 
+ #include "sanitizer_platform.h"
+ 
++// Workaround musl <--> linux conflicting definition of 'struct sysinfo'
++#define _LINUX_SYSINFO_H
++
+ #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
+ // Tests in this file assume that off_t-dependent data structures match the
+ // libc ABI. For example, struct dirent here is what readdir() function (as
+@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
+ 
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ #include <glob.h>
+-#include <obstack.h>
++#  if !SANITIZER_NONGNU
++#    include <obstack.h>
++#  endif
+ #include <mqueue.h>
+-#include <net/if_ppp.h>
+-#include <netax25/ax25.h>
+-#include <netipx/ipx.h>
+-#include <netrom/netrom.h>
++#include <linux/if_ppp.h>
++#include <linux/ax25.h>
++#include <linux/ipx.h>
++#include <linux/netrom.h>
+ #if HAVE_RPC_XDR_H
+ # include <rpc/xdr.h>
+ #elif HAVE_TIRPC_RPC_XDR_H
+@@ -159,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t;
+ # include <sys/procfs.h>
+ #endif
+ #include <sys/user.h>
+-#include <sys/ustat.h>
++// #include <sys/ustat.h>
++#include <sys/statfs.h>
+ #include <linux/cyclades.h>
+ #include <linux/if_eql.h>
+ #include <linux/if_plip.h>
+@@ -251,7 +257,7 @@ namespace __sanitizer {
+   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned struct_ustat_sz = sizeof(struct ustat);
+   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+@@ -309,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ #endif
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   int glob_nomatch = GLOB_NOMATCH;
+   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+ #endif
+@@ -403,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned struct_termios_sz = sizeof(struct termios);
+   unsigned struct_winsize_sz = sizeof(struct winsize);
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+   unsigned struct_arpreq_sz = sizeof(struct arpreq);
+   unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
+   unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
+@@ -453,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+   unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+ #if EV_VERSION > (0x010000)
+@@ -821,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
+   unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
+   unsigned IOCTL_CYGETMON = CYGETMON;
+@@ -976,7 +982,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(glob_t);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
+@@ -1010,6 +1016,7 @@ CHECK_TYPE_SIZE(iovec);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_base);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_len);
+ 
++#if !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(msghdr);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
+@@ -1023,6 +1030,7 @@ CHECK_TYPE_SIZE(cmsghdr);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
++#endif
+ 
+ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
+ CHECK_SIZE_AND_OFFSET(dirent, d_ino);
+@@ -1125,7 +1133,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
+ 
+ CHECK_TYPE_SIZE(ether_addr);
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(ipc_perm);
+ # if SANITIZER_FREEBSD
+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
+@@ -1186,7 +1194,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
+ #endif
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
+ #endif
+ 
+@@ -1236,7 +1244,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
+ COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
+ CHECK_SIZE_AND_OFFSET(FILE, _flags);
+ CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
+@@ -1255,7 +1263,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
+ CHECK_SIZE_AND_OFFSET(FILE, _fileno);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
+diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
+index ead1e5704..2c020e3fe 100644
+--- a/lib/tsan/rtl/tsan_platform_linux.cc
++++ b/lib/tsan/rtl/tsan_platform_linux.cc
+@@ -284,7 +284,7 @@ void InitializePlatform() {
+ // This is required to properly "close" the fds, because we do not see internal
+ // closes within glibc. The code is a pure hack.
+ int ExtractResolvFDs(void *state, int *fds, int nfd) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   int cnt = 0;
+   struct __res_state *statp = (struct __res_state*)state;
+   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
+-- 
+2.16.2
+
diff --git a/pkgs/development/compilers/llvm/6/clang/default.nix b/pkgs/development/compilers/llvm/6/clang/default.nix
new file mode 100644
index 000000000000..919efdc8ef97
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/clang/default.nix
@@ -0,0 +1,108 @@
+{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, release_version, clang-tools-extra_src, python
+, fixDarwinDylibNames
+, enableManpages ? false
+}:
+
+let
+  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
+  self = stdenv.mkDerivation ({
+    name = "clang-${version}";
+
+    unpackPhase = ''
+      unpackFile ${fetch "cfe" "0cnznvfyl3hgbg8gj58pmwf0pvd2sv5k3ccbivy6q6ggv7c6szg0"}
+      mv cfe-${version}* clang
+      sourceRoot=$PWD/clang
+      unpackFile ${clang-tools-extra_src}
+      mv clang-tools-extra-* $sourceRoot/tools/extra
+    '';
+
+    nativeBuildInputs = [ cmake python ]
+      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+
+    buildInputs = [ libedit libxml2 llvm ]
+      ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+    cmakeFlags = [
+      "-DCMAKE_CXX_FLAGS=-std=c++11"
+    ] ++ stdenv.lib.optionals enableManpages [
+      "-DCLANG_INCLUDE_DOCS=ON"
+      "-DLLVM_ENABLE_SPHINX=ON"
+      "-DSPHINX_OUTPUT_MAN=ON"
+      "-DSPHINX_OUTPUT_HTML=OFF"
+      "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+    ]
+    # Maybe with compiler-rt this won't be needed?
+    ++ stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}"
+    ++ stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include";
+
+    patches = [ ./purity.patch ];
+
+    postPatch = ''
+      sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
+             -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
+             lib/Driver/ToolChains/*.cpp
+
+      # Patch for standalone doc building
+      sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
+    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+      sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
+    '';
+
+    outputs = [ "out" "lib" "python" ];
+
+    # Clang expects to find LLVMgold in its own prefix
+    # Clang expects to find sanitizer libraries in its own prefix
+    postInstall = ''
+      ln -sv ${llvm}/lib/LLVMgold.so $out/lib
+      ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/
+      ln -sv $out/bin/clang $out/bin/cpp
+
+      # Move libclang to 'lib' output
+      moveToOutput "lib/libclang.*" "$lib"
+      substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
+          --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang."
+
+      mkdir -p $python/bin $python/share/clang/
+      mv $out/bin/{git-clang-format,scan-view} $python/bin
+      if [ -e $out/bin/set-xcode-analyzer ]; then
+        mv $out/bin/set-xcode-analyzer $python/bin
+      fi
+      mv $out/share/clang/*.py $python/share/clang
+      rm $out/bin/c-index-test
+    '';
+
+    enableParallelBuilding = true;
+
+    passthru = {
+      isClang = true;
+      inherit llvm;
+    } // stdenv.lib.optionalAttrs stdenv.isLinux {
+      inherit gcc;
+    };
+
+    meta = {
+      description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
+      homepage    = http://llvm.org/;
+      license     = stdenv.lib.licenses.ncsa;
+      platforms   = stdenv.lib.platforms.all;
+    };
+  } // stdenv.lib.optionalAttrs enableManpages {
+    name = "clang-manpages-${version}";
+
+    buildPhase = ''
+      make docs-clang-man
+    '';
+
+    installPhase = ''
+      mkdir -p $out/share/man/man1
+      # Manually install clang manpage
+      cp docs/man/*.1 $out/share/man/man1/
+    '';
+
+    outputs = [ "out" ];
+
+    doCheck = false;
+
+    meta.description = "man page for Clang ${version}";
+  });
+in self
diff --git a/pkgs/development/compilers/llvm/6/clang/purity.patch b/pkgs/development/compilers/llvm/6/clang/purity.patch
new file mode 100644
index 000000000000..b30d0d0b5d5b
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/clang/purity.patch
@@ -0,0 +1,30 @@
+From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Thu, 18 May 2017 11:56:12 -0500
+Subject: [PATCH] "purity" patch for 5.0
+
+---
+ lib/Driver/ToolChains/Gnu.cpp | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
+index fe3c0191bb..c6a482bece 100644
+--- a/lib/Driver/ToolChains/Gnu.cpp
++++ b/lib/Driver/ToolChains/Gnu.cpp
+@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+   if (!Args.hasArg(options::OPT_static)) {
+     if (Args.hasArg(options::OPT_rdynamic))
+       CmdArgs.push_back("-export-dynamic");
+-
+-    if (!Args.hasArg(options::OPT_shared)) {
+-      const std::string Loader =
+-          D.DyldPrefix + ToolChain.getDynamicLinker(Args);
+-      CmdArgs.push_back("-dynamic-linker");
+-      CmdArgs.push_back(Args.MakeArgString(Loader));
+-    }
+   }
+ 
+   CmdArgs.push_back("-o");
+-- 
+2.11.0
+
diff --git a/pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch b/pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch
new file mode 100644
index 000000000000..8f4c76bca1eb
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch
@@ -0,0 +1,155 @@
+From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Tue, 19 Sep 2017 13:13:06 -0500
+Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that
+ needs it
+
+---
+ cmake/Modules/AddCompilerRT.cmake |  8 ------
+ test/asan/CMakeLists.txt          | 52 ---------------------------------------
+ test/tsan/CMakeLists.txt          | 47 -----------------------------------
+ 3 files changed, 107 deletions(-)
+
+diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
+index bc5fb9ff7..b64eb4246 100644
+--- a/cmake/Modules/AddCompilerRT.cmake
++++ b/cmake/Modules/AddCompilerRT.cmake
+@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type)
+         set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
+         set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
+       endif()
+-      if(APPLE)
+-        # Ad-hoc sign the dylibs
+-        add_custom_command(TARGET ${libname}
+-          POST_BUILD  
+-          COMMAND codesign --sign - $<TARGET_FILE:${libname}>
+-          WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+-        )
+-      endif()
+     endif()
+     install(TARGETS ${libname}
+       ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt
+index 8bfc15b5c..f23d0f71a 100644
+--- a/test/asan/CMakeLists.txt
++++ b/test/asan/CMakeLists.txt
+@@ -83,58 +83,6 @@ foreach(arch ${ASAN_TEST_ARCH})
+   endif()
+ endforeach()
+ 
+-# iOS and iOS simulator test suites
+-# These are not added into "check-all", in order to run these tests, use
+-# "check-asan-iossim-x86_64" and similar. They also require that an extra env
+-# variable to select which iOS device or simulator to use, e.g.:
+-# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
+-if(APPLE)
+-  set(EXCLUDE_FROM_ALL ON)
+-
+-  set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
+-  set(ASAN_TEST_IOS "1")
+-  pythonize_bool(ASAN_TEST_IOS)
+-  set(ASAN_TEST_DYNAMIC True)
+-
+-  foreach(arch ${DARWIN_iossim_ARCHS})
+-    set(ASAN_TEST_IOSSIM "1")
+-    pythonize_bool(ASAN_TEST_IOSSIM)
+-    set(ASAN_TEST_TARGET_ARCH ${arch})
+-    set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
+-    set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-iossim")
+-    get_bits_for_arch(${arch} ASAN_TEST_BITS)
+-    string(TOUPPER ${arch} ARCH_UPPER_CASE)
+-    set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
+-    configure_lit_site_cfg(
+-      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
+-      )
+-    add_lit_testsuite(check-asan-iossim-${arch} "AddressSanitizer iOS Simulator ${arch} tests"
+-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
+-      DEPENDS ${ASAN_TEST_DEPS})
+-  endforeach()
+-
+-  foreach (arch ${DARWIN_ios_ARCHS})
+-    set(ASAN_TEST_IOSSIM "0")
+-    pythonize_bool(ASAN_TEST_IOSSIM)
+-    set(ASAN_TEST_TARGET_ARCH ${arch})
+-    set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
+-    set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-ios")
+-    get_bits_for_arch(${arch} ASAN_TEST_BITS)
+-    string(TOUPPER ${arch} ARCH_UPPER_CASE)
+-    set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
+-    configure_lit_site_cfg(
+-      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
+-      )
+-    add_lit_testsuite(check-asan-ios-${arch} "AddressSanitizer iOS ${arch} tests"
+-      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
+-      DEPENDS ${ASAN_TEST_DEPS})
+-  endforeach()
+-
+-  set(EXCLUDE_FROM_ALL OFF)
+-endif()
+-
+ # Add unit tests.
+ if(COMPILER_RT_INCLUDE_TESTS)
+   set(ASAN_TEST_DYNAMIC False)
+diff --git a/test/tsan/CMakeLists.txt b/test/tsan/CMakeLists.txt
+index a68908612..cde0accb5 100644
+--- a/test/tsan/CMakeLists.txt
++++ b/test/tsan/CMakeLists.txt
+@@ -42,53 +42,6 @@ foreach(arch ${TSAN_TEST_ARCH})
+   list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+ endforeach()
+ 
+-# iOS and iOS simulator test suites
+-# These are not added into "check-all", in order to run these tests, use
+-# "check-tsan-iossim-x86_64" and similar. They also require an extra environment
+-# variable to select which iOS device or simulator to use, e.g.:
+-# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
+-if(APPLE)
+-  set(EXCLUDE_FROM_ALL ON)
+-
+-  set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
+-  set(TSAN_TEST_IOS "1")
+-  pythonize_bool(TSAN_TEST_IOS)
+-
+-  set(arch "x86_64")
+-  set(TSAN_TEST_IOSSIM "1")
+-  pythonize_bool(TSAN_TEST_IOSSIM)
+-  set(TSAN_TEST_TARGET_ARCH ${arch})
+-  set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
+-  set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-iossim")
+-  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+-  set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
+-  configure_lit_site_cfg(
+-    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+-    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
+-    )
+-  add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests"
+-    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
+-    DEPENDS ${TSAN_TEST_DEPS})
+-
+-  set(arch "arm64")
+-  set(TSAN_TEST_IOSSIM "0")
+-  pythonize_bool(TSAN_TEST_IOSSIM)
+-  set(TSAN_TEST_TARGET_ARCH ${arch})
+-  set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
+-  set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-ios")
+-  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+-  set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
+-  configure_lit_site_cfg(
+-    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+-    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
+-    )
+-  add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS Simulator ${arch} tests"
+-    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
+-    DEPENDS ${TSAN_TEST_DEPS})
+-
+-  set(EXCLUDE_FROM_ALL OFF)
+-endif()
+-
+ if(COMPILER_RT_INCLUDE_TESTS)
+   configure_lit_site_cfg(
+     ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
+-- 
+2.14.1
+
diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix
new file mode 100644
index 000000000000..cfa9e9e15fcf
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/default.nix
@@ -0,0 +1,78 @@
+{ lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook
+, libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun
+, darwin
+}:
+
+let
+  callPackage = newScope (self // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });
+
+  release_version = "6.0.0";
+  version = release_version; # differentiating these is important for rc's
+
+  fetch = name: sha256: fetchurl {
+    url = "http://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz";
+    inherit sha256;
+  };
+
+  compiler-rt_src = fetch "compiler-rt" "16m7rvh3w6vq10iwkjrr1nn293djld3xm62l5zasisaprx117k6h";
+  clang-tools-extra_src = fetch "clang-tools-extra" "1ll9v6r29xfdiywbn9iss49ad39ah3fk91wiv0sr6k6k9i544fq5";
+
+  # Add man output without introducing extra dependencies.
+  overrideManOutput = drv:
+    let drv-manpages = drv.override { enableManpages = true; }; in
+    drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ };
+
+  llvm = callPackage ./llvm.nix {
+    inherit compiler-rt_src stdenv;
+  };
+
+  clang-unwrapped = callPackage ./clang {
+    inherit clang-tools-extra_src stdenv;
+  };
+
+  self = {
+    llvm = overrideManOutput llvm;
+    clang-unwrapped = overrideManOutput clang-unwrapped;
+
+    libclang = self.clang-unwrapped.lib;
+    llvm-manpages = lowPrio self.llvm.man;
+    clang-manpages = lowPrio self.clang-unwrapped.man;
+
+    clang = if stdenv.cc.isGNU then self.libstdcxxClang else self.libcxxClang;
+
+    libstdcxxClang = ccWrapperFun {
+      cc = self.clang-unwrapped;
+      /* FIXME is this right? */
+      inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
+      extraPackages = [ libstdcxxHook ];
+    };
+
+    libcxxClang = ccWrapperFun {
+      cc = self.clang-unwrapped;
+      /* FIXME is this right? */
+      inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
+      extraPackages = [ self.libcxx self.libcxxabi ];
+    };
+
+    stdenv = stdenv.override (drv: {
+      allowedRequisites = null;
+      cc = self.clang;
+    });
+
+    libcxxStdenv = stdenv.override (drv: {
+      allowedRequisites = null;
+      cc = self.libcxxClang;
+    });
+
+    lld = callPackage ./lld.nix {};
+
+    lldb = callPackage ./lldb.nix {};
+
+    libcxx = callPackage ./libc++ {};
+
+    libcxxabi = callPackage ./libc++abi.nix {};
+
+    openmp = callPackage ./openmp.nix {};
+  };
+
+in self
diff --git a/pkgs/development/compilers/llvm/6/libc++/default.nix b/pkgs/development/compilers/llvm/6/libc++/default.nix
new file mode 100644
index 000000000000..3c6c009a58fa
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/libc++/default.nix
@@ -0,0 +1,51 @@
+{ lib, stdenv, fetch, cmake, python, llvm, libcxxabi, fixDarwinDylibNames, version }:
+
+stdenv.mkDerivation rec {
+  name = "libc++-${version}";
+
+  src = fetch "libcxx" "1n8d0iadkk9fdpplvxkdgrgh2szc6msrx1mpdjpmilz9pn3im4vh";
+
+  postUnpack = ''
+    unpackFile ${libcxxabi.src}
+    export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
+  '';
+
+  # on next rebuild, this can be replaced with optionals; for now set to null to avoid
+  # patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+  patches = if stdenv.hostPlatform.isMusl then [
+    ../../libcxx-0001-musl-hacks.patch
+  ] else null;
+
+  prePatch = ''
+    substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
+  '';
+
+  preConfigure = ''
+    # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
+    cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
+    patchShebangs utils/cat_files.py
+  '';
+  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
+
+  buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  cmakeFlags = [
+    "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
+    "-DLIBCXX_LIBCPPABI_VERSION=2"
+    "-DLIBCXX_CXX_ABI=libcxxabi"
+  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
+
+  enableParallelBuilding = true;
+
+  linkCxxAbi = stdenv.isLinux;
+
+  setupHook = ./setup-hook.sh;
+
+  meta = {
+    homepage = http://libcxx.llvm.org/;
+    description = "A new implementation of the C++ standard library, targeting C++11";
+    license = with stdenv.lib.licenses; [ ncsa mit ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh b/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh
new file mode 100644
index 000000000000..9022fced6ecf
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh
@@ -0,0 +1,3 @@
+linkCxxAbi="@linkCxxAbi@"
+export NIX_CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
+export NIX_CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
diff --git a/pkgs/development/compilers/llvm/6/libc++abi.nix b/pkgs/development/compilers/llvm/6/libc++abi.nix
new file mode 100644
index 000000000000..05fab16c25cd
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/libc++abi.nix
@@ -0,0 +1,49 @@
+{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
+
+stdenv.mkDerivation {
+  name = "libc++abi-${version}";
+
+  src = fetch "libcxxabi" "06v4dnqh6q0r3p5h2jznlgb69lg79126lzb2s0lcw1k38b2xkili";
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
+
+  postUnpack = ''
+    unpackFile ${libcxx.src}
+    unpackFile ${llvm.src}
+    export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    export TRIPLE=x86_64-apple-darwin
+  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
+  '';
+
+  installPhase = if stdenv.isDarwin
+    then ''
+      for file in lib/*.dylib; do
+        # this should be done in CMake, but having trouble figuring out
+        # the magic combination of necessary CMake variables
+        # if you fancy a try, take a look at
+        # http://www.cmake.org/Wiki/CMake_RPATH_handling
+        install_name_tool -id $out/$file $file
+      done
+      make install
+      install -d 755 $out/include
+      install -m 644 ../include/*.h $out/include
+    ''
+    else ''
+      install -d -m 755 $out/include $out/lib
+      install -m 644 lib/libc++abi.so.1.0 $out/lib
+      install -m 644 ../include/cxxabi.h $out/include
+      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
+      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
+    '';
+
+  meta = {
+    homepage = http://libcxxabi.llvm.org/;
+    description = "A new implementation of low level support for a standard C++ library";
+    license = with stdenv.lib.licenses; [ ncsa mit ];
+    maintainers = with stdenv.lib.maintainers; [ vlstill ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/6/lld.nix b/pkgs/development/compilers/llvm/6/lld.nix
new file mode 100644
index 000000000000..4997f0a7c94e
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/lld.nix
@@ -0,0 +1,33 @@
+{ stdenv
+, fetch
+, cmake
+, libxml2
+, llvm
+, python
+, version
+}:
+
+stdenv.mkDerivation {
+  name = "lld-${version}";
+
+  src = fetch "lld" "02qfkjkjq0snmf8dw9c255xkh8dg06ndny1x470300pk7j1lm33b";
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ llvm libxml2 ];
+
+  outputs = [ "out" "dev" ];
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    moveToOutput include "$dev"
+    moveToOutput lib "$dev"
+  '';
+
+  meta = {
+    description = "The LLVM Linker";
+    homepage    = http://lld.llvm.org/;
+    license     = stdenv.lib.licenses.ncsa;
+    platforms   = stdenv.lib.platforms.all;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/6/lldb.nix b/pkgs/development/compilers/llvm/6/lldb.nix
new file mode 100644
index 000000000000..eb565a93ef60
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/lldb.nix
@@ -0,0 +1,56 @@
+{ stdenv
+, fetch
+, cmake
+, zlib
+, ncurses
+, swig
+, which
+, libedit
+, libxml2
+, llvm
+, clang-unwrapped
+, python
+, version
+, darwin
+}:
+
+stdenv.mkDerivation {
+  name = "lldb-${version}";
+
+  src = fetch "lldb" "0m6l2ks4banfmdh7xy7l77ri85kmzavgfy81gkc4gl6wg8flrxa6";
+
+  postPatch = ''
+    # Fix up various paths that assume llvm and clang are installed in the same place
+    sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \
+      cmake/modules/LLDBStandalone.cmake
+    sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \
+      cmake/modules/LLDBStandalone.cmake
+    sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \
+      cmake/modules/LLDBStandalone.cmake
+  '';
+
+  nativeBuildInputs = [ cmake python which swig ];
+  buildInputs = [ ncurses zlib libedit libxml2 llvm ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
+
+  CXXFLAGS = "-fno-rtti";
+  hardeningDisable = [ "format" ];
+
+  cmakeFlags = [
+    "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
+  ];
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    mkdir -p $out/share/man/man1
+    cp ../docs/lldb.1 $out/share/man/man1/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A next-generation high-performance debugger";
+    homepage    = http://llvm.org/;
+    license     = licenses.ncsa;
+    platforms   = platforms.all;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/6/llvm-outputs.patch b/pkgs/development/compilers/llvm/6/llvm-outputs.patch
new file mode 100644
index 000000000000..40096fa3497f
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/llvm-outputs.patch
@@ -0,0 +1,26 @@
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 94d426b..37f7794 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
+     ActiveIncludeOption = "-I" + ActiveIncludeDir;
+   }
+ 
++  /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
++  if (!IsInDevelopmentTree) {
++    bool WantShared = true;
++    for (int i = 1; i < argc; ++i) {
++      StringRef Arg = argv[i];
++      if (Arg == "--link-shared")
++        WantShared = true;
++      else if (Arg == "--link-static")
++        WantShared = false; // the last one wins
++    }
++
++    if (WantShared)
++      ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
++  }
++
+   /// We only use `shared library` mode in cases where the static library form
+   /// of the components provided are not available; note however that this is
+   /// skipped if we're run from within the build dir. However, once installed,
diff --git a/pkgs/development/compilers/llvm/6/llvm.nix b/pkgs/development/compilers/llvm/6/llvm.nix
new file mode 100644
index 000000000000..7cb3e88c2f85
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/llvm.nix
@@ -0,0 +1,185 @@
+{ stdenv
+, fetch
+, fetchpatch
+, cmake
+, python
+, libffi
+, libbfd
+, libxml2
+, valgrind
+, ncurses
+, version
+, release_version
+, zlib
+, compiler-rt_src
+, libcxxabi
+, debugVersion ? false
+, enableManpages ? false
+, enableSharedLibraries ? true
+, enableWasm ? true
+, darwin
+}:
+
+let
+  src = fetch "llvm" "0224xvfg6h40y5lrbnb9qaq3grmdc5rg00xq03s1wxjfbf8krx8z";
+
+  # Used when creating a version-suffixed symlink of libLLVM.dylib
+  shortVersion = with stdenv.lib;
+    concatStringsSep "." (take 2 (splitString "." release_version));
+in stdenv.mkDerivation (rec {
+  name = "llvm-${version}";
+
+  unpackPhase = ''
+    unpackFile ${src}
+    mv llvm-${version}* llvm
+    sourceRoot=$PWD/llvm
+    unpackFile ${compiler-rt_src}
+    mv compiler-rt-* $sourceRoot/projects/compiler-rt
+  '';
+
+  outputs = [ "out" "python" ]
+    ++ stdenv.lib.optional enableSharedLibraries "lib";
+
+  nativeBuildInputs = [ cmake python ]
+    ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+
+  buildInputs = [ libxml2 libffi ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ];
+
+  propagatedBuildInputs = [ ncurses zlib ];
+
+  # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+  # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
+  # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
+  # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
+  # a flag and turn the flag off during the stdenv build.
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \
+      --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
+
+    substituteInPlace cmake/modules/AddLLVM.cmake \
+      --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir INSTALL_NAME_DIR "$lib/lib")" \
+      --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' ""
+  ''
+  # Patch llvm-config to return correct library path based on --link-{shared,static}.
+  + stdenv.lib.optionalString (enableSharedLibraries) ''
+    substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
+    patch -p1 < ./llvm-outputs.patch
+  '' + ''
+    # FileSystem permissions tests fail with various special bits
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "Path.cpp" ""
+    rm unittests/Support/Path.cpp
+
+    # Revert compiler-rt commit that makes codesign mandatory
+    patch -p1 -i ${./compiler-rt-codesign.patch} -d projects/compiler-rt
+  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    patch -p1 -i ${../TLI-musl.patch}
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "add_subdirectory(DynamicLibrary)" ""
+    rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+    patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
+  '';
+
+  # hacky fix: created binaries need to be run before installation
+  preBuild = ''
+    mkdir -p $out/
+    ln -sv $PWD/lib $out
+  '';
+
+  cmakeFlags = with stdenv; [
+    "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
+    "-DLLVM_INSTALL_UTILS=ON"  # Needed by rustc
+    "-DLLVM_BUILD_TESTS=ON"
+    "-DLLVM_ENABLE_FFI=ON"
+    "-DLLVM_ENABLE_RTTI=ON"
+    "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code
+  ]
+  ++ stdenv.lib.optional enableSharedLibraries
+    "-DLLVM_LINK_LLVM_DYLIB=ON"
+  ++ stdenv.lib.optionals enableManpages [
+    "-DLLVM_BUILD_DOCS=ON"
+    "-DLLVM_ENABLE_SPHINX=ON"
+    "-DSPHINX_OUTPUT_MAN=ON"
+    "-DSPHINX_OUTPUT_HTML=OFF"
+    "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+  ]
+  ++ stdenv.lib.optional (!isDarwin)
+    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
+  ++ stdenv.lib.optionals (isDarwin) [
+    "-DLLVM_ENABLE_LIBCXX=ON"
+    "-DCAN_TARGET_i386=false"
+  ]
+  ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+    "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
+    "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
+    "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
+  ] ++ stdenv.lib.optional enableWasm
+   "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"
+  ;
+
+  postBuild = ''
+    rm -fR $out
+
+    paxmark m bin/{lli,llvm-rtdyld}
+    paxmark m unittests/ExecutionEngine/MCJIT/MCJITTests
+    paxmark m unittests/ExecutionEngine/Orc/OrcJITTests
+    paxmark m unittests/Support/SupportTests
+    paxmark m bin/lli-child-target
+  '';
+
+  preCheck = ''
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+  '';
+
+  postInstall = ''
+    mkdir -p $python/share
+    mv $out/share/opt-viewer $python/share/opt-viewer
+  ''
+  + stdenv.lib.optionalString enableSharedLibraries ''
+    moveToOutput "lib/libLLVM-*" "$lib"
+    moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
+    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
+  ''
+  + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
+    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
+    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
+    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+  '';
+
+  doCheck = stdenv.isLinux && (!stdenv.isi686);
+
+  checkTarget = "check-all";
+
+  enableParallelBuilding = true;
+
+  passthru.src = src;
+
+  meta = {
+    description = "Collection of modular and reusable compiler and toolchain technologies";
+    homepage    = http://llvm.org/;
+    license     = stdenv.lib.licenses.ncsa;
+    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric dtzWill ];
+    platforms   = stdenv.lib.platforms.all;
+  };
+} // stdenv.lib.optionalAttrs enableManpages {
+  name = "llvm-manpages-${version}";
+
+  buildPhase = ''
+    make docs-llvm-man
+  '';
+
+  propagatedBuildInputs = [];
+
+  installPhase = ''
+    make -C docs install
+  '';
+
+  outputs = [ "out" ];
+
+  doCheck = false;
+
+  meta.description = "man pages for LLVM ${version}";
+})
diff --git a/pkgs/development/compilers/llvm/6/openmp.nix b/pkgs/development/compilers/llvm/6/openmp.nix
new file mode 100644
index 000000000000..091e378af2a1
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/openmp.nix
@@ -0,0 +1,26 @@
+{ stdenv
+, fetch
+, cmake
+, zlib
+, llvm
+, perl
+, version
+}:
+
+stdenv.mkDerivation {
+  name = "openmp-${version}";
+
+  src = fetch "openmp" "1z1qghx6drdvnlp406q1cp3mgikxxmwymcwzaxbv18vxbw6ha3kw";
+
+  nativeBuildInputs = [ cmake perl ];
+  buildInputs = [ llvm ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Components required to build an executable OpenMP program";
+    homepage    = http://openmp.llvm.org/;
+    license     = stdenv.lib.licenses.mit;
+    platforms   = stdenv.lib.platforms.all;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch b/pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch
new file mode 100644
index 000000000000..39a9bbbd207a
--- /dev/null
+++ b/pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch
@@ -0,0 +1,377 @@
+From 8c74f8274369f527f2ada3772f4a0b406cb481ec Mon Sep 17 00:00:00 2001
+From: "Jory A. Pratt" <anarchy@gentoo.org>
+Date: Sat, 9 Sep 2017 08:31:15 -0500
+Subject: [PATCH] Ported to 6.0, taken from gentoo-musl project.
+
+------
+Ported to compiler-rt-sanitizers-5.0.0. Taken from
+
+https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
+Signed-off-by: Jory A. Pratt <anarchy@gentoo.org>
+
+Taken from gentoo-musl project, with a few additional minor fixes.
+---
+ lib/asan/asan_linux.cc                             |  4 +--
+ lib/interception/interception_linux.cc             |  2 +-
+ lib/interception/interception_linux.h              |  3 +-
+ lib/msan/msan_linux.cc                             |  2 +-
+ .../sanitizer_common_interceptors_ioctl.inc        |  4 +--
+ lib/sanitizer_common/sanitizer_common_syscalls.inc |  2 +-
+ lib/sanitizer_common/sanitizer_linux_libcdep.cc    | 10 +++---
+ lib/sanitizer_common/sanitizer_platform.h          |  6 ++++
+ .../sanitizer_platform_interceptors.h              |  4 +--
+ .../sanitizer_platform_limits_posix.cc             | 40 +++++++++++++---------
+ lib/tsan/rtl/tsan_platform_linux.cc                |  2 +-
+ 11 files changed, 46 insertions(+), 33 deletions(-)
+
+diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
+index 625f32d40..73cf77aca 100644
+--- a/lib/asan/asan_linux.cc
++++ b/lib/asan/asan_linux.cc
+@@ -46,7 +46,7 @@
+ #include <link.h>
+ #endif
+ 
+-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
+ #include <ucontext.h>
+ extern "C" void* _DYNAMIC;
+ #elif SANITIZER_NETBSD
+@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
+   UNIMPLEMENTED();
+ }
+ 
+-#if SANITIZER_ANDROID
++#if SANITIZER_ANDROID || SANITIZER_NONGNU
+ // FIXME: should we do anything for Android?
+ void AsanCheckDynamicRTPrereqs() {}
+ void AsanCheckIncompatibleRT() {}
+diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
+index c991550a4..2b706418b 100644
+--- a/lib/interception/interception_linux.cc
++++ b/lib/interception/interception_linux.cc
+@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+ }
+ 
+ // Android and Solaris do not have dlvsym
+-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS
++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
+ void *GetFuncAddrVer(const char *func_name, const char *ver) {
+   return dlvsym(RTLD_NEXT, func_name, ver);
+ }
+diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
+index 98fe51b85..c13302b98 100644
+--- a/lib/interception/interception_linux.h
++++ b/lib/interception/interception_linux.h
+@@ -35,8 +35,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
+       (::__interception::uptr) & (func),                                   \
+       (::__interception::uptr) & WRAP(func))
+ 
+-// Android and Solaris do not have dlvsym
+-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS
++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
+ #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
+   (::__interception::real_##func = (func##_f)(                \
+        unsigned long)::__interception::GetFuncAddrVer(#func, symver))
+diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
+index 4e6321fcb..4d50feb82 100644
+--- a/lib/msan/msan_linux.cc
++++ b/lib/msan/msan_linux.cc
+@@ -13,7 +13,7 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "sanitizer_common/sanitizer_platform.h"
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD
+ 
+ #include "msan.h"
+ #include "msan_thread.h"
+diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+index 24e7548a5..20259b1d6 100644
+--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+@@ -102,7 +102,7 @@ static void ioctl_table_fill() {
+   _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
+ #endif
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+   // Conflicting request ids.
+   // _(CDROMAUDIOBUFSIZ, NONE, 0);
+   // _(SNDCTL_TMR_CONTINUE, NONE, 0);
+@@ -363,7 +363,7 @@ static void ioctl_table_fill() {
+   _(VT_WAITACTIVE, NONE, 0);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
+   _(CYGETDEFTHRESH, WRITE, sizeof(int));
+   _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
+diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+index 469c8eb7e..24f87867d 100644
+--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
+@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
+   }
+ }
+ 
+-#if !SANITIZER_ANDROID
++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
+                        void *old_rlim) {
+   if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
+diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+index 56fdfc870..a932d5db1 100644
+--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+@@ -174,7 +174,7 @@ bool SanitizerGetThreadName(char *name, int max_len) {
+ }
+ 
+ #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \
+-    !SANITIZER_NETBSD && !SANITIZER_SOLARIS
++    !SANITIZER_NETBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
+ static uptr g_tls_size;
+ 
+ #ifdef __i386__
+@@ -207,7 +207,7 @@ void InitTlsSize() { }
+ 
+ #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
+     || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \
+-    || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID
++    || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ // sizeof(struct pthread) from glibc.
+ static atomic_uintptr_t kThreadDescriptorSize;
+ 
+@@ -391,7 +391,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
+ 
+ #if !SANITIZER_GO
+ static void GetTls(uptr *addr, uptr *size) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
+   *addr = ThreadSelf();
+   *size = GetTlsSize();
+@@ -432,7 +432,7 @@ static void GetTls(uptr *addr, uptr *size) {
+       *addr = (uptr)tcb->tcb_dtv[1];
+     }
+   }
+-#elif SANITIZER_ANDROID
++#elif SANITIZER_ANDROID || SANITIZER_NONGNU
+   *addr = 0;
+   *size = 0;
+ #elif SANITIZER_SOLARIS
+@@ -448,7 +448,7 @@ static void GetTls(uptr *addr, uptr *size) {
+ #if !SANITIZER_GO
+ uptr GetTlsSize() {
+ #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \
+-    SANITIZER_SOLARIS
++    SANITIZER_SOLARIS || SANITIZER_NONGNU
+   uptr addr, size;
+   GetTls(&addr, &size);
+   return size;
+diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
+index 334903c26..fc2afac2c 100644
+--- a/lib/sanitizer_common/sanitizer_platform.h
++++ b/lib/sanitizer_common/sanitizer_platform.h
+@@ -195,6 +195,12 @@
+ # define SANITIZER_SOLARIS32 0
+ #endif
+ 
++#if defined(__linux__) && !defined(__GLIBC__)
++# define SANITIZER_NONGNU 1
++#else
++# define SANITIZER_NONGNU 0
++#endif
++
+ // By default we allow to use SizeClassAllocator64 on 64-bit platform.
+ // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
+ // does not work well and we need to fallback to SizeClassAllocator32.
+diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+index b99ac4480..628d226a1 100644
+--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -38,7 +38,7 @@
+ # include "sanitizer_platform_limits_solaris.h"
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ # define SI_LINUX_NOT_ANDROID 1
+ #else
+ # define SI_LINUX_NOT_ANDROID 0
+@@ -291,7 +291,7 @@
+   (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID)
+ #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID)
+ #define SANITIZER_INTERCEPT_SHMCTL                       \
+-  (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \
++  (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \
+                  SANITIZER_WORDSIZE == 64))  // NOLINT
+ #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
+ #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX
+diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+index f12e8206a..8880197b0 100644
+--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -14,6 +14,9 @@
+ 
+ #include "sanitizer_platform.h"
+ 
++// Workaround musl <--> linux conflicting definition of 'struct sysinfo'
++#define _LINUX_SYSINFO_H
++
+ #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
+ // Tests in this file assume that off_t-dependent data structures match the
+ // libc ABI. For example, struct dirent here is what readdir() function (as
+@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
+ 
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ #include <glob.h>
+-#include <obstack.h>
++#  if !SANITIZER_NONGNU
++#    include <obstack.h>
++#  endif
+ #include <mqueue.h>
+-#include <net/if_ppp.h>
+-#include <netax25/ax25.h>
+-#include <netipx/ipx.h>
+-#include <netrom/netrom.h>
++#include <linux/if_ppp.h>
++#include <linux/ax25.h>
++#include <linux/ipx.h>
++#include <linux/netrom.h>
+ #if HAVE_RPC_XDR_H
+ # include <rpc/xdr.h>
+ #elif HAVE_TIRPC_RPC_XDR_H
+@@ -159,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t;
+ # include <sys/procfs.h>
+ #endif
+ #include <sys/user.h>
+-#include <sys/ustat.h>
++// #include <sys/ustat.h>
++#include <sys/statfs.h>
+ #include <linux/cyclades.h>
+ #include <linux/if_eql.h>
+ #include <linux/if_plip.h>
+@@ -252,7 +258,7 @@ namespace __sanitizer {
+   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned struct_ustat_sz = sizeof(struct ustat);
+   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+@@ -311,7 +317,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ #endif
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   int glob_nomatch = GLOB_NOMATCH;
+   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+ #endif
+@@ -405,7 +411,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned struct_termios_sz = sizeof(struct termios);
+   unsigned struct_winsize_sz = sizeof(struct winsize);
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+   unsigned struct_arpreq_sz = sizeof(struct arpreq);
+   unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
+   unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
+@@ -455,7 +461,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+   unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+ #if EV_VERSION > (0x010000)
+@@ -823,7 +829,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+   unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
+   unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
+   unsigned IOCTL_CYGETMON = CYGETMON;
+@@ -978,7 +984,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(glob_t);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
+@@ -1012,6 +1018,7 @@ CHECK_TYPE_SIZE(iovec);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_base);
+ CHECK_SIZE_AND_OFFSET(iovec, iov_len);
+ 
++#if !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(msghdr);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
+ CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
+@@ -1025,6 +1032,7 @@ CHECK_TYPE_SIZE(cmsghdr);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
+ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
++#endif
+ 
+ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
+ CHECK_SIZE_AND_OFFSET(dirent, d_ino);
+@@ -1127,7 +1135,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
+ 
+ CHECK_TYPE_SIZE(ether_addr);
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ CHECK_TYPE_SIZE(ipc_perm);
+ # if SANITIZER_FREEBSD
+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
+@@ -1188,7 +1196,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
+ #endif
+ 
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
+ #endif
+ 
+@@ -1238,7 +1246,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
+ COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
+ CHECK_SIZE_AND_OFFSET(FILE, _flags);
+ CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
+@@ -1257,7 +1265,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
+ CHECK_SIZE_AND_OFFSET(FILE, _fileno);
+ #endif
+ 
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+ COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
+ CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
+diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
+index e14d5f575..389a3bc88 100644
+--- a/lib/tsan/rtl/tsan_platform_linux.cc
++++ b/lib/tsan/rtl/tsan_platform_linux.cc
+@@ -285,7 +285,7 @@ void InitializePlatform() {
+ // This is required to properly "close" the fds, because we do not see internal
+ // closes within glibc. The code is a pure hack.
+ int ExtractResolvFDs(void *state, int *fds, int nfd) {
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
+   int cnt = 0;
+   struct __res_state *statp = (struct __res_state*)state;
+   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
+-- 
+2.16.2
+
diff --git a/pkgs/development/compilers/manticore/default.nix b/pkgs/development/compilers/manticore/default.nix
index 795830e0e707..2c8fe1866120 100644
--- a/pkgs/development/compilers/manticore/default.nix
+++ b/pkgs/development/compilers/manticore/default.nix
@@ -1,15 +1,15 @@
 { stdenv, fetchFromGitHub, coreutils, autoreconfHook, smlnj }:
 
 let
-    rev = "592a5714595b4448b646a7d49df04c285668c2f8";
+  rev= "f8e08c89dd98b7b8dba318d245dcd4abd3328ae2";
 in stdenv.mkDerivation rec {
   name = "manticore-${version}";
-  version = "2014.08.18";
+  version = "2017.08.22";
  
   src = fetchFromGitHub {
-    owner = "rrnewton";
-    repo = "manticore_temp_mirror";
-    sha256 = "1snwlm9a31wfgvzb80y7r7yvc6n0k0bi675lqwzll95as7cdswwi";
+    owner = "ManticoreProject";
+    repo = "manticore";
+    sha256 = "06icq0qdzwyzbsyms53blxpb9i26n2vn7ci8p9xvvnq687hxhr73";
     inherit rev;
   };
 
@@ -25,7 +25,7 @@ in stdenv.mkDerivation rec {
     mkdir -p $out
     cd $out
     unpackFile $src
-    mv manticore_temp_mirror-${rev}-src repo_checkout
+    mv source repo_checkout
     cd repo_checkout
     chmod u+w . -R
   ''; 
diff --git a/pkgs/development/compilers/mit-scheme/default.nix b/pkgs/development/compilers/mit-scheme/default.nix
index 4670f39eac18..f254e91e5c65 100644
--- a/pkgs/development/compilers/mit-scheme/default.nix
+++ b/pkgs/development/compilers/mit-scheme/default.nix
@@ -87,6 +87,6 @@ stdenv.mkDerivation {
 
     # Build fails on Cygwin and Darwin:
     # <http://article.gmane.org/gmane.lisp.scheme.mit-scheme.devel/489>.
-    platforms = platforms.gnu ++ platforms.freebsd;
+    platforms = platforms.gnu ++ platforms.linux ++ platforms.freebsd;
   };
 }
diff --git a/pkgs/development/compilers/mono/4.0.nix b/pkgs/development/compilers/mono/4.0.nix
index 8621751e5a14..f13883db74ff 100644
--- a/pkgs/development/compilers/mono/4.0.nix
+++ b/pkgs/development/compilers/mono/4.0.nix
@@ -3,4 +3,7 @@ callPackage ./generic.nix (rec {
   inherit Foundation libobjc;
   version = "4.0.4.1";
   sha256 = "1ydw9l89apc9p7xr5mdzy0h97g2q6v243g82mxswfc2rrqhfs4gd";
+  meta = {
+    knownVulnerabilities = [ "CVE-2009-0689" ];
+  };
 })
diff --git a/pkgs/development/compilers/mono/generic-cmake.nix b/pkgs/development/compilers/mono/generic-cmake.nix
index 7621bd56d47b..929d00491382 100644
--- a/pkgs/development/compilers/mono/generic-cmake.nix
+++ b/pkgs/development/compilers/mono/generic-cmake.nix
@@ -23,8 +23,6 @@ stdenv.mkDerivation rec {
   # To overcome the bug https://bugzilla.novell.com/show_bug.cgi?id=644723
   dontDisableStatic = true;
 
-  # In fact I think this line does not help at all to what I
-  # wanted to achieve: have mono to find libgdiplus automatically
   configureFlags = [
     "--x-includes=${libX11.dev}/include"
     "--x-libraries=${libX11.out}/lib"
@@ -38,7 +36,7 @@ stdenv.mkDerivation rec {
 
   configurePhase = ''
     patchShebangs ./
-    ./autogen.sh --prefix $out
+    ./autogen.sh --prefix $out $configureFlags
   '';
 
   # Attempt to fix this error when running "mcs --version":
@@ -58,13 +56,13 @@ stdenv.mkDerivation rec {
     substituteInPlace mono/mini/aot-compiler.c --replace "llvm_path = g_strdup (\"\")" "llvm_path = g_strdup (\"${llvm}/bin/\")"
   '';
 
-  # Fix mono DLLMap so it can find libX11 and gdiplus to run winforms apps
+  # Fix mono DLLMap so it can find libX11 to run winforms apps
+  # libgdiplus is correctly handled by the --with-libgdiplus configure flag
   # Other items in the DLLMap may need to be pointed to their store locations, I don't think this is exhaustive
   # http://www.mono-project.com/Config_DllMap
   postBuild = ''
     find . -name 'config' -type f | xargs \
-    sed -i -e "s@libX11.so.6@${libX11.out}/lib/libX11.so.6@g" \
-           -e 's#[^"]*libgdiplus[^"]*"#${libgdiplus}/lib/libgdiplus.so"#' \
+    sed -i -e "s@libX11.so.6@${libX11.out}/lib/libX11.so.6@g"
   '';
 
   # Without this, any Mono application attempting to open an SSL connection will throw with
diff --git a/pkgs/development/compilers/mono/generic.nix b/pkgs/development/compilers/mono/generic.nix
index 3b476bce0273..a62f2f24dd87 100644
--- a/pkgs/development/compilers/mono/generic.nix
+++ b/pkgs/development/compilers/mono/generic.nix
@@ -5,13 +5,15 @@
 , version, sha256
 , withLLVM ? false
 , enableParallelBuilding ? true
+, meta ? {}
 }:
 
 let
   llvm     = callPackage ./llvm.nix { };
-in
-stdenv.mkDerivation rec {
   name = "mono-${version}";
+in
+stdenv.mkDerivation {
+  inherit name;
 
   src = fetchurl {
     inherit sha256;
@@ -91,5 +93,5 @@ stdenv.mkDerivation rec {
     platforms = stdenv.lib.platforms.x86;
     maintainers = with stdenv.lib.maintainers; [ viric thoughtpolice obadz vrthra ];
     license = stdenv.lib.licenses.free; # Combination of LGPL/X11/GPL ?
-  };
+  } // meta;
 }
diff --git a/pkgs/development/compilers/nasm/default.nix b/pkgs/development/compilers/nasm/default.nix
index 5394f2bcbbfb..89dd7dc3fdc5 100644
--- a/pkgs/development/compilers/nasm/default.nix
+++ b/pkgs/development/compilers/nasm/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "nasm-${version}";
-  version = "2.13.02";
+  version = "2.13.03";
 
   src = fetchurl {
     url = "http://www.nasm.us/pub/nasm/releasebuilds/${version}/${name}.tar.bz2";
-    sha256 = "1gmvjckxvkmx1kbglgrakc98qhy55xlqlk5flrdihz5yhv92hc4d";
+    sha256 = "04bh736zfj3xy5ihh1whshpjxsisv7hqkz954clzdw6kg93qdv33";
   };
 
   nativeBuildInputs = [ perl ];
diff --git a/pkgs/development/compilers/neko/default.nix b/pkgs/development/compilers/neko/default.nix
index 4dce11f93b13..42a585ff51f0 100644
--- a/pkgs/development/compilers/neko/default.nix
+++ b/pkgs/development/compilers/neko/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation rec {
   version = "2.2.0";
 
   src = fetchurl {
-    url = "http://nekovm.org/media/neko-${version}-src.tar.gz";
+    url = "https://nekovm.org/media/neko-${version}-src.tar.gz";
     sha256 = "1qv47zaa0vzhjlq5wb71627n7dbsxpc1gqpg0hsngjxnbnh1q46g";
   };
 
diff --git a/pkgs/development/compilers/ocaml/4.07.nix b/pkgs/development/compilers/ocaml/4.07.nix
new file mode 100644
index 000000000000..b39d57cc092b
--- /dev/null
+++ b/pkgs/development/compilers/ocaml/4.07.nix
@@ -0,0 +1,9 @@
+import ./generic.nix {
+  major_version = "4";
+  minor_version = "07";
+  patch_version = "0+beta2";
+  sha256 = "0rrvl47kq982z2ns7cnasmlbj60mpmza2zyhl1kh45c5a3n7692n";
+
+  # If the executable is stripped it does not work
+  dontStrip = true;
+}
diff --git a/pkgs/development/compilers/ocaml/generic.nix b/pkgs/development/compilers/ocaml/generic.nix
index 54e9ae671af5..1ee6fee613c9 100644
--- a/pkgs/development/compilers/ocaml/generic.nix
+++ b/pkgs/development/compilers/ocaml/generic.nix
@@ -45,7 +45,8 @@ stdenv.mkDerivation (args // rec {
   ;
 
   buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
-  buildInputs = [ncurses] ++ optionals useX11 [ libX11 xproto ];
+  buildInputs = optional (!stdenv.lib.versionAtLeast version "4.07") ncurses
+    ++ optionals useX11 [ libX11 xproto ];
   installTargets = "install" + optionalString useNativeCompilers " installopt";
   preConfigure = optionalString (!stdenv.lib.versionAtLeast version "4.04") ''
     CAT=$(type -tp cat)
diff --git a/pkgs/development/compilers/opendylan/bin.nix b/pkgs/development/compilers/opendylan/bin.nix
index 8382be7a2091..d3f654749b04 100644
--- a/pkgs/development/compilers/opendylan/bin.nix
+++ b/pkgs/development/compilers/opendylan/bin.nix
@@ -6,11 +6,11 @@ stdenv.mkDerivation {
   name = "opendylan-2013.2";
 
   src = if stdenv.system == "x86_64-linux" then fetchurl {
-      url = http://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86_64-linux.tar.bz2;
+      url = https://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86_64-linux.tar.bz2;
       sha256 = "035brbw3hm7zrs593q4zc42yglj1gmmkw3b1r7zzlw3ks4i2lg7h";
     }
     else if stdenv.system == "i686-linux" then fetchurl {
-      url = http://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86-linux.tar.bz2;
+      url = https://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86-linux.tar.bz2;
       sha256 = "0c61ihvblcsjrw6ncr8x8ylhskcrqs8pajs4mg5di36cvqw12nq5";
     }
     else throw "platform ${stdenv.system} not supported.";
diff --git a/pkgs/development/compilers/opendylan/default.nix b/pkgs/development/compilers/opendylan/default.nix
index 773ab9f473f1..95f4dc5b215f 100644
--- a/pkgs/development/compilers/opendylan/default.nix
+++ b/pkgs/development/compilers/opendylan/default.nix
@@ -2,18 +2,18 @@
 {stdenv, fetchgit, boehmgc, mps, gnused, opendylan-bootstrap, autoconf, automake, perl, makeWrapper, gcc }:
 
 stdenv.mkDerivation {
-  name = "opendylan-2013.2";
+  name = "opendylan-2016.1pre";
 
   src = fetchgit {
     url = https://github.com/dylan-lang/opendylan;
-    rev = "ce9b14dab6cb9ffedc69fae8c6df524c0c79abd3";
-    sha256 = "17jvhv0y63fj25ma05k70b7phcwgjyna5qkrirk48z3xapb8bknd";
+    rev = "cd9a8395586d33cc43a8611c1dc0513e69ee82dd";
+    sha256 = "00r1dm7mjy5p4hfm13vc4b6qryap40zinia3y15rhvalc3i2np4b";
     fetchSubmodules = true;
   };
 
   buildInputs = (if stdenv.system == "i686-linux" then [ mps ] else [ boehmgc ]) ++ [
     opendylan-bootstrap boehmgc gnused autoconf automake perl makeWrapper
-  ] ;
+  ];
 
   preConfigure = if stdenv.system == "i686-linux" then ''
     mkdir -p $TMPDIR/mps
diff --git a/pkgs/development/compilers/openjdk/9.nix b/pkgs/development/compilers/openjdk/10.nix
index 0a9be04ebb22..7882fa49b07e 100644
--- a/pkgs/development/compilers/openjdk/9.nix
+++ b/pkgs/development/compilers/openjdk/10.nix
@@ -4,8 +4,7 @@
 , libjpeg, giflib
 , setJavaClassPath
 , minimal ? false
-#, enableInfinality ? true # font rendering patch
-, enableGnome2 ? true, gtk2, gnome_vfs, glib, GConf
+, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf
 }:
 
 let
@@ -16,53 +15,20 @@ let
   architecture =
     if stdenv.system == "i686-linux" then
       "i386"
-    else if stdenv.system == "x86_64-linux" then
-      "amd64"
-    else
-      throw "openjdk requires i686-linux or x86_64 linux";
-
-  update = "9.0.4";
-  build = "11";
-  baseurl = "http://hg.openjdk.java.net/jdk-updates/jdk9u";
+    else "amd64";
+
+  update = "10.0.1";
+  build = "10";
   repover = "jdk-${update}+${build}";
   paxflags = if stdenv.isi686 then "msp" else "m";
-  jdk9 = fetchurl {
-             url = "${baseurl}/archive/${repover}.tar.gz";
-             sha256 = "1y8sq0fxvj5s5gx5qm2mbr710xqrgv3d200k6bv71bawjh57v3xx";
-          };
-  langtools = fetchurl {
-             url = "${baseurl}/langtools/archive/${repover}.tar.gz";
-             sha256 = "1n6aqmph6a9spxyfi40k8g5hy2bnfd499gr6jkmq49phdb2qg7wy";
-          };
-  hotspot = fetchurl {
-             url = "${baseurl}/hotspot/archive/${repover}.tar.gz";
-             sha256 = "1i34k3pc2slnjk469zskqq1z0jna1xg2zzjdk7zjrhrfgsrgvfsh";
-          };
-  corba = fetchurl {
-             url = "${baseurl}/corba/archive/${repover}.tar.gz";
-             sha256 = "1k6r5yxf5h1m451vlwzk9zqkmdlln3ky3kir5qjgan4hz892f297";
-          };
-  jdk = fetchurl {
-             url = "${baseurl}/jdk/archive/${repover}.tar.gz";
-             sha256 = "0gafc0jx8fx13y6iir9zxmqrsw1a3w71xgdvjx9rk64acc24piy2";
-          };
-  jaxws = fetchurl {
-             url = "${baseurl}/jaxws/archive/${repover}.tar.gz";
-             sha256 = "1bw3z346mna6pgz76phcmfm0ykydcwagqxhffj0mzbdll7ysw25p";
-          };
-  jaxp = fetchurl {
-             url = "${baseurl}/jaxp/archive/${repover}.tar.gz";
-             sha256 = "063fhnmm2g83jrdv2bl968glr46vvgjpyk9rjmh2fwfplzclb51s";
-          };
-  nashorn = fetchurl {
-             url = "${baseurl}/nashorn/archive/${repover}.tar.gz";
-             sha256 = "0wyx76nd4v6xy4vmp94anxwk9bfqyb0l4n3hqhfqyz6azi8pqk66";
-          };
-  openjdk9 = stdenv.mkDerivation {
+
+  openjdk10 = stdenv.mkDerivation {
     name = "openjdk-${update}-b${build}";
 
-    srcs = [ jdk9 langtools hotspot corba jdk jaxws jaxp nashorn ];
-    sourceRoot = ".";
+    src = fetchurl {
+      url = "http://hg.openjdk.java.net/jdk-updates/jdk10u/archive/${repover}.tar.gz";
+      sha256 = "1fg0rl5pd3f2y3v3bq8p3zdkrpa1pyslwdln4s64clyr7spvxkjw";
+    };
 
     outputs = [ "out" "jre" ];
 
@@ -72,28 +38,15 @@ let
       libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst
       libXi libXinerama libXcursor lndir fontconfig
     ] ++ lib.optionals (!minimal && enableGnome2) [
-      gtk2 gnome_vfs GConf glib
+      gtk3 gnome_vfs GConf glib
     ];
 
-    #move the seven other source dirs under the main jdk8u directory,
-    #with version suffixes removed, as the remainder of the build will expect
-    prePatch = ''
-      mainDir=$(find . -maxdepth 1 -name jdk9\*);
-      find . -maxdepth 1 -name \*jdk\* -not -name jdk9\* | awk -F- '{print $1}' | while read p; do
-        mv $p-* $mainDir/$p
-      done
-      cd $mainDir
-    '';
-
     patches = [
-      ./fix-java-home-jdk9.patch
-      ./read-truststore-from-env-jdk9.patch
-      ./currency-date-range-jdk8.patch
-    #] ++ lib.optionals (!minimal && enableInfinality) [
-    #  ./004_add-fontconfig.patch
-    #  ./005_enable-infinality.patch
+      ./fix-java-home-jdk10.patch
+      ./read-truststore-from-env-jdk10.patch
+      ./currency-date-range-jdk10.patch
     ] ++ lib.optionals (!minimal && enableGnome2) [
-      ./swing-use-gtk-jdk9.patch
+      ./swing-use-gtk-jdk10.patch
     ];
 
     preConfigure = ''
@@ -127,7 +80,7 @@ let
     NIX_LDFLAGS= lib.optionals (!minimal) [
       "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
     ] ++ lib.optionals (!minimal && enableGnome2) [
-      "-lgtk-x11-2.0" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
+      "-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
     ];
 
     buildFlags = [ "all" ];
@@ -160,18 +113,12 @@ let
       rm -rf $out/lib/openjdk/demo
       ${lib.optionalString minimal ''
         for d in $out/lib/openjdk/lib $jre/lib/openjdk/jre/lib; do
-          rm ''${d}/{libjsound,libjsoundalsa,libawt*,libfontmanager}.so
+          rm ''${d}/{libjsound,libjsoundalsa,libfontmanager}.so
         done
       ''}
 
       lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre
 
-      # Make sure cmm/*.pf are not symlinks:
-      # https://youtrack.jetbrains.com/issue/IDEA-147272
-      # in 9, it seems no *.pf files end up in $out ... ?
-      # rm -rf $out/lib/openjdk/jre/lib/cmm
-      # ln -s {$jre,$out}/lib/openjdk/jre/lib/cmm
-
       # Set PaX markings
       exes=$(file $out/lib/openjdk/bin/* $jre/lib/openjdk/jre/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
       echo "to mark: *$exes*"
@@ -188,13 +135,6 @@ let
         fi
       done
 
-      # Generate certificates.
-      (
-        cd $jre/lib/openjdk/jre/lib/security
-        rm cacerts
-        perl ${./generate-cacerts.pl} $jre/lib/openjdk/jre/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt
-      )
-
       ln -s $out/lib/openjdk/bin $out/bin
       ln -s $jre/lib/openjdk/jre/bin $jre/bin
       ln -s $jre/lib/openjdk/jre $out/jre
@@ -251,12 +191,12 @@ let
       license = licenses.gpl2;
       description = "The open-source Java Development Kit";
       maintainers = with maintainers; [ edwtjo ];
-      platforms = platforms.linux;
+      platforms = ["i686-linux" "x86_64-linux"];
     };
 
     passthru = {
       inherit architecture;
-      home = "${openjdk9}/lib/openjdk";
+      home = "${openjdk10}/lib/openjdk";
     };
   };
-in openjdk9
+in openjdk10
diff --git a/pkgs/development/compilers/openjdk/7.nix b/pkgs/development/compilers/openjdk/7.nix
deleted file mode 100644
index 13f8bcfdb1de..000000000000
--- a/pkgs/development/compilers/openjdk/7.nix
+++ /dev/null
@@ -1,244 +0,0 @@
-{ stdenv, fetchurl, unzip, zip, procps, coreutils, alsaLib, ant, freetype
-, which, bootjdk, nettools, xorg, file, cups
-, fontconfig, cpio, cacert, perl, setJavaClassPath
-, minimal ? false
-}:
-
-let
-
-  /**
-   * The JRE libraries are in directories that depend on the CPU.
-   */
-  architecture =
-    if stdenv.system == "i686-linux" then
-      "i386"
-    else if stdenv.system == "x86_64-linux" then
-      "amd64"
-    else
-      throw "openjdk requires i686-linux or x86_64 linux";
-
-  update = "111";
-
-  build = "01";
-
-  # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
-  paxflags = if stdenv.isi686 then "msp" else "m";
-
-  baseurl = "http://hg.openjdk.java.net/jdk7u/jdk7u";
-  repover = "jdk7u${update}-b${build}";
-  jdk7 = fetchurl {
-    url = "${baseurl}/archive/${repover}.tar.gz";
-    sha256 = "0wgb7hr2gipx1jg28fnsjh7xa744sh1mgr6z3xivmnsfy3dm91gi";
-  };
-  langtools = fetchurl {
-    url = "${baseurl}/langtools/archive/${repover}.tar.gz";
-    sha256 = "0x1xs923h6sma02cbp1whg735x8vcndh5k01b7rkf714g6rxwa0y";
-  };
-  hotspot = fetchurl {
-    url = "${baseurl}/hotspot/archive/${repover}.tar.gz";
-    sha256 = "187apnsvnd4cfa7ss5g59dbh7x5ah8f1lwa2wvjfv055h2cmphpn";
-  };
-  corba = fetchurl {
-    url = "${baseurl}/corba/archive/${repover}.tar.gz";
-    sha256 = "0vmxf5sgjcmkm7i1scanaa2x75a1byj8b36vcajlr6j7qmdx6r8c";
-  };
-  jdk = fetchurl {
-    url = "${baseurl}/jdk/archive/${repover}.tar.gz";
-    sha256 = "1f8f2dgrjhx8aw1gzawrf8qggf5j0dygsla08bbsxhx5mc5a6cka";
-  };
-  jaxws = fetchurl {
-    url = "${baseurl}/jaxws/archive/${repover}.tar.gz";
-    sha256 = "03982ajxm0hzany1jg009ym84vryx7a8qfi6wcgjxyxvk8vnz37c";
-  };
-  jaxp = fetchurl {
-    url = "${baseurl}/jaxp/archive/${repover}.tar.gz";
-    sha256 = "0578h04y1ha60yjplsa8lqdjds9s2lxzgs9ybm9rs1rqzxmm0xmy";
-  };
-  openjdk = stdenv.mkDerivation rec {
-    name = "openjdk-7u${update}b${build}";
-
-    srcs = [ jdk7 langtools hotspot corba jdk jaxws jaxp ];
-    sourceRoot = ".";
-
-    outputs = [ "out" "jre" ];
-
-    buildInputs =
-      [ unzip procps ant which zip cpio nettools alsaLib
-        xorg.libX11 xorg.libXt xorg.libXext xorg.libXrender xorg.libXtst
-        xorg.libXi xorg.libXinerama xorg.libXcursor xorg.lndir
-        fontconfig perl file bootjdk
-      ];
-
-    NIX_CFLAGS_COMPILE = [
-      "-Wno-error=deprecated-declarations"
-      "-Wno-error=format-overflow" # newly detected by gcc7
-    ];
-
-    NIX_LDFLAGS = if minimal then null else "-lfontconfig -lXcursor -lXinerama";
-
-    postUnpack = ''
-      ls | grep jdk | grep -v '^jdk7u' | awk -F- '{print $1}' | while read p; do
-        mv $p-* $(ls | grep '^jdk7u')/$p
-      done
-      cd jdk7u-*
-
-      sed -i -e "s@/usr/bin/test@${coreutils}/bin/test@" \
-        -e "s@/bin/ls@${coreutils}/bin/ls@" \
-        hotspot/make/linux/makefiles/sa.make
-
-      sed -i "s@/bin/echo -e@${coreutils}/bin/echo -e@" \
-        {jdk,corba}/make/common/shared/Defs-utils.gmk
-
-      tar xf ${cups.src}
-      cupsDir=$(echo $(pwd)/cups-*)
-      makeFlagsArray+=(CUPS_HEADERS_PATH=$cupsDir)
-    '';
-
-    patches = [
-      ./cppflags-include-fix.patch
-      ./fix-java-home.patch
-      ./paxctl.patch
-      ./read-truststore-from-env.patch
-      ./currency-date-range.patch
-    ];
-
-    NIX_NO_SELF_RPATH = true;
-
-    makeFlags = [
-      "SORT=${coreutils}/bin/sort"
-      "ALSA_INCLUDE=${alsaLib.dev}/include/alsa/version.h"
-      "FREETYPE_HEADERS_PATH=${freetype.dev}/include"
-      "FREETYPE_LIB_PATH=${freetype.out}/lib"
-      "MILESTONE=${update}"
-      "BUILD_NUMBER=b${build}"
-      "USRBIN_PATH="
-      "COMPILER_PATH="
-      "DEVTOOLS_PATH="
-      "UNIXCOMMAND_PATH="
-      "BOOTDIR=${bootjdk.home}"
-      "STATIC_CXX=false"
-      "UNLIMITED_CRYPTO=1"
-      "FULL_DEBUG_SYMBOLS=0"
-    ] ++ stdenv.lib.optional minimal "BUILD_HEADLESS=1";
-
-    configurePhase = "true";
-
-    preBuild = ''
-      # We also need to PaX-mark in the middle of the build
-      substituteInPlace hotspot/make/linux/makefiles/launcher.make \
-         --replace XXX_PAXFLAGS_XXX ${paxflags}
-      substituteInPlace jdk/make/common/Program.gmk  \
-         --replace XXX_PAXFLAGS_XXX ${paxflags}
-    '';
-
-    installPhase = ''
-      mkdir -p $out/lib/openjdk $out/share $jre/lib/openjdk
-
-      cp -av build/*/j2sdk-image/* $out/lib/openjdk
-
-      # Move some stuff to top-level.
-      mv $out/lib/openjdk/include $out/include
-      mv $out/lib/openjdk/man $out/share/man
-
-      # jni.h expects jni_md.h to be in the header search path.
-      ln -s $out/include/linux/*_md.h $out/include/
-
-      # Remove some broken manpages.
-      rm -rf $out/share/man/ja*
-
-      # Remove crap from the installation.
-      rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample
-
-      # Move the JRE to a separate output.
-      mv $out/lib/openjdk/jre $jre/lib/openjdk/
-      mkdir $out/lib/openjdk/jre
-      lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre
-
-      rm -rf $out/lib/openjdk/jre/bin
-      ln -s $out/lib/openjdk/bin $out/lib/openjdk/jre/bin
-
-      # Set PaX markings
-      exes=$(file $out/lib/openjdk/bin/* $jre/lib/openjdk/jre/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
-      echo "to mark: *$exes*"
-      for file in $exes; do
-        echo "marking *$file*"
-        paxmark ${paxflags} "$file"
-      done
-
-      # Remove duplicate binaries.
-      for i in $(cd $out/lib/openjdk/bin && echo *); do
-        if [ "$i" = java ]; then continue; fi
-        if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then
-          ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i
-        fi
-      done
-
-      # Generate certificates.
-      pushd $jre/lib/openjdk/jre/lib/security
-      rm cacerts
-      perl ${./generate-cacerts.pl} $jre/lib/openjdk/jre/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt
-      popd
-
-      ln -s $out/lib/openjdk/bin $out/bin
-      ln -s $jre/lib/openjdk/jre/bin $jre/bin
-    ''; # */
-
-    # FIXME: this is unnecessary once the multiple-outputs branch is merged.
-    preFixup = ''
-      prefix=$jre stripDirs "$stripDebugList" "''${stripDebugFlags:--S}"
-      patchELF $jre
-      propagatedBuildInputs+=" $jre"
-
-      # Propagate the setJavaClassPath setup hook from the JRE so that
-      # any package that depends on the JRE has $CLASSPATH set up
-      # properly.
-      mkdir -p $jre/nix-support
-      printWords ${setJavaClassPath} > $jre/nix-support/propagated-build-inputs
-
-      # Set JAVA_HOME automatically.
-      mkdir -p $out/nix-support
-      cat <<EOF > $out/nix-support/setup-hook
-      if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi
-      EOF
-    '';
-
-    postFixup = ''
-      # Build the set of output library directories to rpath against
-      LIBDIRS=""
-      for output in $outputs; do
-        LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':'):$LIBDIRS"
-      done
-
-      # Add the local library paths to remove dependencies on the bootstrap
-      for output in $outputs; do
-        OUTPUTDIR="$(eval echo \$$output)"
-        BINLIBS="$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)"
-        echo "$BINLIBS" | while read i; do
-          patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true
-          patchelf --shrink-rpath "$i" || true
-        done
-      done
-
-      # Test to make sure that we don't depend on the bootstrap
-      for output in $outputs; do
-        if grep -q -r '${bootjdk}' $(eval echo \$$output); then
-          echo "Extraneous references to ${bootjdk} detected"
-          exit 1
-        fi
-      done
-    '';
-
-    meta = {
-      homepage = http://openjdk.java.net/;
-      license = stdenv.lib.licenses.gpl2;
-      description = "The open-source Java Development Kit";
-      maintainers = [ stdenv.lib.maintainers.eelco ];
-      platforms = stdenv.lib.platforms.linux;
-    };
-
-    passthru = {
-      inherit architecture;
-      home = "${openjdk}/lib/openjdk";
-    };
-  };
-in openjdk
diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix
index b74c8a47dde0..7798418ebfd1 100644
--- a/pkgs/development/compilers/openjdk/8.nix
+++ b/pkgs/development/compilers/openjdk/8.nix
@@ -14,49 +14,49 @@ let
    * The JRE libraries are in directories that depend on the CPU.
    */
   architecture =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       "i386"
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       "amd64"
     else
       throw "openjdk requires i686-linux or x86_64 linux";
 
   update = "172";
-  build = "02";
+  build = "11";
   baseurl = "http://hg.openjdk.java.net/jdk8u/jdk8u";
   repover = "jdk8u${update}-b${build}";
   paxflags = if stdenv.isi686 then "msp" else "m";
   jdk8 = fetchurl {
              url = "${baseurl}/archive/${repover}.tar.gz";
-             sha256 = "0y28by4ifsaxhfrzq35654i8h9jjgvrw51hbxyg8pgfink0n30r2";
+             sha256 = "08mgfqbbgnx9n6prczwm4m8pgsakya45iai1gfslqnb0adh33jpi";
           };
   langtools = fetchurl {
              url = "${baseurl}/langtools/archive/${repover}.tar.gz";
-             sha256 = "0rxp4920xpd9khdg2ia1v1djcw1nndsjfis68whawi7s95zwpxy5";
+             sha256 = "0dph17mpr5ni280z8rmiwlw0v46dnzyph6fq132xvxiw2i1203zg";
           };
   hotspot = fetchurl {
              url = "${baseurl}/hotspot/archive/${repover}.tar.gz";
-             sha256 = "0sdf6rww290wgfqhaix1vjac244drdgg7hapb67wgj733kkdl711";
+             sha256 = "181ixh75xjvlj0l3a58d9iqf50ivq77993yzfv0463dm44h6b8pp";
           };
   corba = fetchurl {
              url = "${baseurl}/corba/archive/${repover}.tar.gz";
-             sha256 = "0vl3aryw3nclqprc35b2iriwfyr9fch3x8snjry1z5ajbdyd5c8b";
+             sha256 = "097azhdmr7ph1gvlzjgx6s2hyxmi2s5293d5hs23dl5i9f55b6x8";
           };
   jdk = fetchurl {
              url = "${baseurl}/jdk/archive/${repover}.tar.gz";
-             sha256 = "1y5fnzxdll3q0jgqxsap3xb21bm1napdlqzs7h6c2l5qldyvw692";
+             sha256 = "1lvk2brd9yclzd7cdk1kvnv4mbdxzjxd595pqhdaxdxxr5anhsvm";
           };
   jaxws = fetchurl {
              url = "${baseurl}/jaxws/archive/${repover}.tar.gz";
-             sha256 = "1yg1ik1klg8pl4b7izi2waqhs7vr6ln3fzc4k1siir4va5qhrhlm";
+             sha256 = "0cl4b4c2qjyhlsa5khlxinilfaj6ai1mzji3y0263klc8q6bglwa";
           };
   jaxp = fetchurl {
              url = "${baseurl}/jaxp/archive/${repover}.tar.gz";
-             sha256 = "03srcj6hhvbdg1iqw85mfm1pwd6yvpykyz5nn4ydf930g4dyxfkf";
+             sha256 = "00s6wm62v7gmkwy46js0lisijng40lnxscndczbgfvvz2q9zz4q1";
           };
   nashorn = fetchurl {
              url = "${baseurl}/nashorn/archive/${repover}.tar.gz";
-             sha256 = "12nn02jiq3vqgwhqh5yvxq1k92fy3n0jpvfpj1npq9fvimywry2k";
+             sha256 = "0ab0rrmmf145nh4mibvknjni4whvzmk6fsnl7ihcn8m0zi6zyfra";
           };
   openjdk8 = stdenv.mkDerivation {
     name = "openjdk-8u${update}b${build}";
@@ -93,7 +93,7 @@ let
       ./004_add-fontconfig.patch
       ./005_enable-infinality.patch
     ] ++ lib.optionals (!minimal && enableGnome2) [
-      ./swing-use-gtk.patch
+      ./swing-use-gtk-jdk8.patch
     ];
 
     preConfigure = ''
diff --git a/pkgs/development/compilers/openjdk/bootstrap.nix b/pkgs/development/compilers/openjdk/bootstrap.nix
index 48a22638813f..3c29df7ec78e 100644
--- a/pkgs/development/compilers/openjdk/bootstrap.nix
+++ b/pkgs/development/compilers/openjdk/bootstrap.nix
@@ -1,33 +1,25 @@
-{ stdenv, runCommand, glibc, fetchurl, file
+{ stdenv
+, runCommand, fetchurl, file, zlib
 
 , version
 }:
 
+assert stdenv.hostPlatform.libc == "glibc";
+
 let
-  # !!! These should be on nixos.org
-  src = if glibc.system == "x86_64-linux" then
-    (if version == "8" then
-      fetchurl {
-        url = "https://www.dropbox.com/s/a0lsq2ig4uguky5/openjdk8-bootstrap-x86_64-linux.tar.xz?dl=1";
-        sha256 = "18zqx6jhm3lizn9hh6ryyqc9dz3i96pwaz8f6nxfllk70qi5gvks";
-      }
-    else if version == "7" then
-      fetchurl {
-        url = "https://www.dropbox.com/s/rssfbeommrfbsjf/openjdk7-bootstrap-x86_64-linux.tar.xz?dl=1";
-        sha256 = "024gg2sgg4labxbc1nhn8lxls2p7d9h3b82hnsahwaja2pm1hbra";
-      }
+  fetchboot = version: arch: sha256: fetchurl {
+    name = "openjdk${version}-bootstrap-${arch}-linux.tar.xz";
+    url  = "http://tarballs.nixos.org/openjdk/2018-03-31/${version}/${arch}-linux.tar.xz";
+    inherit sha256;
+  };
+
+  src = if stdenv.hostPlatform.system == "x86_64-linux" then
+    (if version == "10"    then fetchboot "10" "x86_64" "08085fsxc1qhqiv3yi38w8lrg3vm7s0m2yvnwr1c92v019806yq2"
+    else if version == "8" then fetchboot "8"  "x86_64" "18zqx6jhm3lizn9hh6ryyqc9dz3i96pwaz8f6nxfllk70qi5gvks"
     else throw "No bootstrap for version")
-  else if glibc.system == "i686-linux" then
-    (if version == "8" then
-      fetchurl {
-        url = "https://www.dropbox.com/s/rneqjhlerijsw74/openjdk8-bootstrap-i686-linux.tar.xz?dl=1";
-        sha256 = "1yx04xh8bqz7amg12d13rw5vwa008rav59mxjw1b9s6ynkvfgqq9";
-      }
-    else if version == "7" then
-      fetchurl {
-        url = "https://www.dropbox.com/s/6xe64td7eg2wurs/openjdk7-bootstrap-i686-linux.tar.xz?dl=1";
-        sha256 = "0xwqjk1zx8akziw8q9sbjc1rs8s7c0w6mw67jdmmi26cwwp8ijnx";
-      }
+  else if stdenv.hostPlatform.system == "i686-linux" then
+    (if version == "10"    then fetchboot "10" "i686" "1blb9gyzp8gfyggxvggqgpcgfcyi00ndnnskipwgdm031qva94p7"
+    else if version == "8" then fetchboot "8"  "i686" "1yx04xh8bqz7amg12d13rw5vwa008rav59mxjw1b9s6ynkvfgqq9"
     else throw "No bootstrap for version")
   else throw "No bootstrap for system";
 
@@ -39,22 +31,18 @@ let
 
     LIBDIRS="$(find $out -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':')"
 
-    for i in $out/bin/*; do
-      patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $i || true
-      patchelf --set-rpath "${glibc.out}/lib:$LIBDIRS" $i || true
-    done
-
-    find $out -name \*.so\* | while read lib; do
-      patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $lib || true
-      patchelf --set-rpath "${glibc.out}/lib:${stdenv.cc.cc.lib}/lib:$LIBDIRS" $lib || true
+    find "$out" -type f -print0 | while IFS= read -r -d "" elf; do
+      isELF "$elf" || continue
+      patchelf --set-interpreter $(cat "${stdenv.cc}/nix-support/dynamic-linker") "$elf" || true
+      patchelf --set-rpath "${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib:${zlib}/lib:$LIBDIRS" "$elf" || true
     done
 
     # Temporarily, while NixOS's OpenJDK bootstrap tarball doesn't have PaX markings:
-    exes=$(${file}/bin/file $out/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
-    for file in $exes; do
-      paxmark m "$file"
+    find "$out/bin" -type f -print0 | while IFS= read -r -d "" elf; do
+      isELF "$elf" || continue
+      paxmark m "$elf"
       # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
-      ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''}
+      ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$elf"''}
     done
   '';
 in bootstrap
diff --git a/pkgs/development/compilers/openjdk/cppflags-include-fix.patch b/pkgs/development/compilers/openjdk/cppflags-include-fix.patch
deleted file mode 100644
index 8931c122538f..000000000000
--- a/pkgs/development/compilers/openjdk/cppflags-include-fix.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff -Naur openjdk-orig/jdk/make/sun/awt/mawt.gmk openjdk/jdk/make/sun/awt/mawt.gmk
---- openjdk-orig/jdk/make/sun/awt/mawt.gmk	2012-08-28 19:13:16.000000000 -0400
-+++ openjdk/jdk/make/sun/awt/mawt.gmk	2013-01-22 11:56:22.315418708 -0500
-@@ -234,12 +234,6 @@
- endif # !HEADLESS
- endif # PLATFORM
- 
--ifeq ($(PLATFORM), linux)
--  # Checking for the X11/extensions headers at the additional location
--  CPPFLAGS += -I$(firstword $(wildcard $(OPENWIN_HOME)/include/X11/extensions) \
--                        $(wildcard /usr/include/X11/extensions))
--endif
--
- ifeq ($(PLATFORM), macosx))
-   CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
-               -I$(OPENWIN_HOME)/include 
diff --git a/pkgs/development/compilers/openjdk/currency-date-range.patch b/pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch
index b1c461591d1e..e058eff07466 100644
--- a/pkgs/development/compilers/openjdk/currency-date-range.patch
+++ b/pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch
@@ -1,6 +1,5 @@
-diff -Naur openjdk-7u65-b32-upstream/jdk/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java openjdk-7u65-b32/jdk/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java
---- openjdk-7u65-b32-upstream/jdk/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java	2014-07-17 05:42:14.000000000 -0430
-+++ openjdk-7u65-b32/jdk/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java	2014-12-30 10:15:50.327905933 -0430
+--- ./make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
++++ ./make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
 @@ -281,8 +281,8 @@
              checkCurrencyCode(newCurrency);
              String timeString = currencyInfo.substring(4, length - 4);
diff --git a/pkgs/development/compilers/openjdk-darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix
index cc7c5fd371d2..7457ffceab1f 100644
--- a/pkgs/development/compilers/openjdk-darwin/8.nix
+++ b/pkgs/development/compilers/openjdk/darwin/8.nix
@@ -26,6 +26,11 @@ let
 
       # jni.h expects jni_md.h to be in the header search path.
       ln -s $out/include/darwin/*_md.h $out/include/
+
+      if [ -f $out/LICENSE ]; then
+        install -D $out/LICENSE $out/share/zulu/LICENSE
+        rm $out/LICENSE
+      fi
     '';
 
     preFixup = ''
diff --git a/pkgs/development/compilers/openjdk-darwin/default.nix b/pkgs/development/compilers/openjdk/darwin/default.nix
index 6ecc785be3b9..54239e58002f 100644
--- a/pkgs/development/compilers/openjdk-darwin/default.nix
+++ b/pkgs/development/compilers/openjdk/darwin/default.nix
@@ -16,6 +16,11 @@ let
 
       # jni.h expects jni_md.h to be in the header search path.
       ln -s $out/include/darwin/*_md.h $out/include/
+
+      if [ -f $out/LICENSE ]; then
+        install -D $out/LICENSE $out/share/zulu/LICENSE
+        rm $out/LICENSE
+      fi
     '';
 
     preFixup = ''
diff --git a/pkgs/development/compilers/openjdk/fix-java-home-jdk9.patch b/pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch
index f9755d58e48f..c037fde29722 100644
--- a/pkgs/development/compilers/openjdk/fix-java-home-jdk9.patch
+++ b/pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch
@@ -1,14 +1,14 @@
---- a/hotspot/src/os/linux/vm/os_linux.cpp	2017-07-04 23:09:02.533972226 -0400
-+++ b/hotspot/src/os/linux/vm/os_linux.cpp	2017-07-04 23:07:52.118338845 -0400
-@@ -2318,10 +2318,7 @@
+--- a/src/hotspot/os/linux/os_linux.cpp	2017-07-04 23:09:02.533972226 -0400
++++ b/src/hotspot/os/linux/os_linux.cpp	2017-07-04 23:07:52.118338845 -0400
+@@ -2270,8 +2270,5 @@
    assert(ret, "cannot locate libjvm");
    char *rp = NULL;
    if (ret && dli_fname[0] != '\0') {
--    rp = realpath(dli_fname, buf);
+-    rp = os::Posix::realpath(dli_fname, buf, buflen);
 -  }
 -  if (rp == NULL) {
 -    return;
 +    snprintf(buf, buflen, "%s", dli_fname);
    }
- 
+
    if (Arguments::sun_java_launcher_is_altjvm()) {
diff --git a/pkgs/development/compilers/openjdk/fix-java-home.patch b/pkgs/development/compilers/openjdk/fix-java-home.patch
deleted file mode 100644
index 5def344f1717..000000000000
--- a/pkgs/development/compilers/openjdk/fix-java-home.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-diff -ru -x '*~' openjdk-orig/hotspot/src/os/linux/vm/os_linux.cpp openjdk/hotspot/src/os/linux/vm/os_linux.cpp
---- openjdk-orig/hotspot/src/os/linux/vm/os_linux.cpp	2013-09-06 20:22:03.000000000 +0200
-+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp	2014-01-24 22:44:08.223857012 +0100
-@@ -2358,12 +2358,10 @@
-                 CAST_FROM_FN_PTR(address, os::jvm_path),
-                 dli_fname, sizeof(dli_fname), NULL);
-   assert(ret, "cannot locate libjvm");
-   char *rp = NULL;
-   if (ret && dli_fname[0] != '\0') {
--    rp = realpath(dli_fname, buf);
-+    snprintf(buf, buflen, "%s", dli_fname);
-   }
--  if (rp == NULL)
--    return;
- 
-   if (Arguments::created_by_gamma_launcher()) {
-     // Support for the gamma launcher.  Typical value for buf is
diff --git a/pkgs/development/compilers/openjdk/paxctl.patch b/pkgs/development/compilers/openjdk/paxctl.patch
deleted file mode 100644
index 12528a601cc8..000000000000
--- a/pkgs/development/compilers/openjdk/paxctl.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff --git a/hotspot/make/linux/makefiles/launcher.make b/hotspot/make/linux/makefiles/launcher.make
-index 34bbcd6..41b9332 100644
---- a/hotspot/make/linux/makefiles/launcher.make
-+++ b/hotspot/make/linux/makefiles/launcher.make
-@@ -83,6 +83,8 @@ $(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
- 	$(QUIETLY) echo Linking launcher...
- 	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
- 	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(OBJS) $(LIBS_LAUNCHER)
-+	paxctl -c $(LAUNCHER)
-+	paxctl -zex -XXX_PAXFLAGS_XXX $(LAUNCHER)
- 	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
- 
- $(LAUNCHER): $(LAUNCHER_SCRIPT)
-diff --git a/jdk/make/common/Program.gmk b/jdk/make/common/Program.gmk
-index 091800d..1de8cb4 100644
---- a/jdk/make/common/Program.gmk
-+++ b/jdk/make/common/Program.gmk
-@@ -60,6 +60,10 @@ ACTUAL_PROGRAM      = $(ACTUAL_PROGRAM_DIR)/$(ACTUAL_PROGRAM_NAME)
- program_default_rule: all
- 
- program: $(ACTUAL_PROGRAM)
-+	if [[ "$(PROGRAM)" = "java" ]]; then \
-+		paxctl -c $(ACTUAL_PROGRAM); \
-+		paxctl -zex -XXX_PAXFLAGS_XXX $(ACTUAL_PROGRAM); \
-+	fi
- 
- # Work-around for missing processor specific mapfiles
- ifndef CROSS_COMPILE_ARCH
diff --git a/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk9.patch b/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch
index cb8d59ff8063..b5abc1d794db 100644
--- a/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk9.patch
+++ b/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch
@@ -1,5 +1,5 @@
---- a/jdk/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java	2017-06-26 21:48:25.000000000 -0400
-+++ b/jdk/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java.new	2017-07-05 20:45:57.491295030 -0400
+--- a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java	2017-06-26 21:48:25.000000000 -0400
++++ b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java	2017-07-05 20:45:57.491295030 -0400
 @@ -71,6 +71,7 @@
       *
       * The preference of the default trusted KeyStore is:
diff --git a/pkgs/development/compilers/openjdk/read-truststore-from-env.patch b/pkgs/development/compilers/openjdk/read-truststore-from-env.patch
deleted file mode 100644
index 8fb0f409d0ab..000000000000
--- a/pkgs/development/compilers/openjdk/read-truststore-from-env.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -ur openjdk-7u65-b32/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java openjdk-7u65-b32.new/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
---- openjdk-7u65-b32/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java	2014-07-17 12:12:14.000000000 +0200
-+++ openjdk-7u65-b32.new/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java	2014-12-09 13:31:27.821960372 +0100
-@@ -158,6 +158,7 @@
-         /*
-          * Try:
-          *      javax.net.ssl.trustStore  (if this variable exists, stop)
-+         *      system environment variable JAVAX_NET_SSL_TRUSTSTORE
-          *      jssecacerts
-          *      cacerts
-          *
-@@ -165,6 +166,9 @@
-          */
- 
-         storeFileName = props.get("trustStore");
-+        if (storeFileName == null) {
-+            storeFileName = System.getenv("JAVAX_NET_SSL_TRUSTSTORE");
-+        }
-         if (!"NONE".equals(storeFileName)) {
-             if (storeFileName != null) {
-                 storeFile = new File(storeFileName);
diff --git a/pkgs/development/compilers/openjdk/swing-use-gtk-jdk9.patch b/pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch
index 07d95ba71b8a..b9258c500db4 100644
--- a/pkgs/development/compilers/openjdk/swing-use-gtk-jdk9.patch
+++ b/pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch
@@ -1,6 +1,5 @@
-diff -ru3 a/jdk/src/share/classes/javax/swing/UIManager.java b/jdk/src/share/classes/javax/swing/UIManager.java
---- a/jdk/src/java.desktop/share/classes/javax/swing/UIManager.java	2016-07-26 00:41:37.000000000 +0300
-+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIManager.java	2016-10-02 22:46:01.890071761 +0300
+--- a/src/java.desktop/share/classes/javax/swing/UIManager.java
++++ b/src/java.desktop/share/classes/javax/swing/UIManager.java
 @@ -607,11 +607,9 @@
          if (osType == OSInfo.OSType.WINDOWS) {
              return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
@@ -23,4 +22,3 @@ diff -ru3 a/jdk/src/share/classes/javax/swing/UIManager.java b/jdk/src/share/cla
 +            lafName = getSystemLookAndFeelClassName();
          }
          lafName = swingProps.getProperty(defaultLAFKey, lafName);
- 
diff --git a/pkgs/development/compilers/openjdk/swing-use-gtk.patch b/pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch
index 9538aade6726..9538aade6726 100644
--- a/pkgs/development/compilers/openjdk/swing-use-gtk.patch
+++ b/pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch
diff --git a/pkgs/development/compilers/oraclejdk/jdk9-linux.nix b/pkgs/development/compilers/oraclejdk/jdk10-linux.nix
index 87f2e49b4431..b93a13abc9ca 100644
--- a/pkgs/development/compilers/oraclejdk/jdk9-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk10-linux.nix
@@ -25,11 +25,10 @@
 , setJavaClassPath
 }:
 
-assert stdenv.system == "x86_64-linux";
 assert swingSupport -> xorg != null;
 
 let
-  version = "9.0.4";
+  version = "10.0.1";
 
   downloadUrlBase = http://www.oracle.com/technetwork/java/javase/downloads;
 
@@ -51,20 +50,20 @@ let result = stdenv.mkDerivation rec {
     if packageType == "JDK" then
       requireFile {
         name = "jdk-${version}_linux-x64_bin.tar.gz";
-        url =  "${downloadUrlBase}/jdk9-downloads-3848520.html";
-        sha256 = "18nsjn64wkfmyb09wf2k7lvhazf83cs3dyichr038vl1gs3ymi4h";
+        url =  "${downloadUrlBase}/jdk10-downloads-4416644.html";
+        sha256 = "1975s6cn2lxb8jmxp236afvq6hhxqrx5jix8aqm46f5gwr2xd3mf";
       }
     else if packageType == "JRE" then
       requireFile {
         name = "jre-${version}_linux-x64_bin.tar.gz";
-        url = "${downloadUrlBase}/jre9-downloads-3848532.html";
-        sha256 = "01fp079mr04nniyf06w8vd47qxr6rly1lbh8dqkddb8fp9h6a79k";
+        url = "${downloadUrlBase}/jre10-downloads-4417026.html";
+        sha256 = "11pb8cwzmalc6ax735m84g13jh1mrfc8g84b5qypnmqjjdv6fpiq";
       }
     else if packageType == "ServerJRE" then
       requireFile {
         name = "serverjre-${version}_linux-x64_bin.tar.gz";
-        url = "${downloadUrlBase}/server-jre9-downloads-3848530.html";
-        sha256 = "1jlpa4mn306hx0p9jcw3i6cpdvnng29dwjsymgcan56810q6p6yj";
+        url = "${downloadUrlBase}/sjre10-downloads-4417025.html";
+        sha256 = "0hvfqgr22sq9zyqc496vqgg5ail189h3a4pazp39i8n86brd48lw";
       }
     else abort "unknown package Type ${packageType}";
 
diff --git a/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix b/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix
index 5bafa70af9fc..bdd367ef3523 100644
--- a/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix
@@ -1,11 +1,11 @@
 import ./jdk-linux-base.nix {
   productVersion = "8";
-  patchVersion = "161";
+  patchVersion = "171";
   downloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html;
-  sha256.i686-linux = "1p6p93msn3bsg9775rq171kd4160w4w8z57p0qpjdjycfix62sfg";
-  sha256.x86_64-linux = "07h2wah80qr78y0f821z12lbdmsv90xbckdn3glnj2riwfh5dg3d";
-  sha256.armv7l-linux = "0mngw2lnhx3hzgp444advybhjn5hjk3mi14y72km4kp03gh82a7x";
-  sha256.aarch64-linux = "18l5fny7yxhpj5c935rnlq4pvwadyr5zkid6yh9x87frl401shy7";
+  sha256.i686-linux = "0dh5r02v40pinway952fflw2r0i1xi67hmyb87c278qfp4jn929p";
+  sha256.x86_64-linux = "10jr4z0bw9wcws5xgc4qkw101cadfx5bkyvcnc4l3v5axwvjipdn";
+  sha256.armv7l-linux = "1bqivmp1wfnypgg5bsfzi25yzl7vd2xncfap9mi8jn63aj633dw0";
+  sha256.aarch64-linux = "1016lf3g1syjsl29m58s2s2w9nkj4jkvxhqg4s35vy41cs2v77j7";
   jceName = "jce_policy-8.zip";
   jceDownloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html;
   sha256JCE = "0n8b6b8qmwb14lllk2lk1q1ahd3za9fnjigz5xn65mpg48whl0pk";
diff --git a/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix b/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix
index 78d5a6f2c40c..901eea0f8f15 100644
--- a/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix
@@ -1,11 +1,11 @@
 import ./jdk-linux-base.nix {
   productVersion = "8";
-  patchVersion = "162";
+  patchVersion = "172";
   downloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html;
-  sha256.i686-linux = "097vlvvj1vr7815rgarf5x97lagi4q0kai0x4lvd4y3wrzdqikzf";
-  sha256.x86_64-linux = "0mq2d0lj53gzn4qqdjdgbwl0h857k2rnsnr2hkmvihnrgza85v38";
-  sha256.armv7l-linux = "0xzsgdmpgs1n1g70hgly0mpxflhjrmq3vxwx8gl0kmqdiv4hqwjp";
-  sha256.aarch64-linux = "19ykcsmvkf7sdq2lqwvyi60nhb8v7f88dqjycimrsar9y4r7skf8";
+  sha256.i686-linux = "0csskx8xis0dr1948j76fgrwwsj4gzdbjqfi7if4v4j62b9i0hqa";
+  sha256.x86_64-linux = "0inkx73rwv7cvn9lqcr3hmnm0sr89h1fh29yamikb4dn02a0p818";
+  sha256.armv7l-linux = "1576cb0rlc42dsnmh388gy1wjas7ac6g135s8h74x8sm4b56qpln";
+  sha256.aarch64-linux = "0zpkmq8zxmpifawj611fg67srki63haz02rm6xwfc5qm2lxx5g6s";
   jceName = "jce_policy-8.zip";
   jceDownloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html;
   sha256JCE = "0n8b6b8qmwb14lllk2lk1q1ahd3za9fnjigz5xn65mpg48whl0pk";
diff --git a/pkgs/development/compilers/owl-lisp/default.nix b/pkgs/development/compilers/owl-lisp/default.nix
index 4e2f8b2af5b4..ee076acd8b17 100644
--- a/pkgs/development/compilers/owl-lisp/default.nix
+++ b/pkgs/development/compilers/owl-lisp/default.nix
@@ -1,16 +1,18 @@
-{ stdenv, fetchFromGitHub, coreutils }:
+{ stdenv, fetchFromGitHub, coreutils, which }:
 
 stdenv.mkDerivation rec {
   name    = "owl-lisp-${version}";
-  version = "0.1.14";
+  version = "0.1.15";
 
   src = fetchFromGitHub {
     owner  = "aoh";
     repo   = "owl-lisp";
     rev    = "v${version}";
-    sha256 = "1rr0icprna3zs834q1pj4xy21cql3pcfknfkqipq01rhnl2893sz";
+    sha256 = "0pczmra2x6icyz6b6g66pp5ij83cq4wszg0ssw8qm7a5314kxkq4";
   };
 
+  nativeBuildInputs = [ which ];
+
   prePatch = ''
     substituteInPlace Makefile --replace /usr $out
 
@@ -19,7 +21,7 @@ stdenv.mkDerivation rec {
     done
   '';
 
-  # tests are already run as part of the compilation process
+  # tests are run as part of the compilation process
   doCheck = false;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/compilers/polyml/default.nix b/pkgs/development/compilers/polyml/default.nix
index 390d37dd245f..de5b85055273 100644
--- a/pkgs/development/compilers/polyml/default.nix
+++ b/pkgs/development/compilers/polyml/default.nix
@@ -2,7 +2,7 @@
 
 stdenv.mkDerivation rec {
   name = "polyml-${version}";
-  version = "5.7";
+  version = "5.7.1";
 
   prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
     substituteInPlace configure.ac --replace stdc++ c++
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     owner = "polyml";
     repo = "polyml";
     rev = "v${version}";
-    sha256 = "10nsljmcl0zjbcc7ifc991ypwfwq5gh4rcp5rg4nnb706c6bs16y";
+    sha256 = "0j0wv3ijfrjkfngy7dswm4k1dchk3jak9chl5735dl8yrl8mq755";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/compilers/purescript/psc-package/default.nix b/pkgs/development/compilers/purescript/psc-package/default.nix
index 451722aea060..d94179e16fe9 100644
--- a/pkgs/development/compilers/purescript/psc-package/default.nix
+++ b/pkgs/development/compilers/purescript/psc-package/default.nix
@@ -4,13 +4,13 @@ with lib;
 
 mkDerivation rec {
   pname = "psc-package";
-  version = "0.2.5";
+  version = "0.3.2";
 
   src = fetchFromGitHub {
     owner = "purescript";
     repo = pname;
     rev = "v${version}";
-    sha256 = "15g0l8g8l6m5x4f73w68r9iav091x12b3wjxh0rx3ggnj093g6j1";
+    sha256 = "1zpzcyh82xl0grvgcj8b7yzh053i9z94kbym5qrv413pcx7w50cm";
   };
 
   isLibrary = false;
diff --git a/pkgs/development/compilers/rust/bootstrap.nix b/pkgs/development/compilers/rust/bootstrap.nix
index 9b488bab5b3b..44d96bc4ad1d 100644
--- a/pkgs/development/compilers/rust/bootstrap.nix
+++ b/pkgs/development/compilers/rust/bootstrap.nix
@@ -3,16 +3,16 @@
 let
   # Note: the version MUST be one version prior to the version we're
   # building
-  version = "1.23.0";
+  version = "1.24.1";
 
-  # fetch hashes by running `print-hashes.sh 1.23.0`
+  # fetch hashes by running `print-hashes.sh 1.24.1`
   hashes = {
-    i686-unknown-linux-gnu = "dc5bd0ef47e1036c8ca64676d8967102cb86ce4bf50b90a9845951c3e940423f";
-    x86_64-unknown-linux-gnu = "9a34b23a82d7f3c91637e10ceefb424539dcfa327c2dcd292ff10c047b1fdc7e";
-    armv7-unknown-linux-gnueabihf = "587027899267f1961520438c2c7f6775fe224160d43ddf07332b9b943a26b08e";
-    aarch64-unknown-linux-gnu = "38379fbd976d2286cb73f21466db40a636a583b9f8a80af5eea73617c7912bc7";
-    i686-apple-darwin = "4709eb1ad2fb871fdaee4b3449569cef366b0d170453cf17484a12286564f2ad";
-    x86_64-apple-darwin = "9274e977322bb4b153f092255ac9bd85041142c73eaabf900cb2ef3d3abb2eba";
+    i686-unknown-linux-gnu = "a483576bb2ab237aa1ef62b66c0814f934afd8129d7c9748cb9a75da4a678c98";
+    x86_64-unknown-linux-gnu = "4567e7f6e5e0be96e9a5a7f5149b5452828ab6a386099caca7931544f45d5327";
+    armv7-unknown-linux-gnueabihf = "1169ab005b771c4befcdab536347a90242cae544b6b76eccd0f76796b61a534c";
+    aarch64-unknown-linux-gnu = "64bb25a9689b18ddadf025b90d9bdb150b809ebfb74432dc69cc2e46120adbb2";
+    i686-apple-darwin = "c96f7579e2406220895da80a989daaa194751c141e112ebe95761f2ed4ecb662";
+    x86_64-apple-darwin = "9d4aacdb5849977ea619d399903c9378163bd9c76ea11dac5ef6eca27849f501";
   };
 
   platform =
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix
index dd15580c11b8..f191515b745c 100644
--- a/pkgs/development/compilers/rust/default.nix
+++ b/pkgs/development/compilers/rust/default.nix
@@ -6,11 +6,11 @@
 
 let
   rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}));
-  version = "1.24.0";
-  cargoVersion = "0.24.0";
+  version = "1.25.0";
+  cargoVersion = "0.26.0";
   src = fetchurl {
     url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
-    sha256 = "17v3jpyky8vkkgai5yd2zr8zl87qpgj6dx99gx27x1sf0kv7d0mv";
+    sha256 = "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf";
   };
 in rec {
   rustc = callPackage ./rustc.nix {
@@ -20,11 +20,15 @@ in rec {
 
     configureFlags = [ "--release-channel=stable" ];
 
+    # 1. Upstream is not running tests on aarch64:
+    # see https://github.com/rust-lang/rust/issues/49807#issuecomment-380860567
+    # So we do the same.
+    # 2. Tests run out of memory for i686
+    doCheck = !stdenv.isAarch64 && !stdenv.isi686;
+
     patches = [
       ./patches/0001-Disable-fragile-tests-libstd-net-tcp-on-Darwin-Linux.patch
-    ] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch
-      # https://github.com/rust-lang/rust/issues/45410
-      ++ stdenv.lib.optional stdenv.isAarch64 ./patches/aarch64-disable-test_loading_cosine.patch;
+    ] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
 
   };
 
diff --git a/pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch b/pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch
deleted file mode 100644
index bafab0e9ef71..000000000000
--- a/pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs
-index 1b42fa0..92256dc 100644
---- a/src/librustc_metadata/dynamic_lib.rs
-+++ b/src/librustc_metadata/dynamic_lib.rs
-@@ -80,6 +80,7 @@ mod tests {
-     use std::mem;
- 
-     #[test]
-+    #[ignore]
-     fn test_loading_cosine() {
-         if cfg!(windows) {
-             return
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index 92b149865fa2..19c4a590e454 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -1,5 +1,5 @@
 { stdenv, targetPackages
-, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
+, fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps
 , llvm, jemalloc, ncurses, darwin, rustPlatform, git, cmake, curl
 , which, libffi, gdb
 , version
@@ -19,8 +19,6 @@ let
   inherit (stdenv.lib) optional optionalString;
   inherit (darwin.apple_sdk.frameworks) Security;
 
-  procps = if stdenv.isDarwin then darwin.ps else args.procps;
-
   llvmShared = llvm.override { enableSharedLibraries = true; };
 
   target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
@@ -55,6 +53,7 @@ stdenv.mkDerivation {
   RUSTFLAGS = "-Ccodegen-units=10";
 
   # We need rust to build rust. If we don't provide it, configure will try to download it.
+  # Reference: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py
   configureFlags = configureFlags
                 ++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
                 ++ [ "--enable-vendor" ]
@@ -64,6 +63,13 @@ stdenv.mkDerivation {
                 ++ optional (targets != []) "--target=${target}"
                 ++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
 
+  # The boostrap.py will generated a Makefile that then executes the build.
+  # The BOOTSTRAP_ARGS used by this Makefile must include all flags to pass
+  # to the bootstrap builder.
+  postConfigure = ''
+    substituteInPlace Makefile --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)'
+  '';
+
   patches = patches ++ targetPatches;
 
   # the rust build system complains that nix alters the checksums
@@ -102,8 +108,7 @@ stdenv.mkDerivation {
 
     # Useful debugging parameter
     # export VERBOSE=1
-  ''
-  + optionalString stdenv.isDarwin ''
+  '' + optionalString stdenv.isDarwin ''
     # Disable all lldb tests.
     # error: Can't run LLDB test because LLDB's python path is not set
     rm -vr src/test/debuginfo/*
@@ -127,7 +132,7 @@ stdenv.mkDerivation {
 
   # ps is needed for one of the test cases
   nativeBuildInputs =
-    [ file python2 procps rustPlatform.rust.rustc git cmake
+    [ file python2 ps rustPlatform.rust.rustc git cmake
       which libffi
     ]
     # Only needed for the debuginfo tests
diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix
index 8006648a7dc3..261a2fb6432c 100644
--- a/pkgs/development/compilers/sbcl/default.nix
+++ b/pkgs/development/compilers/sbcl/default.nix
@@ -9,11 +9,11 @@
 
 stdenv.mkDerivation rec {
   name    = "sbcl-${version}";
-  version = "1.4.4";
+  version = "1.4.7";
 
   src = fetchurl {
     url    = "mirror://sourceforge/project/sbcl/sbcl/${version}/${name}-source.tar.bz2";
-    sha256 = "1k6v5b8qv7vyxvh8asx6phf2hbapx5pp5p5j47hgnq123fwnh4fa";
+    sha256 = "1wmxly94pn8527092hyzg5mq58mg7qlc46nm31f268wb2dm67rvm";
   };
 
   patchPhase = ''
diff --git a/pkgs/development/compilers/scala/default.nix b/pkgs/development/compilers/scala/default.nix
index 7622fbb9d18d..a25d4f6e6544 100644
--- a/pkgs/development/compilers/scala/default.nix
+++ b/pkgs/development/compilers/scala/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }:
 
 stdenv.mkDerivation rec {
-  name = "scala-2.12.4";
+  name = "scala-2.12.6";
 
   src = fetchurl {
     url = "http://www.scala-lang.org/files/archive/${name}.tgz";
-    sha256 = "089a54qj8psh4jxqbrrwk5zahw13fyqq24l87s3031xa675a0m4m";
+    sha256 = "05ili2959yrshqi44wpmwy0dyfm4kvp6i8mlbnj1xvc5b9649iqs";
   };
 
   propagatedBuildInputs = [ jre ] ;
diff --git a/pkgs/development/compilers/sdcc/default.nix b/pkgs/development/compilers/sdcc/default.nix
index 7383f39f6cbb..ec93ba79d44a 100644
--- a/pkgs/development/compilers/sdcc/default.nix
+++ b/pkgs/development/compilers/sdcc/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, bison, flex, boost, texinfo, gputils ? null }:
 
 stdenv.mkDerivation rec {
-  version = "3.6.0";
+  version = "3.7.0";
   name = "sdcc-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/sdcc/sdcc-src-${version}.tar.bz2";
-    sha256 = "0x53gh5yrrfjvlnkk29mjn8hq4v52alrsf7c8nsyzzq13sqwwpg8";
+    sha256 = "13llvx0j3v5qa7qd4fh7nix4j3alpd3ccprxvx163c4q8q4lfkc5";
   };
 
   # TODO: remove this comment when gputils != null is tested
diff --git a/pkgs/development/compilers/solc/default.nix b/pkgs/development/compilers/solc/default.nix
index 4c79fb15c5cb..d94ce75e3f55 100644
--- a/pkgs/development/compilers/solc/default.nix
+++ b/pkgs/development/compilers/solc/default.nix
@@ -1,7 +1,9 @@
-{ stdenv, fetchzip, fetchurl, boost, cmake, z3 }:
+{ stdenv, fetchzip, fetchFromGitHub, boost, cmake, z3 }:
 
 let
-  version = "0.4.20";
+  version = "0.4.23";
+  rev = "124ca40dc525a987a88176c6e5170978e82fa290";
+  sha256 = "07l8rfqh95yrdmbxc4pfb77s06k5v65dk3rgdqscqmwchkndrmm0";
   jsoncppURL = https://github.com/open-source-parsers/jsoncpp/archive/1.7.7.tar.gz;
   jsoncpp = fetchzip {
     url = jsoncppURL;
@@ -12,33 +14,45 @@ in
 stdenv.mkDerivation {
   name = "solc-${version}";
 
-  # Cannot use `fetchFromGitHub' because of submodules
-  src = fetchurl {
-    url = "https://github.com/ethereum/solidity/releases/download/v${version}/solidity_${version}.tar.gz";
-    sha256 = "0jyqnykj537ksfsf2m6ww9vganmpa6yd5fmlfpa5qm1076kq7zd6";
+  src = fetchFromGitHub {
+    owner = "ethereum";
+    repo = "solidity";
+    inherit rev sha256;
   };
 
-  patchPhase = ''
+  patches = [
+    ./patches/boost-shared-libs.patch
+    ./patches/shared-libs-install.patch
+  ];
+
+  postPatch = ''
+    touch prerelease.txt
+    echo >commit_hash.txt "${rev}"
     substituteInPlace cmake/jsoncpp.cmake \
-      --replace '${jsoncppURL}' ${jsoncpp}
+      --replace "${jsoncppURL}" ${jsoncpp}
     substituteInPlace cmake/EthCompilerSettings.cmake \
-      --replace 'add_compile_options(-Werror)' ""
+      --replace "add_compile_options(-Werror)" ""
   '';
 
   cmakeFlags = [
     "-DBoost_USE_STATIC_LIBS=OFF"
+    "-DBUILD_SHARED_LIBS=ON"
+    "-DINSTALL_LLLC=ON"
+    "-DTESTS=OFF"
   ];
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ boost z3 ];
 
-  meta = {
+  outputs = [ "out" "dev" ];
+
+  meta = with stdenv.lib; {
     description = "Compiler for Ethereum smart contract language Solidity";
     longDescription = "This package also includes `lllc', the LLL compiler.";
     homepage = https://github.com/ethereum/solidity;
-    license = stdenv.lib.licenses.gpl3;
-    platforms = with stdenv.lib.platforms; linux ++ darwin;
-    maintainers = [ stdenv.lib.maintainers.dbrock ];
+    license = licenses.gpl3;
+    platforms = with platforms; linux ++ darwin;
+    maintainers = with maintainers; [ dbrock akru ];
     inherit version;
   };
 }
diff --git a/pkgs/development/compilers/solc/patches/boost-shared-libs.patch b/pkgs/development/compilers/solc/patches/boost-shared-libs.patch
new file mode 100644
index 000000000000..499fc46c6caf
--- /dev/null
+++ b/pkgs/development/compilers/solc/patches/boost-shared-libs.patch
@@ -0,0 +1,24 @@
+diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt
+index 97b01c83..0bdec4b4 100644
+--- a/libsolidity/CMakeLists.txt
++++ b/libsolidity/CMakeLists.txt
+@@ -28,7 +28,7 @@ else()
+ endif()
+ 
+ add_library(solidity ${sources} ${headers})
+-target_link_libraries(solidity PUBLIC evmasm devcore)
++target_link_libraries(solidity PUBLIC evmasm devcore ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
+ 
+ if (${Z3_FOUND})
+   target_link_libraries(solidity PUBLIC ${Z3_LIBRARY})
+diff --git a/lllc/CMakeLists.txt b/lllc/CMakeLists.txt
+index 5c480093..d6538ee2 100644
+--- a/lllc/CMakeLists.txt
++++ b/lllc/CMakeLists.txt
+@@ -1,5 +1,5 @@
+ add_executable(lllc main.cpp)
+-target_link_libraries(lllc PRIVATE lll)
++target_link_libraries(lllc PRIVATE lll ${Boost_SYSTEM_LIBRARY})
+ 
+ if (INSTALL_LLLC)
+ 	include(GNUInstallDirs)
diff --git a/pkgs/development/compilers/solc/patches/shared-libs-install.patch b/pkgs/development/compilers/solc/patches/shared-libs-install.patch
new file mode 100644
index 000000000000..732797e5ae7d
--- /dev/null
+++ b/pkgs/development/compilers/solc/patches/shared-libs-install.patch
@@ -0,0 +1,64 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4ac56b43..dacf3853 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -48,6 +48,19 @@ add_subdirectory(libevmasm)
+ add_subdirectory(libsolidity)
+ add_subdirectory(libsolc)
+ 
++install(DIRECTORY libdevcore/
++        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libdevcore
++        FILES_MATCHING PATTERN "*.h")
++install(DIRECTORY libevmasm/
++        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libevmasm
++        FILES_MATCHING PATTERN "*.h")
++install(DIRECTORY libsolidity/
++        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libsolidity
++        FILES_MATCHING PATTERN "*.h")
++install(DIRECTORY liblll/
++        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/liblll
++        FILES_MATCHING PATTERN "*.h")
++
+ if (NOT EMSCRIPTEN)
+ 	add_subdirectory(solc)
+ 	add_subdirectory(liblll)
+diff --git a/libdevcore/CMakeLists.txt b/libdevcore/CMakeLists.txt
+index fa7e3f48..1f9f52b4 100644
+--- a/libdevcore/CMakeLists.txt
++++ b/libdevcore/CMakeLists.txt
+@@ -6,3 +6,4 @@ target_link_libraries(devcore PRIVATE jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Bo
+ target_include_directories(devcore PUBLIC "${CMAKE_SOURCE_DIR}")
+ target_include_directories(devcore SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
+ add_dependencies(devcore solidity_BuildInfo.h)
++install(TARGETS devcore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff --git a/libevmasm/CMakeLists.txt b/libevmasm/CMakeLists.txt
+index 86192c1b..e7f15e93 100644
+--- a/libevmasm/CMakeLists.txt
++++ b/libevmasm/CMakeLists.txt
+@@ -3,3 +3,4 @@ file(GLOB headers "*.h")
+ 
+ add_library(evmasm ${sources} ${headers})
+ target_link_libraries(evmasm PUBLIC jsoncpp devcore)
++install(TARGETS evmasm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff --git a/liblll/CMakeLists.txt b/liblll/CMakeLists.txt
+index 4cdc073a..b61f03c7 100644
+--- a/liblll/CMakeLists.txt
++++ b/liblll/CMakeLists.txt
+@@ -3,3 +3,4 @@ file(GLOB headers "*.h")
+ 
+ add_library(lll ${sources} ${headers})
+ target_link_libraries(lll PUBLIC evmasm devcore)
++install(TARGETS lll LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt
+index 97b01c83..e876177e 100644
+--- a/libsolidity/CMakeLists.txt
++++ b/libsolidity/CMakeLists.txt
+@@ -28,7 +28,8 @@ else()
+ endif()
+ 
+ add_library(solidity ${sources} ${headers})
+ target_link_libraries(solidity PUBLIC evmasm devcore ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
++install(TARGETS solidity LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ 
+ if (${Z3_FOUND})
+   target_link_libraries(solidity PUBLIC ${Z3_LIBRARY})
diff --git a/pkgs/development/compilers/souffle/default.nix b/pkgs/development/compilers/souffle/default.nix
index c56ea8cc6495..099a591b407d 100644
--- a/pkgs/development/compilers/souffle/default.nix
+++ b/pkgs/development/compilers/souffle/default.nix
@@ -1,25 +1,28 @@
-{ stdenv, fetchFromGitHub, autoconf, automake, boost, bison, flex, openjdk, doxygen, perl, graphviz }:
+{ stdenv, fetchFromGitHub
+, boost, bison, flex, openjdk, doxygen
+, perl, graphviz, libtool, ncurses, zlib, sqlite
+, autoreconfHook }:
 
 stdenv.mkDerivation rec {
-  version = "1.0.0";
+  version = "1.2.0";
   name    = "souffle-${version}";
 
   src = fetchFromGitHub {
     owner  = "souffle-lang";
     repo   = "souffle";
     rev    = version;
-    sha256 = "13j14227dgxcm25z9iizcav563wg2ak9338pb03aqqz8yqxbmz4n";
+    sha256 = "1g8yvm40h102mab8lacpl1cwgqsw1js0s1yn4l84l9fjdvlh2ygd";
   };
 
+  nativeBuildInputs = [ autoreconfHook bison flex ];
+
   buildInputs = [
-    autoconf automake boost bison flex openjdk
-    # Used for docs
-    doxygen perl graphviz
+    boost openjdk ncurses zlib sqlite doxygen perl graphviz
   ];
 
   patchPhase = ''
     substituteInPlace configure.ac \
-      --replace "m4_esyscmd([git describe --tags --abbrev=0 | tr -d '\n'])" "${version}"
+      --replace "m4_esyscmd([git describe --tags --abbrev=0 --always | tr -d '\n'])" "${version}"
   '';
 
   # Without this, we get an obscure error about not being able to find a library version
@@ -27,19 +30,11 @@ stdenv.mkDerivation rec {
   # for boost and failing there, so we tell it what's what here.
   configureFlags = [ "--with-boost-libdir=${boost}/lib" ];
 
-  preConfigure = "./bootstrap";
-
-  # in 1.0.0: parser.hh:40:0: error: unterminated #ifndef
-  enableParallelBuilding = false;
-
-  # See https://github.com/souffle-lang/souffle/issues/176
-  hardeningDisable = [ "fortify" ];
-
   meta = with stdenv.lib; {
     description = "A translator of declarative Datalog programs into the C++ language";
     homepage    = "http://souffle-lang.github.io/";
     platforms   = platforms.unix;
-    maintainers = with maintainers; [ copumpkin ];
+    maintainers = with maintainers; [ copumpkin wchresta ];
     license     = licenses.upl;
   };
 }
diff --git a/pkgs/development/compilers/swi-prolog/default.nix b/pkgs/development/compilers/swi-prolog/default.nix
index 0f84b8ba4cd8..670a00e250f2 100644
--- a/pkgs/development/compilers/swi-prolog/default.nix
+++ b/pkgs/development/compilers/swi-prolog/default.nix
@@ -1,20 +1,20 @@
-{ stdenv, fetchurl, gmp, readline, openssl, libjpeg, unixODBC, zlib
+{ stdenv, fetchurl, jdk, gmp, readline, openssl, libjpeg, unixODBC, zlib
 , libXinerama, libXft, libXpm, libSM, libXt, freetype, pkgconfig
 , fontconfig, makeWrapper ? stdenv.isDarwin
 }:
 
 let
-  version = "7.4.2";
+  version = "7.6.4";
 in
 stdenv.mkDerivation {
   name = "swi-prolog-${version}";
 
   src = fetchurl {
     url = "http://www.swi-prolog.org/download/stable/src/swipl-${version}.tar.gz";
-    sha256 = "12yzy3w2l1p9fv77lv20xbqq47d0zjw5rkz96mx1xg1lldyja5vz";
+    sha256 = "14bq4sqs61maqpnmgy6687jjj0shwc27cpfsqbf056nrssmplg9d";
   };
 
-  buildInputs = [ gmp readline openssl libjpeg unixODBC libXinerama
+  buildInputs = [ jdk gmp readline openssl libjpeg unixODBC libXinerama
     libXft libXpm libSM libXt zlib freetype pkgconfig fontconfig ]
   ++ stdenv.lib.optional stdenv.isDarwin makeWrapper;
 
diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix
index fc142a4026bd..abbfdd2abb72 100644
--- a/pkgs/development/compilers/swift/default.nix
+++ b/pkgs/development/compilers/swift/default.nix
@@ -37,7 +37,7 @@
 }:
 
 let
-  v_major = "4.0.3";
+  v_major = "4.1";
   version = "${v_major}-RELEASE";
   version_friendly = "${v_major}";
 
@@ -55,15 +55,15 @@ let
     # For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759
     clang = fetch {
       repo = "swift-clang";
-      sha256 = "0zm624iwiprk3c3nzqf4p1fd9zqic4yi3jv51cw3249ax4x6vy10";
+      sha256 = "0j8bi6jv4m4hqiib02q5cvnxd9j6bwiri853x6px86vai3mdff0h";
     };
     llvm = fetch {
       repo = "swift-llvm";
-      sha256 = "11vw6461c0cdvwm1wna1a5709fjj14hzp6br6jg94p4f6jp3yv4d";
+      sha256 = "03558f5zbchqvdabi3x9ahyz4xkmj7w69gazivz372832lgr9zfh";
     };
     compilerrt = fetch {
       repo = "swift-compiler-rt";
-      sha256 = "1hj4qaj4c9n2wzg2cvarbyl0n708zd1dlw4zkzq07fjxxqs36nfa";
+      sha256 = "1wkymmxi2v759xkwlzfrq9rivndjfvp6ikrzz10mvvrvyvrgwqnl";
     };
     cmark = fetch {
       repo = "swift-cmark";
@@ -71,32 +71,32 @@ let
     };
     lldb = fetch {
       repo = "swift-lldb";
-      sha256 = "0yk5qg85008vcn63vn2jpn5ls9pdhda222p2w1cfkrj27k5k8vqr";
+      sha256 = "09x3d3bc6rn9g6jpi3fb120c4r2carsmqla4bq4scjrs0867jz9m";
     };
     llbuild = fetch {
       repo = "swift-llbuild";
-      sha256 = "0jffw6z1s6ck1i05brw59x6vsg7zrxbz5n2wz72fj29rh3nppc7a";
+      sha256 = "04y0ihfyam2n671vmpk9gy0gb9lb3ivh6mr19862p5kg5bmrcic1";
     };
     pm = fetch {
       repo = "swift-package-manager";
-      sha256 = "0xj070b8fii7ijfsnyq4fxgv6569vdrg0yippi85h2p1l7s9aagh";
+      sha256 = "08d87fc29qq7m92jaxkiczsa7b567pwbibiwwkzdrj6a0gr11qn3";
     };
     xctest = fetch {
       repo = "swift-corelibs-xctest";
-      sha256 = "0l355wq8zfwrpv044xf4smjwbm0bmib360748n8cwls3vkr9l2yv";
+      sha256 = "1alkgxx8jsr2jjv2kchnjaaddb1byjwim015m1z3qxh6lknqm0k5";
     };
     foundation = fetch {
       repo = "swift-corelibs-foundation";
-      sha256 = "0s7yc5gsbd96a4bs8c6q24dyfjm4xhcr2nzhl2ics8dmi60j15s4";
+      sha256 = "06pbhb7wg4q5qgprhiyzbqy6hssga7xxjclhlh81gd6rvfd6bxvw";
     };
     libdispatch = fetch {
       repo = "swift-corelibs-libdispatch";
-      sha256 = "0x8zzq3shhvmhq4sbhaaa0ddiv3nw347pz6ayym6jyzq7j9n15ia";
+      sha256 = "198vskbajch8s168a649qz5an92i2mxmmmzcjlgxlzh38fgxri0n";
       fetchSubmodules = true;
     };
     swift = fetch {
       repo = "swift";
-      sha256 = "0a1gq0k5701i418f0qi7kywv16q7vh4a4wp0f6fpyv4sjkq27msx";
+      sha256 = "1flvr12bg8m4k44yq0xy9qrllv5rpxgxisjgbpakk5p3myfsx7ky";
     };
   };
 
@@ -132,19 +132,6 @@ let
       install_destdir=$SWIFT_INSTALL_DIR \
       extra_cmake_options="${stdenv.lib.concatStringsSep "," cmakeFlags}"'';
 
-  # from llvm/4/llvm.nix
-  sigaltstackPatch = fetchpatch {
-    name = "sigaltstack.patch"; # for glibc-2.26
-    url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
-    sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
-  };
-
-  # https://bugs.swift.org/browse/SR-6409
-  sigunusedPatch = fetchpatch {
-    name = "sigunused.patch";
-    url = "https://github.com/apple/swift-llbuild/commit/303a89bc6da606c115560921a452686aa0655f5e.diff";
-    sha256 = "04sw7ym1grzggj1v3xrzr2ljxz8rf9rnn9n5fg1xjbwlrdagkc7m";
-  };
 in
 stdenv.mkDerivation rec {
   name = "swift-${version_friendly}";
@@ -179,7 +166,7 @@ stdenv.mkDerivation rec {
 
   configurePhase = ''
     cd ..
-    
+
     export INSTALLABLE_PACKAGE=$PWD/swift.tar.gz
 
     mkdir build install
@@ -236,20 +223,18 @@ stdenv.mkDerivation rec {
   '' + ''
     patch -p1 -d swift -i ${./patches/0001-build-presets-linux-don-t-require-using-Ninja.patch}
     patch -p1 -d swift -i ${./patches/0002-build-presets-linux-allow-custom-install-prefix.patch}
-    patch -p1 -d swift -i ${./patches/0003-build-presets-linux-disable-tests.patch}
     patch -p1 -d swift -i ${./patches/0004-build-presets-linux-plumb-extra-cmake-options.patch}
-    # https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
-    patch -p1 -i ${./patches/remove_xlocale.patch}
-    # https://bugs.swift.org/browse/SR-4633
-    patch -p1 -d swift -i ${./patches/icu59.patch}
+
+    sed -i swift/utils/build-presets.ini \
+      -e 's/^test-installable-package$/# \0/' \
+      -e 's/^test$/# \0/' \
+      -e 's/^validation-test$/# \0/' \
+      -e 's/^long-test$/# \0/'
 
     # https://bugs.swift.org/browse/SR-5779
     sed -i -e 's|"-latomic"|"-Wl,-rpath,${clang.cc.gcc.lib}/lib" "-L${clang.cc.gcc.lib}/lib" "-latomic"|' swift/cmake/modules/AddSwift.cmake
 
-    # https://bugs.swift.org/browse/SR-4838
-    sed -i -e '30i#include <functional>' lldb/include/lldb/Utility/TaskPool.h
-
-    substituteInPlace clang/lib/Driver/ToolChains.cpp \
+    substituteInPlace clang/lib/Driver/ToolChains/Linux.cpp \
       --replace '  addPathIfExists(D, SysRoot + "/usr/lib", Paths);' \
                 '  addPathIfExists(D, SysRoot + "/usr/lib", Paths); addPathIfExists(D, "${glibc}/lib", Paths);'
     patch -p1 -d clang -i ${./purity.patch}
@@ -258,19 +243,15 @@ stdenv.mkDerivation rec {
     sed -i 's,curses,ncurses,' llbuild/*/*/CMakeLists.txt
 
     # This test fails on one of my machines, not sure why.
-    # Disabling for now. 
+    # Disabling for now.
     rm llbuild/tests/Examples/buildsystem-capi.llbuild
 
     PREFIX=''${out/#\/}
     substituteInPlace swift-corelibs-xctest/build_script.py \
       --replace usr "$PREFIX"
     substituteInPlace swiftpm/Utilities/bootstrap \
-      --replace "usr" "$PREFIX"
-  '' + stdenv.lib.optionalString (stdenv ? glibc) ''
-    patch -p1 -d compiler-rt -i ${sigaltstackPatch}
-    patch -p1 -d compiler-rt -i ${./patches/sigaltstack.patch}
-    patch -p1 -d llbuild -i ${sigunusedPatch}
-    patch -p1 -i ${./patches/sigunused.patch}
+      --replace \"usr\" \"$PREFIX\" \
+      --replace usr/lib "$PREFIX/lib"
   '';
 
   doCheck = false;
@@ -305,7 +286,8 @@ stdenv.mkDerivation rec {
     maintainers = with maintainers; [ dtzWill ];
     license = licenses.asl20;
     # Swift doesn't support 32bit Linux, unknown on other platforms.
-    platforms = [ "x86_64-linux" ];
+    platforms = platforms.linux;
+    badPlatforms = platforms.i686;
   };
 }
 
diff --git a/pkgs/development/compilers/swift/patches/0003-build-presets-linux-disable-tests.patch b/pkgs/development/compilers/swift/patches/0003-build-presets-linux-disable-tests.patch
deleted file mode 100644
index f647d9189dd2..000000000000
--- a/pkgs/development/compilers/swift/patches/0003-build-presets-linux-disable-tests.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From fcc7c216da6cd255f884b7aa39f361786e3afa6a Mon Sep 17 00:00:00 2001
-From: Will Dietz <w@wdtz.org>
-Date: Tue, 28 Mar 2017 15:02:18 -0500
-Subject: [PATCH 3/4] build-presets: (linux) disable tests.
-
----
- utils/build-presets.ini | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/utils/build-presets.ini b/utils/build-presets.ini
-index 1095cbaab7..1739e91dc2 100644
---- a/utils/build-presets.ini
-+++ b/utils/build-presets.ini
-@@ -700,7 +700,7 @@ build-swift-stdlib-unittest-extra
- 
- # Executes the lit tests for the installable package that is created
- # Assumes the swift-integration-tests repo is checked out
--test-installable-package
-+# test-installable-package
- 
- # Path to the root of the installation filesystem.
- install-destdir=%(install_destdir)s
-@@ -713,9 +713,9 @@ mixin-preset=mixin_linux_installation
- build-subdir=buildbot_linux
- lldb
- release
--test
--validation-test
--long-test
-+#test
-+#validation-test
-+#long-test
- foundation
- libdispatch
- lit-args=-v
--- 
-2.12.2
-
diff --git a/pkgs/development/compilers/swift/patches/icu59.patch b/pkgs/development/compilers/swift/patches/icu59.patch
deleted file mode 100644
index 26337814cafa..000000000000
--- a/pkgs/development/compilers/swift/patches/icu59.patch
+++ /dev/null
@@ -1,113 +0,0 @@
---- a/stdlib/public/stubs/UnicodeNormalization.cpp
-+++ b/stdlib/public/stubs/UnicodeNormalization.cpp
-@@ -86,11 +86,8 @@ ASCIICollation() {
-     for (unsigned char c = 0; c < 128; ++c) {
-       UErrorCode ErrorCode = U_ZERO_ERROR;
-       intptr_t NumCollationElts = 0;
--#if defined(__CYGWIN__) || defined(_MSC_VER)
-       UChar Buffer[1];
--#else
--      uint16_t Buffer[1];
--#endif
-+
-       Buffer[0] = c;
- 
-       UCollationElements *CollationIterator =
-@@ -127,18 +124,9 @@ swift::_swift_stdlib_unicode_compare_utf16_utf16(const uint16_t *LeftString,
-                                                  int32_t LeftLength,
-                                                  const uint16_t *RightString,
-                                                  int32_t RightLength) {
--#if defined(__CYGWIN__) || defined(_MSC_VER)
--  // ICU UChar type is platform dependent. In Cygwin, it is defined
--  // as wchar_t which size is 2. It seems that the underlying binary
--  // representation is same with swift utf16 representation.
-   return ucol_strcoll(GetRootCollator(),
-     reinterpret_cast<const UChar *>(LeftString), LeftLength,
-     reinterpret_cast<const UChar *>(RightString), RightLength);
--#else
--  return ucol_strcoll(GetRootCollator(),
--    LeftString, LeftLength,
--    RightString, RightLength);
--#endif
- }
- 
- /// Compares the strings via the Unicode Collation Algorithm on the root locale.
-@@ -156,12 +144,8 @@ swift::_swift_stdlib_unicode_compare_utf8_utf16(const unsigned char *LeftString,
-   UErrorCode ErrorCode = U_ZERO_ERROR;
- 
-   uiter_setUTF8(&LeftIterator, reinterpret_cast<const char *>(LeftString), LeftLength);
--#if defined(__CYGWIN__) || defined(_MSC_VER)
-   uiter_setString(&RightIterator, reinterpret_cast<const UChar *>(RightString),
-                   RightLength);
--#else
--  uiter_setString(&RightIterator, RightString, RightLength);
--#endif
- 
-   uint32_t Diff = ucol_strcollIter(GetRootCollator(),
-     &LeftIterator, &RightIterator, &ErrorCode);
-@@ -199,14 +183,10 @@ swift::_swift_stdlib_unicode_compare_utf8_utf8(const unsigned char *LeftString,
- void *swift::_swift_stdlib_unicodeCollationIterator_create(
-     const __swift_uint16_t *Str, __swift_uint32_t Length) {
-   UErrorCode ErrorCode = U_ZERO_ERROR;
--#if defined(__CYGWIN__) || defined(_MSC_VER)
-   UCollationElements *CollationIterator = ucol_openElements(
-     GetRootCollator(), reinterpret_cast<const UChar *>(Str), Length,
-     &ErrorCode);
--#else
--  UCollationElements *CollationIterator = ucol_openElements(
--    GetRootCollator(), Str, Length, &ErrorCode);
--#endif
-+
-   if (U_FAILURE(ErrorCode)) {
-     swift::crash("_swift_stdlib_unicodeCollationIterator_create: ucol_openElements() failed.");
-   }
-@@ -244,17 +224,12 @@ swift::_swift_stdlib_unicode_strToUpper(uint16_t *Destination,
-                                         const uint16_t *Source,
-                                         int32_t SourceLength) {
-   UErrorCode ErrorCode = U_ZERO_ERROR;
--#if defined(__CYGWIN__) || defined(_MSC_VER)
-   uint32_t OutputLength = u_strToUpper(reinterpret_cast<UChar *>(Destination),
-                                        DestinationCapacity,
-                                        reinterpret_cast<const UChar *>(Source),
-                                        SourceLength,
-                                        "", &ErrorCode);
--#else
--  uint32_t OutputLength = u_strToUpper(Destination, DestinationCapacity,
--                                       Source, SourceLength,
--                                       "", &ErrorCode);
--#endif
-+
-   if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
-     swift::crash("u_strToUpper: Unexpected error uppercasing unicode string.");
-   }
-@@ -271,17 +246,12 @@ swift::_swift_stdlib_unicode_strToLower(uint16_t *Destination,
-                                         const uint16_t *Source,
-                                         int32_t SourceLength) {
-   UErrorCode ErrorCode = U_ZERO_ERROR;
--#if defined(__CYGWIN__) || defined(_MSC_VER)
-   uint32_t OutputLength = u_strToLower(reinterpret_cast<UChar *>(Destination),
-                                        DestinationCapacity,
-                                        reinterpret_cast<const UChar *>(Source),
-                                        SourceLength,
-                                        "", &ErrorCode);
--#else
--  uint32_t OutputLength = u_strToLower(Destination, DestinationCapacity,
--                                       Source, SourceLength,
--                                       "", &ErrorCode);
--#endif
-+
-   if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
-     swift::crash("u_strToLower: Unexpected error lowercasing unicode string.");
-   }
-@@ -300,9 +300,9 @@
- 
- swift::__swift_stdlib_UBreakIterator *swift::__swift_stdlib_ubrk_open(
-     swift::__swift_stdlib_UBreakIteratorType type, const char *locale,
--    const UChar *text, int32_t textLength, __swift_stdlib_UErrorCode *status) {
-+    const __swift_stdlib_UChar * text, __swift_int32_t textLength, __swift_stdlib_UErrorCode *status) {
-   return ptr_cast<swift::__swift_stdlib_UBreakIterator>(
--      ubrk_open(static_cast<UBreakIteratorType>(type), locale, text, textLength,
-+      ubrk_open(static_cast<UBreakIteratorType>(type), locale, reinterpret_cast<const UChar *>(text), textLength,
-                 ptr_cast<UErrorCode>(status)));
- }
- 
diff --git a/pkgs/development/compilers/swift/patches/remove_xlocale.patch b/pkgs/development/compilers/swift/patches/remove_xlocale.patch
deleted file mode 100644
index 8ef7e3916962..000000000000
--- a/pkgs/development/compilers/swift/patches/remove_xlocale.patch
+++ /dev/null
@@ -1,54 +0,0 @@
---- a/swift/stdlib/public/SDK/os/os_trace_blob.c
-+++ b/swift/stdlib/public/SDK/os/os_trace_blob.c
-@@ -14,7 +14,6 @@
- #include <dispatch/dispatch.h>
- #include <os/base.h>
- #include <os/log.h>
--#include <xlocale.h>
- #include "os_trace_blob.h"
- 
- OS_NOINLINE
-
---- a/swift/stdlib/public/stubs/Stubs.cpp
-+++ b/swift/stdlib/public/stubs/Stubs.cpp
-@@ -61,7 +61,6 @@
- #define strtof_l swift_strtof_l
- #define strtold_l swift_strtold_l
- #else
--#include <xlocale.h>
- #endif
- #include <limits>
- #include "llvm/ADT/StringExtras.h"
-
---- a/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringDefaultEncoding.h
-+++ b/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringDefaultEncoding.h
-@@ -20,7 +20,6 @@
- #include <unistd.h>
- #include <string.h>
- #include <stdio.h>
--#include <xlocale.h>
- 
- CF_EXTERN_C_BEGIN
- 
-
---- a/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringEncodings.c
-+++ b/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringEncodings.c
-@@ -24,7 +24,6 @@
- #include <unistd.h>
- #include <string.h>
- #include <stdio.h>
--#include <xlocale.h>
- #include <CoreFoundation/CFStringDefaultEncoding.h>
- #endif
- 
-
---- a/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFInternal.h
-+++ b/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFInternal.h
-@@ -95,7 +95,6 @@
- #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
- #if TARGET_OS_CYGWIN
- #else
--#include <xlocale.h>
- #endif
- #include <unistd.h>
- #include <sys/time.h>
diff --git a/pkgs/development/compilers/swift/patches/sigaltstack.patch b/pkgs/development/compilers/swift/patches/sigaltstack.patch
deleted file mode 100644
index c529fa3777b3..000000000000
--- a/pkgs/development/compilers/swift/patches/sigaltstack.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/lib/esan/esan_sideline_linux.cpp
-+++ b/lib/esan/esan_sideline_linux.cpp
-@@ -70,7 +70,7 @@ int SidelineThread::runSideline(void *Arg) {
- 
-   // Set up a signal handler on an alternate stack for safety.
-   InternalScopedBuffer<char> StackMap(SigAltStackSize);
--  struct sigaltstack SigAltStack;
-+  stack_t SigAltStack;
-   SigAltStack.ss_sp = StackMap.data();
-   SigAltStack.ss_size = SigAltStackSize;
-   SigAltStack.ss_flags = 0;
diff --git a/pkgs/development/compilers/swift/patches/sigunused.patch b/pkgs/development/compilers/swift/patches/sigunused.patch
deleted file mode 100644
index 2701d1a3ae25..000000000000
--- a/pkgs/development/compilers/swift/patches/sigunused.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/swiftpm/Sources/Basic/Process.swift
-+++ b/swiftpm/Sources/Basic/Process.swift
-@@ -258,7 +258,7 @@ public func launch() throws {
-         // modify, so we have to take care about the set we use.
-         var mostSignals = sigset_t()
-         sigemptyset(&mostSignals)
--        for i in 1 ..< SIGUNUSED {
-+        for i in 1 ..< SIGSYS {
-             if i == SIGKILL || i == SIGSTOP {
-                 continue
-             }
diff --git a/pkgs/development/compilers/swift/purity.patch b/pkgs/development/compilers/swift/purity.patch
index f5fb4c73af47..b30d0d0b5d5b 100644
--- a/pkgs/development/compilers/swift/purity.patch
+++ b/pkgs/development/compilers/swift/purity.patch
@@ -1,6 +1,17 @@
---- a/lib/Driver/Tools.cpp	2016-08-25 15:48:05.187553443 +0200
-+++ b/lib/Driver/Tools.cpp	2016-08-25 15:48:47.534468882 +0200
-@@ -9420,13 +9420,6 @@
+From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Thu, 18 May 2017 11:56:12 -0500
+Subject: [PATCH] "purity" patch for 5.0
+
+---
+ lib/Driver/ToolChains/Gnu.cpp | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
+index fe3c0191bb..c6a482bece 100644
+--- a/lib/Driver/ToolChains/Gnu.cpp
++++ b/lib/Driver/ToolChains/Gnu.cpp
+@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
    if (!Args.hasArg(options::OPT_static)) {
      if (Args.hasArg(options::OPT_rdynamic))
        CmdArgs.push_back("-export-dynamic");
@@ -14,3 +25,6 @@
    }
  
    CmdArgs.push_back("-o");
+-- 
+2.11.0
+
diff --git a/pkgs/development/compilers/teyjus/default.nix b/pkgs/development/compilers/teyjus/default.nix
index 222a22bf1cd9..04efe1a91342 100644
--- a/pkgs/development/compilers/teyjus/default.nix
+++ b/pkgs/development/compilers/teyjus/default.nix
@@ -1,11 +1,15 @@
 { stdenv, fetchurl, omake, ocaml, flex, bison }:
 
+let
+  version = "2.1";
+in
+
 stdenv.mkDerivation {
-  name = "teyjus-2.0b2";
+  name = "teyjus-${version}";
 
   src = fetchurl {
-    url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/teyjus/teyjus-source-2.0-b2.tar.gz";
-    sha256 = "f589fb460d7095a6e674b7a6413772c41b98654c38602c3e8c477a976da99052";
+    url = "https://github.com/teyjus/teyjus/archive/v${version}.tar.gz";
+    sha256 = "0393wpg8v1vvarqy2xh4fdmrwlrl6jaj960kql7cq79mb9p3m269";
   };
 
   patches = [ ./fix-lex-to-flex.patch ];
diff --git a/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch b/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch
index d2da1d3facca..fa82d80633ad 100644
--- a/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch
+++ b/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch
@@ -1,9 +1,9 @@
 diff --git a/source/OMakefile b/source/OMakefile
-index 6b19d84..095b8b6 100644
+index e6bd37e..1bbc0a8 100644
 --- a/source/OMakefile
 +++ b/source/OMakefile
-@@ -164,12 +164,17 @@ LNK_MAIN = $(FNT)/linkerfront
- DEP_MAIN = $(FNT)/dependfront

+@@ -184,6 +184,12 @@ DEP_MAIN = $(FNT)/dependfront
+ PAR_MAIN = $(FNT)/parsefront

  

  ############################################################

 +# Nixpkgs specific changes

@@ -15,9 +15,11 @@ index 6b19d84..095b8b6 100644
  # Platform specific changes

  #

  

+@@ -194,7 +200,6 @@ if $(mem $(SYSNAME), Linux)
+ 

  if $(mem $(OSTYPE), Cygwin Win32)

      YACC = bison -by

 -    LEX = flex

-     CFLAGS += -mno-cygwin

+     CC = i686-pc-mingw32-gcc

      INC_C[] += $(INC)/byteswap $(INC)/search

      export

diff --git a/pkgs/development/compilers/vala/default.nix b/pkgs/development/compilers/vala/default.nix
index f42cdcabae3f..f36bea42e2a8 100644
--- a/pkgs/development/compilers/vala/default.nix
+++ b/pkgs/development/compilers/vala/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, flex, bison, libxslt, autoconf, graphviz
-, glib, libiconv, libintlOrEmpty, libtool, expat
+, glib, libiconv, libintl, libtool, expat
 }:
 
 let
@@ -16,14 +16,14 @@ let
 
     nativeBuildInputs = [ pkgconfig flex bison libxslt ] ++ extraNativeBuildInputs;
 
-    buildInputs = [ glib libiconv ] ++ libintlOrEmpty ++ extraBuildInputs;
+    buildInputs = [ glib libiconv libintl ] ++ extraBuildInputs;
 
     meta = with stdenv.lib; {
       description = "Compiler for GObject type system";
-      homepage = http://live.gnome.org/Vala;
+      homepage = https://wiki.gnome.org/Projects/Vala;
       license = licenses.lgpl21Plus;
       platforms = platforms.unix;
-      maintainers = with maintainers; [ antono lethalman peterhoeg ];
+      maintainers = with maintainers; [ antono jtojnar lethalman peterhoeg ];
     };
   };
 
@@ -55,14 +55,14 @@ in rec {
 
   vala_0_34 = generic {
     major   = "0.34";
-    minor   = "13";
-    sha256  = "0ahbnhgwhhjkndmbr1d039ws0g2bb324c60fk6wgx7py5wvmgcd2";
+    minor   = "17";
+    sha256  = "0wd2zxww4z1ys4iqz218lvzjqjjqwsaad4x2by8pcyy43sbr7qp2";
   };
 
   vala_0_36 = generic {
     major   = "0.36";
-    minor   = "8";
-    sha256  = "1nz5a8kcb22ss9idb7k1higwpvghd617xwf40fi0a9ggws614lfz";
+    minor   = "12";
+    sha256  = "1nvw721piwdh15bipg0sdll9kvgpz0y9i5fpszlc7y9w64yis25l";
   };
 
   vala_0_38 = generic {
@@ -73,5 +73,13 @@ in rec {
     extraBuildInputs = [ graphviz ];
   };
 
+  vala_0_40 = generic {
+    major   = "0.40";
+    minor   = "0";
+    sha256  = "0wcfljl55a9qvslfcc4sf76wdpwgn83n96b7fgb7r49ib35qz20m";
+    extraNativeBuildInputs = stdenv.lib.optionals stdenv.isDarwin [ expat ];
+    extraBuildInputs = [ graphviz ];
+  };
+
   vala = vala_0_38;
 }
diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix
index 063fd71c0433..4bd5640c854c 100644
--- a/pkgs/development/compilers/yosys/default.nix
+++ b/pkgs/development/compilers/yosys/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchFromBitbucket
+{ stdenv, fetchFromGitHub
 , pkgconfig, tcl, readline, libffi, python3, bison, flex
 }:
 
@@ -6,25 +6,25 @@ with builtins;
 
 stdenv.mkDerivation rec {
   name = "yosys-${version}";
-  version = "2018.02.14";
+  version = "2018.05.03";
 
   srcs = [
     (fetchFromGitHub {
       owner  = "yosyshq";
       repo   = "yosys";
-      rev    = "c1abd3b02cab235334342f3520e2535eb74c5792";
-      sha256 = "0pzrplv4p0qzy115rg19lxv4w274iby337zfd7hhlinnpx3gzqvw";
+      rev    = "a572b495387743a58111e7264917a497faa17ebf";
+      sha256 = "0q4xh4sy3n83c8il8lygzv0i6ca4qw36i2k6qz6giw0wd2pkibkb";
       name   = "yosys";
     })
 
     # NOTE: the version of abc used here is synchronized with
     # the one in the yosys Makefile of the version above;
     # keep them the same for quality purposes.
-    (fetchFromBitbucket {
-      owner  = "alanmi";
+    (fetchFromGitHub {
+      owner  = "berkeley-abc";
       repo   = "abc";
-      rev    = "6e3c24b3308a";
-      sha256 = "1i4wv0si4fb6dpv2yrpkp588mdlfrnx2s02q2fgra5apdm54c53w";
+      rev    = "f23ea8e33f6d5cc54f58bec6d9200483e5d8c704";
+      sha256 = "1xwmq3k5hfavdrs7zbqjxh35kr2pis4i6hhzrq7qzyzs0az0hls9";
       name   = "yosys-abc";
     })
   ];
@@ -35,14 +35,18 @@ stdenv.mkDerivation rec {
   buildInputs = [ tcl readline libffi python3 bison flex ];
 
   patchPhase = ''
+    substituteInPlace ../yosys-abc/Makefile \
+      --replace 'CC   := gcc' ""
     substituteInPlace ./Makefile \
+      --replace 'CXX = clang' "" \
+      --replace 'ABCMKARGS = CC="$(CXX)"' 'ABCMKARGS =' \
       --replace 'echo UNKNOWN' 'echo ${substring 0 10 (elemAt srcs 0).rev}'
   '';
 
   preBuild = ''
     chmod -R u+w ../yosys-abc
     ln -s ../yosys-abc abc
-    make config-gcc
+    make config-${if stdenv.cc.isClang or false then "clang" else "gcc"}
     echo 'ABCREV := default' >> Makefile.conf
     makeFlags="PREFIX=$out $makeFlags"
   '';
@@ -61,6 +65,6 @@ stdenv.mkDerivation rec {
     homepage    = http://www.clifford.at/yosys/;
     license     = stdenv.lib.licenses.isc;
     maintainers = with stdenv.lib.maintainers; [ shell thoughtpolice ];
-    platforms   = stdenv.lib.platforms.linux;
+    platforms   = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/zig/default.nix b/pkgs/development/compilers/zig/default.nix
index cffc683f9e7b..44d1f7bfe4a2 100644
--- a/pkgs/development/compilers/zig/default.nix
+++ b/pkgs/development/compilers/zig/default.nix
@@ -1,17 +1,18 @@
-{ stdenv, fetchFromGitHub, cmake, llvmPackages }:
+{ stdenv, fetchFromGitHub, cmake, llvmPackages, libxml2 }:
 
 stdenv.mkDerivation rec {
-  version = "0.1.1";
+  version = "0.2.0";
   name = "zig-${version}";
 
   src = fetchFromGitHub {
     owner = "zig-lang";
     repo = "zig";
     rev = "${version}";
-    sha256 = "01yqjyi25f99bfmxxwyh45k7j84z0zg7n9jl8gg0draf96mzdh06";
+    sha256 = "0lym28z9mj6hfiq78x1fsd8y89h8xyfc1jgqyazi1g9r72427n07";
   };
 
-  buildInputs = [ cmake llvmPackages.clang-unwrapped llvmPackages.llvm ];
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ llvmPackages.clang-unwrapped llvmPackages.llvm libxml2 ];
 
   cmakeFlags = [
     "-DZIG_LIBC_INCLUDE_DIR=${stdenv.cc.libc_dev}/include"
@@ -26,7 +27,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Programming languaged designed for robustness, optimality, and clarity";
-    homepage = http://ziglang.org/;
+    homepage = https://ziglang.org/;
     license = licenses.mit;
     platforms = platforms.unix;
     maintainers = [ maintainers.andrewrk ];
diff --git a/pkgs/development/compilers/zulu/8.nix b/pkgs/development/compilers/zulu/8.nix
index 23ae8ba06bb5..fb1798ab819c 100644
--- a/pkgs/development/compilers/zulu/8.nix
+++ b/pkgs/development/compilers/zulu/8.nix
@@ -4,11 +4,11 @@
 , swingSupport ? true }:
 
 let
-  version = "8.21.0.1";
-  openjdk = "8.0.131";
+  version = "8.28.0.1";
+  openjdk = "8.0.163";
 
-  sha256_linux = "0cr1wvk1ifdq69ia8sr6171yzciba8l5x7dszwa5g2v0vmmqq88p";
-  sha256_darwin = "0xq9bdzbdq8wq48gj6j56bw30l2iafz6sy1wdhrf92n9bnz5qmw7";
+  sha256_linux = "1z8s3a948nvv92wybnhkyr27ipibcy45k0zv5h5gp37ynd91df45";
+  sha256_darwin = "0i0prjijsgg0yyycplpp9rlfl428126rqz7bb31pchrhi6jhk699";
 
   platform = if stdenv.isDarwin then "macosx" else "linux";
   hash = if stdenv.isDarwin then sha256_darwin else sha256_linux;
diff --git a/pkgs/development/compilers/zulu/default.nix b/pkgs/development/compilers/zulu/default.nix
index 040af83ece20..908aa29e178f 100644
--- a/pkgs/development/compilers/zulu/default.nix
+++ b/pkgs/development/compilers/zulu/default.nix
@@ -4,11 +4,11 @@
 , swingSupport ? true }:
 
 let
-  version = "9.0.0.15";
-  openjdk = "9.0.0";
+  version = "10.1+11";
+  openjdk = "10";
 
-  sha256_linux = "0s9vr135yhdnxqds4hfafyrlh33j6g78v6l1v0ap2y6yqgabh9qi";
-  sha256_darwin = "104w1msrwijf8dv3n65hjinp7i47z6ygzjipdzqriqam2zljxn4b";
+  sha256_linux = "0g51n2zc7inal29n5ly3mrrfj15c7vl87zb6b2r1q67n4mnbrgm8";
+  sha256_darwin = "1c5ib136nv6gz7ij31mg15nhzrl6zr7kp8spm17zwm1ib82bc73y";
 
   platform = if stdenv.isDarwin then "macosx" else "linux";
   hash = if stdenv.isDarwin then sha256_darwin else sha256_linux;