about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-05-17 10:56:54 +0000
committerAlyssa Ross <hi@alyssa.is>2019-05-17 10:56:54 +0000
commitc1d22074139ab0d048a05b5e5116265d099114d6 (patch)
tree97977009422d675f8930f97c309b010481289e72 /nixpkgs/pkgs/development/compilers
parent4dc8afe4fd6b18437150129e0a1ecc23c6a1c0b9 (diff)
parentbc9df0f66110039e495b6debe3a6cda4a1bb0fed (diff)
downloadnixlib-c1d22074139ab0d048a05b5e5116265d099114d6.tar
nixlib-c1d22074139ab0d048a05b5e5116265d099114d6.tar.gz
nixlib-c1d22074139ab0d048a05b5e5116265d099114d6.tar.bz2
nixlib-c1d22074139ab0d048a05b5e5116265d099114d6.tar.lz
nixlib-c1d22074139ab0d048a05b5e5116265d099114d6.tar.xz
nixlib-c1d22074139ab0d048a05b5e5116265d099114d6.tar.zst
nixlib-c1d22074139ab0d048a05b5e5116265d099114d6.zip
Merge commit 'bc9df0f66110039e495b6debe3a6cda4a1bb0fed'
Diffstat (limited to 'nixpkgs/pkgs/development/compilers')
-rw-r--r--nixpkgs/pkgs/development/compilers/dmd/default.nix3
-rw-r--r--nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix18
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix3
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/5/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/9/default.nix384
-rw-r--r--nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/ghc/head.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/go/1.10.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/go/1.11.nix7
-rw-r--r--nixpkgs/pkgs/development/compilers/go/1.12.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/001_mx.py.patch257
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/002_setjmp.c.patch16
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/003_mx_truffle.py.patch12
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/004_mx_jvmci.py.patch12
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/default.nix312
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/truffle.make14
-rw-r--r--nixpkgs/pkgs/development/compilers/ldc/default.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix16
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/4/lld.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix16
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/5/lld.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix16
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix2
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch74
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix7
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/default.nix4
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix2
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix2
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/lld.nix2
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix8
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix22
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix2
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix2
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch74
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix3
-rw-r--r--nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch36
-rw-r--r--nixpkgs/pkgs/development/compilers/mruby/default.nix10
-rw-r--r--nixpkgs/pkgs/development/compilers/rgbds/default.nix30
-rw-r--r--nixpkgs/pkgs/development/compilers/rust/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/default.nix71
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch4
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch14
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/0003-build-presets-linux-don-t-build-extra-libs.patch23
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch2
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch8
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/libdispatch-fortify-fix.patch13
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch2
-rw-r--r--nixpkgs/pkgs/development/compilers/swift/purity.patch2
53 files changed, 1138 insertions, 435 deletions
diff --git a/nixpkgs/pkgs/development/compilers/dmd/default.nix b/nixpkgs/pkgs/development/compilers/dmd/default.nix
index b15e1a9aa309..5c4e570fcb81 100644
--- a/nixpkgs/pkgs/development/compilers/dmd/default.nix
+++ b/nixpkgs/pkgs/development/compilers/dmd/default.nix
@@ -103,8 +103,7 @@ stdenv.mkDerivation rec {
 
   checkPhase = ''
     cd dmd
-    # https://github.com/NixOS/nixpkgs/pull/55998#issuecomment-465871846
-    #make -j$NIX_BUILD_CORES -C test -f Makefile PIC=1 CC=$CXX DMD=${pathToDmd} BUILD=release SHELL=$SHELL
+    make -j$NIX_BUILD_CORES -C test -f Makefile PIC=1 CC=$CXX DMD=${pathToDmd} BUILD=release SHELL=$SHELL
     cd ../druntime
     make -j$NIX_BUILD_CORES -f posix.mak unittest PIC=1 DMD=${pathToDmd} BUILD=release
     cd ../phobos
diff --git a/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix b/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix
index 4e8ab34b1011..b4f35b1c4c01 100644
--- a/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix
+++ b/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix
@@ -12,25 +12,21 @@ let
   rpath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc libunwind libuuid icu openssl zlib curl ];
 in
   stdenv.mkDerivation rec {
-    version = "2.2.103";
-    netCoreVersion = "2.2.1";
-    name = "dotnet-sdk-${version}";
+    version = "2.2.203";
+    netCoreVersion = "2.2.4";
+    pname = "dotnet-sdk";
 
     src = fetchurl {
-      url = "https://dotnetcli.azureedge.net/dotnet/Sdk/${version}/dotnet-sdk-${version}-linux-x64.tar.gz";
+      url = "https://dotnetcli.azureedge.net/dotnet/Sdk/${version}/${pname}-${version}-linux-x64.tar.gz";
       # use sha512 from the download page
-      sha512 = "777AC6DCD0200BA447392E451A1779F0FBFA548BD620A7BBA3EEBDF35892236C3F10B19FF81D4F64B5BC134923CB47F9CC45EE6B004140E1249582249944DB69";
+      sha512 = "8DA955FA0AEEBB6513A6E8C4C23472286ED78BD5533AF37D79A4F2C42060E736FDA5FD48B61BF5AEC10BBA96EB2610FACC0F8A458823D374E1D437B26BA61A5C";
     };
 
-    unpackPhase = ''
-      mkdir src
-      cd src
-      tar xvzf $src
-    '';
+    sourceRoot = ".";
 
     buildPhase = ''
       runHook preBuild
-      patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./dotnet
+      patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ./dotnet
       patchelf --set-rpath "${rpath}" ./dotnet
       find -type f -name "*.so" -exec patchelf --set-rpath "${rpath}" {} \;
       echo -n "dotnet-sdk version: "
diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix
index b9a24183cde2..8fba9be4901b 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix
@@ -411,13 +411,14 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ peti ];
+    maintainers = with stdenv.lib.maintainers; [ peti veprbl ];
 
     platforms =
       stdenv.lib.platforms.linux ++
       stdenv.lib.platforms.freebsd ++
       stdenv.lib.platforms.illumos ++
       stdenv.lib.platforms.darwin;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
 
diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix
index 36ad5b46b791..3ce5ea1f64c2 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix
@@ -430,6 +430,7 @@ stdenv.mkDerivation ({
       stdenv.lib.platforms.freebsd ++
       stdenv.lib.platforms.illumos ++
       stdenv.lib.platforms.darwin;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
 
diff --git a/nixpkgs/pkgs/development/compilers/gcc/5/default.nix b/nixpkgs/pkgs/development/compilers/gcc/5/default.nix
index 2d7ac9497bbb..e6115b104817 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/5/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/5/default.nix
@@ -435,6 +435,7 @@ stdenv.mkDerivation ({
       stdenv.lib.platforms.freebsd ++
       stdenv.lib.platforms.illumos ++
       stdenv.lib.platforms.darwin;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
 
diff --git a/nixpkgs/pkgs/development/compilers/gcc/9/default.nix b/nixpkgs/pkgs/development/compilers/gcc/9/default.nix
new file mode 100644
index 000000000000..0d75de7557be
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/gcc/9/default.nix
@@ -0,0 +1,384 @@
+{ stdenv, targetPackages, fetchurl, noSysDirs
+, langC ? true, langCC ? true, langFortran ? false
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
+, langGo ? false
+, profiledCompiler ? false
+, staticCompiler ? false
+, enableShared ? true
+, texinfo ? null
+, perl ? null # optional, for texi2pod (then pod2man)
+, gmp, mpfr, libmpc, gettext, which
+, libelf                      # optional, for link-time optimizations (LTO)
+, isl ? null # optional, for the Graphite optimization framework.
+, zlib ? null
+, enableMultilib ? false
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
+, name ? "gcc"
+, libcCross ? null
+, crossStageStatic ? false
+, # Strip kills static libs of other archs (hence no cross)
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
+, gnused ? null
+, cloog # unused; just for compat with gcc4, as we override the parameter on some places
+, buildPackages
+}:
+
+# LTO needs libelf and zlib.
+assert libelf != null -> zlib != null;
+
+# Make sure we get GNU sed.
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
+
+# The go frontend is written in c++
+assert langGo -> langCC;
+
+with stdenv.lib;
+with builtins;
+
+let version = "9.1.0";
+
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+    patches =
+         optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
+      ++ optional noSysDirs ../no-sys-dirs.patch
+      /* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied
+        url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
+        sha256 = ""; # TODO: uncomment and check hash when available.
+      }) */
+      ++ optional langFortran ../gfortran-driving.patch
+      ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch;
+
+    /* Cross-gcc settings (build == host != target) */
+    crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
+    crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
+    crossConfigureFlags =
+      # Ensure that -print-prog-name is able to find the correct programs.
+      [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
+        "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
+      (if crossMingw && crossStageStatic then [
+        "--with-headers=${libcCross}/include"
+        "--with-gcc"
+        "--with-gnu-as"
+        "--with-gnu-ld"
+        "--with-gnu-ld"
+        "--disable-shared"
+        "--disable-nls"
+        "--disable-debug"
+        "--enable-sjlj-exceptions"
+        "--enable-threads=win32"
+        "--disable-win32-registry"
+        "--disable-libmpx" # requires libc
+      ] else if crossStageStatic then [
+        "--disable-libssp"
+        "--disable-nls"
+        "--without-headers"
+        "--disable-threads"
+        "--disable-libgomp"
+        "--disable-libquadmath"
+        "--disable-shared"
+        "--disable-libatomic" # requires libc
+        "--disable-decimal-float" # requires libc
+        "--disable-libmpx" # requires libc
+      ] else [
+        (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot"
+         else                "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}")
+        "--enable-__cxa_atexit"
+        "--enable-long-long"
+      ] ++
+        (if crossMingw then [
+          "--enable-threads=win32"
+          "--enable-sjlj-exceptions"
+          "--enable-hash-synchronization"
+          "--enable-libssp"
+          "--disable-nls"
+          "--with-dwarf2"
+          # To keep ABI compatibility with upstream mingw-w64
+          "--enable-fully-dynamic-string"
+        ] else
+          optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
+            # libsanitizer requires netrom/netrom.h which is not
+            # available in uclibc.
+            "--disable-libsanitizer"
+            # In uclibc cases, libgomp needs an additional '-ldl'
+            # and as I don't know how to pass it, I disable libgomp.
+            "--disable-libgomp"
+            # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865
+            "--disable-libmpx"
+          ]
+          ++ optional (targetPlatform.libc == "newlib") "--with-newlib"
+          ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc"
+          ++ [
+            "--enable-threads=${if targetPlatform.isUnix then "posix"
+                                else if targetPlatform.isWindows then "win32"
+                                else "single"}"
+            "--enable-nls"
+            "--disable-decimal-float" # No final libdecnumber (it may work only in 386)
+        ]));
+    stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
+    crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
+
+    bootstrap = targetPlatform == hostPlatform;
+
+in
+
+stdenv.mkDerivation ({
+  name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
+
+  builder = ../builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+    sha256 = "1817nc2bqdc251k0lpc51cimna7v68xjrnvqzvc50q3ax4s6i9kr";
+  };
+
+  inherit patches;
+
+  outputs = [ "out" "lib" "man" "info" ];
+  setOutputFlags = false;
+  NIX_NO_SELF_RPATH = true;
+
+  libc_dev = stdenv.cc.libc_dev;
+
+  hardeningDisable = [ "format" "pie" ];
+
+  # This should kill all the stdinc frameworks that gcc and friends like to
+  # insert into default search paths.
+  prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+    substituteInPlace gcc/config/darwin-c.c \
+      --replace 'if (stdinc)' 'if (0)'
+
+    substituteInPlace libgcc/config/t-slibgcc-darwin \
+      --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)"
+
+    substituteInPlace libgfortran/configure \
+      --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname"
+  '';
+
+  postPatch = ''
+    configureScripts=$(find . -name configure)
+    for configureScript in $configureScripts; do
+      patchShebangs $configureScript
+    done
+  '' + (
+    if targetPlatform != hostPlatform || stdenv.cc.libc != null then
+      # On NixOS, use the right path to the dynamic linker instead of
+      # `/lib/ld*.so'.
+      let
+        libc = if libcCross != null then libcCross else stdenv.cc.libc;
+      in
+        (
+        '' 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 _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:]]*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 "");
+
+  inherit noSysDirs staticCompiler crossStageStatic
+    libcCross crossMingw;
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ texinfo which gettext ]
+    ++ (optional (perl != null) perl);
+
+  # For building runtime libs
+  depsBuildTarget =
+    if hostPlatform == buildPlatform then [
+      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+    ] else assert targetPlatform == hostPlatform; [ # build != host == target
+      stdenv.cc
+    ];
+
+  buildInputs = [
+    gmp mpfr libmpc libelf
+    targetPackages.stdenv.cc.bintools # For linking code at run-time
+  ] ++ (optional (isl != null) isl)
+    ++ (optional (zlib != null) zlib)
+    # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
+    # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
+    ++ (optional hostPlatform.isDarwin gnused)
+    ;
+
+  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+
+  preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) ''
+    export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+    export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+    export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+    export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+  '';
+
+  dontDisableStatic = true;
+
+  # TODO(@Ericson2314): Always pass "--target" and always prefix.
+  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+  configureFlags =
+    # Basic dependencies
+    [
+      "--with-gmp-include=${gmp.dev}/include"
+      "--with-gmp-lib=${gmp.out}/lib"
+      "--with-mpfr-include=${mpfr.dev}/include"
+      "--with-mpfr-lib=${mpfr.out}/lib"
+      "--with-mpc=${libmpc}"
+    ] ++
+    optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
+
+    # Basic configuration
+    [
+      "--enable-lto"
+      "--disable-libstdcxx-pch"
+      "--without-included-gettext"
+      "--with-system-zlib"
+      "--enable-static"
+      "--enable-languages=${
+        concatStrings (intersperse ","
+          (  optional langC        "c"
+          ++ optional langCC       "c++"
+          ++ optional langFortran  "fortran"
+          ++ optional langGo       "go"
+          ++ optional langObjC     "objc"
+          ++ optional langObjCpp   "obj-c++"
+          ++ optionals crossDarwin [ "objc" "obj-c++" ]
+          )
+        )
+      }"
+    ] ++
+
+    (if (enableMultilib || targetPlatform.isAvr)
+      then ["--enable-multilib" "--disable-libquadmath"]
+      else ["--disable-multilib"]) ++
+    optional (!enableShared) "--disable-shared" ++
+    (if enablePlugin
+      then ["--enable-plugin"]
+      else ["--disable-plugin"]) ++
+
+    # Optional features
+    optional (isl != null) "--with-isl=${isl}" ++
+
+    (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
+    optional (targetPlatform != hostPlatform) crossConfigureFlags ++
+    optional (!bootstrap) "--disable-bootstrap" ++
+
+    # Platform-specific flags
+    optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++
+    optionals hostPlatform.isSunOS [
+      "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit"
+      # On Illumos/Solaris GNU as is preferred
+      "--with-gnu-as" "--without-gnu-ld"
+    ]
+    ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [
+      "--disable-libsanitizer"
+      "--disable-symvers"
+      "libat_cv_have_ifunc=no"
+      "--disable-gnu-indirect-function"
+    ]
+  ;
+
+  targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
+
+  buildFlags = optional
+    (bootstrap && hostPlatform == buildPlatform)
+    (if profiledCompiler then "profiledbootstrap" else "bootstrap");
+
+  dontStrip = !stripped;
+
+  installTargets =
+    if stripped
+    then "install-strip"
+    else "install";
+
+  # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
+
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Likewise, the LTO code doesn't find zlib.
+  #
+  # Cross-compiling, we need gcc not to read ./specs in order to build the g++
+  # compiler (after the specs for the cross-gcc are created). Having
+  # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks.
+
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
+    ++ optional (zlib != null) zlib
+  ));
+
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib));
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}${libcCross.libdir or "/lib"}"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}"
+    ] ++ (if crossStageStatic then [
+        "-B${libcCross.out}${libcCross.libdir or "/lib"}"
+      ] else [
+        "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}"
+        "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}"
+    ]));
+
+  passthru = {
+    inherit langC langCC langObjC langObjCpp langFortran langGo version;
+    isGNU = true;
+  };
+
+  enableParallelBuilding = true;
+  inherit enableMultilib;
+
+  inherit (stdenv) is64bit;
+
+  meta = {
+    homepage = https://gcc.gnu.org/;
+    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    description = "GNU Compiler Collection, version ${version}"
+      + (if stripped then "" else " (with debugging info)");
+
+    longDescription = ''
+      The GNU Compiler Collection includes compiler front ends for C, C++,
+      Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as
+      libraries for these languages (libstdc++, libgomp,...).
+
+      GCC development is a part of the GNU Project, aiming to improve the
+      compiler used in the GNU system including the GNU/Linux variant.
+    '';
+
+    maintainers = with stdenv.lib.maintainers; [ synthetica ];
+
+    platforms =
+      stdenv.lib.platforms.linux ++
+      stdenv.lib.platforms.freebsd ++
+      stdenv.lib.platforms.illumos ++
+      stdenv.lib.platforms.darwin;
+  };
+}
+
+// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
+  makeFlags = [ "all-gcc" "all-target-libgcc" ];
+  installTargets = "install-gcc install-target-libgcc";
+}
+
+// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
+)
diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix b/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix
index 640709aba1b8..54c53691574e 100644
--- a/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix
+++ b/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix
@@ -9,7 +9,7 @@
 , # GHC can be built with system libffi or a bundled one.
   libffi ? null
 
-, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -31,7 +31,8 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+    (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
   # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix b/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix
index e891ff42ff60..bc45540036d2 100644
--- a/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix
+++ b/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix
@@ -9,7 +9,7 @@
 , # GHC can be built with system libffi or a bundled one.
   libffi ? null
 
-, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -31,7 +31,8 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+    (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
   # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix b/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix
index 9772d045b765..ad2d64866f85 100644
--- a/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix
+++ b/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix
@@ -9,7 +9,7 @@
 , # GHC can be built with system libffi or a bundled one.
   libffi ? null
 
-, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -31,7 +31,8 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+    (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
   # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
diff --git a/nixpkgs/pkgs/development/compilers/ghc/head.nix b/nixpkgs/pkgs/development/compilers/ghc/head.nix
index 88b273500dc0..46d8dfafd0fe 100644
--- a/nixpkgs/pkgs/development/compilers/ghc/head.nix
+++ b/nixpkgs/pkgs/development/compilers/ghc/head.nix
@@ -6,7 +6,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -29,7 +29,8 @@
 , version ? "8.7.20190115"
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+    (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
   # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
diff --git a/nixpkgs/pkgs/development/compilers/go/1.10.nix b/nixpkgs/pkgs/development/compilers/go/1.10.nix
index 5dce1529a8b8..d18d260b5058 100644
--- a/nixpkgs/pkgs/development/compilers/go/1.10.nix
+++ b/nixpkgs/pkgs/development/compilers/go/1.10.nix
@@ -131,11 +131,6 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  postPatch = optionalString stdenv.isDarwin ''
-    echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil"
-    substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil
-  '';
-
   GOOS = if stdenv.isDarwin then "darwin" else "linux";
   GOARCH = if stdenv.isDarwin then "amd64"
            else if stdenv.hostPlatform.system == "i686-linux" then "386"
@@ -187,5 +182,6 @@ stdenv.mkDerivation rec {
     license = licenses.bsd3;
     maintainers = with maintainers; [ cstrahan orivej velovix mic92 ];
     platforms = platforms.linux ++ platforms.darwin;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/nixpkgs/pkgs/development/compilers/go/1.11.nix b/nixpkgs/pkgs/development/compilers/go/1.11.nix
index 1e3a63983f4a..eec472fb88e6 100644
--- a/nixpkgs/pkgs/development/compilers/go/1.11.nix
+++ b/nixpkgs/pkgs/development/compilers/go/1.11.nix
@@ -136,11 +136,6 @@ stdenv.mkDerivation rec {
     ./skip-test-extra-files-on-386.patch
   ];
 
-  postPatch = optionalString stdenv.isDarwin ''
-    echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil"
-    substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil
-  '';
-
   GOOS = stdenv.targetPlatform.parsed.kernel.name;
   GOARCH = goarch stdenv.targetPlatform;
   # GOHOSTOS/GOHOSTARCH must match the building system, not the host system.
@@ -188,7 +183,7 @@ stdenv.mkDerivation rec {
     (cd src && ./make.bash)
   '';
 
-  doCheck = stdenv.hostPlatform == stdenv.targetPlatform;
+  doCheck = stdenv.hostPlatform == stdenv.targetPlatform && !stdenv.isDarwin;
 
   checkPhase = ''
     runHook preCheck
diff --git a/nixpkgs/pkgs/development/compilers/go/1.12.nix b/nixpkgs/pkgs/development/compilers/go/1.12.nix
index 44304006f6b4..68f9d1d531f4 100644
--- a/nixpkgs/pkgs/development/compilers/go/1.12.nix
+++ b/nixpkgs/pkgs/development/compilers/go/1.12.nix
@@ -141,9 +141,6 @@ stdenv.mkDerivation rec {
 
   postPatch = ''
     find . -name '*.orig' -exec rm {} ';'
-  '' + optionalString stdenv.isDarwin ''
-    echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil"
-    substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil
   '';
 
   GOOS = stdenv.targetPlatform.parsed.kernel.name;
@@ -193,7 +190,7 @@ stdenv.mkDerivation rec {
     (cd src && ./make.bash)
   '';
 
-  doCheck = stdenv.hostPlatform == stdenv.targetPlatform;
+  doCheck = stdenv.hostPlatform == stdenv.targetPlatform && !stdenv.isDarwin;
 
   checkPhase = ''
     runHook preCheck
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/001_mx.py.patch b/nixpkgs/pkgs/development/compilers/graalvm/001_mx.py.patch
new file mode 100644
index 000000000000..25a9efa96415
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/graalvm/001_mx.py.patch
@@ -0,0 +1,257 @@
+diff --git a/mx.py b/mx.py
+index d119b62..471fe98 100644
+--- a/mx.py
++++ b/mx.py
+@@ -4961,30 +4961,6 @@ class PackedResourceLibrary(ResourceLibrary):
+ 
+     def get_path(self, resolve):
+         extract_path = _make_absolute(self.extract_path, self.suite.dir)
+-        download_path = super(PackedResourceLibrary, self).get_path(resolve)
+-        if resolve and self._check_extract_needed(extract_path, download_path):
+-            extract_path_tmp = tempfile.mkdtemp(suffix=basename(extract_path), dir=dirname(extract_path))
+-            try:
+-                # extract archive
+-                Extractor.create(download_path).extract(extract_path_tmp)
+-                # ensure modification time is up to date
+-                os.utime(extract_path_tmp, None)
+-                logv("Moving temporary directory {} to {}".format(extract_path_tmp, extract_path))
+-                try:
+-                    # attempt atomic overwrite
+-                    os.rename(extract_path_tmp, extract_path)
+-                except OSError:
+-                    # clean destination & re-try for cases where atomic overwrite doesn't work
+-                    rmtree(extract_path, ignore_errors=True)
+-                    os.rename(extract_path_tmp, extract_path)
+-            except OSError as ose:
+-                # Rename failed. Race with other process?
+-                if self._check_extract_needed(extract_path, download_path):
+-                    # ok something really went wrong
+-                    abort("Extracting {} failed!".format(download_path), context=ose)
+-            finally:
+-                rmtree(extract_path_tmp, ignore_errors=True)
+-
+         return extract_path
+ 
+     def _check_download_needed(self):
+@@ -5885,7 +5861,7 @@ class HgConfig(VC):
+ 
+     def update_to_branch(self, vcdir, branch, abortOnError=True):
+         cmd = ['update', branch]
+-        self.hg_command(vcdir, cmd, abortOnError=abortOnError)
++        self.run(['hg', vcdir] + cmd)
+ 
+     def add(self, vcdir, path, abortOnError=True):
+         return self.run(['hg', '-q', '-R', vcdir, 'add', path]) == 0
+@@ -5922,7 +5898,7 @@ class HgConfig(VC):
+                 return None
+ 
+     def parent_info(self, vcdir, abortOnError=True):
+-        out = self.hg_command(vcdir, ["log", "-r", ".", "--template", "{author}|||{date|hgdate}"], abortOnError=abortOnError)
++        out = _check_output_str(["hg", '-R', vcdir, "log", "-r", ".", "--template", "{author}|||{date|hgdate}"])
+         author, date = out.split("|||")
+         ts, _ = date.split(" ")
+         return self._sanitize_parent_info({
+@@ -8287,46 +8263,8 @@ class SuiteImport:
+         version = import_dict.get("version")
+         suite_dir = None
+         version_from = import_dict.get("versionFrom")
+-        if version_from and version:
+-            abort("In import for '{}': 'version' and 'versionFrom' can not be both set".format(name), context=context)
+-        if version is None and version_from is None:
+-            if not (in_subdir and (importer.vc_dir != importer.dir or isinstance(importer, BinarySuite))):
+-                abort("In import for '{}': No version given and not a 'subdir' suite of the same repository".format(name), context=context)
+-            if importer.isSourceSuite():
+-                suite_dir = join(importer.vc_dir, name)
+-            version = importer.version()
+-        if urls is None:
+-            if not in_subdir:
+-                if import_dict.get("subdir") is None and importer.vc_dir != importer.dir:
+-                    warn("In import for '{}': No urls given but 'subdir' is not set, assuming 'subdir=True'".format(name), context)
+-                    in_subdir = True
+-                else:
+-                    abort("In import for '{}': No urls given and not a 'subdir' suite".format(name), context=context)
+-            return SuiteImport(name, version, None, None, dynamicImport=dynamicImport, in_subdir=in_subdir, version_from=version_from, suite_dir=suite_dir)
+-        # urls a list of alternatives defined as dicts
+-        if not isinstance(urls, list):
+-            abort('suite import urls must be a list', context=context)
+-        urlinfos = []
+-        mainKind = None
+-        for urlinfo in urls:
+-            if isinstance(urlinfo, dict) and urlinfo.get('url') and urlinfo.get('kind'):
+-                kind = urlinfo.get('kind')
+-                if not VC.is_valid_kind(kind):
+-                    abort('suite import kind ' + kind + ' illegal', context=context)
+-            else:
+-                abort('suite import url must be a dict with {"url", kind", attributes', context=context)
+-            vc = vc_system(kind)
+-            if kind != 'binary':
+-                assert not mainKind or mainKind == kind, "Only expecting one non-binary kind"
+-                mainKind = kind
+-            url = mx_urlrewrites.rewriteurl(urlinfo.get('url'))
+-            urlinfos.append(SuiteImportURLInfo(url, kind, vc))
+-        vc_kind = None
+-        if mainKind:
+-            vc_kind = mainKind
+-        elif urlinfos:
+-            vc_kind = 'binary'
+-        return SuiteImport(name, version, urlinfos, vc_kind, dynamicImport=dynamicImport, in_subdir=in_subdir, version_from=version_from, suite_dir=suite_dir)
++        suite_dir = join(get_env('MX_GIT_CACHE_DIR'), name)
++        return SuiteImport(name, version, [], None, True, in_subdir=in_subdir, version_from=version_from, suite_dir=suite_dir)
+ 
+     @staticmethod
+     def get_source_urls(source, kind=None):
+@@ -8367,8 +8305,6 @@ class Suite(object):
+     :type dists: list[Distribution]
+     """
+     def __init__(self, mxDir, primary, internal, importing_suite, load, vc, vc_dir, dynamicallyImported=False):
+-        if primary is True and vc_dir is None:
+-            abort("The primary suite must be in a vcs repository")
+         self.imported_by = [] if primary else [importing_suite]
+         self.mxDir = mxDir
+         self.dir = dirname(mxDir)
+@@ -8396,7 +8332,7 @@ class Suite(object):
+         self._outputRoot = None
+         self._preloaded_suite_dict = None
+         self.vc = vc
+-        self.vc_dir = vc_dir
++        self.vc_dir = get_env('MX_GIT_CACHE_DIR')
+         self._preload_suite_dict()
+         self._init_imports()
+         if load:
+@@ -9295,7 +9231,9 @@ def get_dynamic_imports():
+ class SourceSuite(Suite):
+     """A source suite"""
+     def __init__(self, mxDir, primary=False, load=True, internal=False, importing_suite=None, dynamicallyImported=False):
+-        vc, vc_dir = VC.get_vc_root(dirname(mxDir), abortOnError=False)
++        vc, vc_dir_test = VC.get_vc_root(dirname(mxDir), abortOnError=False)
++        vc_dir = get_env('MX_GIT_CACHE_DIR')
++        warn("LOOKING FOR: " + mxDir)
+         Suite.__init__(self, mxDir, primary, internal, importing_suite, load, vc, vc_dir, dynamicallyImported=dynamicallyImported)
+         logvv("SourceSuite.__init__({}), got vc={}, vc_dir={}".format(mxDir, self.vc, self.vc_dir))
+         self.projects = []
+@@ -9344,17 +9282,7 @@ class SourceSuite(Suite):
+         """
+         Gets the release tag from VC or create a time based once if VC is unavailable
+         """
+-        if snapshotSuffix not in self._releaseVersion:
+-            _version = self._get_early_suite_dict_property('version')
+-            if _version and self.getMxCompatibility().addVersionSuffixToExplicitVersion():
+-                if not self.is_release():
+-                    _version = _version + '-' + snapshotSuffix
+-            if not _version:
+-                _version = self.vc.release_version_from_tags(self.vc_dir, self.name, snapshotSuffix=snapshotSuffix)
+-            if not _version:
+-                _version = 'unknown-{0}-{1}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z'))
+-            self._releaseVersion[snapshotSuffix] = _version
+-        return self._releaseVersion[snapshotSuffix]
++        return get_env('version')
+ 
+     def scm_metadata(self, abortOnError=False):
+         scm = self.scm
+@@ -12526,55 +12454,8 @@ def _attempt_download(url, path, jarEntryName=None):
+     return False
+ 
+ def download(path, urls, verbose=False, abortOnError=True, verifyOnly=False):
+-    """
+-    Attempts to downloads content for each URL in a list, stopping after the first successful download.
+-    If the content cannot be retrieved from any URL, the program is aborted, unless abortOnError=False.
+-    The downloaded content is written to the file indicated by `path`.
+-    """
+-    if not verifyOnly:
+-        ensure_dirname_exists(path)
+-        assert not path.endswith(os.sep)
+-
+-    # https://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection.html
+-    jarURLPattern = re.compile('jar:(.*)!/(.*)')
+-    verify_errors = {}
+-    for url in urls:
+-        if not verifyOnly or verbose:
+-            log('Downloading ' + url + ' to ' + path)
+-        m = jarURLPattern.match(url)
+-        jarEntryName = None
+-        if m:
+-            url = m.group(1)
+-            jarEntryName = m.group(2)
+-
+-        if verifyOnly:
+-            try:
+-                conn = _urlopen(url, timeout=10)
+-                conn.close()
+-                return True
+-            except (IOError, socket.timeout) as e:
+-                _suggest_tlsv1_error(e)
+-                verify_errors[url] = e
+-            continue
+-
+-        for i in range(4):
+-            if i != 0:
+-                time.sleep(1)
+-                warn('Retry {} to download from {}'.format(i, url))
+-            res = _attempt_download(url, path, jarEntryName)
+-            if res is True:
+-                return True
+-            if res is False:
+-                break
+-
+-    if abortOnError:
+-        msg = 'Could not download to ' + path + ' from any of the following URLs: ' + ', '.join(urls)
+-        if verifyOnly:
+-            for url, e in verify_errors.items():
+-                msg += '\n  ' + url + ': ' + str(e)
+-        abort(msg)
+-    else:
+-        return False
++    print("FAKE download(path={} urls={} verbose={} abortOnError={} verifyOnly={})".format(path, urls, verbose, abortOnError, verifyOnly))
++    return True
+ 
+ def update_file(path, content, showDiff=False):
+     """
+@@ -13378,6 +13259,7 @@ class Archiver(SafeFileCreation):
+ 
+     def _add_zip(self, filename, archive_name, provenance):
+         self._add_provenance(archive_name, provenance)
++        os.utime(filename, (315532800, 315532800))
+         self.zf.write(filename, archive_name)
+ 
+     def _add_str_zip(self, data, archive_name, provenance):
+@@ -18526,12 +18408,35 @@ def _find_suite_import(importing_suite, suite_import, fatalIfMissing=True, load=
+         Attempts to locate an existing suite in the local context
+         Returns the path to the mx.name dir if found else None
+         """
+-        if mode == 'binary':
+-            # binary suites are always stored relative to the importing suite in mx-private directory
+-            return importing_suite._find_binary_suite_dir(suite_import.name)
++        warn("FAKE CLONE: " + str(suite_import))
++        if (suite_import.name == "truffle"):
++            return join(get_env('TMP'), "source", "truffle", "mx.truffle")
++        if (suite_import.name == "graal-nodejs"):
++            return join(get_env('MX_GIT_CACHE_DIR'), "graaljs", "graal-nodejs", "mx.graal-nodejs")
++        if (suite_import.name == "truffleruby"):
++            return join(get_env('MX_GIT_CACHE_DIR'), "truffleruby", "mx.truffleruby")
++        if (suite_import.name == "graalpython"):
++            return join(get_env('MX_GIT_CACHE_DIR'), "graalpython", "mx.graalpython")
++        if (suite_import.name == "vm"):
++            return join(get_env('TMP'), "source", "vm", "mx.vm")
++        if (suite_import.name == "fastr"):
++            return join(get_env('MX_GIT_CACHE_DIR'), "fastr", "mx.fastr")
++        if (suite_import.name == "sdk"):
++            return join(get_env('TMP'), "source", "sdk", "mx.sdk")
++        if (suite_import.name == "graal-js"):
++            return join(get_env('MX_GIT_CACHE_DIR'), "graaljs", "graal-js", "mx.graal-js")
++        if (suite_import.name == "regex"):
++            return join(get_env('TMP'), "source", "regex", "mx.regex")
++        if (suite_import.name == "substratevm"):
++            return join(get_env('TMP'), "source", "substratevm", "mx.substratevm")
++        if (suite_import.name == "tools"):
++            return join(get_env('TMP'), "source", "tools", "mx.tools")
++        if (suite_import.name == "sulong"):
++            return join(get_env('TMP'), "source", "sulong", "mx.sulong")
++        if (suite_import.name == "compiler"):
++            return join(get_env('TMP'), "source", "compiler", "mx.compiler")
+         else:
+-            # use the SuiteModel to locate a local source copy of the suite
+-            return _suitemodel.find_suite_dir(suite_import)
++            return join(get_env('MX_GIT_CACHE_DIR'), suite_import.name)
+ 
+     def _get_import_dir(url, mode):
+         """Return directory where the suite will be cloned to"""
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/002_setjmp.c.patch b/nixpkgs/pkgs/development/compilers/graalvm/002_setjmp.c.patch
new file mode 100644
index 000000000000..38a29fd8fbfd
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/graalvm/002_setjmp.c.patch
@@ -0,0 +1,16 @@
+diff --git a/sulong/projects/com.oracle.truffle.llvm.libraries.bitcode/src/setjmp.c b/sulong/projects/com.oracle.truffle.llvm.libraries.bitcode/src/setjmp.c
+index 16b869354d8..3691739d13b 100644
+--- a/sulong/projects/com.oracle.truffle.llvm.libraries.bitcode/src/setjmp.c
++++ b/sulong/projects/com.oracle.truffle.llvm.libraries.bitcode/src/setjmp.c
+@@ -41,11 +41,3 @@ int sigsetjmp(sigjmp_buf env, int savesigs) {
+   WARN_UNSUPPORTED(sigsetjmp);
+   return 0;
+ }
+-
+-void longjmp(jmp_buf env, int val) {
+-  ERR_UNSUPPORTED(longjmp);
+-}
+-
+-void siglongjmp(sigjmp_buf env, int val) {
+-  ERR_UNSUPPORTED(siglongjmp);
+-}
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/003_mx_truffle.py.patch b/nixpkgs/pkgs/development/compilers/graalvm/003_mx_truffle.py.patch
new file mode 100644
index 000000000000..bb9a00687124
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/graalvm/003_mx_truffle.py.patch
@@ -0,0 +1,12 @@
+diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py
+index 8889c5ad810..add211a45c5 100644
+--- a/truffle/mx.truffle/mx_truffle.py
++++ b/truffle/mx.truffle/mx_truffle.py
+@@ -695,6 +695,7 @@ class LibffiBuildTask(mx.AbstractNativeBuildTask):
+                      os.path.relpath(self.subject.delegate.dir, self.subject.suite.vc_dir)]
+         for patch in self.subject.patches:
+             mx.run(git_apply + [patch], cwd=self.subject.suite.vc_dir)
++        mx.run(['cp', os.path.join(os.getenv('TMP'), 'truffle.make'), os.path.join(self.subject.delegate.dir, 'Makefile')])
+ 
+         self.delegate.logBuild()
+         self.delegate.build()
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/004_mx_jvmci.py.patch b/nixpkgs/pkgs/development/compilers/graalvm/004_mx_jvmci.py.patch
new file mode 100644
index 000000000000..0aa1bc9b88dd
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/graalvm/004_mx_jvmci.py.patch
@@ -0,0 +1,12 @@
+diff --git a/mx.jvmci/mx_jvmci.py b/mx.jvmci/mx_jvmci.py
+index 491fc19ab9..b4ddc03abb 100644
+--- a/mx.jvmci/mx_jvmci.py
++++ b/mx.jvmci/mx_jvmci.py
+@@ -192,6 +192,7 @@ class HotSpotVMJDKDeployedDist(JDKDeployedDist):
+                 if m.name in _hs_deploy_map:
+                     targetDir = join(jdkDir, _hs_deploy_map[m.name])
+                     mx.logv('Deploying {} from {} to {}'.format(m.name, dist.name, targetDir))
++                    subprocess.call(["chmod", "-R", "+rw", targetDir])
+                     tar.extract(m, targetDir)
+ 
+ """
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/default.nix b/nixpkgs/pkgs/development/compilers/graalvm/default.nix
index f051b24065a5..3cb0d7430ab3 100644
--- a/nixpkgs/pkgs/development/compilers/graalvm/default.nix
+++ b/nixpkgs/pkgs/development/compilers/graalvm/default.nix
@@ -1,31 +1,90 @@
-{ stdenv, lib, fetchFromGitHub, fetchurl, fetchzip, mercurial, python27, zlib, makeWrapper, oraclejdk8 }:
+{ stdenv, lib, fetchFromGitHub, fetchurl, fetchzip, fetchgit, mercurial, python27,
+  zlib, makeWrapper, openjdk, unzip, git, clang, llvm, which, icu, ruby, bzip2
+  # gfortran, readline, bzip2, lzma, pcre, curl, ed, tree ## WIP: fastr deps
+}:
 
 let
+  version = "1.0.0-rc15";
+  truffleMake = ./truffle.make;
+  R = fetchurl {
+    url = "http://cran.rstudio.com/src/base/R-3/R-3.5.1.tar.gz";
+    sha256 = "1vap2k8kj5icy9naw61f9zyphf4rs0c9rxvil0zxkwx0xvsvyqq4";
+  };
+  makeMxGitCache = list: out: ''
+     mkdir ${out}
+    ${lib.concatMapStrings ({ url, name, rev, sha256 }: ''
+      mkdir -p ${out}/${name}
+      cp -rf ${fetchgit { inherit url rev sha256; }}/* ${out}/${name}
+    ''
+    ) list}
+
+    # # GRAAL-NODEJS # #
+    chmod -R +rw ${out}
+    sed -i "s|#include \"../../../../mxbuild/trufflenode/coremodules/node_snapshots.h\"| \
+           #include \"$NIX_BUILD_TOP/mxbuild/graal-nodejs/trufflenode/coremodules/node_snapshots.h\"|g" \
+      ${out}/graaljs/graal-nodejs/deps/v8/src/graal/callbacks.cc
+
+    # patch the shebang in python script runner
+    chmod -R +rw ${out}/graaljs/graal-nodejs/mx.graal-nodejs/python2
+    patchShebangs ${out}/graaljs/graal-nodejs/mx.graal-nodejs/python2/python
+
+    cd ${out}
+    hg init
+    hg add
+    hg commit -m 'dummy commit'
+    hg tag      ${lib.escapeShellArg "vm${version}"}
+    hg checkout ${lib.escapeShellArg "vm${version}"}
+  '';
+
   # pre-download some cache entries ('mx' will not be able to download under nixbld1)
   makeMxCache = list:
     stdenv.mkDerivation {
       name = "mx-cache";
-      buildCommand = ''
+      buildInputs = [ unzip ];
+      buildCommand = with lib; ''
         mkdir $out
-        ${lib.concatMapStrings ({url, name, sha1}: ''
-                                  install -D ${fetchurl { inherit url sha1; }} $out/${name}
-                                  echo -n ${sha1} > $out/${name}.sha1
-                                '') list}
+        ${lib.concatMapStrings
+          ({url, name, sha1, isNinja ? false}: ''
+            install -D ${fetchurl { inherit url sha1; }} $out/${name}
+            echo -n ${sha1} > $out/${name}.sha1
+            ${if isNinja then ''
+                export BASENAME=${removeSuffix ".zip" name}
+                mkdir "$out/$BASENAME.extracted" &&
+                unzip "$out/${name}" -d "$out/$BASENAME.extracted"
+
+                # Ninja is called later in the build process
+                if [ -f $out/$BASENAME.extracted/ninja ]; then
+                  patchelf --set-interpreter \
+                    "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+                    --set-rpath "${stdenv.cc.cc.lib}/lib64" \
+                    $out/$BASENAME.extracted/ninja
+                fi
+              ''
+            else ""}
+         '') list}
       '';
     };
 
   jvmci8-mxcache = [
-    rec { sha1 = "66215826a684eb6866d4c14a5a4f9c344f1d1eef"; name = "JACOCOCORE_${sha1}/jacococore.jar";                                               url = mirror://maven/org/jacoco/org.jacoco.core/0.7.9/org.jacoco.core-0.7.9.jar; }
-    rec { sha1 = "a365ee459836b2aa18028929923923d15f0c3af9"; name = "JACOCOCORE_${sha1}/jacococore.sources.jar";                                       url = mirror://maven/org/jacoco/org.jacoco.core/0.7.9/org.jacoco.core-0.7.9-sources.jar; }
-    rec { sha1 = "8a7f78fdf2a4e58762890d8e896a9298c2980c10"; name = "JACOCOREPORT_${sha1}/jacocoreport.jar";                                           url = mirror://maven/org/jacoco/org.jacoco.report/0.7.9/org.jacoco.report-0.7.9.jar; }
-    rec { sha1 = "e6703ef288523a8e63fa756d8adeaa70858d41b0"; name = "JACOCOREPORT_${sha1}/jacocoreport.sources.jar";                                   url = mirror://maven/org/jacoco/org.jacoco.report/0.7.9/org.jacoco.report-0.7.9-sources.jar; }
+    rec { sha1 = "977b33afe2344a9ee801fd3317c54d8e1f9d7a79"; name = "JACOCOCORE_0.8.2_${sha1}/jacococore-0.8.2.jar";                                   url = mirror://maven/org/jacoco/org.jacoco.core/0.8.2/org.jacoco.core-0.8.2.jar; }
+    rec { sha1 = "46f38efb779fb08216379e1a196396f4e22bbe41"; name = "JACOCOCORE_0.8.2_${sha1}/jacococore-0.8.2.sources.jar";                           url = mirror://maven/org/jacoco/org.jacoco.core/0.8.2/org.jacoco.core-0.8.2-sources.jar; }
+    rec { sha1 = "50e133cdfd2d31ca5702b73615be70f801d3ae26"; name = "JACOCOREPORT_0.8.2_${sha1}/jacocoreport-0.8.2.jar";                               url = mirror://maven/org/jacoco/org.jacoco.report/0.8.2/org.jacoco.report-0.8.2.jar; }
+    rec { sha1 = "7488cd6e42cc4fa85b51200b7f451465692e033b"; name = "JACOCOREPORT_0.8.2_${sha1}/jacocoreport-0.8.2.sources.jar";                       url = mirror://maven/org/jacoco/org.jacoco.report/0.8.2/org.jacoco.report-0.8.2-sources.jar; }
+    rec { sha1 = "4806883004063feb978b8811f00d5ea2138750bb"; name = "JACOCOAGENT_0.8.2_${sha1}/jacocoagent-0.8.2.jar";                                 url = mirror://maven/org/jacoco/org.jacoco.agent/0.8.2/org.jacoco.agent-0.8.2-runtime.jar; }
     rec { sha1 = "306816fb57cf94f108a43c95731b08934dcae15c"; name = "JOPTSIMPLE_4_6_${sha1}/joptsimple-4-6.jar";                                       url = mirror://maven/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar; }
     rec { sha1 = "9cd14a61d7aa7d554f251ef285a6f2c65caf7b65"; name = "JOPTSIMPLE_4_6_${sha1}/joptsimple-4-6.sources.jar";                               url = mirror://maven/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6-sources.jar; }
     rec { sha1 = "b852fb028de645ad2852bbe998e084d253f450a5"; name = "JMH_GENERATOR_ANNPROCESS_1_18_${sha1}/jmh-generator-annprocess-1-18.jar";         url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.18/jmh-generator-annprocess-1.18.jar; }
     rec { sha1 = "d455b0dc6108b5e6f1fb4f6cf1c7b4cbedbecc97"; name = "JMH_GENERATOR_ANNPROCESS_1_18_${sha1}/jmh-generator-annprocess-1-18.sources.jar"; url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.18/jmh-generator-annprocess-1.18-sources.jar; }
     rec { sha1 = "7aac374614a8a76cad16b91f1a4419d31a7dcda3"; name = "JMH_GENERATOR_ANNPROCESS_1_21_${sha1}/jmh-generator-annprocess-1-21.jar";         url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar; }
     rec { sha1 = "fb48e2a97df95f8b9dced54a1a37749d2a64d2ae"; name = "JMH_GENERATOR_ANNPROCESS_1_21_${sha1}/jmh-generator-annprocess-1-21.sources.jar"; url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21-sources.jar; }
-    rec { sha1 = "702b8525fcf81454235e5e2fa2a35f15ffc0ec7e"; name = "ASM_DEBUG_ALL_${sha1}/asm-debug-all.jar";                                         url = mirror://maven/org/ow2/asm/asm-debug-all/5.0.4/asm-debug-all-5.0.4.jar; }
+    rec { sha1 = "c01b6798f81b0fc2c5faa70cbe468c275d4b50c7"; name = "ASM_6.2.1_${sha1}/asm-6.2.1.jar";                                                 url = mirror://maven/org/ow2/asm/asm/6.2.1/asm-6.2.1.jar; }
+    rec { sha1 = "cee28077ac7a63d3de0b205ec314d83944ff6267"; name = "ASM_6.2.1_${sha1}/asm-6.2.1.sources.jar";                                         url = mirror://maven/org/ow2/asm/asm/6.2.1/asm-6.2.1-sources.jar; }
+    rec { sha1 = "332b022092ecec53cdb6272dc436884b2d940615"; name = "ASM_TREE_6.2.1_${sha1}/asm-tree-6.2.1.jar";                                       url = mirror://maven/org/ow2/asm/asm-tree/6.2.1/asm-tree-6.2.1.jar; }
+    rec { sha1 = "072bd64989090e4ed58e4657e3d4481d96f643af"; name = "ASM_TREE_6.2.1_${sha1}/asm-tree-6.2.1.sources.jar";                               url = mirror://maven/org/ow2/asm/asm-tree/6.2.1/asm-tree-6.2.1-sources.jar; }
+    rec { sha1 = "e8b876c5ccf226cae2f44ed2c436ad3407d0ec1d"; name = "ASM_ANALYSIS_6.2.1_${sha1}/asm-analysis-6.2.1.jar";                               url = mirror://maven/org/ow2/asm/asm-analysis/6.2.1/asm-analysis-6.2.1.jar; }
+    rec { sha1 = "b0b249bd185677648692e7c57b488b6d7c2a6653"; name = "ASM_ANALYSIS_6.2.1_${sha1}/asm-analysis-6.2.1.sources.jar";                       url = mirror://maven/org/ow2/asm/asm-analysis/6.2.1/asm-analysis-6.2.1-sources.jar; }
+    rec { sha1 = "eaf31376d741a3e2017248a4c759209fe25c77d3"; name = "ASM_COMMONS_6.2.1_${sha1}/asm-commons-6.2.1.jar";                                 url = mirror://maven/org/ow2/asm/asm-commons/6.2.1/asm-commons-6.2.1.jar; }
+    rec { sha1 = "667fa0f9d370e7848b0e3d173942855a91fd1daf"; name = "ASM_COMMONS_6.2.1_${sha1}/asm-commons-6.2.1.sources.jar";                         url = mirror://maven/org/ow2/asm/asm-commons/6.2.1/asm-commons-6.2.1-sources.jar; }
     rec { sha1 = "ec2544ab27e110d2d431bdad7d538ed509b21e62"; name = "COMMONS_MATH3_3_2_${sha1}/commons-math3-3-2.jar";                                 url = mirror://maven/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar; }
     rec { sha1 = "cd098e055bf192a60c81d81893893e6e31a6482f"; name = "COMMONS_MATH3_3_2_${sha1}/commons-math3-3-2.sources.jar";                         url = mirror://maven/org/apache/commons/commons-math3/3.2/commons-math3-3.2-sources.jar; }
     rec { sha1 = "0174aa0077e9db596e53d7f9ec37556d9392d5a6"; name = "JMH_1_18_${sha1}/jmh-1-18.jar";                                                   url = mirror://maven/org/openjdk/jmh/jmh-core/1.18/jmh-core-1.18.jar; }
@@ -36,63 +95,125 @@ let
     rec { sha1 = "a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa"; name = "JUNIT_${sha1}/junit.sources.jar";                                                 url = mirror://maven/junit/junit/4.12/junit-4.12-sources.jar; }
     rec { sha1 = "42a25dc3219429f0e5d060061f71acb49bf010a0"; name = "HAMCREST_${sha1}/hamcrest.jar";                                                   url = mirror://maven/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar; }
     rec { sha1 = "1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b"; name = "HAMCREST_${sha1}/hamcrest.sources.jar";                                           url = mirror://maven/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar; }
-    rec { sha1 = "0d031013db9a80d6c88330c42c983fbfa7053193"; name = "jvmci/intel-hsdis-amd64-linux-${sha1}.so";                                        url = "https://lafo.ssw.uni-linz.ac.at/pub/hsdis/intel/hsdis-amd64-linux-${sha1}.so"; }
+    rec { sha1 = "0d031013db9a80d6c88330c42c983fbfa7053193"; name = "hsdis_${sha1}/hsdis.so";                                                          url = "https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/hsdis/intel/hsdis-amd64-linux-${sha1}.so"; }
   ];
 
   graal-mxcache = jvmci8-mxcache ++ [
+    rec { sha1 = "a990b2dba1c706f5c43c56fedfe70bad9a695852"; name = "LLVM_WRAPPER_${sha1}/llvm-wrapper.jar";                                           url = mirror://maven/org/bytedeco/javacpp-presets/llvm/6.0.1-1.4.2/llvm-6.0.1-1.4.2.jar; }
+    rec { sha1 = "decbd95d46092fa9afaf2523b5b23d07ad7ad6bc"; name = "LLVM_WRAPPER_${sha1}/llvm-wrapper.sources.jar";                                   url = mirror://maven/org/bytedeco/javacpp-presets/llvm/6.0.1-1.4.2/llvm-6.0.1-1.4.2-sources.jar; }
+    rec { sha1 = "344483aefa15147c121a8fb6fb35a2406768cc5c"; name = "LLVM_PLATFORM_SPECIFIC_${sha1}/llvm-platform-specific.jar";                       url = mirror://maven/org/bytedeco/javacpp-presets/llvm/6.0.1-1.4.2/llvm-6.0.1-1.4.2-linux-x86_64.jar; }
+    rec { sha1 = "503402aa0cf80fd95ede043c0011152c2b4556fd"; name = "LLVM_PLATFORM_${sha1}/llvm-platform.jar";                                         url = mirror://maven/org/bytedeco/javacpp-presets/llvm-platform/6.0.1-1.4.2/llvm-platform-6.0.1-1.4.2.jar; }
+    rec { sha1 = "cfa6a0259d98bff5aa8d41ba11b4d1dad648fbaa"; name = "JAVACPP_${sha1}/javacpp.jar";                                                     url = mirror://maven/org/bytedeco/javacpp/1.4.2/javacpp-1.4.2.jar; }
+    rec { sha1 = "fdb2d2c17f6b91cdd5421554396da8905f0dfed2"; name = "JAVACPP_${sha1}/javacpp.sources.jar";                                             url = mirror://maven/org/bytedeco/javacpp/1.4.2/javacpp-1.4.2-sources.jar; }
+    rec { sha1 = "702ca2d0ae93841c5ab75e4d119b29780ec0b7d9"; name = "NINJA_SYNTAX_${sha1}/ninja-syntax.tar.gz";                                        url = "https://pypi.org/packages/source/n/ninja_syntax/ninja_syntax-1.7.2.tar.gz"; }
+    rec { sha1 = "987234c4ce45505c21302e097c24efef4873325c"; name = "NINJA_${sha1}/ninja.zip";                                                         url = "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip";
+          isNinja = true; }
     rec { sha1 = "f2cfb09cee12469ff64f0d698b13de19903bb4f7"; name = "NanoHTTPD-WebSocket_${sha1}/nanohttpd-websocket.jar";                             url = mirror://maven/org/nanohttpd/nanohttpd-websocket/2.3.1/nanohttpd-websocket-2.3.1.jar; }
     rec { sha1 = "a8d54d1ca554a77f377eff6bf9e16ca8383c8f6c"; name = "NanoHTTPD_${sha1}/nanohttpd.jar";                                                 url = mirror://maven/org/nanohttpd/nanohttpd/2.3.1/nanohttpd-2.3.1.jar; }
-    rec { sha1 = "30b13b7efc55b7feea667691509cf59902375001"; name = "ANTLR4_${sha1}/antlr4.jar";                                                       url = mirror://maven/org/antlr/antlr4-runtime/4.7/antlr4-runtime-4.7.jar; }
-    rec { sha1 = "fdedd5f2522122102f0b3db85fe7aa563a009926"; name = "JLINE_${sha1}/jline.jar";                                                         url = mirror://maven/jline/jline/2.14.5/jline-2.14.5.jar; }
+    rec { sha1 = "946f8aa9daa917dd81a8b818111bec7e288f821a"; name = "ANTLR4_${sha1}/antlr4.jar";                                                       url = mirror://maven/org/antlr/antlr4-runtime/4.7.1/antlr4-runtime-4.7.1.jar; }
+    rec { sha1 = "c3aeac59c022bdc497c8c48ed86fa50450e4896a"; name = "JLINE_${sha1}/jline.jar";                                                         url = mirror://maven/jline/jline/2.14.6/jline-2.14.6.jar; }
     rec { sha1 = "d0bdc21c5e6404726b102998e44c66a738897905"; name = "JAVA_ALLOCATION_INSTRUMENTER_${sha1}/java-allocation-instrumenter.jar";           url = mirror://maven/com/google/code/java-allocation-instrumenter/java-allocation-instrumenter/3.1.0/java-allocation-instrumenter-3.1.0.jar; }
-    rec { sha1 = "0da08b8cce7bbf903602a25a3a163ae252435795"; name = "ASM5_${sha1}/asm5.jar";                                                           url = mirror://maven/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar; }
+    rec { sha1 = "0da08b8cce7bbf903602a25a3a163ae252435795"; name = "ASM5_${sha1}/asm5.jar";                                                        url = mirror://maven/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar; }
     rec { sha1 = "396ce0c07ba2b481f25a70195c7c94922f0d1b0b"; name = "ASM_TREE5_${sha1}/asm-tree5.jar";                                                 url = mirror://maven/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.jar; }
-    rec { sha1 = "280c265b789e041c02e5c97815793dfc283fb1e6"; name = "LIBFFI_${sha1}/libffi.tar.gz";                                                    url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/libffi-3.2.1.tar.gz; }
+    rec { sha1 = "280c265b789e041c02e5c97815793dfc283fb1e6"; name = "LIBFFI_SOURCES_${sha1}/libffi-sources.tar.gz";                                    url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/libffi-3.2.1.tar.gz; }
     rec { sha1 = "8819cea8bfe22c9c63f55465e296b3855ea41786"; name = "TruffleJSON_${sha1}/trufflejson.jar";                                             url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/trufflejson-20180130.jar; }
     rec { sha1 = "9712a8124c40298015f04a74f61b3d81a51513af"; name = "CHECKSTYLE_8.8_${sha1}/checkstyle-8.8.jar";                                       url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/checkstyle-8.8-all.jar; }
-    rec { sha1 = "a828a4f32caf9ac0b74f2548f87310959558c526"; name = "VISUALVM_COMMON_${sha1}/visualvm-common.tar.gz";                                  url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/visualvm-612.tar.gz; }
-    rec { sha1 = "7ac829f0c9a37f5cc39afd2265588a365480720d"; name = "VISUALVM_PLATFORM_SPECIFIC_${sha1}/visualvm-platform-specific.tar.gz";            url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/visualvm-612-linux-amd64.tar.gz; }
+    rec { sha1 = "5a5574f03b58465226166a638641a384b9f44445"; name = "VISUALVM_COMMON_${sha1}/visualvm-common.tar.gz";                                  url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/visualvm-655.tar.gz; }
+    rec { sha1 = "64f07398bac9897e9b8123edeaf5cf9ff19517b5"; name = "VISUALVM_PLATFORM_SPECIFIC_${sha1}/visualvm-platform-specific.tar.gz";            url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/visualvm-655-linux-amd64.tar.gz; }
     rec { sha1 = "e6e60889b7211a80b21052a249bd7e0f88f79fee"; name = "Java-WebSocket_${sha1}/java-websocket.jar";                                       url = mirror://maven/org/java-websocket/Java-WebSocket/1.3.9/Java-WebSocket-1.3.9.jar; }
+    rec { sha1 = "7a4d00d5ec5febd252a6182e8b6e87a0a9821f81"; name = "ICU4J_${sha1}/icu4j.jar";                                                         url = mirror://maven/com/ibm/icu/icu4j/62.1/icu4j-62.1.jar; }
+   # This duplication of asm with underscore and minus is totally weird
+    rec { sha1 = "c01b6798f81b0fc2c5faa70cbe468c275d4b50c7"; name = "ASM-6.2.1_${sha1}/asm-6.2.1.jar";                                                 url = mirror://maven/org/ow2/asm/asm/6.2.1/asm-6.2.1.jar; }
+    rec { sha1 = "cee28077ac7a63d3de0b205ec314d83944ff6267"; name = "ASM-6.2.1_${sha1}/asm-6.2.1.sources.jar";                                         url = mirror://maven/org/ow2/asm/asm/6.2.1/asm-6.2.1-sources.jar; }
+    rec { sha1 = "332b022092ecec53cdb6272dc436884b2d940615"; name = "ASM_TREE-6.2.1_${sha1}/asm-tree-6.2.1.jar";                                       url = mirror://maven/org/ow2/asm/asm-tree/6.2.1/asm-tree-6.2.1.jar; }
+    rec { sha1 = "072bd64989090e4ed58e4657e3d4481d96f643af"; name = "ASM_TREE-6.2.1_${sha1}/asm-tree-6.2.1.sources.jar";                               url = mirror://maven/org/ow2/asm/asm-tree/6.2.1/asm-tree-6.2.1-sources.jar; }
+    rec { sha1 = "e8b876c5ccf226cae2f44ed2c436ad3407d0ec1d"; name = "ASM_ANALYSIS-6.2.1_${sha1}/asm-analysis-6.2.1.jar";                               url = mirror://maven/org/ow2/asm/asm-analysis/6.2.1/asm-analysis-6.2.1.jar; }
+    rec { sha1 = "b0b249bd185677648692e7c57b488b6d7c2a6653"; name = "ASM_ANALYSIS-6.2.1_${sha1}/asm-analysis-6.2.1.sources.jar";                       url = mirror://maven/org/ow2/asm/asm-analysis/6.2.1/asm-analysis-6.2.1-sources.jar; }
+    rec { sha1 = "eaf31376d741a3e2017248a4c759209fe25c77d3"; name = "ASM_COMMONS-6.2.1_${sha1}/asm-commons-6.2.1.jar";                                 url = mirror://maven/org/ow2/asm/asm-commons/6.2.1/asm-commons-6.2.1.jar; }
+    rec { sha1 = "667fa0f9d370e7848b0e3d173942855a91fd1daf"; name = "ASM_COMMONS-6.2.1_${sha1}/asm-commons-6.2.1.sources.jar";                         url = mirror://maven/org/ow2/asm/asm-commons/6.2.1/asm-commons-6.2.1-sources.jar; }
+    # From here on the deps are new
+    rec { sha1 = "400d664d7c92a659d988c00cb65150d1b30cf339"; name = "ASM_UTIL-6.2.1_${sha1}/asm-util-6.2.1.jar";                                       url = mirror://maven/org/ow2/asm/asm-util/6.2.1/asm-util-6.2.1.jar; }
+    rec { sha1 = "c9f7246bf93bb0dc7fe9e7c9eca531a8fb98d252"; name = "ASM_UTIL-6.2.1_${sha1}/asm-util-6.2.1.sources.jar";                               url = mirror://maven/org/ow2/asm/asm-util/6.2.1/asm-util-6.2.1-sources.jar; }
+    rec { sha1 = "4b52bd03014f6d080ef0528865c1ee50621e35c6"; name = "NETBEANS_PROFILER_${sha1}/netbeans-profiler.jar";                                 url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/truffle/js/org-netbeans-lib-profiler-8.2-201609300101.jar; }
+    rec { sha1 = "b5840706cc8ce639fcafeab1bc61da2d8aa37afd"; name = "NASHORN_INTERNAL_TESTS_${sha1}/nashorn-internal-tests.jar";                       url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/truffle/js/nashorn-internal-tests-700f5e3f5ff2.jar; }
+    rec { sha1 = "9577018f9ce3636a2e1cb0a0c7fe915e5098ded5"; name = "JACKSON_ANNOTATIONS_${sha1}/jackson-annotations.jar";                             url = mirror://maven/com/fasterxml/jackson/core/jackson-annotations/2.8.6/jackson-annotations-2.8.6.jar; }
+    rec { sha1 = "2ef7b1cc34de149600f5e75bc2d5bf40de894e60"; name = "JACKSON_CORE_${sha1}/jackson-core.jar";                                           url = mirror://maven/com/fasterxml/jackson/core/jackson-core/2.8.6/jackson-core-2.8.6.jar; }
+    rec { sha1 = "c43de61f74ecc61322ef8f402837ba65b0aa2bf4"; name = "JACKSON_DATABIND_${sha1}/jackson-databind.jar";                                   url = mirror://maven/com/fasterxml/jackson/core/jackson-databind/2.8.6/jackson-databind-2.8.6.jar; }
+    rec { sha1 = "2838952e91baa37ac73ed817451268a193ba440a"; name = "JCODINGS_${sha1}/jcodings.jar";                                                   url = mirror://maven/org/jruby/jcodings/jcodings/1.0.40/jcodings-1.0.40.jar; }
+    rec { sha1 = "0ed89e096c83d540acac00d6ee3ea935b4c905ff"; name = "JCODINGS_${sha1}/jcodings.sources.jar";                                           url = mirror://maven/org/jruby/jcodings/jcodings/1.0.40/jcodings-1.0.40-sources.jar; }
+    rec { sha1 = "5dbb09787a9b8780737b71fbf942235ef59051b9"; name = "JONI_${sha1}/joni.jar";                                                           url = mirror://maven/org/jruby/joni/joni/2.1.25/joni-2.1.25.jar; }
+    rec { sha1 = "505a09064f6e2209616f38724f6d97d8d889aa92"; name = "JONI_${sha1}/joni.sources.jar";                                                   url = mirror://maven/org/jruby/joni/joni/2.1.25/joni-2.1.25-sources.jar; }
+    rec { sha1 = "c4f7d054303948eb6a4066194253886c8af07128"; name = "XZ-1.8_${sha1}/xz-1.8.jar";                                                       url = mirror://maven/org/tukaani/xz/1.8/xz-1.8.jar; }
+    rec { sha1 = "9314d3d372b05546a33791fbc8dd579c92ebd16b"; name = "GNUR_${sha1}/gnur.tar.gz";                                                        url = http://cran.rstudio.com/src/base/R-3/R-3.5.1.tar.gz; }
+    rec { sha1 = "90aa8308da72ae610207d8f6ca27736921be692a"; name = "ANTLR4_COMPLETE_${sha1}/antlr4-complete.jar";                                     url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/antlr-4.7.1-complete.jar; }
+  ];
+
+  graal-mxcachegit = [
+    { sha256 = "0siryzvmj9h8zkyr0d3gy9fqgyxb9s5xs15rf7lnx9zh3ykq549y"; name = "graaljs";
+      url = "http://github.com/graalvm/graaljs.git"; rev = "vm-${version}"; }
+    { sha256 = "1ii3mwa0c2zk9vm51hyrymdz3whfihm6sccd2r5ja2v53jcdc1a3"; name = "truffleruby";
+      url = "http://github.com/oracle/truffleruby.git"; rev = "vm-${version}"; }
+    { sha256 = "1nz8yqg2k9shpmhj3jv7k2icfg72cm55baf354rsh1pqanay8qb7"; name = "fastr";
+      url = "http://github.com/oracle/fastr.git"; rev = "vm-${version}"; }
+    { sha256 = "1c8nnrl30fys22gk3y6dvxzq0fq1a5hjkqrw15p68cwpz9wma4gi"; name = "graalpython";
+      url = "https://github.com/graalvm/graalpython.git"; rev = "vm-${version}"; }
   ];
 
+  ninja-syntax = python27.pkgs.buildPythonPackage rec {
+    version = "1.7.2";
+    pname = "ninja_syntax";
+    doCheck = false;
+    src = python27.pkgs.fetchPypi {
+      inherit pname version;
+      sha256 = "07zg30m0khx55fv2gxxn7pqd549z0vk3x592mrdlk9l8krxwjb9l";
+    };
+  };
+
   findbugs = fetchzip {
     name   = "findbugs-3.0.0";
     url    = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/findbugs-3.0.0.zip;
     sha256 = "0sf5f9h1s6fmhfigjy81i109j1ani5kzdr4njlpq0mnkkh9fpr7m";
   };
 
+  python27withPackages = python27.withPackages (ps: [ ninja-syntax ]);
+
 in rec {
 
   mx = stdenv.mkDerivation rec {
-    version = "5.192.0";
+    version = "5.215.4";
     pname = "mx";
     src = fetchFromGitHub {
       owner  = "graalvm";
       repo   = "mx";
       rev    = version;
-      sha256 = "04gdf1gzlc8a6li8lcnrs2j9zicj11fs1vqqf7cmhb4pm2h72hml";
+      sha256 = "0wrwfiwqjw6xp0bvp2g15jn6yrjb9w6jw1xnwvkyhkw1s6m0w0z1";
     };
     nativeBuildInputs = [ makeWrapper ];
+    prePatch = ''
+      cp mx.py bak_mx.py
+    '';
+    patches = [ ./001_mx.py.patch ];
+    postPatch = ''
+      mv mx.py internal_mx.py
+      mv bak_mx.py mx.py
+    '';
     buildPhase = ''
       substituteInPlace mx --replace /bin/pwd pwd
 
-      # forbid network access while simulate success for passing obligatory "VerifyLibraryURL"
-      substituteInPlace mx.py --replace \
-        'def download(path, urls, verbose=False, abortOnError=True, verifyOnly=False):' \
-        'def download(path, urls, verbose=False, abortOnError=True, verifyOnly=False):
-          print("FAKE download(path={} urls={} verbose={} abortOnError={} verifyOnly={})".format(path, urls, verbose, abortOnError, verifyOnly))
-          return True'
-
       # avoid crash with 'ValueError: ZIP does not support timestamps before 1980'
-      substituteInPlace mx.py --replace \
-        'zipfile.ZipInfo(arcname, time.localtime(os.path.getmtime(join(root, f)))[:6])' \
+      substituteInPlace internal_mx.py --replace \
+        'zipfile.ZipInfo(arcname, time.localtime(getmtime(join(root, f)))[:6])' \
         'zipfile.ZipInfo(arcname, time.strptime ("1 Jan 1980", "%d %b %Y"       )[:6])'
     '';
     installPhase = ''
       mkdir -p $out/bin
       cp -dpR * $out/bin
       wrapProgram $out/bin/mx \
-        --prefix PATH : ${lib.makeBinPath [ python27 mercurial ]} \
+        --prefix PATH : ${lib.makeBinPath [ python27withPackages mercurial ]} \
+        --set    FINDBUGS_HOME ${findbugs}
+      makeWrapper ${python27}/bin/python $out/bin/mx-internal \
+        --add-flags "$out/bin/internal_mx.py" \
+        --prefix PATH : ${lib.makeBinPath [ python27withPackages mercurial ]} \
         --set    FINDBUGS_HOME ${findbugs}
     '';
     meta = with stdenv.lib; {
@@ -103,22 +224,16 @@ in rec {
     };
   };
 
-  # copy of pkgs.oraclejvm8 with JVMCI interface (TODO: it should work with pkgs.openjdk8 too)
   jvmci8 = stdenv.mkDerivation rec {
-    version = "0.49";
-    name = let
-             n = "jvmci${/*"8u191"*/ lib.removePrefix "oraclejdk-" oraclejdk8.name}-${version}";
-           in if (lib.stringLength n) == (lib.stringLength oraclejdk8.name) then
-                n
-              else
-                throw "length of string `${n}' must be equal to the length of `${oraclejdk8.name}'";
+    version = "0.58";
+    name = "jvmci-${version}";
     src = fetchFromGitHub {
       owner  = "graalvm";
       repo   = "graal-jvmci-8";
       rev    = "jvmci-${version}";
-      sha256 = "1zgin0w1qa7wmfhcisx470fhnmddfxxp5nyyix31yaa7dznql82k";
+      sha256 = "0p8icn3d99zggsh6pqb15dz1j186ck442sjpn2cv43n4nvdmmp1m";
     };
-    buildInputs = [ mx mercurial ];
+    buildInputs = [ mx mercurial openjdk ];
     postUnpack = ''
       # a fake mercurial dir to prevent mx crash and supply the version to mx
       ( cd $sourceRoot
@@ -129,46 +244,55 @@ in rec {
         hg checkout ${lib.escapeShellArg src.rev}
       )
     '';
+    patches = [ ./004_mx_jvmci.py.patch ];
+    postPatch =''
+      # The hotspot version name regex fix
+      substituteInPlace mx.jvmci/mx_jvmci.py \
+        --replace "\\d+.\\d+-b\\d+" "\\d+.\\d+-bga"
+    '';
     hardeningDisable = [ "fortify" ];
     NIX_CFLAGS_COMPILE = [
       "-Wno-error=format-overflow" # newly detected by gcc7
       "-Wno-error=nonnull"
     ];
     buildPhase = ''
-      cp -dpR ${oraclejdk8} writable-copy-of-jdk
-      chmod +w -R writable-copy-of-jdk
-
       export MX_ALT_OUTPUT_ROOT=$NIX_BUILD_TOP/mxbuild
       export MX_CACHE_DIR=${makeMxCache jvmci8-mxcache}
-      mx --java-home $(pwd)/writable-copy-of-jdk build
+
+      mx-internal --primary-suite . --vm=server -v build -DFULL_DEBUG_SYMBOLS=0
+      mx-internal --primary-suite . --vm=server -v vm -version
+      mx-internal --primary-suite . --vm=server -v unittest
     '';
     installPhase = ''
-      mv jdk1.8.0_*/linux-amd64/product $out
-      find $out -type f -exec sed -i "s#${oraclejdk8}#$out#g" {} \;
-
-      install -v -m0555 -D $MX_CACHE_DIR/jvmci/*hsdis*.so $out/jre/lib/amd64/hsdis-amd64.so
+      mkdir -p $out
+      mv openjdk1.8.0_*/linux-amd64/product/* $out
+      install -v -m0555 -D $MX_CACHE_DIR/hsdis*/hsdis.so $out/jre/lib/amd64/hsdis-amd64.so
     '';
     dontFixup = true; # do not nuke path of ffmpeg etc
     dontStrip = true; # why? see in oraclejdk derivation
-    inherit (oraclejdk8) meta;
+    meta = openjdk.meta // { inherit (graalvm8.meta) platforms; };
+    inherit (openjdk) postFixup;
   };
 
   graalvm8 = stdenv.mkDerivation rec {
-    version = "1.0.0-rc8";
-    name = let
-             n = "graal-${version}";
-           in if (lib.stringLength n) == (lib.stringLength jvmci8.name) then
-                n
-              else
-                throw "length of string `${n}' must be equal to the length of `${jvmci8.name}'";
+    inherit version;
+    name = "graal-${version}";
     src = fetchFromGitHub {
       owner  = "oracle";
       repo   = "graal";
       rev    = "vm-${version}";
-      sha256 = "1fada4awrr8bhw294xdiq4bagvgrlcr44mw6338gaal0ky3vkm0p";
+      sha256 = "18fqah8x7gwz02ji40b4vyqav9x5dw703xwikjc117wlyymb1k56";
     };
-    buildInputs = [ mx zlib mercurial jvmci8 ];
+    patches = [ ./002_setjmp.c.patch ./003_mx_truffle.py.patch ];
+    buildInputs = [ mx zlib mercurial jvmci8 git clang llvm
+                    python27withPackages which icu ruby bzip2
+                    # gfortran readline bzip2 lzma pcre.dev curl ed ## WIP: fastr dependencies
+                  ];
     postUnpack = ''
+      cp ${stdenv.cc.cc}/include/c++/${stdenv.cc.cc.version}/stdlib.h \
+        $sourceRoot/sulong/projects/com.oracle.truffle.llvm.libraries.bitcode/include
+      cp ${truffleMake} $TMP && mv *truffle.make truffle.make
+      rm $sourceRoot/truffle/src/libffi/patches/others/0001-Add-mx-bootstrap-Makefile.patch
       # a fake mercurial dir to prevent mx crash and supply the version to mx
       ( cd $sourceRoot
         hg init
@@ -188,58 +312,54 @@ in rec {
           'command.add(Platform.includedIn(Platform.WINDOWS.class) ? "CL" : "${stdenv.cc}/bin/gcc");'
       substituteInPlace substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java \
         --replace 'protected String compilerCommand = "cc";' 'protected String compilerCommand = "${stdenv.cc}/bin/cc";'
+      # prevent cyclical imports caused by identical <include> names
+      substituteInPlace sulong/projects/com.oracle.truffle.llvm.libraries.bitcode/include/stdlib.h \
+        --replace '# include <cstdlib>' '# include "${stdenv.cc.cc}/include/c++/${stdenv.cc.cc.version}/cstdlib"'
+      # dragonegg can't seem to compile on nix, so let's not require it
+      substituteInPlace sulong/mx.sulong/suite.py \
+        --replace '"requireDragonegg" : True,' '"requireDragonegg" : False,'
+      substituteInPlace truffle/mx.truffle/mx_truffle.py \
+        --replace 'os.path.relpath(self.subject.delegate.dir, self.subject.suite.vc_dir)' \
+                  'self.subject.delegate.dir'
+
+      # Patch the native-image template, as it will be run during build
+      chmod +x vm/mx.vm/launcher_template.sh && patchShebangs vm/mx.vm
     '';
+
     buildPhase = ''
       # make a copy of jvmci8
-      cp -dpR ${jvmci8} $out
-      chmod +w -R $out
-      find $out -type f -exec sed -i "s#${jvmci8}#$out#g" {} \;
+      mkdir $NIX_BUILD_TOP/jvmci8
+      cp -dpR ${jvmci8}/* $NIX_BUILD_TOP/jvmci8
+      chmod +w -R $NIX_BUILD_TOP/jvmci8
 
       export MX_ALT_OUTPUT_ROOT=$NIX_BUILD_TOP/mxbuild
       export MX_CACHE_DIR=${makeMxCache graal-mxcache}
+      export MX_GIT_CACHE='refcache'
+      export MX_GIT_CACHE_DIR=$NIX_BUILD_TOP/mxgitcache
+      export JVMCI_VERSION_CHECK='ignore'
+      export JAVA_HOME=$NIX_BUILD_TOP/jvmci8
+      # export FASTR_RELEASE=true ## WIP
+      ${makeMxGitCache graal-mxcachegit "$MX_GIT_CACHE_DIR"}
+      cd $NIX_BUILD_TOP/source
 
-      ( cd substratevm
-
-        mkdir -p clibraries
-        mx --java-home $out build
-
-        # bootstrap native-image (that was removed from mx build in https://github.com/oracle/graal/commit/140d7a7edf54ec5872a8ff45869cd1ae499efde4)
-        mx --java-home $out native-image -cp $MX_ALT_OUTPUT_ROOT/substratevm/dists/jdk1.8/svm-driver.jar com.oracle.svm.driver.NativeImage
-      )
-      ( cd tools
-        mx --java-home $out build
+      ( cd vm
+        mx-internal -v --dynamicimports /substratevm,/tools,sulong,/graal-nodejs,graalpython build
       )
     '';
-    installPhase = ''
-      # add graal files modelling after directory structure of "graalvm-ce" binary distribution
-      mkdir -p $out/jre/tools/{profiler,chromeinspector,truffle/builder} $out/jre/lib/{graal,include,truffle/include}
-      cp -vpLR substratevm/svmbuild/native-image-root/lib/*                         $out/jre/lib/           || true # ignore "same file" error when dereferencing symlinks
-      cp -vp   $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/bin/*     $out/jre/lib/amd64/
-      cp -vp   $MX_ALT_OUTPUT_ROOT/compiler/dists/jdk1.8/graal-*processor*.jar      $out/jre/lib/graal/
-      cp -vp   $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/include/* $out/jre/lib/include/
-      cp -vp   $MX_ALT_OUTPUT_ROOT/compiler/dists/jdk1.8/graal-management.jar       $out/jre/lib/jvmci/
-      cp -vdpR $out/jre/lib/svm/clibraries                                          $out/jre/lib/svm/builder/
-      cp -vpR  $MX_ALT_OUTPUT_ROOT/truffle/dists/jdk1.8/*                           $out/jre/lib/truffle/
-      cp -vp   $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/include/* $out/jre/lib/truffle/include/
-      cp -vpLR substratevm/svmbuild/native-image-root/tools/*                       $out/jre/tools/
-      cp -vpR  $MX_ALT_OUTPUT_ROOT/tools/dists/chromeinspector*                     $out/jre/tools/chromeinspector/
-      cp -vpR  $MX_ALT_OUTPUT_ROOT/tools/dists/truffle-profiler*                    $out/jre/tools/profiler/
-      cp -vpR  $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/*         $out/jre/tools/truffle/
-      cp -vp   $MX_ALT_OUTPUT_ROOT/truffle/dists/jdk1.8/truffle-nfi.jar             $out/jre/tools/truffle/builder/
-
-      echo "name=GraalVM ${version}"                                              > $out/jre/lib/amd64/server/vm.properties
-      echo -n "graal"                                                             > $out/jre/lib/jvmci/compiler-name
-      echo -n "../truffle/truffle-api.jar:../truffle/truffle-nfi.jar"             > $out/jre/lib/jvmci/parentClassLoader.classpath
 
-      install -v -m0555 -D substratevm/com.oracle.svm.driver.nativeimage            $out/jre/lib/svm/bin/native-image
-      ln -s                ../lib/svm/bin/native-image                              $out/jre/bin/native-image
-      ln -s                ../jre/bin/native-image                                  $out/bin/native-image
+    installPhase = ''
+      mkdir -p $out
+      cp -rf $MX_ALT_OUTPUT_ROOT/vm/linux-amd64/GRAALVM_CMP_GU_GVM_INS_JS_LIBPOLY_NFI_NJS_POLY_POLYNATIVE_PRO_PYN_RGX_SLG_SVM_SVMAG_SVMCF_SVML_TFL_VVM/graalvm-unknown-${version}/* $out
 
       # BUG workaround http://mail.openjdk.java.net/pipermail/graal-dev/2017-December/005141.html
       substituteInPlace $out/jre/lib/security/java.security \
         --replace file:/dev/random    file:/dev/./urandom \
         --replace NativePRNGBlocking  SHA1PRNG
+      # Organize the out dir
+      mkdir -p $out/share && mv $out/man $out/share
+      rm $out/ASSEMBLY_EXCEPTION $out/release $out/LICENSE $out/THIRD_PARTY_README
     '';
+
     dontFixup = true; # do not nuke path of ffmpeg etc
     dontStrip = true; # why? see in oraclejdk derivation
     doInstallCheck = true;
@@ -268,8 +388,8 @@ in rec {
     meta = with stdenv.lib; {
       homepage = https://github.com/oracle/graal;
       description = "High-Performance Polyglot VM";
-      license = licenses.unfree;
-      maintainers = with maintainers; [ volth ];
+      license = licenses.gpl2;
+      maintainers = with maintainers; [ volth hlolli ];
       platforms = [ "x86_64-linux" ];
     };
   };
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/truffle.make b/nixpkgs/pkgs/development/compilers/graalvm/truffle.make
new file mode 100644
index 000000000000..da887c142408
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/graalvm/truffle.make
@@ -0,0 +1,14 @@
+# This Makefile is used by mx to bootstrap libffi build.
+
+# `make MX_VERBOSE=y` will report all lines executed. The actual value doesn't
+# matter as long as it's not empty.
+QUIETLY$(MX_VERBOSE) = @
+
+.PHONY: default
+
+default:
+	$(QUIETLY) echo CONFIGURE libffi
+	$(QUIETLY) mkdir ../$(OUTPUT)
+	$(QUIETLY) cd ../$(OUTPUT) && ../$(SOURCES)/configure $(CONFIGURE_ARGS) > ../libffi.configure.log
+	$(QUIETLY) echo MAKE libffi
+	$(QUIETLY) $(MAKE) -C ../$(OUTPUT) > ../libffi.build.log
diff --git a/nixpkgs/pkgs/development/compilers/ldc/default.nix b/nixpkgs/pkgs/development/compilers/ldc/default.nix
index 71473be580ea..b3cf84fdd0f8 100644
--- a/nixpkgs/pkgs/development/compilers/ldc/default.nix
+++ b/nixpkgs/pkgs/development/compilers/ldc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, ninja, llvm, llvm_8, curl, tzdata
+{ stdenv, fetchurl, cmake, ninja, llvm_5, llvm_8, curl, tzdata
 , python, libconfig, lit, gdb, unzip, darwin, bash
 , callPackage, makeWrapper, targetPackages
 , bootstrapVersion ? false
@@ -83,7 +83,7 @@ stdenv.mkDerivation rec {
   ++ stdenv.lib.optional (!bootstrapVersion && stdenv.hostPlatform.isDarwin) [
     # https://github.com/NixOS/nixpkgs/issues/57120
     # https://github.com/NixOS/nixpkgs/pull/59197#issuecomment-481972515
-    llvm
+    llvm_5
   ]
 
   ++ stdenv.lib.optional (!bootstrapVersion && !stdenv.hostPlatform.isDarwin) [
@@ -96,7 +96,7 @@ stdenv.mkDerivation rec {
   ]
 
   ++ stdenv.lib.optional (bootstrapVersion) [
-    libconfig llvm
+    libconfig llvm_5
   ]
 
   ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix
index 462e35a483f4..7b7ac7297ba3 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix
@@ -43,5 +43,6 @@ stdenv.mkDerivation rec {
     description = "A new implementation of the C++ standard library, targeting C++11";
     license = with stdenv.lib.licenses; [ ncsa mit ];
     platforms = stdenv.lib.platforms.unix;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix
index 6c935fd88de5..174cb17908cc 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix
@@ -22,10 +22,13 @@ assert (stdenv.hostPlatform != stdenv.buildPlatform) -> !enableSharedLibraries;
 let
   src = fetch "llvm" "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z";
 
-  # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
-    concatStringsSep "." (take 2 (splitString "." version));
-in stdenv.mkDerivation rec {
+  # Used when creating a versioned symlinks of libLLVM.dylib
+  versionSuffixes = with stdenv.lib;
+    let parts = splitString "." version; in
+    imap (i: _: concatStringsSep "." (take i parts)) parts;
+in
+
+stdenv.mkDerivation {
   name = "llvm-${version}";
 
   unpackPhase = ''
@@ -153,8 +156,9 @@ in stdenv.mkDerivation rec {
   + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${version}.dylib
+    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
+    '') versionSuffixes}
   '';
 
   enableParallelBuilding = true;
diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix
index 21b0c1c3601c..cf6de26a9e83 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix
@@ -27,5 +27,6 @@ stdenv.mkDerivation {
     homepage    = http://lld.llvm.org/;
     license     = stdenv.lib.licenses.ncsa;
     platforms   = stdenv.lib.platforms.all;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix
index 5cd7901fe22c..ecb18a580540 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix
@@ -19,10 +19,13 @@
 let
   src = fetch "llvm" "0l9bf7kdwhlj0kq1hawpyxhna1062z3h7qcz2y8nfl9dz2qksy6s";
 
-  # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
-    concatStringsSep "." (take 2 (splitString "." release_version));
-in stdenv.mkDerivation (rec {
+  # Used when creating a versioned symlinks of libLLVM.dylib
+  versionSuffixes = with stdenv.lib;
+    let parts = splitString "." release_version; in
+    imap (i: _: concatStringsSep "." (take i parts)) parts;
+in
+
+stdenv.mkDerivation (rec {
   name = "llvm-${version}";
 
   unpackPhase = ''
@@ -136,8 +139,9 @@ in stdenv.mkDerivation (rec {
   + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
+    '') versionSuffixes}
   '';
 
   doCheck = stdenv.isLinux && (!stdenv.isi686);
diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix
index 9a47435cf140..bf23f80ef103 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix
@@ -27,5 +27,6 @@ stdenv.mkDerivation {
     homepage    = http://lld.llvm.org/;
     license     = stdenv.lib.licenses.ncsa;
     platforms   = stdenv.lib.platforms.all;
+    badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix
index 41dc20ec4fe3..d6839f0f2909 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix
@@ -18,10 +18,13 @@
 let
   src = fetch "llvm" "0g1bbj2n6xv4p1n6hh17vj3vpvg56wacipc81dgwga9mg2lys8nm";
 
-  # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
-    concatStringsSep "." (take 2 (splitString "." release_version));
-in stdenv.mkDerivation (rec {
+  # Used when creating a versioned symlinks of libLLVM.dylib
+  versionSuffixes = with stdenv.lib;
+    let parts = splitString "." release_version; in
+    imap (i: _: concatStringsSep "." (take i parts)) parts;
+in
+
+stdenv.mkDerivation (rec {
   name = "llvm-${version}";
 
   unpackPhase = ''
@@ -119,8 +122,9 @@ in stdenv.mkDerivation (rec {
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLTO.dylib" "$lib/lib/libLTO.dylib"
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
+    '') versionSuffixes}
   '';
 
   doCheck = stdenv.isLinux && (!stdenv.isi686);
diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix
index 1d96513a0ece..9237d442b776 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix
@@ -21,11 +21,13 @@ let
 
   src = fetch "llvm" "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn";
 
-  # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
-    concatStringsSep "." (take 2 (splitString "." release_version));
+  # Used when creating a versioned symlinks of libLLVM.dylib
+  versionSuffixes = with stdenv.lib;
+    let parts = splitString "." release_version; in
+    imap (i: _: concatStringsSep "." (take i parts)) parts;
+in
 
-in stdenv.mkDerivation (rec {
+stdenv.mkDerivation (rec {
   name = "llvm-${version}";
 
   unpackPhase = ''
@@ -133,8 +135,9 @@ in stdenv.mkDerivation (rec {
   + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
+    '') versionSuffixes}
   '';
 
   doCheck = stdenv.isLinux && (!stdenv.isi686);
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
index e4252647ce6d..a4877b3fe6f5 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
@@ -9,7 +9,7 @@ let
     name = "clang-${version}";
 
     unpackPhase = ''
-      unpackFile ${fetch "cfe" "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"}
+      unpackFile ${fetch "cfe" "0vc4i87qwxnw9lci4ayws9spakg0z6w5w670snj9f8g5m9rc8zg9"}
       mv cfe-${version}* clang
       sourceRoot=$PWD/clang
       unpackFile ${clang-tools-extra_src}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch
deleted file mode 100644
index f9323ed95c05..000000000000
--- a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-commit f00c7bccf7955b7dfbb4859fd9019e9eb3349f2d
-Author: Tobias Mayer <tobim@fastmail.fm>
-Date:   Wed Feb 13 12:44:17 2019 +0100
-
-    Provide clock_gettime for xray on macos < 10.12
-
-diff --git a/lib/xray/xray_basic_logging.cc b/lib/xray/xray_basic_logging.cc
-index a46c151af..38aea6932 100644
---- a/lib/xray/xray_basic_logging.cc
-+++ b/lib/xray/xray_basic_logging.cc
-@@ -36,6 +36,29 @@
- #include "xray_tsc.h"
- #include "xray_utils.h"
- 
-+#if __MACH__
-+#include <mach/clock.h>
-+#include <mach/mach.h>
-+enum clockid_t {
-+    CLOCK_MONOTONIC = REALTIME_CLOCK,
-+    CLOCK_REALTIME = REALTIME_CLOCK
-+};
-+
-+int clock_gettime(clockid_t clock_id, struct timespec *ts) {
-+  if (ts != NULL) {
-+      clock_serv_t cclock;
-+      mach_timespec_t mts;
-+      host_get_clock_service(mach_host_self(), clock_id, &cclock);
-+      clock_get_time(cclock, &mts);
-+      mach_port_deallocate(mach_task_self(), cclock);
-+      ts->tv_sec = mts.tv_sec;
-+      ts->tv_nsec = mts.tv_nsec;
-+      return 0;
-+  }
-+  return -1;
-+}
-+#endif
-+
- namespace __xray {
- 
- SpinMutex LogMutex;
-diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc
-index 4b308b27f..1d044c8fd 100644
---- a/lib/xray/xray_fdr_logging.cc
-+++ b/lib/xray/xray_fdr_logging.cc
-@@ -38,6 +38,29 @@
- #include "xray_tsc.h"
- #include "xray_utils.h"
- 
-+#if __MACH__
-+#include <mach/clock.h>
-+#include <mach/mach.h>
-+enum clockid_t {
-+    CLOCK_MONOTONIC = REALTIME_CLOCK,
-+    CLOCK_REALTIME = REALTIME_CLOCK
-+};
-+
-+int clock_gettime(clockid_t clock_id, struct timespec *ts) {
-+  if (ts != NULL) {
-+      clock_serv_t cclock;
-+      mach_timespec_t mts;
-+      host_get_clock_service(mach_host_self(), clock_id, &cclock);
-+      clock_get_time(cclock, &mts);
-+      mach_port_deallocate(mach_task_self(), cclock);
-+      ts->tv_sec = mts.tv_sec;
-+      ts->tv_nsec = mts.tv_nsec;
-+      return 0;
-+  }
-+  return -1;
-+}
-+#endif
-+
- namespace __xray {
- 
- atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED};
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix
index 7a6c91fb832b..989529ff8cc8 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix
@@ -2,7 +2,7 @@
 stdenv.mkDerivation rec {
   name = "compiler-rt-${version}";
   inherit version;
-  src = fetch "compiler-rt" "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq";
+  src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
 
   nativeBuildInputs = [ cmake python llvm ];
   buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
@@ -26,9 +26,8 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin ./compiler-rt-clock_gettime.patch;
+  ] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch
+    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix
index 060bef69bc15..7f99cc9ae2cd 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix
@@ -5,7 +5,7 @@
 }:
 
 let
-  release_version = "7.0.1";
+  release_version = "7.1.0";
   version = release_version; # differentiating these is important for rc's
 
   fetch = name: sha256: fetchurl {
@@ -13,7 +13,7 @@ let
     inherit sha256;
   };
 
-  clang-tools-extra_src = fetch "clang-tools-extra" "1v9vc7id1761qm7mywlknsp810232iwyz8rd4y5km4h7pg9cg4sc";
+  clang-tools-extra_src = fetch "clang-tools-extra" "0lb4kdh7j2fhfz8kd6iv5df7m3pikiryk1vvwsf87spc90n09q0w";
 
   tools = stdenv.lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix
index d372984dac7c..e2ec4e274f4c 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation rec {
   name = "libc++-${version}";
 
-  src = fetch "libcxx" "1wdrxg365ig0kngx52pd0n820sncp24blb0zpalc579iidhh4002";
+  src = fetch "libcxx" "0kmhcapm2cjwalyiqasj9dmqbw59mcwdl8fgl951wg7ax84b8hj4";
 
   postUnpack = ''
     unpackFile ${libcxxabi.src}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix
index b65b75b36886..2fe6f1c58f66 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation {
   name = "libc++abi-${version}";
 
-  src = fetch "libcxxabi" "1n6yx0949l9bprh75dffchahn8wplkm79ffk4f2ap9vw2lx90s41";
+  src = fetch "libcxxabi" "1zcqxsdjhawgz1cvpk07y3jl6fg9p3ay4nl69zsirqb2ghgyhhb2";
 
   nativeBuildInputs = [ cmake ];
   buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix
index 33085eb3c808..63ad43e62cd7 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix
@@ -9,7 +9,7 @@
 stdenv.mkDerivation {
   name = "lld-${version}";
 
-  src = fetch "lld" "0ca0qygrk87lhjk6cpv1wbmdfnficqqjsda3k7b013idvnralsc8";
+  src = fetch "lld" "0rsqb7zcnij5r5ipfhr129j7skr5n9pyr388kjpqwh091952f3x1";
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ llvm libxml2 ];
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix
index 14cc0514fe6d..f58871f1d7cd 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix
@@ -17,7 +17,7 @@
 stdenv.mkDerivation {
   name = "lldb-${version}";
 
-  src = fetch "lldb" "10k9lyk3i72j9hca523r9pz79qp7d8q7jqnjy0i3saj1bgknpd3n";
+  src = fetch "lldb" "0klsscg1sczc4nw2l53xggi969k361cng2sjjrfp3bv4g5x14s4v";
 
   postPatch = ''
     # Fix up various paths that assume llvm and clang are installed in the same place
@@ -27,6 +27,9 @@ stdenv.mkDerivation {
       cmake/modules/LLDBStandalone.cmake
     sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \
       cmake/modules/LLDBStandalone.cmake
+    sed -i -e 's,message(SEND_ERROR "Cannot find debugserver on system."),,' \
+           -e 's,string(STRIP ''${XCODE_DEV_DIR} XCODE_DEV_DIR),,' \
+           tools/debugserver/source/CMakeLists.txt
   '';
 
   nativeBuildInputs = [ cmake python which swig ];
@@ -36,8 +39,11 @@ stdenv.mkDerivation {
   CXXFLAGS = "-fno-rtti";
   hardeningDisable = [ "format" ];
 
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-I${libxml2.dev}/include/libxml2";
+
   cmakeFlags = [
     "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
+    "-DSKIP_DEBUGSERVER=ON"
   ];
 
   enableParallelBuilding = true;
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix
index 34f8a5478d1b..c288fd3e2a5c 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix
@@ -22,12 +22,13 @@
 let
   inherit (stdenv.lib) optional optionals optionalString;
 
-  src = fetch "llvm" "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3";
-  polly_src = fetch "polly" "0wgvayfilgb530bq51l7szxfb13l24nnrmyji2f6ncq95a24dw8v";
+  src = fetch "llvm" "0r1p5didv4rkgxyvbkyz671xddg6i3dxvbpsi1xxipkla0l9pk0v";
+  polly_src = fetch "polly" "16qkns4ab4x0azrvhy4j7cncbyb2rrbdrqj87zphvqxm5pvm8m1h";
 
-  # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
-    concatStringsSep "." (take 1 (splitString "." release_version));
+  # Used when creating a versioned symlinks of libLLVM.dylib
+  versionSuffixes = with stdenv.lib;
+    let parts = splitString "." release_version; in
+    imap (i: _: concatStringsSep "." (take i parts)) parts;
 
 in stdenv.mkDerivation (rec {
   name = "llvm-${version}";
@@ -53,12 +54,6 @@ in stdenv.mkDerivation (rec {
   propagatedBuildInputs = [ ncurses zlib ];
 
   patches = [
-    # https://bugs.llvm.org/show_bug.cgi?id=39427
-    # https://github.com/NixOS/nixpkgs/issues/54370
-    (fetchpatch {
-      url = "https://github.com/llvm-mirror/llvm/commit/57567def148f387153a8149fb590bd39b1b006a1.patch";
-      sha256 = "1w1xg5pxpc6cals1nf5j5k4p6qi8lcrpvn0paxc86m415i79xmcg";
-    })
     # backport, fix building rust crates with lto
     (fetchpatch {
       url = "https://github.com/llvm-mirror/llvm/commit/da1fb72bb305d6bc1f3899d541414146934bf80f.patch";
@@ -148,8 +143,9 @@ in stdenv.mkDerivation (rec {
   + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
+    '') versionSuffixes}
   '';
 
   doCheck = stdenv.isLinux && (!stdenv.isx86_32);
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix
index fb856eaa51fd..e55f4aa5ba13 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix
@@ -9,7 +9,7 @@
 stdenv.mkDerivation {
   name = "openmp-${version}";
 
-  src = fetch "openmp" "030dkg5cypd7j9hq0mcqb5gs31lxwmzfq52j81l7v9ldcy5bf5mz";
+  src = fetch "openmp" "1dg53wzsci2kra8lh1y0chh60h2l8h1by93br5spzvzlxshkmrqy";
 
   nativeBuildInputs = [ cmake perl ];
   buildInputs = [ llvm ];
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
index 8709e47dd3aa..c0a0e0851450 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
@@ -42,7 +42,7 @@ let
       # Backport for -static-pie, which the latter touches, and which is nice in
       # its own right.
       ./static-pie.patch
-      # Backport for the `--unwindlib=[libgcc|complier-rt]` flag, which is
+      # Backport for the `--unwindlib=[libgcc|compiler-rt]` flag, which is
       # needed for our bootstrapping to not interfere with C.
       ./unwindlib.patch
     ];
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch
deleted file mode 100644
index f9323ed95c05..000000000000
--- a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-commit f00c7bccf7955b7dfbb4859fd9019e9eb3349f2d
-Author: Tobias Mayer <tobim@fastmail.fm>
-Date:   Wed Feb 13 12:44:17 2019 +0100
-
-    Provide clock_gettime for xray on macos < 10.12
-
-diff --git a/lib/xray/xray_basic_logging.cc b/lib/xray/xray_basic_logging.cc
-index a46c151af..38aea6932 100644
---- a/lib/xray/xray_basic_logging.cc
-+++ b/lib/xray/xray_basic_logging.cc
-@@ -36,6 +36,29 @@
- #include "xray_tsc.h"
- #include "xray_utils.h"
- 
-+#if __MACH__
-+#include <mach/clock.h>
-+#include <mach/mach.h>
-+enum clockid_t {
-+    CLOCK_MONOTONIC = REALTIME_CLOCK,
-+    CLOCK_REALTIME = REALTIME_CLOCK
-+};
-+
-+int clock_gettime(clockid_t clock_id, struct timespec *ts) {
-+  if (ts != NULL) {
-+      clock_serv_t cclock;
-+      mach_timespec_t mts;
-+      host_get_clock_service(mach_host_self(), clock_id, &cclock);
-+      clock_get_time(cclock, &mts);
-+      mach_port_deallocate(mach_task_self(), cclock);
-+      ts->tv_sec = mts.tv_sec;
-+      ts->tv_nsec = mts.tv_nsec;
-+      return 0;
-+  }
-+  return -1;
-+}
-+#endif
-+
- namespace __xray {
- 
- SpinMutex LogMutex;
-diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc
-index 4b308b27f..1d044c8fd 100644
---- a/lib/xray/xray_fdr_logging.cc
-+++ b/lib/xray/xray_fdr_logging.cc
-@@ -38,6 +38,29 @@
- #include "xray_tsc.h"
- #include "xray_utils.h"
- 
-+#if __MACH__
-+#include <mach/clock.h>
-+#include <mach/mach.h>
-+enum clockid_t {
-+    CLOCK_MONOTONIC = REALTIME_CLOCK,
-+    CLOCK_REALTIME = REALTIME_CLOCK
-+};
-+
-+int clock_gettime(clockid_t clock_id, struct timespec *ts) {
-+  if (ts != NULL) {
-+      clock_serv_t cclock;
-+      mach_timespec_t mts;
-+      host_get_clock_service(mach_host_self(), clock_id, &cclock);
-+      clock_get_time(cclock, &mts);
-+      mach_port_deallocate(mach_task_self(), cclock);
-+      ts->tv_sec = mts.tv_sec;
-+      ts->tv_nsec = mts.tv_nsec;
-+      return 0;
-+  }
-+  return -1;
-+}
-+#endif
-+
- namespace __xray {
- 
- atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED};
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix
index 2b591cc94aff..a8bbb1f719bf 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix
@@ -34,8 +34,7 @@ stdenv.mkDerivation rec {
   patches = [
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
   ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin ./compiler-rt-clock_gettime.patch;
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
diff --git a/nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch b/nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch
deleted file mode 100644
index 779391fc62a9..000000000000
--- a/nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From f3db284516105fd30b5513a5528104574a7b8545 Mon Sep 17 00:00:00 2001
-From: Samuel Dionne-Riel <samuel@dionne-riel.com>
-Date: Thu, 9 Aug 2018 19:07:45 -0400
-Subject: [PATCH] Disables `IO#isatty` test for sandboxed builds.
-
----
- mrbgems/mruby-io/test/io.rb | 13 -------------
- 1 file changed, 13 deletions(-)
-
-diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb
-index e06b1499..e8a54736 100644
---- a/mrbgems/mruby-io/test/io.rb
-+++ b/mrbgems/mruby-io/test/io.rb
-@@ -342,19 +342,6 @@ assert('IO#_read_buf') do
-   io.closed?
- end
- 
--assert('IO#isatty') do
--  skip "isatty is not supported on this platform" if MRubyIOTestUtil.win?
--  f1 = File.open("/dev/tty")
--  f2 = File.open($mrbtest_io_rfname)
--
--  assert_true  f1.isatty
--  assert_false f2.isatty
--
--  f1.close
--  f2.close
--  true
--end
--
- assert('IO#pos=, IO#seek') do
-   fd = IO.sysopen $mrbtest_io_rfname
-   io = IO.new fd
--- 
-2.16.4
-
diff --git a/nixpkgs/pkgs/development/compilers/mruby/default.nix b/nixpkgs/pkgs/development/compilers/mruby/default.nix
index cfc1f00a8036..03f3d56fd93d 100644
--- a/nixpkgs/pkgs/development/compilers/mruby/default.nix
+++ b/nixpkgs/pkgs/development/compilers/mruby/default.nix
@@ -1,20 +1,16 @@
 { stdenv, ruby, bison, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
-  name = "mruby-${version}";
-  version = "2.0.0";
+  pname = "mruby";
+  version = "2.0.1";
 
   src = fetchFromGitHub {
     owner   = "mruby";
     repo    = "mruby";
     rev     = version;
-    sha256  = "1r6w1asjshff43ymdwa6xmrkggza99mi2kw88k7ic6ag2j81hcj5";
+    sha256  = "1zm2d5kj9fnfx8ifj8ysrrr838ipwmvz35byzjhprakrg64911p9";
   };
 
-  patches = [
-    ./0001-Disables-IO-isatty-test-for-sandboxed-builds.patch
-  ];
-
   nativeBuildInputs = [ ruby bison ];
 
   # Necessary so it uses `gcc` instead of `ld` for linking.
diff --git a/nixpkgs/pkgs/development/compilers/rgbds/default.nix b/nixpkgs/pkgs/development/compilers/rgbds/default.nix
index f883500eeb9f..eee4507d6cec 100644
--- a/nixpkgs/pkgs/development/compilers/rgbds/default.nix
+++ b/nixpkgs/pkgs/development/compilers/rgbds/default.nix
@@ -1,21 +1,35 @@
-{stdenv, fetchFromGitHub, yacc}:
+{stdenv, fetchFromGitHub, bison, flex, pkg-config, libpng}:
+
+# TODO: byacc is the recommended parser generator but due to https://github.com/rednex/rgbds/issues/333
+# it does not work for the moment. We should switch back to byacc as soon as the fix is integrated
+# in a published version.
 
 stdenv.mkDerivation rec {
   name = "rgbds-${version}";
-  version = "0.2.4";
+  version = "0.3.8";
   src = fetchFromGitHub {
-    owner = "bentley";
+    owner = "rednex";
     repo = "rgbds";
     rev = "v${version}";
-    sha256 = "0dwq0p9g1lci8sm12a2rfk0g33z2vr75x78zdf1g84djwbz8ipc6";
+    sha256 = "0db37z886026svhj6qnc3wk56sndbnz1vi41gn2k3bl6ppbnjlpk";
   };
-  nativeBuildInputs = [ yacc ];
+  nativeBuildInputs = [ bison flex pkg-config libpng ];
   installFlags = "PREFIX=\${out}";
 
   meta = with stdenv.lib; {
-    homepage = https://www.anjbe.name/rgbds/;
-    description = "An assembler/linker package that produces Game Boy programs";
-    license = licenses.free;
+    homepage = https://rednex.github.io/rgbds/;
+    description = "A free assembler/linker package for the Game Boy and Game Boy Color";
+    license = licenses.mit;
+    longDescription =
+      ''RGBDS (Rednex Game Boy Development System) is a free assembler/linker package for the Game Boy and Game Boy Color. It consists of:
+
+          - rgbasm (assembler)
+          - rgblink (linker)
+          - rgbfix (checksum/header fixer)
+          - rgbgfx (PNG‐to‐Game Boy graphics converter)
+
+        This is a fork of the original RGBDS which aims to make the programs more like other UNIX tools.
+      '';
     maintainers = with maintainers; [ matthewbauer ];
     platforms = platforms.all;
   };
diff --git a/nixpkgs/pkgs/development/compilers/rust/default.nix b/nixpkgs/pkgs/development/compilers/rust/default.nix
index 47df7e716dc1..5c3c08952074 100644
--- a/nixpkgs/pkgs/development/compilers/rust/default.nix
+++ b/nixpkgs/pkgs/development/compilers/rust/default.nix
@@ -2,6 +2,8 @@
 , buildPackages
 , newScope, callPackage
 , CoreFoundation, Security
+, llvmPackages_5
+, pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost
 }: rec {
   makeRustPlatform = { rustc, cargo, ... }: {
     rust = {
@@ -48,10 +50,15 @@
       buildRustPackages = buildPackages.rust.packages.stable;
       # Analogous to stdenv
       rustPlatform = makeRustPlatform self.buildRustPackages;
-      rustc = self.callPackage ./rustc.nix {
+      rustc = self.callPackage ./rustc.nix ({
         # Use boot package set to break cycle
         rustPlatform = bootRustPlatform;
-      };
+      } // lib.optionalAttrs (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) {
+        stdenv = llvmPackages_5.stdenv;
+        pkgsBuildBuild = pkgsBuildBuild // { targetPackages.stdenv = llvmPackages_5.stdenv; };
+        pkgsBuildHost = pkgsBuildBuild // { targetPackages.stdenv = llvmPackages_5.stdenv; };
+        pkgsBuildTarget = pkgsBuildTarget // { targetPackages.stdenv = llvmPackages_5.stdenv; };
+      });
       cargo = self.callPackage ./cargo.nix {
         # Use boot package set to break cycle
         rustPlatform = bootRustPlatform;
diff --git a/nixpkgs/pkgs/development/compilers/swift/default.nix b/nixpkgs/pkgs/development/compilers/swift/default.nix
index 91fb962f87cc..33f4d2a33fce 100644
--- a/nixpkgs/pkgs/development/compilers/swift/default.nix
+++ b/nixpkgs/pkgs/development/compilers/swift/default.nix
@@ -34,7 +34,7 @@
 }:
 
 let
-  v_base = "4.2.3";
+  v_base = "5.0.1";
   version = "${v_base}-RELEASE";
   version_friendly = "${v_base}";
 
@@ -52,48 +52,48 @@ let
     # For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759
     clang = fetch {
       repo = "swift-clang";
-      sha256 = "0l6w4xzpl3w2nax9a0b885nfzhfj38p2g99158nb5bzfd4s0man7";
+      sha256 = "1ap26425zhn2sdw3m9snyrqhi4phv2fgblyv9wp8xppjlnjkax9k";
     };
     llvm = fetch {
       repo = "swift-llvm";
-      sha256 = "1664zwxbq0a1cmxr9n5a0vw6vdk6ygr7rpglpdsfc7ki857vpsyv";
+      sha256 = "1bnscqsiljiclij60f44h2fyx5c84pzry0lz1jbwknphwmqd6f84";
     };
     compilerrt = fetch {
       repo = "swift-compiler-rt";
-      sha256 = "19s6qxn4i0kxpf39xjp2i7zg427iinbmaxqkbb1p91g616y367sf";
+      sha256 = "0bba54xa7z0wj6k7a24q74gc4yajc6s64g1m894i3yd6swdk7f6r";
     };
     cmark = fetch {
       repo = "swift-cmark";
-      sha256 = "1nmxp0fj749sgar682c5nsj7zxxigqwg973baxj2r656a7ybh325";
+      sha256 = "079smm79hbwr06bvghd2sb86b8gpkprnzlyj9kh95jy38xhlhdnj";
     };
     lldb = fetch {
       repo = "swift-lldb";
-      sha256 = "00kz0xhj1p6ckyandj2gs1yfl29kxv84x9pfph00r8crbkd2jz7b";
+      sha256 = "01yrhc1ggv89qii03fdjdvb2aq9v4hd1wk83n8ygrwwc75p44qmi";
     };
     llbuild = fetch {
       repo = "swift-llbuild";
-      sha256 = "1mkkhydshhxr28igbldzr0hhqvb6ql43cpf3ba5vglfkbcz6wh6q";
+      sha256 = "0ipwryzpqxpk3rzkxilfahlkz06k39j91q2lv7fprf0slqknrdms";
     };
     pm = fetch {
       repo = "swift-package-manager";
-      sha256 = "1aqvmgq9g5zs4k2qnkvw3h3mar66d690hqq6g2dmrapsyb321j9l";
+      sha256 = "1mnywlm7i2mbp16q0rskskvnbx1ap8lchwr8q3gx0xs3b2fs6chh";
     };
     xctest = fetch {
       repo = "swift-corelibs-xctest";
-      sha256 = "1n4w7bfgy73vjzbvbphlwayy0dw73bbrayrpkqq8lbidg0x9lam8";
+      sha256 = "1vpljkxhfk3yd07ry0xsv3qwbn62pwd2mdn9cw22jhbhvqinc13z";
     };
     foundation = fetch {
       repo = "swift-corelibs-foundation";
-      sha256 = "11kwc5pcq4ibxkyglmqs7h7gka3xkzl9j856x1rq2xdvq756wq2s";
+      sha256 = "11w0iapccrk13hjbrwylq8g71znrncnc3mrm345gvnjfgz08ffaq";
     };
     libdispatch = fetch {
       repo = "swift-corelibs-libdispatch";
-      sha256 = "09c15mn9s5lf2akzfhik70zk91h97nnm8pq1ppfqry2nn3vmib2i";
+      sha256 = "1mgzsq3nfzbkssfkswzvvjgsbv2fx36i1r83d4nzw3di8spxmg32";
       fetchSubmodules = true;
     };
     swift = fetch {
       repo = "swift";
-      sha256 = "09wksqad0w6pk3xdxc278w4mj300h48rvbvx0m4an7npkj6i7n9q";
+      sha256 = "02bv47pd0k0xy4k7q6c3flwxwkm2palnzvpr4w3nmvqk0flrbsq6";
     };
   };
 
@@ -120,6 +120,9 @@ let
   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"
+    # During the Swift build, a full local LLVM build is performed and the resulting clang is invoked.
+    # This compiler is not using the Nix wrappers, so it needs some help to find things.
+    export NIX_LDFLAGS_BEFORE="-rpath ${clang.cc.gcc.lib}/lib -L${clang.cc.gcc.lib}/lib $NIX_LDFLAGS_BEFORE"
 
     $SWIFT_SOURCE_ROOT/swift/utils/build-script \
       --preset=buildbot_linux \
@@ -132,23 +135,25 @@ in
 stdenv.mkDerivation rec {
   name = "swift-${version_friendly}";
 
-  buildInputs = devInputs ++ [
+  nativeBuildInputs = [
     autoconf
     automake
     bash
-    clang
     cmake
     coreutils
+    findutils
+    gnumake
     libtool
+    makeWrapper
     ninja
     perl
     pkgconfig
     python
     rsync
     which
-    findutils
-    makeWrapper
-    gnumake
+  ];
+  buildInputs = devInputs ++ [
+    clang
   ];
 
   # TODO: Revisit what's propagated and how
@@ -212,13 +217,12 @@ stdenv.mkDerivation rec {
 
     substituteInPlace swift/stdlib/public/Platform/CMakeLists.txt \
       --replace '/usr/include' "${stdenv.cc.libc.dev}/include"
-    substituteInPlace swift-corelibs-libdispatch/src/CMakeLists.txt \
-      --replace '/usr/include' "${stdenv.cc.libc.dev}/include"
     substituteInPlace swift/utils/build-script-impl \
       --replace '/usr/include/c++' "${clang.cc.gcc}/include/c++"
     patch -p1 -d swift -i ${./patches/glibc-arch-headers.patch}
     patch -p1 -d swift -i ${./patches/0001-build-presets-linux-don-t-require-using-Ninja.patch}
     patch -p1 -d swift -i ${./patches/0002-build-presets-linux-allow-custom-install-prefix.patch}
+    patch -p1 -d swift -i ${./patches/0003-build-presets-linux-don-t-build-extra-libs.patch}
     patch -p1 -d swift -i ${./patches/0004-build-presets-linux-plumb-extra-cmake-options.patch}
 
     sed -i swift/utils/build-presets.ini \
@@ -227,10 +231,12 @@ stdenv.mkDerivation rec {
       -e 's/^validation-test$/# \0/' \
       -e 's/^long-test$/# \0/' \
       -e 's/^stress-test$/# \0/' \
-      -e 's/^test-optimized$/# \0/'
+      -e 's/^test-optimized$/# \0/' \
+      \
+      -e 's/^swift-install-components=autolink.*$/\0;editor-integration/'
 
-    # https://bugs.swift.org/browse/SR-5779
-    sed -i -e 's|"-latomic"|"-Wl,-rpath,${clang.cc.gcc.lib}/lib" "-L${clang.cc.gcc.lib}/lib" "-latomic"|' swift/cmake/modules/AddSwift.cmake
+    # https://bugs.swift.org/browse/SR-10559
+    patch -p1 -d swift-corelibs-libdispatch -i ${./patches/libdispatch-fortify-fix.patch}
 
     substituteInPlace clang/lib/Driver/ToolChains/Linux.cpp \
       --replace 'SysRoot + "/usr/lib' '"${glibc}/lib" "'
@@ -241,8 +247,6 @@ stdenv.mkDerivation rec {
     sed -i 's,curses,ncurses,' llbuild/*/*/CMakeLists.txt
 
     PREFIX=''${out/#\/}
-    substituteInPlace swift-corelibs-foundation/build.py \
-      --replace usr/lib "$PREFIX/lib"
     substituteInPlace swift-corelibs-xctest/build_script.py \
       --replace usr "$PREFIX"
     substituteInPlace swiftpm/Utilities/bootstrap \
@@ -250,9 +254,19 @@ stdenv.mkDerivation rec {
       --replace usr/lib "$PREFIX/lib"
   '';
 
+  buildPhase = builder;
+
   doCheck = false;
 
-  buildPhase = builder;
+  checkInputs = [ file ];
+
+  # TODO: investigate the non-working tests
+  checkPhase = ''
+    checkTarget=check-swift-all
+    ninjaFlags='-C buildbot_linux/swift-${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}'
+
+    ninjaCheckPhase
+  '';
 
   installPhase = ''
     mkdir -p $out
@@ -262,13 +276,10 @@ stdenv.mkDerivation rec {
     tar xf $INSTALLABLE_PACKAGE -C $out --strip-components=3 $PREFIX
     find $out -type d -empty -delete
 
-    # 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.bintools_bin}/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
+      --suffix CPLUS_INCLUDE_PATH : $out/lib/swift/clang/include \
+      --suffix LIBRARY_PATH : $icu/lib
   '';
 
   # Hack to avoid TMPDIR in RPATHs.
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch
index f2b30e5dcdb6..79482ac10e69 100644
--- a/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch
@@ -11,8 +11,8 @@ diff --git a/utils/build-presets.ini b/utils/build-presets.ini
 index 7ee57ad2df..e6b0af3581 100644
 --- a/utils/build-presets.ini
 +++ b/utils/build-presets.ini
-@@ -717,7 +717,7 @@ swiftpm
- xctest
+@@ -721,7 +721,7 @@ swiftpm
+ 
  dash-dash
  
 -build-ninja
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch
index 612b33cdb483..5c1927acb7f1 100644
--- a/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch
@@ -9,17 +9,17 @@ Subject: [PATCH 2/4] build-presets: (linux) allow custom install prefix
 
 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
-@@ -723,7 +723,7 @@ install-lldb
- install-llbuild
+--- a/utils/build-presets.ini	2019-04-11 14:51:40.060259462 +0200
++++ b/utils/build-presets.ini	2019-04-11 15:16:17.471137969 +0200
+@@ -728,7 +728,7 @@
  install-swiftpm
  install-xctest
+ install-libicu
 -install-prefix=/usr
 +install-prefix=%(install_prefix)s
- 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
+ swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
+ llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-headers;compiler-rt
+ install-libcxx
 -- 
 2.12.2
 
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0003-build-presets-linux-don-t-build-extra-libs.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0003-build-presets-linux-don-t-build-extra-libs.patch
new file mode 100644
index 000000000000..5d766bc25901
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/0003-build-presets-linux-don-t-build-extra-libs.patch
@@ -0,0 +1,23 @@
+--- a/utils/build-presets.ini	2019-04-11 15:19:57.845178834 +0200
++++ b/utils/build-presets.ini	2019-04-11 15:27:42.041297057 +0200
+@@ -716,8 +716,6 @@
+ llbuild
+ swiftpm
+ xctest
+-libicu
+-libcxx
+ 
+ dash-dash
+ 
+@@ -727,11 +725,9 @@
+ install-llbuild
+ install-swiftpm
+ install-xctest
+-install-libicu
+ install-prefix=%(install_prefix)s
+ swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
+ llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-headers;compiler-rt
+-install-libcxx
+ build-swift-static-stdlib
+ build-swift-static-sdk-overlay
+ build-swift-stdlib-unittest-extra
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch
index e84c7eb2a08a..1d0a6a9577aa 100644
--- a/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch
@@ -11,7 +11,7 @@ diff --git a/utils/build-presets.ini b/utils/build-presets.ini
 index 1739e91dc2..0608fed9c1 100644
 --- a/utils/build-presets.ini
 +++ b/utils/build-presets.ini
-@@ -740,6 +740,8 @@ install-destdir=%(install_destdir)s
+@@ -743,6 +743,8 @@ install-destdir=%(install_destdir)s
  # Path to the .tar.gz package we would create.
  installable-package=%(installable_package)s
  
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch b/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch
index 650e1a2429d4..df906f9c84c7 100644
--- a/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch
@@ -1,13 +1,13 @@
 The Nix glibc headers do not use include/x86_64-linux-gnu subdirectories.
 
---- swift/stdlib/public/Platform/CMakeLists.txt	2018-09-30 17:51:51.581766303 +0200
-+++ swift/stdlib/public/Platform/CMakeLists.txt	2018-09-30 18:40:04.118956708 +0200
-@@ -65,7 +65,7 @@
+--- swift/stdlib/public/Platform/CMakeLists.txt	2019-04-09 20:14:44.493801403 +0200
++++ swift/stdlib/public/Platform/CMakeLists.txt	2019-04-09 20:14:44.577800593 +0200
+@@ -68,7 +68,7 @@
      endif()
  
      set(GLIBC_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}")
 -    set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}")
 +    set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}")
  
-     if(NOT "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}" STREQUAL "/")
+     if(NOT "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}" STREQUAL "/" AND NOT "${sdk}" STREQUAL "ANDROID")
        set(GLIBC_INCLUDE_PATH "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}${GLIBC_INCLUDE_PATH}")
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/libdispatch-fortify-fix.patch b/nixpkgs/pkgs/development/compilers/swift/patches/libdispatch-fortify-fix.patch
new file mode 100644
index 000000000000..d23a308d68f4
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/libdispatch-fortify-fix.patch
@@ -0,0 +1,13 @@
+Nix compiles with _FORTIFY_SOURCE enabled. Fix error due to -Werror and an unused return value warning.
+
+--- swift-corelibs-libdispatch/src/internal.h	2019-04-26 09:33:38.287289099 +0200
++++ swift-corelibs-libdispatch/src/internal.h	2019-04-26 15:31:10.485334128 +0200
+@@ -1053,7 +1053,7 @@
+ #else
+ #define _dispatch_client_assert_fail(fmt, ...)  do { \
+ 		char *_msg = NULL; \
+-		asprintf(&_msg, "%s" fmt, DISPATCH_ASSERTION_FAILED_MESSAGE, \
++		(void)asprintf(&_msg, "%s" fmt, DISPATCH_ASSERTION_FAILED_MESSAGE, \
+ 				##__VA_ARGS__); \
+ 		_dispatch_assert_crash(_msg); \
+ 		free(_msg); \
diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch b/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch
index 9523943c4801..789c0be7e7a8 100644
--- a/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch
@@ -2,7 +2,7 @@ Only use the Nix include dirs when no sysroot is configured.
 
 --- clang/lib/Driver/ToolChains/Linux.cpp	2018-10-05 18:01:15.731109551 +0200
 +++ clang/lib/Driver/ToolChains/Linux.cpp	2018-10-05 18:00:27.959509924 +0200
-@@ -565,7 +565,7 @@
+@@ -641,7 +641,7 @@
  
    // Check for configure-time C include directories.
    StringRef CIncludeDirs(C_INCLUDE_DIRS);
diff --git a/nixpkgs/pkgs/development/compilers/swift/purity.patch b/nixpkgs/pkgs/development/compilers/swift/purity.patch
index d10e407260a5..832decdc41f5 100644
--- a/nixpkgs/pkgs/development/compilers/swift/purity.patch
+++ b/nixpkgs/pkgs/development/compilers/swift/purity.patch
@@ -11,7 +11,7 @@ diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
 index fe3c0191bb..c6a482bece 100644
 --- a/lib/Driver/ToolChains/Gnu.cpp
 +++ b/lib/Driver/ToolChains/Gnu.cpp
-@@ -398,13 +398,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+@@ -380,13 +380,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
    if (!Args.hasArg(options::OPT_static)) {
      if (Args.hasArg(options::OPT_rdynamic))
        CmdArgs.push_back("-export-dynamic");