summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/arachne-pnr/default.nix16
-rw-r--r--pkgs/development/compilers/binaryen/default.nix4
-rw-r--r--pkgs/development/compilers/chez/default.nix45
-rw-r--r--pkgs/development/compilers/compcert/default.nix9
-rw-r--r--pkgs/development/compilers/dmd/default.nix8
-rw-r--r--pkgs/development/compilers/gambit/default.nix11
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/5/default.nix24
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix21
-rw-r--r--pkgs/development/compilers/gcc/6/fix-objdump-check.patch43
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix37
-rw-r--r--pkgs/development/compilers/gerbil/default.nix34
-rw-r--r--pkgs/development/compilers/ghc/8.2.2.nix10
-rw-r--r--pkgs/development/compilers/ghc/8.4.1.nix18
-rw-r--r--pkgs/development/compilers/go/1.6.nix168
-rw-r--r--pkgs/development/compilers/go/1.7.nix168
-rw-r--r--pkgs/development/compilers/go/1.8.nix7
-rw-r--r--pkgs/development/compilers/go/1.9.nix7
-rw-r--r--pkgs/development/compilers/go/fix-systime-1.6.patch45
-rw-r--r--pkgs/development/compilers/go/new-binutils.patch194
-rw-r--r--pkgs/development/compilers/go/remove-tools-1.5.patch48
-rw-r--r--pkgs/development/compilers/go/remove-tools-1.7.patch35
-rw-r--r--pkgs/development/compilers/go/strip.patch12
-rw-r--r--pkgs/development/compilers/haxe/default.nix4
-rw-r--r--pkgs/development/compilers/hhvm/default.nix1
-rw-r--r--pkgs/development/compilers/jwasm/default.nix27
-rw-r--r--pkgs/development/compilers/llvm/4/clang/default.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/dynamiclibrary-musl.patch33
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/default.nix12
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/max_align_t.patch54
-rw-r--r--pkgs/development/compilers/llvm/4/libc++abi.nix3
-rw-r--r--pkgs/development/compilers/llvm/4/llvm.nix13
-rw-r--r--pkgs/development/compilers/llvm/5/clang/default.nix2
-rw-r--r--pkgs/development/compilers/llvm/5/libc++/default.nix15
-rw-r--r--pkgs/development/compilers/llvm/5/libc++abi.nix2
-rw-r--r--pkgs/development/compilers/llvm/5/llvm.nix21
-rw-r--r--pkgs/development/compilers/llvm/TLI-musl.patch35
-rw-r--r--pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch39
-rw-r--r--pkgs/development/compilers/mono/5.8.nix8
-rw-r--r--pkgs/development/compilers/openjdk/7.nix5
-rw-r--r--pkgs/development/compilers/purescript/psc-package/default.nix2
-rw-r--r--pkgs/development/compilers/rust/binaryBuild.nix14
-rw-r--r--pkgs/development/compilers/rust/bootstrap.nix16
-rw-r--r--pkgs/development/compilers/rust/cargo.nix23
-rw-r--r--pkgs/development/compilers/rust/default.nix24
-rw-r--r--pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch6
-rw-r--r--pkgs/development/compilers/rust/rustc.nix21
-rw-r--r--pkgs/development/compilers/sbcl/default.nix4
-rw-r--r--pkgs/development/compilers/scala/dotty-bare.nix4
-rw-r--r--pkgs/development/compilers/solc/default.nix14
-rw-r--r--pkgs/development/compilers/swift/default.nix80
-rw-r--r--pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch4
-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/yap/default.nix2
-rw-r--r--pkgs/development/compilers/yosys/default.nix18
-rw-r--r--pkgs/development/compilers/z88dk/default.nix50
-rw-r--r--pkgs/development/compilers/zig/default.nix4
61 files changed, 867 insertions, 852 deletions
diff --git a/pkgs/development/compilers/arachne-pnr/default.nix b/pkgs/development/compilers/arachne-pnr/default.nix
index 8dcebbf442b1..97eb8e8b6421 100644
--- a/pkgs/development/compilers/arachne-pnr/default.nix
+++ b/pkgs/development/compilers/arachne-pnr/default.nix
@@ -1,21 +1,29 @@
 { stdenv, fetchFromGitHub, icestorm }:
 
+with builtins;
+
 stdenv.mkDerivation rec {
   name = "arachne-pnr-${version}";
-  version = "2018.02.04";
+  version = "2018.02.14";
 
   src = fetchFromGitHub {
     owner  = "cseed";
     repo   = "arachne-pnr";
-    rev    = "c21df0062c6ee13e8c8280cefbb7c017823336c0";
-    sha256 = "1ah1gn07av3ff5lnay4p7dahaacbyj0mfakbx7g5fs3p1m1m8p1k";
+    rev    = "b54675413f9aac1d9a1fb0a8e9354bec2a2a8f3c";
+    sha256 = "06slsb239qk1r2g96n1g37yp8314cy7yi4g1yf86fr87fr11ml8l";
   };
 
   enableParallelBuilding = true;
   makeFlags =
-    [ "PREFIX=$(out)" "ICEBOX=${icestorm}/share/icebox"
+    [ "PREFIX=$(out)"
+      "ICEBOX=${icestorm}/share/icebox"
     ];
 
+  patchPhase = ''
+    substituteInPlace ./Makefile \
+      --replace 'echo UNKNOWN' 'echo ${substring 0 10 src.rev}'
+  '';
+
   meta = {
     description = "Place and route tool for FPGAs";
     longDescription = ''
diff --git a/pkgs/development/compilers/binaryen/default.nix b/pkgs/development/compilers/binaryen/default.nix
index 72eaae998779..3f9ee17ca279 100644
--- a/pkgs/development/compilers/binaryen/default.nix
+++ b/pkgs/development/compilers/binaryen/default.nix
@@ -1,14 +1,14 @@
 { stdenv, cmake, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
-  version = "33";
+  version = "42";
   rev = "version_${version}";
   name = "binaryen-${version}";
 
   src = fetchFromGitHub {
     owner = "WebAssembly";
     repo = "binaryen";
-    sha256 = "0zijs2mcgfv0iynwdb0l4zykm0891b1zccf6r8w35ipxvcdwbsbp";
+    sha256 = "0b8qc9cd7ncshgfjwv4hfapmwa81gmniaycnxmdkihq9bpm26x2k";
     inherit rev;
   };
 
diff --git a/pkgs/development/compilers/chez/default.nix b/pkgs/development/compilers/chez/default.nix
index f238e5f8fb50..3ffd024305de 100644
--- a/pkgs/development/compilers/chez/default.nix
+++ b/pkgs/development/compilers/chez/default.nix
@@ -2,8 +2,7 @@
 
 stdenv.mkDerivation rec {
   name    = "chez-scheme-${version}";
-  version = "9.5-${dver}";
-  dver    = "20171109";
+  version = "9.5.1";
 
   src = fetchgit {
     url    = "https://github.com/cisco/chezscheme.git";
@@ -13,10 +12,12 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ coreutils ] ++ stdenv.lib.optional stdenv.isDarwin cctools;
-
   buildInputs = [ ncurses libiconv libX11 ];
 
-  /* We patch out a very annoying 'feature' in ./configure, which
+  enableParallelBuilding = true;
+
+  /*
+  ** We patch out a very annoying 'feature' in ./configure, which
   ** tries to use 'git' to update submodules.
   **
   ** We have to also fix a few occurrences to tools with absolute
@@ -38,19 +39,47 @@ stdenv.mkDerivation rec {
       --replace "/usr/bin/libtool" libtool
   '';
 
-  /* Don't use configureFlags, since that just implicitly appends
+  /*
+  ** Don't use configureFlags, since that just implicitly appends
   ** everything onto a --prefix flag, which ./configure gets very angry
   ** about.
+  **
+  ** Also, carefully set a manual workarea argument, so that we
+  ** can later easily find the machine type that we built Chez
+  ** for.
   */
   configurePhase = ''
-    ./configure --threads --installprefix=$out --installman=$out/share/man
+    ./configure --threads \
+      --installprefix=$out --installman=$out/share/man \
+      --workarea=work
   '';
 
-  enableParallelBuilding = true;
+  /*
+  ** Install the kernel.o file, so we can compile C applications that
+  ** link directly to the Chez runtime (for booting their own files, or
+  ** embedding.)
+  **
+  ** Ideally in the future this would be less of a hack and could be
+  ** done by Chez itself. Alternatively, there could just be a big
+  ** case statement matching to the different stdenv.platform values...
+  */
+  postInstall = ''
+    m="$(ls ./work/boot)"
+    if [ "x''${m[1]}" != "x" ]; then
+      >&2 echo "ERROR: more than one bootfile build found; this is a nixpkgs error"
+      exit 1
+    fi
+
+    kernel=./work/boot/$m/kernel.o
+    kerneldest=$out/lib/csv${version}/$m/
+
+    echo installing $kernel to $kerneldest
+    cp $kernel $kerneldest/kernel.o
+  '';
 
   meta = {
     description = "A powerful and incredibly fast R6RS Scheme compiler";
-    homepage    = "http://www.scheme.com";
+    homepage    = https://cisco.github.io/ChezScheme/;
     license     = stdenv.lib.licenses.asl20;
     platforms   = stdenv.lib.platforms.unix;
     maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
diff --git a/pkgs/development/compilers/compcert/default.nix b/pkgs/development/compilers/compcert/default.nix
index a12f1c42ba61..51392e23d8cf 100644
--- a/pkgs/development/compilers/compcert/default.nix
+++ b/pkgs/development/compilers/compcert/default.nix
@@ -7,11 +7,11 @@ assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
 
 stdenv.mkDerivation rec {
   name    = "compcert-${version}";
-  version = "3.1";
+  version = "3.2";
 
   src = fetchurl {
     url    = "http://compcert.inria.fr/release/${name}.tgz";
-    sha256 = "0irfwlw2chalp0g2gw0makc699hn3z37sha1a239p9d90mzx03cx";
+    sha256 = "11q4121s0rxva63njjwya7syfx9w0p4hzr6avh8s57vfbrcakc93";
   };
 
   buildInputs = [ coq ]
@@ -19,8 +19,11 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  postPatch = ''
+    sed -i -e 's/8\.6\.1|8\.7\.0|8\.7\.1)/8.6.1|8.7.0|8.7.1|8.7.2)/' configure
+  '';
+
   configurePhase = ''
-    substituteInPlace VERSION --replace '3.0.1' '3.1'
     substituteInPlace ./configure --replace '{toolprefix}gcc' '{toolprefix}cc'
     ./configure -clightgen -prefix $out -toolprefix ${tools}/bin/ '' +
     (if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux");
diff --git a/pkgs/development/compilers/dmd/default.nix b/pkgs/development/compilers/dmd/default.nix
index de3544a3a638..094cdb06b698 100644
--- a/pkgs/development/compilers/dmd/default.nix
+++ b/pkgs/development/compilers/dmd/default.nix
@@ -3,9 +3,9 @@
 , curl, tzdata, gdb, darwin
 , callPackage
 , bootstrapVersion ? false
-, version ? "2.078.1"
-, dmdSha256 ? "0b9lphh4g3r9cyzv4wcfppv9j3w952vvwv615za23acgwav3mqg2"
-, druntimeSha256 ? "16jv40m073cflpkyl0vmg1g58cianybfcsgcvwli7pfryxbgsbrr"
+, version ? "2.078.2"
+, dmdSha256 ? "0x9q4aw4jl36dz7m5111y2sm8jdaj3zg36zhj6vqg1lqpdn3bhls"
+, druntimeSha256 ? "0nfqjcmwqc490bzi3582x1c3zigkf306g4nyd1cyd3vs8lfm6x66"
 , phobosSha256 ? "08ircpf4ilznz638kra272hz8fi5ccvw2cswj5hqckssl1lyqzs8"
 }:
 
@@ -111,7 +111,7 @@ let
     ''
 
     + stdenv.lib.optionalString stdenv.hostPlatform.isLinux ''
-        # See https://github.com/NixOS/nixpkgs/issues/29443
+        # See https://github.com/dlang/phobos/pull/5960
         substituteInPlace phobos/std/path.d \
             --replace "\"/root" "\"${ROOT_HOME_DIR}"
     '';
diff --git a/pkgs/development/compilers/gambit/default.nix b/pkgs/development/compilers/gambit/default.nix
index 01463f091c29..7466c85ca6ed 100644
--- a/pkgs/development/compilers/gambit/default.nix
+++ b/pkgs/development/compilers/gambit/default.nix
@@ -1,19 +1,20 @@
-{ stdenv, fetchurl, fetchgit, git, openssl, autoconf, pkgs }:
+{ stdenv, fetchurl, fetchgit, git, openssl, autoconf, pkgs, makeStaticLibraries }:
 
 # TODO: distinct packages for gambit-release and gambit-devel
 
 stdenv.mkDerivation rec {
   name    = "gambit-${version}";
-  version = "4.8.8-427-g37b111a5";
+  version = "4.8.8-435-gd1991ba7";
   bootstrap = import ./bootstrap.nix ( pkgs );
 
   src = fetchgit {
     url = "https://github.com/feeley/gambit.git";
-    rev = "37b111a5ca3aeff9dc6cb8be470277a8c1e80f24";
-    sha256 = "14l7jql9nh7bjs6c822a17rcp9583l6bb5kiq95allgyf229vy50";
+    rev = "d1991ba7e90ed0149964320f7cafa1a8289e61f0";
+    sha256 = "02harwcsqxxcxgn2yc1y9kyxdp32mampyvnbxrzg2jzfmnp5g6cm";
   };
 
-  buildInputs = [ openssl git autoconf bootstrap ];
+  # Use makeStaticLibraries to enable creation of statically linked binaries
+  buildInputs = [ git autoconf bootstrap openssl (makeStaticLibraries openssl)];
 
   configurePhase = ''
     options=(
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 0105a159877a..36adfd075df2 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -169,7 +169,7 @@ let version = "4.8.5";
           # To keep ABI compatibility with upstream mingw-w64
           "--enable-fully-dynamic-string"
         ] else
-          optionals (targetPlatform.libc == "uclibc") [
+          optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
             # In uclibc cases, libgomp needs an additional '-ldl'
             # and as I don't know how to pass it, I disable libgomp.
             "--disable-libgomp"
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 1b1492686d0e..c436da678fd9 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -160,7 +160,7 @@ let version = "4.9.4";
           # To keep ABI compatibility with upstream mingw-w64
           "--enable-fully-dynamic-string"
         ] else
-          optionals (targetPlatform.libc == "uclibc") [
+          optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
             # libsanitizer requires netrom/netrom.h which is not
             # available in uclibc.
             "--disable-libsanitizer"
diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix
index 0636ce7381ae..b9ca8696d4e3 100644
--- a/pkgs/development/compilers/gcc/5/default.nix
+++ b/pkgs/development/compilers/gcc/5/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -74,7 +74,11 @@ let version = "5.5.0";
 
       # This could be applied unconditionally but I don't want to cause a full
       # Linux rebuild.
-      ++ optional stdenv.cc.isClang ./libcxx38-and-above.patch;
+      ++ optional stdenv.cc.isClang ./libcxx38-and-above.patch
+      ++ optional stdenv.hostPlatform.isMusl (fetchpatch {
+        url = https://raw.githubusercontent.com/richfelker/musl-cross-make/e84b1bd1fc12a3def33111ca6df522cd6e5ec361/patches/gcc-5.3.0/0001-musl.diff;
+        sha256 = "0pppbf8myi2kjhm3z3479ihn1cm60kycfv60gj8yy1bs0pl1qcfm";
+      });
 
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
@@ -160,7 +164,7 @@ let version = "5.5.0";
           # To keep ABI compatibility with upstream mingw-w64
           "--enable-fully-dynamic-string"
         ] else
-          optionals (targetPlatform.libc == "uclibc") [
+          optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
             # libsanitizer requires netrom/netrom.h which is not
             # available in uclibc.
             "--disable-libsanitizer"
@@ -258,15 +262,22 @@ 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
         ''
+        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        ''
+            sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
+        ''
+        )
     else null;
 
   # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
@@ -396,6 +407,7 @@ stdenv.mkDerivation ({
       # 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;
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index 2614e96e1b7c..df0c1578daed 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -142,6 +142,9 @@ let version = "6.4.0";
         "--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 [
         (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot"
          else                "--with-headers=${getDev libcCross}/include")
@@ -158,13 +161,15 @@ let version = "6.4.0";
           # To keep ABI compatibility with upstream mingw-w64
           "--enable-fully-dynamic-string"
         ] else
-          optionals (targetPlatform.libc == "uclibc") [
+          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"
@@ -257,15 +262,22 @@ 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
         ''
+        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        ''
+            sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
+        ''
+        )
     else null;
 
   # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
@@ -399,6 +411,7 @@ stdenv.mkDerivation ({
       # 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;
diff --git a/pkgs/development/compilers/gcc/6/fix-objdump-check.patch b/pkgs/development/compilers/gcc/6/fix-objdump-check.patch
new file mode 100644
index 000000000000..f9adbe9eb1ca
--- /dev/null
+++ b/pkgs/development/compilers/gcc/6/fix-objdump-check.patch
@@ -0,0 +1,43 @@
+commit 4c38abe0967bad78dd6baa61c86923e4d4b346d3
+Author: Ben Gamari <ben@smart-cactus.org>
+Date:   Sun Nov 5 13:14:19 2017 -0500
+
+    Fix it
+
+diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
+index dd06a58..f4435b8 100644
+--- a/config/gcc-plugin.m4
++++ b/config/gcc-plugin.m4
+@@ -13,6 +13,32 @@ dnl the same distribution terms as the rest of that program.
+ # Sets the shell variables enable_plugin and pluginlibs.
+ AC_DEFUN([GCC_ENABLE_PLUGINS],
+   [# Check for plugin support
++
++   # Figure out what objdump we will be using.
++   AS_VAR_SET_IF(gcc_cv_objdump,, [
++   if test -f $gcc_cv_binutils_srcdir/configure.ac \
++        && test -f ../binutils/Makefile \
++        && test x$build = x$host; then
++   	# Single tree build which includes binutils.
++   	gcc_cv_objdump=../binutils/objdump$build_exeext
++   elif test -x objdump$build_exeext; then
++   	gcc_cv_objdump=./objdump$build_exeext
++   elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then
++           gcc_cv_objdump="$OBJDUMP_FOR_TARGET"
++   else
++           AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET)
++   fi])
++   
++   AC_MSG_CHECKING(what objdump to use)
++   if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then
++   	# Single tree build which includes binutils.
++   	AC_MSG_RESULT(newly built objdump)
++   elif test x$gcc_cv_objdump = x; then
++   	AC_MSG_RESULT(not found)
++   else
++   	AC_MSG_RESULT($gcc_cv_objdump)
++   fi
++
+    AC_ARG_ENABLE(plugin,
+    [AS_HELP_STRING([--enable-plugin], [enable plugin support])],
+    enable_plugin=$enableval,
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 0e5f69c27262..e8997b1efb06 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -33,7 +33,6 @@
 , gnused ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , darwin ? null
-, flex ? null
 , buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
@@ -67,6 +66,10 @@ let version = "7.3.0";
       [ ]
       ++ 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
@@ -140,6 +143,9 @@ let version = "7.3.0";
         "--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 [
         (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot"
          else                "--with-headers=${getDev libcCross}/include")
@@ -156,13 +162,15 @@ let version = "7.3.0";
           # To keep ABI compatibility with upstream mingw-w64
           "--enable-fully-dynamic-string"
         ] else
-          optionals (targetPlatform.libc == "uclibc") [
+          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"
@@ -254,15 +262,22 @@ 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
         ''
+        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        ''
+            sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
+        ''
+        )
     else null;
 
   # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
@@ -284,7 +299,7 @@ stdenv.mkDerivation ({
     ];
 
   buildInputs = [
-    gmp mpfr libmpc libelf flex
+    gmp mpfr libmpc libelf
     targetPackages.stdenv.cc.bintools # For linking code at run-time
   ] ++ (optional (isl != null) isl)
     ++ (optional (zlib != null) zlib)
@@ -392,13 +407,13 @@ stdenv.mkDerivation ({
       # 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 = if bootstrap then
-    (if profiledCompiler then "profiledbootstrap" else "bootstrap")
-    else "";
+  buildFlags =
+    optional bootstrap (if profiledCompiler then "profiledbootstrap" else "bootstrap");
 
   installTargets =
     if stripped
@@ -511,7 +526,7 @@ stdenv.mkDerivation ({
 }
 
 # Strip kills static libs of other archs (hence targetPlatform != hostPlatform)
-// optionalAttrs (!stripped || targetPlatform != hostPlatform) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
+// optionalAttrs (!stripped || targetPlatform != hostPlatform) { dontStrip = true; }
 
 // optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
 )
diff --git a/pkgs/development/compilers/gerbil/default.nix b/pkgs/development/compilers/gerbil/default.nix
index 9bd23aebfc43..f67582385e6f 100644
--- a/pkgs/development/compilers/gerbil/default.nix
+++ b/pkgs/development/compilers/gerbil/default.nix
@@ -1,24 +1,26 @@
-{ stdenv, fetchurl, fetchgit, gambit,
+{ stdenv, lib, fetchurl, fetchgit, makeStaticLibraries, gambit,
   coreutils, rsync, bash,
-  openssl, zlib, sqlite, libxml2, libyaml, mysql, lmdb, leveldb }:
+  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}";
 
-  version = "0.12-DEV-1030-gbbed3bc";
+  version = "0.12-DEV-1404-g0a266db";
   src = fetchgit {
     url = "https://github.com/vyzo/gerbil.git";
-    rev = "bbed3bc4cf7bcaa64eaabdf097192bfcc2bfc928";
-    sha256 = "1dc0j143j860yq72lfjp71fin7hpsy1426azz7rl1szxvjfb7h4r";
+    rev = "0a266db5e2e241272711bc150cc2607204bf2b78";
+    sha256 = "1lvawqn8havfyxkkgfqffc213zq2pgm179l42yj49fy3fhpzia4m";
   };
 
-  buildInputs = [
-    gambit
-    coreutils rsync bash
-    openssl zlib sqlite libxml2 libyaml mysql.connector-c lmdb leveldb
-  ];
+  # 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" ];
 
@@ -30,6 +32,18 @@ stdenv.mkDerivation rec {
     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 = ''
diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix
index 8b62bbffcc84..f4aa2de3241e 100644
--- a/pkgs/development/compilers/ghc/8.2.2.nix
+++ b/pkgs/development/compilers/ghc/8.2.2.nix
@@ -26,6 +26,10 @@
     !(targetPlatform.isDarwin
       # On iOS, dynamic linking is not supported
       && (targetPlatform.isAarch64 || targetPlatform.isArm))
+, # 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
 }:
 
 assert !enableIntegerSimple -> gmp != null;
@@ -85,7 +89,11 @@ stdenv.mkDerivation rec {
       url = "https://git.haskell.org/ghc.git/commitdiff_plain/2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3";
       sha256 = "03253ci40np1v6k0wmi4aypj3nmj3rdyvb1k6rwqipb30nfc719f";
     })
-  ];
+  ] ++ stdenv.lib.optional deterministicProfiling
+    (fetchpatch { # Backport of https://phabricator.haskell.org/D4388 for more determinism
+      url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch";
+      sha256 = "1lyysz6hfd1njcigpm8xppbnkadqfs0kvrp7s8vqgb38pjswj5hg";
+    });
 
   postPatch = "patchShebangs .";
 
diff --git a/pkgs/development/compilers/ghc/8.4.1.nix b/pkgs/development/compilers/ghc/8.4.1.nix
index 17dc24e567f4..e7ec9be16b69 100644
--- a/pkgs/development/compilers/ghc/8.4.1.nix
+++ b/pkgs/development/compilers/ghc/8.4.1.nix
@@ -3,7 +3,7 @@
 
 # build-tools
 , bootPkgs, alex, happy
-, autoconf, automake, coreutils, fetchgit, perl, python3
+, autoconf, automake, coreutils, fetchgit, fetchpatch, perl, python3
 
 , libffi, libiconv ? null, ncurses
 
@@ -24,7 +24,11 @@
   # platform). Static libs are always built.
   enableShared ? true
 
-, version ? "8.4.20180122"
+, version ? "8.4.0.20180204"
+, # 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
 }:
 
 assert !enableIntegerSimple -> gmp != null;
@@ -73,14 +77,20 @@ stdenv.mkDerivation rec {
 
   src = fetchgit {
     url = "git://git.haskell.org/ghc.git";
-    rev = "61db0b8941cfb7ed8941ed29bdb04bd8ef3b71a5";
-    sha256 = "15sbpgkal4854jc1xn3sprvpnxwdj0fyy43y5am0h9vja3pjhjyi";
+    rev = "111737cd218751f06ea58d3cf2c7c144265b5dfc";
+    sha256 = "0ksp0k3sp928aq2cv6whgbfmjnr7l2j10diha13nncksp4byf0s9";
   };
 
   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";
+    });
+
   postPatch = "patchShebangs .";
 
   # GHC is a bit confused on its cross terminology.
diff --git a/pkgs/development/compilers/go/1.6.nix b/pkgs/development/compilers/go/1.6.nix
deleted file mode 100644
index 0eebc92ee594..000000000000
--- a/pkgs/development/compilers/go/1.6.nix
+++ /dev/null
@@ -1,168 +0,0 @@
-{ stdenv, lib, fetchurl, tzdata, iana-etc, go_bootstrap, runCommand
-, perl, which, pkgconfig, patch, fetchpatch
-, pcre
-, Security, Foundation, bash }:
-
-let
-  goBootstrap = runCommand "go-bootstrap" {} ''
-    mkdir $out
-    cp -rf ${go_bootstrap}/* $out/
-    chmod -R u+w $out
-    find $out -name "*.c" -delete
-    cp -rf $out/bin/* $out/share/go/bin/
-  '';
-in
-
-stdenv.mkDerivation rec {
-  name = "go-${version}";
-  version = "1.6.4";
-
-  src = fetchurl {
-    url = "https://github.com/golang/go/archive/go${version}.tar.gz";
-    sha256 = "1212pijypippg3sq9c9645kskq4ib73y1f8cv0ka6n279smk0mq9";
-  };
-
-  # perl is used for testing go vet
-  nativeBuildInputs = [ perl which pkgconfig patch ];
-  buildInputs = [ pcre ];
-  propagatedBuildInputs = lib.optionals stdenv.isDarwin [
-    Security Foundation
-  ];
-
-  hardeningDisable = [ "all" ];
-
-  # I'm not sure what go wants from its 'src', but the go installation manual
-  # describes an installation keeping the src.
-  preUnpack = ''
-    topdir=$PWD
-    mkdir -p $out/share
-    cd $out/share
-  '';
-
-  prePatch = ''
-    # Ensure that the source directory is named go
-    cd ..
-    if [ ! -d go ]; then
-      mv * go
-    fi
-
-    cd go
-    patchShebangs ./ # replace /bin/bash
-
-    # This script produces another script at run time,
-    # and thus it is not corrected by patchShebangs.
-    substituteInPlace misc/cgo/testcarchive/test.bash \
-      --replace '#!/usr/bin/env bash' '#!${stdenv.shell}'
-
-    # Disabling the 'os/http/net' tests (they want files not available in
-    # chroot builds)
-    rm src/net/{listen,parse}_test.go
-    rm src/syscall/exec_linux_test.go
-    # !!! substituteInPlace does not seems to be effective.
-    # The os test wants to read files in an existing path. Just don't let it be /usr/bin.
-    sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go
-    sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go
-    # Disable the unix socket test
-    sed -i '/TestShutdownUnix/areturn' src/net/net_test.go
-    # Disable the hostname test
-    sed -i '/TestHostname/areturn' src/os/os_test.go
-    # ParseInLocation fails the test
-    sed -i '/TestParseInSydney/areturn' src/time/format_test.go
-    # Remove the api check as it never worked
-    sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go
-    # Remove the coverage test as we have removed this utility
-    sed -i '/TestCoverageWithCgo/areturn' src/cmd/go/go_test.go
-    # Remove the timezone naming test
-    sed -i '/TestLoadFixed/areturn' src/time/time_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
-  '' + lib.optionalString stdenv.isLinux ''
-    sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
-  '' + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace src/race.bash --replace \
-      "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
-    sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
-    sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go
-    sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go
-    sed -i '/TestCgoLookupIP/areturn' src/net/cgo_unix_test.go
-    sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go
-    sed -i '/TestRead0/areturn' src/os/os_test.go
-    sed -i '/TestNohup/areturn' src/os/signal/signal_test.go
-    rm src/crypto/x509/root_darwin_test.go src/crypto/x509/verify_test.go
-
-    sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/areturn' src/cmd/go/go_test.go
-    sed -i '/TestBuildDashIInstallsDependencies/areturn' src/cmd/go/go_test.go
-
-    sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go
-
-    touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd
-
-    sed -i '1 a\exit 0' misc/cgo/errors/test.bash
-
-    mkdir $topdir/dirtyhacks
-    cat <<EOF > $topdir/dirtyhacks/clang
-    #!${bash}/bin/bash
-    $(type -P clang) "\$@" 2> >(sed '/ld: warning:.*ignoring unexpected dylib file/ d' 1>&2)
-    exit $?
-    EOF
-    chmod +x $topdir/dirtyhacks/clang
-    PATH=$topdir/dirtyhacks:$PATH
-  '';
-
-  patches = [
-    ./remove-tools-1.5.patch
-    ./creds-test.patch
-    ./fix-systime-1.6.patch
-
-    # This test checks for the wrong thing with recent tzdata. It's been fixed in master but the patch
-    # actually works on old versions too.
-    (fetchpatch {
-      url    = "https://github.com/golang/go/commit/91563ced5897faf729a34be7081568efcfedda31.patch";
-      sha256 = "1ny5l3f8a9dpjjrnjnsplb66308a0x13sa0wwr4j6yrkc8j4qxqi";
-    })
-  ];
-
-  GOOS = if stdenv.isDarwin then "darwin" else "linux";
-  GOARCH = if stdenv.isDarwin then "amd64"
-           else if stdenv.system == "i686-linux" then "386"
-           else if stdenv.system == "x86_64-linux" then "amd64"
-           else if stdenv.isArm then "arm"
-           else if stdenv.isAarch64 then "arm64"
-           else throw "Unsupported system";
-  GOARM = stdenv.lib.optionalString (stdenv.system == "armv5tel-linux") "5";
-  GO386 = 387; # from Arch: don't assume sse2 on i686
-  CGO_ENABLED = 1;
-  GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
-
-  # The go build actually checks for CC=*/clang and does something different, so we don't
-  # just want the generic `cc` here.
-  CC = if stdenv.isDarwin then "clang" else "cc";
-
-  installPhase = ''
-    mkdir -p "$out/bin"
-    export GOROOT="$(pwd)/"
-    export GOBIN="$out/bin"
-    export PATH="$GOBIN:$PATH"
-    cd ./src
-    echo Building
-    ./all.bash
-  '';
-
-  preFixup = ''
-    rm -r $out/share/go/pkg/bootstrap
-  '';
-
-  setupHook = ./setup-hook.sh;
-
-  disallowedReferences = [ go_bootstrap ];
-
-  meta = with stdenv.lib; {
-    branch = "1.6";
-    homepage = http://golang.org/;
-    description = "The Go Programming language";
-    license = licenses.bsd3;
-    maintainers = with maintainers; [ cstrahan wkennington ];
-    platforms = platforms.linux ++ platforms.darwin;
-  };
-}
diff --git a/pkgs/development/compilers/go/1.7.nix b/pkgs/development/compilers/go/1.7.nix
deleted file mode 100644
index 82ed9b53c60f..000000000000
--- a/pkgs/development/compilers/go/1.7.nix
+++ /dev/null
@@ -1,168 +0,0 @@
-{ stdenv, fetchFromGitHub, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin
-, perl, which, pkgconfig, patch, fetchpatch
-, pcre, cacert
-, Security, Foundation, bash }:
-
-let
-
-  inherit (stdenv.lib) optional optionals optionalString;
-
-  clangHack = writeScriptBin "clang" ''
-    #!${stdenv.shell}
-    exec ${stdenv.cc}/bin/clang "$@" 2> >(sed '/ld: warning:.*ignoring unexpected dylib file/ d' 1>&2)
-  '';
-
-  goBootstrap = runCommand "go-bootstrap" {} ''
-    mkdir $out
-    cp -rf ${go_bootstrap}/* $out/
-    chmod -R u+w $out
-    find $out -name "*.c" -delete
-    cp -rf $out/bin/* $out/share/go/bin/
-  '';
-
-in
-
-stdenv.mkDerivation rec {
-  name = "go-${version}";
-  version = "1.7.6";
-
-  src = fetchFromGitHub {
-    owner = "golang";
-    repo = "go";
-    rev = "go${version}";
-    sha256 = "1gacjwbs1qbx8x84746qdxx2xwylirvd31ybgagfglfsl77vi4m2";
-  };
-
-  # perl is used for testing go vet
-  nativeBuildInputs = [ perl which pkgconfig patch ];
-  buildInputs = [ cacert pcre ];
-  propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ];
-
-  hardeningDisable = [ "all" ];
-
-  prePatch = ''
-    patchShebangs ./ # replace /bin/bash
-
-    # This source produces shell script at run time,
-    # and thus it is not corrected by patchShebangs.
-    substituteInPlace misc/cgo/testcarchive/carchive_test.go \
-      --replace '#!/usr/bin/env bash' '#!${stdenv.shell}'
-
-    # Disabling the 'os/http/net' tests (they want files not available in
-    # chroot builds)
-    rm src/net/{listen,parse}_test.go
-    rm src/syscall/exec_linux_test.go
-    # !!! substituteInPlace does not seems to be effective.
-    # The os test wants to read files in an existing path. Just don't let it be /usr/bin.
-    sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go
-    sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go
-    # Disable the unix socket test
-    sed -i '/TestShutdownUnix/areturn' src/net/net_test.go
-    # Disable the hostname test
-    sed -i '/TestHostname/areturn' src/os/os_test.go
-    # ParseInLocation fails the test
-    sed -i '/TestParseInSydney/areturn' src/time/format_test.go
-    # Remove the api check as it never worked
-    sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go
-    # Remove the coverage test as we have removed this utility
-    sed -i '/TestCoverageWithCgo/areturn' src/cmd/go/go_test.go
-    # Remove the timezone naming test
-    sed -i '/TestLoadFixed/areturn' src/time/time_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
-
-    # Disable cgo lookup tests not works, they depend on resolver
-    rm src/net/cgo_unix_test.go
-
-  '' + optionalString stdenv.isLinux ''
-    sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
-  '' + optionalString stdenv.isDarwin ''
-    substituteInPlace src/race.bash --replace \
-      "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
-    sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
-    sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go
-    sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go
-
-    sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go
-    sed -i '/TestRead0/areturn' src/os/os_test.go
-    sed -i '/TestNohup/areturn' src/os/signal/signal_test.go
-    sed -i '/TestCurrent/areturn' src/os/user/user_test.go
-    sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go
-
-    sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/areturn' src/cmd/go/go_test.go
-    sed -i '/TestBuildDashIInstallsDependencies/areturn' src/cmd/go/go_test.go
-
-    sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go
-
-    sed -i 's/unrecognized/unknown/' src/cmd/link/internal/ld/lib.go
-    sed -i 's/unrecognized/unknown/' src/cmd/go/build.go
-
-    touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd
-
-    sed -i '1 a\exit 0' misc/cgo/errors/test.bash
-  '';
-
-  patches =
-    [ ./remove-tools-1.7.patch
-      ./ssl-cert-file.patch
-      ./creds-test.patch
-
-      # This test checks for the wrong thing with recent tzdata. It's been fixed in master but the patch
-      # actually works on old versions too.
-      (fetchpatch {
-        url    = "https://github.com/golang/go/commit/91563ced5897faf729a34be7081568efcfedda31.patch";
-        sha256 = "1ny5l3f8a9dpjjrnjnsplb66308a0x13sa0wwr4j6yrkc8j4qxqi";
-      })
-    ];
-
-  GOOS = if stdenv.isDarwin then "darwin" else "linux";
-  GOARCH = if stdenv.isDarwin then "amd64"
-           else if stdenv.system == "i686-linux" then "386"
-           else if stdenv.system == "x86_64-linux" then "amd64"
-           else if stdenv.isArm then "arm"
-           else if stdenv.isAarch64 then "arm64"
-           else throw "Unsupported system";
-  GOARM = optionalString (stdenv.system == "armv5tel-linux") "5";
-  GO386 = 387; # from Arch: don't assume sse2 on i686
-  CGO_ENABLED = 1;
-  GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
-
-  # The go build actually checks for CC=*/clang and does something different, so we don't
-  # just want the generic `cc` here.
-  CC = if stdenv.isDarwin then "clang" else "cc";
-
-  configurePhase = ''
-    mkdir -p $out/share/go/bin
-    export GOROOT=$out/share/go
-    export GOBIN=$GOROOT/bin
-    export PATH=$GOBIN:$PATH
-  '';
-
-  postConfigure = optionalString stdenv.isDarwin ''
-    export PATH=${clangHack}/bin:$PATH
-  '';
-
-  installPhase = ''
-    cp -r . $GOROOT
-    ( cd $GOROOT/src && ./all.bash )
-  '';
-
-  preFixup = ''
-    rm -r $out/share/go/pkg/bootstrap
-    ln -s $out/share/go/bin $out/bin
-  '';
-
-  setupHook = ./setup-hook.sh;
-
-  disallowedReferences = [ go_bootstrap ];
-
-  meta = with stdenv.lib; {
-    branch = "1.7";
-    homepage = http://golang.org/;
-    description = "The Go Programming language";
-    license = licenses.bsd3;
-    maintainers = with maintainers; [ cstrahan wkennington ];
-    platforms = platforms.linux ++ platforms.darwin;
-  };
-}
diff --git a/pkgs/development/compilers/go/1.8.nix b/pkgs/development/compilers/go/1.8.nix
index ee71d2aabad6..7775a17a646c 100644
--- a/pkgs/development/compilers/go/1.8.nix
+++ b/pkgs/development/compilers/go/1.8.nix
@@ -25,20 +25,21 @@ in
 
 stdenv.mkDerivation rec {
   name = "go-${version}";
-  version = "1.8.5";
+  version = "1.8.7";
 
   src = fetchFromGitHub {
     owner = "golang";
     repo = "go";
     rev = "go${version}";
-    sha256 = "1ab021l3v29ciaxp738cjpbkh1chlsl6928672q3i82anmdzn5m5";
+    sha256 = "06v83fb75079dy2dc1927sr9bwvcpkkzl9d4wcw10scj70vj4a0x";
   };
 
   # perl is used for testing go vet
   nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ]
     ++ optionals stdenv.isLinux [ procps ];
   buildInputs = [ cacert pcre ]
-    ++ optionals stdenv.isLinux [ stdenv.glibc.out stdenv.glibc.static ];
+    ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ]
+    ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
   propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ];
 
   hardeningDisable = [ "all" ];
diff --git a/pkgs/development/compilers/go/1.9.nix b/pkgs/development/compilers/go/1.9.nix
index b226cd7a7ebc..f1017d4a48c4 100644
--- a/pkgs/development/compilers/go/1.9.nix
+++ b/pkgs/development/compilers/go/1.9.nix
@@ -25,20 +25,21 @@ in
 
 stdenv.mkDerivation rec {
   name = "go-${version}";
-  version = "1.9.3";
+  version = "1.9.4";
 
   src = fetchFromGitHub {
     owner = "golang";
     repo = "go";
     rev = "go${version}";
-    sha256 = "0ivb6z30d6qrrkwjm9fdz9jfs567q4b6dljwwxc9shmdr2l9chah";
+    sha256 = "15d9lfiy1cjfz6nqnig5884ykqckx58cynd1bva1xna7bwcwwp2r";
   };
 
   # perl is used for testing go vet
   nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ]
     ++ optionals stdenv.isLinux [ procps ];
   buildInputs = [ cacert pcre ]
-    ++ optionals stdenv.isLinux [ stdenv.glibc.out stdenv.glibc.static ];
+    ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ]
+    ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
   propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ];
 
   hardeningDisable = [ "all" ];
diff --git a/pkgs/development/compilers/go/fix-systime-1.6.patch b/pkgs/development/compilers/go/fix-systime-1.6.patch
deleted file mode 100644
index e4a3932001e5..000000000000
--- a/pkgs/development/compilers/go/fix-systime-1.6.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
-index e09b906ba5..fa8ff2f65c 100644
---- a/src/runtime/sys_darwin_amd64.s
-+++ b/src/runtime/sys_darwin_amd64.s
-@@ -157,6 +157,7 @@ systime:
- 	// Fall back to system call (usually first call in this thread).
- 	MOVQ	SP, DI
- 	MOVQ	$0, SI
-+	MOVQ	$0, DX  // required as of Sierra; Issue 16570
- 	MOVL	$(0x2000000+116), AX
- 	SYSCALL
- 	CMPQ	AX, $0
-diff --git a/src/syscall/syscall_darwin_amd64.go b/src/syscall/syscall_darwin_amd64.go
-index 70b53b87f4..79083117b6 100644
---- a/src/syscall/syscall_darwin_amd64.go
-+++ b/src/syscall/syscall_darwin_amd64.go
-@@ -26,14 +26,21 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
- }
- 
- //sysnb	gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
--func Gettimeofday(tv *Timeval) (err error) {
--	// The tv passed to gettimeofday must be non-nil
--	// but is otherwise unused.  The answers come back
--	// in the two registers.
-+func Gettimeofday(tv *Timeval) error {
-+	// The tv passed to gettimeofday must be non-nil.
-+	// Before macOS Sierra (10.12), tv was otherwise unused and
-+	// the answers came back in the two registers.
-+	// As of Sierra, gettimeofday return zeros and populates
-+	// tv itself.
- 	sec, usec, err := gettimeofday(tv)
--	tv.Sec = sec
--	tv.Usec = usec
--	return err
-+	if err != nil {
-+		return err
-+	}
-+	if sec != 0 || usec != 0 {
-+		tv.Sec = sec
-+		tv.Usec = usec
-+	}
-+	return nil
- }
- 
- func SetKevent(k *Kevent_t, fd, mode, flags int) {
diff --git a/pkgs/development/compilers/go/new-binutils.patch b/pkgs/development/compilers/go/new-binutils.patch
deleted file mode 100644
index a547e3ab9b9a..000000000000
--- a/pkgs/development/compilers/go/new-binutils.patch
+++ /dev/null
@@ -1,194 +0,0 @@
-https://github.com/golang/go/issues/13114
-https://gnats.netbsd.org/50777
-
---- a/src/cmd/6l/asm.c	2015-09-23 06:20:05.000000000 +0200
-+++ b/src/cmd/6l/asm.c	2016-03-10 21:00:29.032083210 +0100
-@@ -118,6 +118,8 @@
- 		return;
- 	
- 	case 256 + R_X86_64_GOTPCREL:
-+	case 256 + R_X86_64_GOTPCRELX:
-+	case 256 + R_X86_64_REX_GOTPCRELX:
- 		if(targ->type != SDYNIMPORT) {
- 			// have symbol
- 			if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
---- a/src/cmd/8l/asm.c	2015-09-23 06:20:05.000000000 +0200
-+++ b/src/cmd/8l/asm.c	2016-03-10 21:02:16.702064080 +0100
-@@ -115,6 +115,7 @@
- 		return;		
- 	
- 	case 256 + R_386_GOT32:
-+	case 256 + R_386_GOT32X:
- 		if(targ->type != SDYNIMPORT) {
- 			// have symbol
- 			if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
---- a/src/cmd/ld/elf.h	2015-09-23 06:20:05.000000000 +0200
-+++ b/src/cmd/ld/elf.h	2016-03-10 21:00:29.033083211 +0100
-@@ -478,32 +478,47 @@
-  * Relocation types.
-  */
- 
--#define	R_X86_64_NONE	0	/* No relocation. */
--#define	R_X86_64_64	1	/* Add 64 bit symbol value. */
--#define	R_X86_64_PC32	2	/* PC-relative 32 bit signed sym value. */
--#define	R_X86_64_GOT32	3	/* PC-relative 32 bit GOT offset. */
--#define	R_X86_64_PLT32	4	/* PC-relative 32 bit PLT offset. */
--#define	R_X86_64_COPY	5	/* Copy data from shared object. */
--#define	R_X86_64_GLOB_DAT 6	/* Set GOT entry to data address. */
--#define	R_X86_64_JMP_SLOT 7	/* Set GOT entry to code address. */
--#define	R_X86_64_RELATIVE 8	/* Add load address of shared object. */
--#define	R_X86_64_GOTPCREL 9	/* Add 32 bit signed pcrel offset to GOT. */
--#define	R_X86_64_32	10	/* Add 32 bit zero extended symbol value */
--#define	R_X86_64_32S	11	/* Add 32 bit sign extended symbol value */
--#define	R_X86_64_16	12	/* Add 16 bit zero extended symbol value */
--#define	R_X86_64_PC16	13	/* Add 16 bit signed extended pc relative symbol value */
--#define	R_X86_64_8	14	/* Add 8 bit zero extended symbol value */
--#define	R_X86_64_PC8	15	/* Add 8 bit signed extended pc relative symbol value */
--#define	R_X86_64_DTPMOD64 16	/* ID of module containing symbol */
--#define	R_X86_64_DTPOFF64 17	/* Offset in TLS block */
--#define	R_X86_64_TPOFF64 18	/* Offset in static TLS block */
--#define	R_X86_64_TLSGD	19	/* PC relative offset to GD GOT entry */
--#define	R_X86_64_TLSLD	20	/* PC relative offset to LD GOT entry */
--#define	R_X86_64_DTPOFF32 21	/* Offset in TLS block */
--#define	R_X86_64_GOTTPOFF 22	/* PC relative offset to IE GOT entry */
--#define	R_X86_64_TPOFF32 23	/* Offset in static TLS block */
--
--#define	R_X86_64_COUNT	24	/* Count of defined relocation types. */
-+#define	R_X86_64_NONE           0
-+#define	R_X86_64_64             1
-+#define	R_X86_64_PC32           2
-+#define	R_X86_64_GOT32          3
-+#define	R_X86_64_PLT32          4
-+#define	R_X86_64_COPY           5
-+#define	R_X86_64_GLOB_DAT       6
-+#define	R_X86_64_JMP_SLOT       7
-+#define	R_X86_64_RELATIVE       8
-+#define	R_X86_64_GOTPCREL       9
-+#define	R_X86_64_32             10
-+#define	R_X86_64_32S            11
-+#define	R_X86_64_16             12
-+#define	R_X86_64_PC16           13
-+#define	R_X86_64_8              14
-+#define	R_X86_64_PC8            15
-+#define	R_X86_64_DTPMOD64       16
-+#define	R_X86_64_DTPOFF64       17
-+#define	R_X86_64_TPOFF64        18
-+#define	R_X86_64_TLSGD          19
-+#define	R_X86_64_TLSLD          20
-+#define	R_X86_64_DTPOFF32       21
-+#define	R_X86_64_GOTTPOFF       22
-+#define	R_X86_64_TPOFF32        23
-+#define	R_X86_64_PC64           24
-+#define	R_X86_64_GOTOFF64       25
-+#define	R_X86_64_GOTPC32        26
-+#define	R_X86_64_GOT64          27
-+#define	R_X86_64_GOTPCREL64     28
-+#define	R_X86_64_GOTPC64        29
-+#define	R_X86_64_GOTPLT64       30
-+#define	R_X86_64_PLTOFF64       31
-+#define	R_X86_64_SIZE32         32
-+#define	R_X86_64_SIZE64         33
-+#define	R_X86_64_GOTPC32_TLSDEC 34
-+#define	R_X86_64_TLSDESC_CALL   35
-+#define	R_X86_64_TLSDESC        36
-+#define	R_X86_64_IRELATIVE      37
-+#define	R_X86_64_PC32_BND       40
-+#define	R_X86_64_GOTPCRELX      41
-+#define	R_X86_64_REX_GOTPCRELX  42
- 
- 
- #define	R_ALPHA_NONE		0	/* No reloc */
-@@ -581,39 +596,42 @@
- #define	R_ARM_COUNT		38	/* Count of defined relocation types. */
- 
- 
--#define	R_386_NONE	0	/* No relocation. */
--#define	R_386_32	1	/* Add symbol value. */
--#define	R_386_PC32	2	/* Add PC-relative symbol value. */
--#define	R_386_GOT32	3	/* Add PC-relative GOT offset. */
--#define	R_386_PLT32	4	/* Add PC-relative PLT offset. */
--#define	R_386_COPY	5	/* Copy data from shared object. */
--#define	R_386_GLOB_DAT	6	/* Set GOT entry to data address. */
--#define	R_386_JMP_SLOT	7	/* Set GOT entry to code address. */
--#define	R_386_RELATIVE	8	/* Add load address of shared object. */
--#define	R_386_GOTOFF	9	/* Add GOT-relative symbol address. */
--#define	R_386_GOTPC	10	/* Add PC-relative GOT table address. */
--#define	R_386_TLS_TPOFF	14	/* Negative offset in static TLS block */
--#define	R_386_TLS_IE	15	/* Absolute address of GOT for -ve static TLS */
--#define	R_386_TLS_GOTIE	16	/* GOT entry for negative static TLS block */
--#define	R_386_TLS_LE	17	/* Negative offset relative to static TLS */
--#define	R_386_TLS_GD	18	/* 32 bit offset to GOT (index,off) pair */
--#define	R_386_TLS_LDM	19	/* 32 bit offset to GOT (index,zero) pair */
--#define	R_386_TLS_GD_32	24	/* 32 bit offset to GOT (index,off) pair */
--#define	R_386_TLS_GD_PUSH 25	/* pushl instruction for Sun ABI GD sequence */
--#define	R_386_TLS_GD_CALL 26	/* call instruction for Sun ABI GD sequence */
--#define	R_386_TLS_GD_POP 27	/* popl instruction for Sun ABI GD sequence */
--#define	R_386_TLS_LDM_32 28	/* 32 bit offset to GOT (index,zero) pair */
--#define	R_386_TLS_LDM_PUSH 29	/* pushl instruction for Sun ABI LD sequence */
--#define	R_386_TLS_LDM_CALL 30	/* call instruction for Sun ABI LD sequence */
--#define	R_386_TLS_LDM_POP 31	/* popl instruction for Sun ABI LD sequence */
--#define	R_386_TLS_LDO_32 32	/* 32 bit offset from start of TLS block */
--#define	R_386_TLS_IE_32	33	/* 32 bit offset to GOT static TLS offset entry */
--#define	R_386_TLS_LE_32	34	/* 32 bit offset within static TLS block */
--#define	R_386_TLS_DTPMOD32 35	/* GOT entry containing TLS index */
--#define	R_386_TLS_DTPOFF32 36	/* GOT entry containing TLS offset */
--#define	R_386_TLS_TPOFF32 37	/* GOT entry of -ve static TLS offset */
--
--#define	R_386_COUNT	38	/* Count of defined relocation types. */
-+#define	R_386_NONE          0
-+#define	R_386_32            1
-+#define	R_386_PC32          2
-+#define	R_386_GOT32         3
-+#define	R_386_PLT32         4
-+#define	R_386_COPY          5
-+#define	R_386_GLOB_DAT      6
-+#define	R_386_JMP_SLOT      7
-+#define	R_386_RELATIVE      8
-+#define	R_386_GOTOFF        9
-+#define	R_386_GOTPC         10
-+#define	R_386_TLS_TPOFF     14
-+#define	R_386_TLS_IE        15
-+#define	R_386_TLS_GOTIE     16
-+#define	R_386_TLS_LE        17
-+#define	R_386_TLS_GD        18
-+#define	R_386_TLS_LDM       19
-+#define	R_386_TLS_GD_32     24
-+#define	R_386_TLS_GD_PUSH   25
-+#define	R_386_TLS_GD_CALL   26
-+#define	R_386_TLS_GD_POP    27
-+#define	R_386_TLS_LDM_32    28
-+#define	R_386_TLS_LDM_PUSH  29
-+#define	R_386_TLS_LDM_CALL  30
-+#define	R_386_TLS_LDM_POP   31
-+#define	R_386_TLS_LDO_32    32
-+#define	R_386_TLS_IE_32     33
-+#define	R_386_TLS_LE_32     34
-+#define	R_386_TLS_DTPMOD32  35
-+#define	R_386_TLS_DTPOFF32  36
-+#define	R_386_TLS_TPOFF32   37
-+#define	R_386_TLS_GOTDESC   39
-+#define	R_386_TLS_DESC_CALL 40
-+#define	R_386_TLS_DESC      41
-+#define	R_386_IRELATIVE     42
-+#define	R_386_GOT32X        43
- 
- #define	R_PPC_NONE		0	/* No relocation. */
- #define	R_PPC_ADDR32		1
---- a/src/cmd/ld/ldelf.c	2015-09-23 06:20:05.000000000 +0200
-+++ b/src/cmd/ld/ldelf.c	2016-03-10 21:00:29.033083211 +0100
-@@ -888,12 +888,15 @@
- 	case R('6', R_X86_64_PC32):
- 	case R('6', R_X86_64_PLT32):
- 	case R('6', R_X86_64_GOTPCREL):
-+	case R('6', R_X86_64_GOTPCRELX):
-+	case R('6', R_X86_64_REX_GOTPCRELX):
- 	case R('8', R_386_32):
- 	case R('8', R_386_PC32):
- 	case R('8', R_386_GOT32):
- 	case R('8', R_386_PLT32):
- 	case R('8', R_386_GOTOFF):
- 	case R('8', R_386_GOTPC):
-+	case R('8', R_386_GOT32X):
- 		*siz = 4;
- 		break;
- 	case R('6', R_X86_64_64):
diff --git a/pkgs/development/compilers/go/remove-tools-1.5.patch b/pkgs/development/compilers/go/remove-tools-1.5.patch
deleted file mode 100644
index 5aad4b4abc3f..000000000000
--- a/pkgs/development/compilers/go/remove-tools-1.5.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
-index 61e3d8d..b8422ad 100644
---- a/src/cmd/go/pkg.go
-+++ b/src/cmd/go/pkg.go
-@@ -678,7 +678,7 @@ var goTools = map[string]targetDir{
- 	"cmd/trace":                            toTool,
- 	"cmd/vet":                              toTool,
- 	"cmd/yacc":                             toTool,
--	"golang.org/x/tools/cmd/godoc":         toBin,
-+	"nixos.org/x/tools/cmd/godoc":          toBin,
- 	"code.google.com/p/go.tools/cmd/cover": stalePath,
- 	"code.google.com/p/go.tools/cmd/godoc": stalePath,
- 	"code.google.com/p/go.tools/cmd/vet":   stalePath,
-diff --git a/src/go/build/build.go b/src/go/build/build.go
-index 496fe11..8c81dbd 100644
---- a/src/go/build/build.go
-+++ b/src/go/build/build.go
-@@ -1388,7 +1388,7 @@ func init() {
- }
- 
- // ToolDir is the directory containing build tools.
--var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
-+var ToolDir = runtime.GOTOOLDIR()
- 
- // IsLocalImport reports whether the import path is
- // a local import path, like ".", "..", "./foo", or "../foo".
-diff --git a/src/runtime/extern.go b/src/runtime/extern.go
-index d346362..fb22b6e 100644
---- a/src/runtime/extern.go
-+++ b/src/runtime/extern.go
-@@ -194,6 +194,17 @@ func GOROOT() string {
- 	return defaultGoroot
- }
- 
-+// GOTOOLDIR returns the root of the Go tree.
-+// It uses the GOTOOLDIR environment variable, if set,
-+// or else the root used during the Go build.
-+func GOTOOLDIR() string {
-+	s := gogetenv("GOTOOLDIR")
-+	if s != "" {
-+		return s
-+	}
-+	return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
-+}
-+
- // Version returns the Go tree's version string.
- // It is either the commit hash and date at the time of the build or,
- // when possible, a release tag like "go1.3".
diff --git a/pkgs/development/compilers/go/remove-tools-1.7.patch b/pkgs/development/compilers/go/remove-tools-1.7.patch
deleted file mode 100644
index b53e48e1a515..000000000000
--- a/pkgs/development/compilers/go/remove-tools-1.7.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff --git a/src/go/build/build.go b/src/go/build/build.go
-index 9706b8b..f250751 100644
---- a/src/go/build/build.go
-+++ b/src/go/build/build.go
-@@ -1513,7 +1513,7 @@ func init() {
- }
- 
- // ToolDir is the directory containing build tools.
--var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
-+var ToolDir = runtime.GOTOOLDIR()
- 
- // IsLocalImport reports whether the import path is
- // a local import path, like ".", "..", "./foo", or "../foo".
-diff --git a/src/runtime/extern.go b/src/runtime/extern.go
-index 441dcd9..a50277e 100644
---- a/src/runtime/extern.go
-+++ b/src/runtime/extern.go
-@@ -230,6 +230,17 @@ func GOROOT() string {
- 	return sys.DefaultGoroot
- }
- 
-+// GOTOOLDIR returns the root of the Go tree.
-+// It uses the GOTOOLDIR environment variable, if set,
-+// or else the root used during the Go build.
-+func GOTOOLDIR() string {
-+	s := gogetenv("GOTOOLDIR")
-+	if s != "" {
-+		return s
-+	}
-+	return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
-+}
-+
- // Version returns the Go tree's version string.
- // It is either the commit hash and date at the time of the build or,
- // when possible, a release tag like "go1.3".
diff --git a/pkgs/development/compilers/go/strip.patch b/pkgs/development/compilers/go/strip.patch
deleted file mode 100644
index 7b036802d51c..000000000000
--- a/pkgs/development/compilers/go/strip.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
-index 0b14725..a7608ce 100644
---- a/src/cmd/go/build.go
-+++ b/src/cmd/go/build.go
-@@ -2310,6 +2310,7 @@ func (gcToolchain) ld(b *builder, root *action, out string, allactions []*action
- 		}
- 	}
- 	var ldflags []string
-+	ldflags = append(ldflags, "-s")
- 	if buildContext.InstallSuffix != "" {
- 		ldflags = append(ldflags, "-installsuffix", buildContext.InstallSuffix)
- 	}
diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix
index c6b4913c6236..a420949711e0 100644
--- a/pkgs/development/compilers/haxe/default.nix
+++ b/pkgs/development/compilers/haxe/default.nix
@@ -72,8 +72,8 @@ in {
     '';
   };
   haxe_3_4 = generic {
-    version = "3.4.4";
-    sha256 = "057psarsmz8q2y9pqv5221vpdya241gcy8xnl2wg9wyscn6z1lx6";
+    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 -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 a66b2264f073..1cb28118ccbe 100644
--- a/pkgs/development/compilers/hhvm/default.nix
+++ b/pkgs/development/compilers/hhvm/default.nix
@@ -53,6 +53,7 @@ stdenv.mkDerivation rec {
       hphp/runtime/ext/std/*.cpp \
       hphp/runtime/ext_zend_compat/php-src/main/*.cpp \
       hphp/runtime/ext_zend_compat/php-src/main/*.h
+    sed '1i#include <functional>' -i third-party/mcrouter/src/mcrouter/lib/cycles/Cycles.h
     patchShebangs .
   '';
 
diff --git a/pkgs/development/compilers/jwasm/default.nix b/pkgs/development/compilers/jwasm/default.nix
new file mode 100644
index 000000000000..9800b33e7a9e
--- /dev/null
+++ b/pkgs/development/compilers/jwasm/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub
+, cmake }:
+
+with stdenv.lib;
+stdenv.mkDerivation rec {
+  name = "jwasm-${version}";
+  version = "git-2017-11-22";
+
+  src = fetchFromGitHub {
+    owner = "JWasm";
+    repo  = "JWasm";
+    rev    = "26f97c8b5c9d9341ec45538701116fa3649b7766";
+    sha256 = "0m972pc8vk8s9yv1pi85fsjgm6hj24gab7nalw2q04l0359nqi7w";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  installPhase = "mkdir -p $out/bin ; cp jwasm $out/bin/";
+
+  meta = {
+    description = "A MASM-compatible x86 assembler";
+    homepage = http://jwasm.github.io/;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.darwin ++ platforms.linux;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix
index 77863ab4f1ea..5531fd2ab77e 100644
--- a/pkgs/development/compilers/llvm/4/clang/default.nix
+++ b/pkgs/development/compilers/llvm/4/clang/default.nix
@@ -43,6 +43,8 @@ let
 
       # 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/Tools.cpp
     '';
 
     outputs = [ "out" "lib" "python" ];
diff --git a/pkgs/development/compilers/llvm/4/dynamiclibrary-musl.patch b/pkgs/development/compilers/llvm/4/dynamiclibrary-musl.patch
new file mode 100644
index 000000000000..d5d7f07b5e11
--- /dev/null
+++ b/pkgs/development/compilers/llvm/4/dynamiclibrary-musl.patch
@@ -0,0 +1,33 @@
+From d12ecb83d01dcb580dd94f4d57828f33d3eb4c35 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 15:33:21 +0100
+Subject: [PATCH 3/3] Fix DynamicLibrary to build with musl libc
+
+stdin/out/err is part of the libc and not the kernel so we check for the
+specific libc that does the unexpected instead of linux.
+
+This is needed for making it build with musl libc.
+---
+ lib/Support/DynamicLibrary.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
+index 9a7aeb5..0c1c8f8 100644
+--- a/lib/Support/DynamicLibrary.cpp
++++ b/lib/Support/DynamicLibrary.cpp
+@@ -140,10 +140,10 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
+ #define EXPLICIT_SYMBOL(SYM) \
+    if (!strcmp(symbolName, #SYM)) return &SYM
+ 
+-// On linux we have a weird situation. The stderr/out/in symbols are both
++// On GNU libc we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+ // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
+-#if defined(__linux__) and !defined(__ANDROID__)
++#if defined(__GLIBC__)
+   {
+     EXPLICIT_SYMBOL(stderr);
+     EXPLICIT_SYMBOL(stdout);
+-- 
+2.7.3
+
diff --git a/pkgs/development/compilers/llvm/4/libc++/default.nix b/pkgs/development/compilers/llvm/4/libc++/default.nix
index db751bcffd42..f28957c35185 100644
--- a/pkgs/development/compilers/llvm/4/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/4/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }:
+{ lib, stdenv, fetch, cmake, python, llvm, libcxxabi, fixDarwinDylibNames, version }:
 
 stdenv.mkDerivation rec {
   name = "libc++-${version}";
@@ -15,6 +15,9 @@ stdenv.mkDerivation rec {
     ./pthread_mach_thread_np.patch
     # glibc 2.26 fix
     ./xlocale-glibc-2.26.patch
+  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+    ../../libcxx-0001-musl-hacks.patch
+    ./max_align_t.patch
   ];
 
   prePatch = ''
@@ -24,9 +27,10 @@ stdenv.mkDerivation rec {
   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 ];
+  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
@@ -34,7 +38,7 @@ stdenv.mkDerivation rec {
     "-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;
 
diff --git a/pkgs/development/compilers/llvm/4/libc++/max_align_t.patch b/pkgs/development/compilers/llvm/4/libc++/max_align_t.patch
new file mode 100644
index 000000000000..060be5b23de8
--- /dev/null
+++ b/pkgs/development/compilers/llvm/4/libc++/max_align_t.patch
@@ -0,0 +1,54 @@
+From 917331c88bd2afce0cf0fdbcab55a64541b5bcf0 Mon Sep 17 00:00:00 2001
+From: "David L. Jones" <dlj@google.com>
+Date: Fri, 10 Feb 2017 01:27:42 +0000
+Subject: [PATCH] Check for musl-libc's max_align_t in addition to other
+ variants.
+
+Summary:
+Libcxx will define its own max_align_t when it is not available. However, the
+availability checks today only check for Clang's definition and GCC's
+definition. In particular, it does not check for musl's definition, which is the
+same as GCC's but guarded with a different macro.
+
+Reviewers: mclow.lists, EricWF
+
+Reviewed By: EricWF
+
+Subscribers: chandlerc, cfe-commits
+
+Differential Revision: https://reviews.llvm.org/D28478
+
+git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294683 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ include/cstddef  | 3 ++-
+ include/stddef.h | 3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/include/cstddef b/include/cstddef
+index edd106c00..103898b7d 100644
+--- a/include/cstddef
++++ b/include/cstddef
+@@ -48,7 +48,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
+ using ::ptrdiff_t;
+ using ::size_t;
+ 
+-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
++#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
++    defined(__DEFINED_max_align_t)
+ // Re-use the compiler's <stddef.h> max_align_t where possible.
+ using ::max_align_t;
+ #else
+diff --git a/include/stddef.h b/include/stddef.h
+index 8841bbea2..faf8552d8 100644
+--- a/include/stddef.h
++++ b/include/stddef.h
+@@ -53,7 +53,8 @@ using std::nullptr_t;
+ }
+ 
+ // Re-use the compiler's <stddef.h> max_align_t where possible.
+-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T)
++#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
++    !defined(__DEFINED_max_align_t)
+ typedef long double max_align_t;
+ #endif
+ 
diff --git a/pkgs/development/compilers/llvm/4/libc++abi.nix b/pkgs/development/compilers/llvm/4/libc++abi.nix
index 6a3d91101360..41eb40e124eb 100644
--- a/pkgs/development/compilers/llvm/4/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/4/libc++abi.nix
@@ -14,6 +14,9 @@ stdenv.mkDerivation {
     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}
+    patch -p1 -d $(ls -d libcxx-*) -i ${./libc++/max_align_t.patch}
   '';
 
   installPhase = if stdenv.isDarwin
diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix
index 17a25889e64f..7fd94316d738 100644
--- a/pkgs/development/compilers/llvm/4/llvm.nix
+++ b/pkgs/development/compilers/llvm/4/llvm.nix
@@ -65,7 +65,7 @@ in stdenv.mkDerivation (rec {
     substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
     patch -p1 < ./llvm-outputs.patch
   ''
-  + stdenv.lib.optionalString (stdenv ? glibc) ''
+  + ''
     (
       cd projects/compiler-rt
       patch -p1 < ${
@@ -80,6 +80,9 @@ in stdenv.mkDerivation (rec {
     )
   '' + 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}
   '';
 
   # hacky fix: created binaries need to be run before installation
@@ -110,6 +113,14 @@ in stdenv.mkDerivation (rec {
   ++ 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}"
+
+    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+    "-DCOMPILER_RT_BUILD_XRAY=OFF"
   ];
 
   postBuild = ''
diff --git a/pkgs/development/compilers/llvm/5/clang/default.nix b/pkgs/development/compilers/llvm/5/clang/default.nix
index c8eafce4e396..b5aea54b5771 100644
--- a/pkgs/development/compilers/llvm/5/clang/default.nix
+++ b/pkgs/development/compilers/llvm/5/clang/default.nix
@@ -44,6 +44,8 @@ let
 
       # 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" ];
diff --git a/pkgs/development/compilers/llvm/5/libc++/default.nix b/pkgs/development/compilers/llvm/5/libc++/default.nix
index 6f03e225ad65..9ddeea7ef79a 100644
--- a/pkgs/development/compilers/llvm/5/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/5/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }:
+{ lib, stdenv, fetch, cmake, python, llvm, libcxxabi, fixDarwinDylibNames, version }:
 
 stdenv.mkDerivation rec {
   name = "libc++-${version}";
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
     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++"
   '';
@@ -17,9 +23,10 @@ stdenv.mkDerivation rec {
   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 ];
+  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
@@ -27,7 +34,7 @@ stdenv.mkDerivation rec {
     "-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;
 
diff --git a/pkgs/development/compilers/llvm/5/libc++abi.nix b/pkgs/development/compilers/llvm/5/libc++abi.nix
index 166f4260291f..6d27dcd47b0b 100644
--- a/pkgs/development/compilers/llvm/5/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/5/libc++abi.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation {
     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
diff --git a/pkgs/development/compilers/llvm/5/llvm.nix b/pkgs/development/compilers/llvm/5/llvm.nix
index 1f55e6c54e7d..f574eb05f92b 100644
--- a/pkgs/development/compilers/llvm/5/llvm.nix
+++ b/pkgs/development/compilers/llvm/5/llvm.nix
@@ -36,7 +36,7 @@ in stdenv.mkDerivation (rec {
     mv compiler-rt-* $sourceRoot/projects/compiler-rt
   '';
 
-  outputs = [ "out" ]
+  outputs = [ "out" "python" ]
     ++ stdenv.lib.optional enableSharedLibraries "lib";
 
   nativeBuildInputs = [ cmake python ]
@@ -74,6 +74,11 @@ in stdenv.mkDerivation (rec {
     patch -p1 -i ${./compiler-rt-codesign.patch} -d projects/compiler-rt
   '' + stdenv.lib.optionalString stdenv.isAarch64 ''
     patch -p0 < ${../aarch64.patch}
+  '' + 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
   '';
 
   # hacky fix: created binaries need to be run before installation
@@ -104,6 +109,14 @@ in stdenv.mkDerivation (rec {
   ++ 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}"
+
+    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+    "-DCOMPILER_RT_BUILD_XRAY=OFF"
   ];
 
   postBuild = ''
@@ -120,7 +133,11 @@ in stdenv.mkDerivation (rec {
     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
   '';
 
-  postInstall = stdenv.lib.optionalString enableSharedLibraries ''
+  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" \
diff --git a/pkgs/development/compilers/llvm/TLI-musl.patch b/pkgs/development/compilers/llvm/TLI-musl.patch
new file mode 100644
index 000000000000..1a6908086637
--- /dev/null
+++ b/pkgs/development/compilers/llvm/TLI-musl.patch
@@ -0,0 +1,35 @@
+From 5c571082fdaf61f6df19d9b7137dc26d71334058 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 10:33:04 +0100
+Subject: [PATCH 2/3] Fix build with musl libc
+
+On musl libc the fopen64 and fopen are the same thing, but for
+compatibility they have a `#define fopen64 fopen`. Same applies for
+fseek64, fstat64, fstatvfs64, ftello64, lstat64, stat64 and tmpfile64.
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 7becdf0..7f14427 100644
+--- a/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/Module.h"
+ #include "llvm/Pass.h"
+ 
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ /// VecDesc - Describes a possible vectorization of a function.
+ /// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
+-- 
+2.7.3
+
diff --git a/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch b/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch
new file mode 100644
index 000000000000..bcb5ad8cfb87
--- /dev/null
+++ b/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch
@@ -0,0 +1,39 @@
+From 1c936d7fda3275265e37f93697232a1ed652390f Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Sat, 9 Jul 2016 19:22:54 -0500
+Subject: [PATCH] musl fixes/hacks
+
+Conflicts:
+
+	include/__config
+	include/locale
+	src/locale.cpp
+---
+ include/locale |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/locale b/include/locale
+index 3d804e8..9b01f5b 100644
+--- a/include/locale
++++ b/include/locale
+@@ -695,7 +695,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
+         typename remove_reference<decltype(errno)>::type __save_errno = errno;
+         errno = 0;
+         char *__p2;
+-        long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++        long long __ll = strtoll(__a, &__p2, __base);
+         typename remove_reference<decltype(errno)>::type __current_errno = errno;
+         if (__current_errno == 0)
+             errno = __save_errno;
+@@ -735,7 +735,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
+         typename remove_reference<decltype(errno)>::type __save_errno = errno;
+         errno = 0;
+         char *__p2;
+-        unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++        unsigned long long __ll = strtoull(__a, &__p2, __base);
+         typename remove_reference<decltype(errno)>::type __current_errno = errno;
+         if (__current_errno == 0)
+             errno = __save_errno;
+-- 
+1.7.1
+
diff --git a/pkgs/development/compilers/mono/5.8.nix b/pkgs/development/compilers/mono/5.8.nix
new file mode 100644
index 000000000000..6db9e19807bb
--- /dev/null
+++ b/pkgs/development/compilers/mono/5.8.nix
@@ -0,0 +1,8 @@
+{ stdenv, callPackage, Foundation, libobjc }:
+
+callPackage ./generic-cmake.nix (rec {
+  inherit Foundation libobjc;
+  version = "5.8.0.108";
+  sha256 = "177khb06dfll0pcncr84vvibni7f8m5fgb30ndgsdjk25xfcbmzc";
+  enableParallelBuilding = false;
+})
diff --git a/pkgs/development/compilers/openjdk/7.nix b/pkgs/development/compilers/openjdk/7.nix
index 372bb1532698..13f8bcfdb1de 100644
--- a/pkgs/development/compilers/openjdk/7.nix
+++ b/pkgs/development/compilers/openjdk/7.nix
@@ -69,7 +69,10 @@ let
         fontconfig perl file bootjdk
       ];
 
-    NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
+    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";
 
diff --git a/pkgs/development/compilers/purescript/psc-package/default.nix b/pkgs/development/compilers/purescript/psc-package/default.nix
index 5e298dbf2cee..451722aea060 100644
--- a/pkgs/development/compilers/purescript/psc-package/default.nix
+++ b/pkgs/development/compilers/purescript/psc-package/default.nix
@@ -22,5 +22,5 @@ mkDerivation rec {
 
   description = "An experimental package manager for PureScript";
   license = licenses.bsd3;
-  maintainers = with lib.maintainers; [ profpatsch ];
+  maintainers = with lib.maintainers; [ Profpatsch ];
 }
diff --git a/pkgs/development/compilers/rust/binaryBuild.nix b/pkgs/development/compilers/rust/binaryBuild.nix
index 6c6f6b55e1e6..1904c12dfdc1 100644
--- a/pkgs/development/compilers/rust/binaryBuild.nix
+++ b/pkgs/development/compilers/rust/binaryBuild.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl, darwin
+{ stdenv, fetchurl, makeWrapper, bash, cacert, zlib, buildRustPackage, curl, darwin
 , version
 , src
 , platform
@@ -34,9 +34,11 @@ rec {
       license = [ licenses.mit licenses.asl20 ];
     };
 
-    phases = ["unpackPhase" "installPhase" "fixupPhase"];
+    buildInputs = [ bash ] ++ stdenv.lib.optional stdenv.isDarwin Security;
 
-    buildInputs = stdenv.lib.optional stdenv.isDarwin Security;
+    postPatch = ''
+      patchShebangs .
+    '';
 
     installPhase = ''
       ./install.sh --prefix=$out \
@@ -86,9 +88,11 @@ rec {
       license = [ licenses.mit licenses.asl20 ];
     };
 
-    phases = ["unpackPhase" "installPhase" "fixupPhase"];
+    buildInputs = [ makeWrapper bash ] ++ stdenv.lib.optional stdenv.isDarwin Security;
 
-    buildInputs = [ makeWrapper ] ++ stdenv.lib.optional stdenv.isDarwin Security;
+    postPatch = ''
+      patchShebangs .
+    '';
 
     installPhase = ''
       patchShebangs ./install.sh
diff --git a/pkgs/development/compilers/rust/bootstrap.nix b/pkgs/development/compilers/rust/bootstrap.nix
index 034334f58500..9b488bab5b3b 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.21.0";
+  version = "1.23.0";
 
-  # fetch hashes by running `print-hashes.sh 1.21.0`
+  # fetch hashes by running `print-hashes.sh 1.23.0`
   hashes = {
-    i686-unknown-linux-gnu = "b7caed0f602cdb8ef22e0bfa9125a65bec411e15c0b8901d937e43303ec7dbee";
-    x86_64-unknown-linux-gnu = "b41e70e018402bc04d02fde82f91bea24428e6be432f0df12ac400cfb03108e8";
-    armv7-unknown-linux-gnueabihf = "416fa6f107ad9e386002e6af1aec495472e2ee489c842183dd429a25b07488d6";
-    aarch64-unknown-linux-gnu = "491ee6c43cc672006968d665bd34c94cc2219ef3592d93d38097c97eaaa864c3";
-    i686-apple-darwin = "c8b0fabeebcde66b683f3a871187e614e07305adda414c2862cb332aecb2b3bf";
-    x86_64-apple-darwin = "75a7f4bd7c72948030bb9e421df27e8a650dea826fb5b836cf59d23d6f985a0d";
+    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";
   };
 
   platform =
diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix
index 4c397c8c1a48..46caabf33917 100644
--- a/pkgs/development/compilers/rust/cargo.nix
+++ b/pkgs/development/compilers/rust/cargo.nix
@@ -1,7 +1,8 @@
 { stdenv, fetchFromGitHub, file, curl, pkgconfig, python, openssl, cmake, zlib
 , makeWrapper, libiconv, cacert, rustPlatform, rustc, libgit2, darwin
-, version, srcSha, cargoSha256
-, patches ? [] }:
+, version
+, patches ? []
+, src }:
 
 let
   inherit (darwin.apple_sdk.frameworks) CoreFoundation;
@@ -9,20 +10,18 @@ in
 
 rustPlatform.buildRustPackage rec {
   name = "cargo-${version}";
-  inherit version;
+  inherit version src patches;
 
-  src = fetchFromGitHub {
-    owner  = "rust-lang";
-    repo   = "cargo";
-    rev    = version;
-    sha256 = srcSha;
-  };
-
-  inherit cargoSha256;
-  inherit patches;
+  # the rust source tarball already has all the dependencies vendored, no need to fetch them again
+  cargoVendorDir = "src/vendor";
+  preBuild = "cd src; pushd tools/cargo";
+  postBuild = "popd";
 
   passthru.rustc = rustc;
 
+  # changes hash of vendor directory otherwise on aarch64
+  dontUpdateAutotoolsGnuConfigScripts = if stdenv.isAarch64 then "1" else null;
+
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ cacert file curl python openssl cmake zlib makeWrapper libgit2 ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation libiconv ];
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix
index b5550a96a835..dd15580c11b8 100644
--- a/pkgs/development/compilers/rust/default.nix
+++ b/pkgs/development/compilers/rust/default.nix
@@ -6,21 +6,20 @@
 
 let
   rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}));
-  version = "1.22.1";
-in
-rec {
+  version = "1.24.0";
+  cargoVersion = "0.24.0";
+  src = fetchurl {
+    url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
+    sha256 = "17v3jpyky8vkkgai5yd2zr8zl87qpgj6dx99gx27x1sf0kv7d0mv";
+  };
+in rec {
   rustc = callPackage ./rustc.nix {
-    inherit llvm targets targetPatches targetToolchains rustPlatform version;
+    inherit stdenv llvm targets targetPatches targetToolchains rustPlatform version src;
 
     forceBundledLLVM = true;
 
     configureFlags = [ "--release-channel=stable" ];
 
-    src = fetchurl {
-      url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
-      sha256 = "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb";
-    };
-
     patches = [
       ./patches/0001-Disable-fragile-tests-libstd-net-tcp-on-Darwin-Linux.patch
     ] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch
@@ -30,10 +29,9 @@ rec {
   };
 
   cargo = callPackage ./cargo.nix rec {
-    version = "0.23.0";
-    srcSha = "14b2n1msxma19ydchj54hd7f2zdsr524fg133dkmdn7j65f1x6aj";
-    cargoSha256 = "1sj59z0w172qvjwg1ma5fr5am9dgw27086xwdnrvlrk4hffcr7y7";
-
+    version = cargoVersion;
+    inherit src;
+    inherit stdenv;
     inherit rustc; # the rustc that will be wrapped by cargo
     inherit rustPlatform; # used to build cargo
   };
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
index d29eb16cfe55..bafab0e9ef71 100644
--- a/pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch
+++ b/pkgs/development/compilers/rust/patches/aarch64-disable-test_loading_cosine.patch
@@ -1,7 +1,7 @@
-diff --git a/src/librustc_back/dynamic_lib.rs b/src/librustc_back/dynamic_lib.rs
+diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs
 index 1b42fa0..92256dc 100644
---- a/src/librustc_back/dynamic_lib.rs
-+++ b/src/librustc_back/dynamic_lib.rs
+--- a/src/librustc_metadata/dynamic_lib.rs
++++ b/src/librustc_metadata/dynamic_lib.rs
 @@ -80,6 +80,7 @@ mod tests {
      use std::mem;
  
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index 9d6f641bc46c..92b149865fa2 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -57,9 +57,9 @@ stdenv.mkDerivation {
   # We need rust to build rust. If we don't provide it, configure will try to download it.
   configureFlags = configureFlags
                 ++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
-                ++ [ "--enable-vendor" "--disable-locked-deps" ]
+                ++ [ "--enable-vendor" ]
                 # ++ [ "--jemalloc-root=${jemalloc}/lib"
-                ++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" "--default-ar=${targetPackages.stdenv.cc.bintools}/bin/ar" ]
+                ++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
                 ++ optional (!forceBundledLLVM) [ "--enable-llvm-link-shared" ]
                 ++ optional (targets != []) "--target=${target}"
                 ++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
@@ -72,6 +72,8 @@ stdenv.mkDerivation {
   passthru.target = target;
 
   postPatch = ''
+    patchShebangs src/etc
+
     # Fix dynamic linking against llvm
     #${optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
 
@@ -86,7 +88,7 @@ stdenv.mkDerivation {
 
     # Disable fragile tests.
     rm -vr src/test/run-make/linker-output-non-utf8 || true
-    rm -vr src/test/run-make/issue-26092.rs || true
+    rm -vr src/test/run-make/issue-26092 || true
 
     # Remove test targeted at LLVM 3.9 - https://github.com/rust-lang/rust/issues/36835
     rm -vr src/test/run-pass/issue-36023.rs || true
@@ -98,19 +100,6 @@ stdenv.mkDerivation {
     # On Hydra: `TcpListener::bind(&addr)`: Address already in use (os error 98)'
     sed '/^ *fn fast_rebind()/i#[ignore]' -i src/libstd/net/tcp.rs
 
-    # Disable some failing gdb tests. Try re-enabling these when gdb
-    # is updated past version 7.12.
-    rm src/test/debuginfo/basic-types-globals.rs
-    rm src/test/debuginfo/basic-types-mut-globals.rs
-    rm src/test/debuginfo/c-style-enum.rs
-    rm src/test/debuginfo/lexical-scopes-in-block-expression.rs
-    rm src/test/debuginfo/limited-debuginfo.rs
-    rm src/test/debuginfo/simple-struct.rs
-    rm src/test/debuginfo/simple-tuple.rs
-    rm src/test/debuginfo/union-smoke.rs
-    rm src/test/debuginfo/vec-slices.rs
-    rm src/test/debuginfo/vec.rs
-
     # Useful debugging parameter
     # export VERBOSE=1
   ''
diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix
index 54610467e7ae..39b84ae6a365 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.3";
+  version = "1.4.4";
 
   src = fetchurl {
     url    = "mirror://sourceforge/project/sbcl/sbcl/${version}/${name}-source.tar.bz2";
-    sha256 = "1z8d11k6vc6jhmpwzy0nawj84qdd2jvibrvqmb1nmq3h8w64hlam";
+    sha256 = "1k6v5b8qv7vyxvh8asx6phf2hbapx5pp5p5j47hgnq123fwnh4fa";
   };
 
   patchPhase = ''
diff --git a/pkgs/development/compilers/scala/dotty-bare.nix b/pkgs/development/compilers/scala/dotty-bare.nix
index 60cb3e9a2029..bff73337e9e8 100644
--- a/pkgs/development/compilers/scala/dotty-bare.nix
+++ b/pkgs/development/compilers/scala/dotty-bare.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, makeWrapper, jre }:
 
 stdenv.mkDerivation rec {
-  version = "0.4.0-RC1";
+  version = "0.6.0-RC1";
   name = "dotty-bare-${version}";
 
   src = fetchurl {
     url = "https://github.com/lampepfl/dotty/releases/download/${version}/dotty-${version}.tar.gz";
-    sha256 = "1d1ab08b85bd6898ce6273fa50818de0d314fc6e5377fb6ee05494827043321b";
+    sha256 = "de1f5e72fb0e0b4c377d6cec93f565eff49769698cd8be01b420705fe8475ca4";
   };
 
   propagatedBuildInputs = [ jre ] ;
diff --git a/pkgs/development/compilers/solc/default.nix b/pkgs/development/compilers/solc/default.nix
index cd8c839cf4fe..4c79fb15c5cb 100644
--- a/pkgs/development/compilers/solc/default.nix
+++ b/pkgs/development/compilers/solc/default.nix
@@ -1,9 +1,7 @@
-{ stdenv, fetchzip, fetchgit, boost, cmake, z3 }:
+{ stdenv, fetchzip, fetchurl, boost, cmake, z3 }:
 
 let
-  version = "0.4.19";
-  rev = "c4cbbb054b5ed3b8ceaa21ee5b47b0704762ff40";
-  sha256 = "1h2ziwdswghj4aa3vd3k3y2ckfiwjk6x38w2kp4m324k2ydxd15c";
+  version = "0.4.20";
   jsoncppURL = https://github.com/open-source-parsers/jsoncpp/archive/1.7.7.tar.gz;
   jsoncpp = fetchzip {
     url = jsoncppURL;
@@ -15,14 +13,12 @@ stdenv.mkDerivation {
   name = "solc-${version}";
 
   # Cannot use `fetchFromGitHub' because of submodules
-  src = fetchgit {
-    url = "https://github.com/ethereum/solidity";
-    inherit rev sha256;
+  src = fetchurl {
+    url = "https://github.com/ethereum/solidity/releases/download/v${version}/solidity_${version}.tar.gz";
+    sha256 = "0jyqnykj537ksfsf2m6ww9vganmpa6yd5fmlfpa5qm1076kq7zd6";
   };
 
   patchPhase = ''
-    echo >commit_hash.txt '${rev}'
-    echo >prerelease.txt
     substituteInPlace cmake/jsoncpp.cmake \
       --replace '${jsoncppURL}' ${jsoncpp}
     substituteInPlace cmake/EthCompilerSettings.cmake \
diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix
index 937977b0a97d..360f96e12427 100644
--- a/pkgs/development/compilers/swift/default.nix
+++ b/pkgs/development/compilers/swift/default.nix
@@ -12,7 +12,6 @@
 , swig
 , bash
 , libxml2
-, llvm
 , clang
 , python
 , ncurses
@@ -28,13 +27,17 @@
 , git
 , libgit2
 , fetchFromGitHub
+, fetchpatch
 , paxctl
 , findutils
+, makeWrapper
+, gnumake
+, file
 #, systemtap
 }:
 
 let
-  v_major = "3.1.1";
+  v_major = "4.0.3";
   version = "${v_major}-RELEASE";
   version_friendly = "${v_major}";
 
@@ -47,53 +50,53 @@ let
       name = "${repo}-${version}-src";
     };
 
-sources = {
+  sources = {
     # FYI: SourceKit probably would work but currently requires building everything twice
     # For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759
     clang = fetch {
       repo = "swift-clang";
-      sha256 = "1gmdgr8jph87nya8cgdl7iwrggbji2sag996m27hkbszw4nxy8sd";
+      sha256 = "0zm624iwiprk3c3nzqf4p1fd9zqic4yi3jv51cw3249ax4x6vy10";
     };
     llvm = fetch {
       repo = "swift-llvm";
-      sha256 = "0nwd7cp6mbj7f6a2rx8123n7ygs8406hsx7hp7ybagww6v75bwzi";
+      sha256 = "11vw6461c0cdvwm1wna1a5709fjj14hzp6br6jg94p4f6jp3yv4d";
     };
     compilerrt = fetch {
       repo = "swift-compiler-rt";
-      sha256 = "1gjcr6g3ffs3nhf4a84iwg4flbd7rqcf9rvvclwyq96msa3mj950";
+      sha256 = "1hj4qaj4c9n2wzg2cvarbyl0n708zd1dlw4zkzq07fjxxqs36nfa";
     };
     cmark = fetch {
       repo = "swift-cmark";
-      sha256 = "0qf2f3zd8lndkfbxbz6vkznzz8rvq5gigijh7pgmfx9fi4zcssqx";
+      sha256 = "1nmxp0fj749sgar682c5nsj7zxxigqwg973baxj2r656a7ybh325";
     };
     lldb = fetch {
       repo = "swift-lldb";
-      sha256 = "17n4whpf3wxw9zaayiq21gk9q3547qxi4rvxld2hybh0k7a1bj5c";
+      sha256 = "0yk5qg85008vcn63vn2jpn5ls9pdhda222p2w1cfkrj27k5k8vqr";
     };
     llbuild = fetch {
       repo = "swift-llbuild";
-      sha256 = "1l3hnb2s01jby91k1ipbc3bhszq14vyx5pzdhf2chld1yhpg420d";
+      sha256 = "0jffw6z1s6ck1i05brw59x6vsg7zrxbz5n2wz72fj29rh3nppc7a";
     };
     pm = fetch {
       repo = "swift-package-manager";
-      sha256 = "1ayy5vk3mjk354pg9bf68wvnaj3jymx23w0qnlw1jxz256ff8fwi";
+      sha256 = "0xj070b8fii7ijfsnyq4fxgv6569vdrg0yippi85h2p1l7s9aagh";
     };
     xctest = fetch {
       repo = "swift-corelibs-xctest";
-      sha256 = "0cj5y7wanllfldag08ci567x12aw793c79afckpbsiaxmwy4xhnm";
+      sha256 = "0l355wq8zfwrpv044xf4smjwbm0bmib360748n8cwls3vkr9l2yv";
     };
     foundation = fetch {
       repo = "swift-corelibs-foundation";
-      sha256 = "1d1ldk7ckqn4mhmdhsx2zrmsd6jfxzgdywn2pki7limk979hcwjc";
+      sha256 = "0s7yc5gsbd96a4bs8c6q24dyfjm4xhcr2nzhl2ics8dmi60j15s4";
     };
     libdispatch = fetch {
       repo = "swift-corelibs-libdispatch";
-      sha256 = "0ckjg41fjak06i532azhryckjq64fkxzsal4svf5v4s8n9mkq2sg";
+      sha256 = "0x8zzq3shhvmhq4sbhaaa0ddiv3nw347pz6ayym6jyzq7j9n15ia";
       fetchSubmodules = true;
     };
     swift = fetch {
       repo = "swift";
-      sha256 = "0879jlv37lmxc1apzi53xn033y72548i86r7fzwr0g52124q5gry";
+      sha256 = "0a1gq0k5701i418f0qi7kywv16q7vh4a4wp0f6fpyv4sjkq27msx";
     };
   };
 
@@ -119,6 +122,9 @@ sources = {
   ];
 
   builder = ''
+    # gcc-6.4.0/include/c++/6.4.0/cstdlib:75:15: fatal error: 'stdlib.h' file not found
+    NIX_CFLAGS_COMPILE="$( echo ${clang.default_cxx_stdlib_compile} ) $NIX_CFLAGS_COMPILE"
+
     $SWIFT_SOURCE_ROOT/swift/utils/build-script \
       --preset=buildbot_linux \
       installable_package=$INSTALLABLE_PACKAGE \
@@ -126,6 +132,20 @@ sources = {
       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}";
@@ -145,6 +165,8 @@ stdenv.mkDerivation rec {
     rsync
     which
     findutils
+    makeWrapper
+    gnumake
   ] ++ stdenv.lib.optional stdenv.needsPax paxctl;
 
   # TODO: Revisit what's propagated and how
@@ -198,6 +220,14 @@ stdenv.mkDerivation rec {
     # Just patch all the things for now, we can focus this later
     patchShebangs $SWIFT_SOURCE_ROOT
 
+    # TODO eliminate use of env.
+    find -type f -print0 | xargs -0 sed -i \
+      -e 's|/usr/bin/env|${coreutils}/bin/env|g' \
+      -e 's|/usr/bin/make|${gnumake}/bin/make|g' \
+      -e 's|/bin/mkdir|${coreutils}/bin/mkdir|g' \
+      -e 's|/bin/cp|${coreutils}/bin/cp|g' \
+      -e 's|/usr/bin/file|${file}/bin/file|g'
+
     substituteInPlace swift/stdlib/public/Platform/CMakeLists.txt \
       --replace '/usr/include' "${stdenv.cc.libc.dev}/include"
     substituteInPlace swift/utils/build-script-impl \
@@ -209,6 +239,13 @@ stdenv.mkDerivation rec {
     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}
+
+    # 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
 
     substituteInPlace clang/lib/Driver/ToolChains.cpp \
       --replace '  addPathIfExists(D, SysRoot + "/usr/lib", Paths);' \
@@ -217,21 +254,21 @@ stdenv.mkDerivation rec {
 
     # Workaround hardcoded dep on "libcurses" (vs "libncurses"):
     sed -i 's,curses,ncurses,' llbuild/*/*/CMakeLists.txt
-    substituteInPlace llbuild/tests/BuildSystem/Build/basic.llbuild \
-      --replace /usr/bin/env $(type -p env)
 
     # This test fails on one of my machines, not sure why.
     # Disabling for now. 
     rm llbuild/tests/Examples/buildsystem-capi.llbuild
 
-    substituteInPlace swift-corelibs-foundation/lib/script.py \
-      --replace /bin/cp $(type -p cp)
-
     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}
   '';
 
   doCheck = false;
@@ -251,6 +288,10 @@ stdenv.mkDerivation rec {
     # TODO: Use wrappers to get these on the PATH for swift tools, instead
     ln -s ${clang}/bin/* $out/bin/
     ln -s ${targetPackages.stdenv.cc.bintools}/bin/ar $out/bin/ar
+
+    wrapProgram $out/bin/swift \
+      --suffix C_INCLUDE_PATH : $out/lib/swift/clang/include \
+      --suffix CPLUS_INCLUDE_PATH : $out/lib/swift/clang/include
   '';
 
   # Hack to avoid TMPDIR in RPATHs.
@@ -263,7 +304,6 @@ stdenv.mkDerivation rec {
     license = licenses.asl20;
     # Swift doesn't support 32bit Linux, unknown on other platforms.
     platforms = [ "x86_64-linux" ];
-    broken = true;
   };
 }
 
diff --git a/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch b/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch
index 0e18e8812a84..66723f1cdf39 100644
--- a/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch
+++ b/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch
@@ -11,13 +11,13 @@ diff --git a/utils/build-presets.ini b/utils/build-presets.ini
 index e6b0af3581..1095cbaab7 100644
 --- a/utils/build-presets.ini
 +++ b/utils/build-presets.ini
-@@ -692,7 +692,7 @@ install-lldb
+@@ -708,7 +708,7 @@ install-lldb
  install-llbuild
  install-swiftpm
  install-xctest
 -install-prefix=/usr
 +install-prefix=%(install_prefix)s
- swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license
+ swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
  build-swift-static-stdlib
  build-swift-static-sdk-overlay
 -- 
diff --git a/pkgs/development/compilers/swift/patches/icu59.patch b/pkgs/development/compilers/swift/patches/icu59.patch
new file mode 100644
index 000000000000..26337814cafa
--- /dev/null
+++ b/pkgs/development/compilers/swift/patches/icu59.patch
@@ -0,0 +1,113 @@
+--- 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
new file mode 100644
index 000000000000..8ef7e3916962
--- /dev/null
+++ b/pkgs/development/compilers/swift/patches/remove_xlocale.patch
@@ -0,0 +1,54 @@
+--- 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
new file mode 100644
index 000000000000..c529fa3777b3
--- /dev/null
+++ b/pkgs/development/compilers/swift/patches/sigaltstack.patch
@@ -0,0 +1,11 @@
+--- 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
new file mode 100644
index 000000000000..2701d1a3ae25
--- /dev/null
+++ b/pkgs/development/compilers/swift/patches/sigunused.patch
@@ -0,0 +1,11 @@
+--- 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/yap/default.nix b/pkgs/development/compilers/yap/default.nix
index 8e37dc76441b..d93da8cb9965 100644
--- a/pkgs/development/compilers/yap/default.nix
+++ b/pkgs/development/compilers/yap/default.nix
@@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
 
   configureFlags = "--enable-tabling=yes";
 
+  NIX_CFLAGS_COMPILE = [ "-fpermissive" ];
+
   meta = {
     homepage = http://www.dcc.fc.up.pt/~vsc/Yap/;
     description = "A ISO-compatible high-performance Prolog compiler";
diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix
index eb96acafb9e1..063fd71c0433 100644
--- a/pkgs/development/compilers/yosys/default.nix
+++ b/pkgs/development/compilers/yosys/default.nix
@@ -2,18 +2,24 @@
 , pkgconfig, tcl, readline, libffi, python3, bison, flex
 }:
 
+with builtins;
+
 stdenv.mkDerivation rec {
   name = "yosys-${version}";
-  version = "2018.02.04";
+  version = "2018.02.14";
 
   srcs = [
     (fetchFromGitHub {
       owner  = "yosyshq";
       repo   = "yosys";
-      rev    = "0659d9eac7b546ee6f5acab46dbc83c91d556a34";
-      sha256 = "1hy21gxcp3q3hlbh5sh46h2340r11fwalkb9if9sbpc9y3279njj";
+      rev    = "c1abd3b02cab235334342f3520e2535eb74c5792";
+      sha256 = "0pzrplv4p0qzy115rg19lxv4w274iby337zfd7hhlinnpx3gzqvw";
       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";
       repo   = "abc";
@@ -27,6 +33,12 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ tcl readline libffi python3 bison flex ];
+
+  patchPhase = ''
+    substituteInPlace ./Makefile \
+      --replace 'echo UNKNOWN' 'echo ${substring 0 10 (elemAt srcs 0).rev}'
+  '';
+
   preBuild = ''
     chmod -R u+w ../yosys-abc
     ln -s ../yosys-abc abc
diff --git a/pkgs/development/compilers/z88dk/default.nix b/pkgs/development/compilers/z88dk/default.nix
new file mode 100644
index 000000000000..1590075dc2a0
--- /dev/null
+++ b/pkgs/development/compilers/z88dk/default.nix
@@ -0,0 +1,50 @@
+{ fetchFromGitHub, fetchpatch, stdenv, makeWrapper, unzip, libxml2, m4, uthash }:
+
+stdenv.mkDerivation rec {
+  name = "z88dk-${version}";
+  version = "20180217";
+  rev = "49a7c6032b2675af742f5b0b3aa5bd5260bdd814";
+  short_rev = "${builtins.substring 0 7 rev}";
+
+  src = fetchFromGitHub {
+    owner = "z88dk";
+    repo  = "z88dk";
+    inherit rev;
+    sha256 = "00vbklh6lkq1gyd08ig2vcg6c1mghvlwfx3vq3wldf34hcs3k4pp";
+  };
+
+  # https://github.com/z88dk/z88dk/pull/612
+  patches = [(fetchpatch {
+    url = "https://github.com/Mic92/z88dk/commit/5b4ca132fa1f31c9ac48cf2220358715739ca0b2.patch";
+    sha256 = "1p2l31j68p7jzykhkhd9iagn2lr08hdclk3cl9l32p1q6ghdipfv";
+  })];
+
+  postPatch = ''
+    # we dont rely on build.sh :
+    export PATH="$PWD/bin:$PATH" # needed to have zcc in testsuite
+    export ZCCCFG=$PWD/lib/config/
+  '';
+
+  makeFlags = [
+    "prefix=$(out)"
+    "git_rev=${short_rev}"
+    "version=${version}"
+    "git_count=0"
+  ];
+  nativeBuildInputs = [ makeWrapper unzip ];
+  buildInputs = [ libxml2 m4 uthash ];
+
+  preInstall = ''
+    mkdir -p $out/{bin,share}
+  '';
+
+  installTargets = "libs install";
+
+  meta = with stdenv.lib; {
+    homepage    = https://www.z88dk.org;
+    description = "z80 Development Kit";
+    license     = licenses.clArtistic;
+    maintainers = [ maintainers.genesis ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/development/compilers/zig/default.nix b/pkgs/development/compilers/zig/default.nix
index 6f0c6d19e450..cffc683f9e7b 100644
--- a/pkgs/development/compilers/zig/default.nix
+++ b/pkgs/development/compilers/zig/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, llvmPackages_5, llvm_5 }:
+{ stdenv, fetchFromGitHub, cmake, llvmPackages }:
 
 stdenv.mkDerivation rec {
   version = "0.1.1";
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "01yqjyi25f99bfmxxwyh45k7j84z0zg7n9jl8gg0draf96mzdh06";
   };
 
-  buildInputs = [ cmake llvmPackages_5.clang-unwrapped llvm_5 ];
+  buildInputs = [ cmake llvmPackages.clang-unwrapped llvmPackages.llvm ];
 
   cmakeFlags = [
     "-DZIG_LIBC_INCLUDE_DIR=${stdenv.cc.libc_dev}/include"