about summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/llvm')
-rw-r--r--pkgs/development/compilers/llvm/3.5/clang-purity.patch22
-rw-r--r--pkgs/development/compilers/llvm/3.5/clang-separate-build.patch8
-rw-r--r--pkgs/development/compilers/llvm/3.5/clang.nix59
-rw-r--r--pkgs/development/compilers/llvm/3.5/default.nix43
-rw-r--r--pkgs/development/compilers/llvm/3.5/dragonegg.nix27
-rw-r--r--pkgs/development/compilers/llvm/3.5/fix-15974.patch15
-rw-r--r--pkgs/development/compilers/llvm/3.5/libc++/darwin.patch30
-rw-r--r--pkgs/development/compilers/llvm/3.5/libc++/default.nix54
-rw-r--r--pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh6
-rw-r--r--pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch17
-rw-r--r--pkgs/development/compilers/llvm/3.5/libc++abi/default.nix60
-rw-r--r--pkgs/development/compilers/llvm/3.5/lld.nix30
-rw-r--r--pkgs/development/compilers/llvm/3.5/lldb.nix45
-rw-r--r--pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch12
-rw-r--r--pkgs/development/compilers/llvm/3.5/llvm.nix97
-rw-r--r--pkgs/development/compilers/llvm/3.5/polly-separate-build.patch12
-rw-r--r--pkgs/development/compilers/llvm/3.5/polly.nix26
-rw-r--r--pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch63
-rw-r--r--pkgs/development/compilers/llvm/3.9/clang/default.nix85
-rw-r--r--pkgs/development/compilers/llvm/3.9/clang/purity.patch16
-rw-r--r--pkgs/development/compilers/llvm/3.9/default.nix59
-rw-r--r--pkgs/development/compilers/llvm/3.9/libc++/darwin.patch39
-rw-r--r--pkgs/development/compilers/llvm/3.9/libc++/default.nix52
-rw-r--r--pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh6
-rw-r--r--pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch19
-rw-r--r--pkgs/development/compilers/llvm/3.9/libc++abi.nix52
-rw-r--r--pkgs/development/compilers/llvm/3.9/lldb.nix57
-rw-r--r--pkgs/development/compilers/llvm/3.9/llvm-outputs.patch26
-rw-r--r--pkgs/development/compilers/llvm/3.9/llvm.nix174
-rw-r--r--pkgs/development/compilers/llvm/4/clang/0001-Fix-compilation-w-gcc9.patch59
-rw-r--r--pkgs/development/compilers/llvm/4/clang/default.nix116
-rw-r--r--pkgs/development/compilers/llvm/4/clang/purity.patch16
-rw-r--r--pkgs/development/compilers/llvm/4/cmdline-help.patch39
-rw-r--r--pkgs/development/compilers/llvm/4/default.nix74
-rw-r--r--pkgs/development/compilers/llvm/4/fix-gcc9.patch33
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/default.nix59
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch41
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/setup-hook.sh6
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch19
-rw-r--r--pkgs/development/compilers/llvm/4/libc++abi.nix52
-rw-r--r--pkgs/development/compilers/llvm/4/lld.nix33
-rw-r--r--pkgs/development/compilers/llvm/4/lldb-libedit.patch30
-rw-r--r--pkgs/development/compilers/llvm/4/lldb.nix63
-rw-r--r--pkgs/development/compilers/llvm/4/llvm-outputs.patch26
-rw-r--r--pkgs/development/compilers/llvm/4/llvm.nix194
-rw-r--r--pkgs/development/compilers/llvm/4/openmp.nix26
-rw-r--r--pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch368
-rw-r--r--pkgs/development/compilers/llvm/5/clang/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/5/compiler-rt.nix4
-rw-r--r--pkgs/development/compilers/llvm/5/default.nix10
-rw-r--r--pkgs/development/compilers/llvm/5/libc++/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/5/lldb.nix4
-rw-r--r--pkgs/development/compilers/llvm/5/llvm.nix8
-rw-r--r--pkgs/development/compilers/llvm/6/clang/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/6/compiler-rt.nix4
-rw-r--r--pkgs/development/compilers/llvm/6/default.nix10
-rw-r--r--pkgs/development/compilers/llvm/6/libc++/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/6/lldb.nix4
-rw-r--r--pkgs/development/compilers/llvm/6/llvm.nix8
-rw-r--r--pkgs/development/compilers/llvm/7/clang/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/7/compiler-rt.nix4
-rw-r--r--pkgs/development/compilers/llvm/7/default.nix10
-rw-r--r--pkgs/development/compilers/llvm/7/libc++/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/7/lldb.nix4
-rw-r--r--pkgs/development/compilers/llvm/7/llvm.nix8
-rw-r--r--pkgs/development/compilers/llvm/8/clang/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/8/compiler-rt.nix4
-rw-r--r--pkgs/development/compilers/llvm/8/default.nix10
-rw-r--r--pkgs/development/compilers/llvm/8/libc++/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/8/lldb.nix4
-rw-r--r--pkgs/development/compilers/llvm/8/llvm.nix8
-rw-r--r--pkgs/development/compilers/llvm/9/clang/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/9/compiler-rt.nix4
-rw-r--r--pkgs/development/compilers/llvm/9/default.nix10
-rw-r--r--pkgs/development/compilers/llvm/9/libc++/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/9/lldb.nix4
-rw-r--r--pkgs/development/compilers/llvm/9/llvm.nix8
-rw-r--r--pkgs/development/compilers/llvm/dynamiclibrary-musl.patch33
-rw-r--r--pkgs/development/compilers/llvm/fix-llvm-config.patch13
-rw-r--r--pkgs/development/compilers/llvm/libcxx-max_align_t.patch54
80 files changed, 90 insertions, 2655 deletions
diff --git a/pkgs/development/compilers/llvm/3.5/clang-purity.patch b/pkgs/development/compilers/llvm/3.5/clang-purity.patch
deleted file mode 100644
index dc3b54e304fc..000000000000
--- a/pkgs/development/compilers/llvm/3.5/clang-purity.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
-index 198e82e..810d006 100644
---- a/lib/Driver/Tools.cpp
-+++ b/lib/Driver/Tools.cpp
-@@ -7355,17 +7355,6 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
-     CmdArgs.push_back("-shared");
-   }
- 
--  if (ToolChain.getArch() == llvm::Triple::arm ||
--      ToolChain.getArch() == llvm::Triple::armeb ||
--      ToolChain.getArch() == llvm::Triple::thumb ||
--      ToolChain.getArch() == llvm::Triple::thumbeb ||
--      (!Args.hasArg(options::OPT_static) &&
--       !Args.hasArg(options::OPT_shared))) {
--    CmdArgs.push_back("-dynamic-linker");
--    CmdArgs.push_back(Args.MakeArgString(
--        D.DyldPrefix + getLinuxDynamicLinker(Args, ToolChain)));
--  }
--
-   CmdArgs.push_back("-o");
-   CmdArgs.push_back(Output.getFilename());
- 
diff --git a/pkgs/development/compilers/llvm/3.5/clang-separate-build.patch b/pkgs/development/compilers/llvm/3.5/clang-separate-build.patch
deleted file mode 100644
index 5fb67f169f45..000000000000
--- a/pkgs/development/compilers/llvm/3.5/clang-separate-build.patch
+++ /dev/null
@@ -1,8 +0,0 @@
-diff -Naur clang-3.4-orig/tools/extra/CMakeLists.txt clang-3.4/tools/extra/CMakeLists.txt
---- clang-3.4-orig/tools/extra/CMakeLists.txt	2013-11-07 19:08:23.000000000 -0500
-+++ clang-3.4/tools/extra/CMakeLists.txt	2014-01-20 11:47:22.678435223 -0500
-@@ -1,3 +1,4 @@
-+include(CheckLibraryExists)
- check_library_exists(edit el_init "" HAVE_LIBEDIT)
- 
- add_subdirectory(clang-apply-replacements)
diff --git a/pkgs/development/compilers/llvm/3.5/clang.nix b/pkgs/development/compilers/llvm/3.5/clang.nix
deleted file mode 100644
index 9a602c62777d..000000000000
--- a/pkgs/development/compilers/llvm/3.5/clang.nix
+++ /dev/null
@@ -1,59 +0,0 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src }:
-let
-  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
-in stdenv.mkDerivation {
-  pname = "clang";
-  inherit version;
-
-  src = fetch "cfe" "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg";
-
-  unpackPhase = ''
-    unpackFile $src
-    mv cfe-${version}.src clang
-    sourceRoot=$PWD/clang
-    unpackFile ${clang-tools-extra_src}
-    mv clang-tools-extra-* $sourceRoot/tools/extra
-  '';
-
-  buildInputs = [ cmake libxml2 llvm ];
-
-  cmakeFlags = [
-    "-DCMAKE_CXX_FLAGS=-std=c++11"
-  ] ++
-  # Maybe with compiler-rt this won't be needed?
-  (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++
-  (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include");
-
-  patches = [ ./clang-purity.patch ];
-
-  postPatch = ''
-    sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp
-    sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp
-  '';
-
-  # Clang expects to find LLVMgold in its own prefix
-  # Clang expects to find sanitizer libraries in its own prefix
-  postInstall = ''
-    if [ -e ${llvm}/lib/LLVMgold.so ]; then
-      ln -sv ${llvm}/lib/LLVMgold.so $out/lib
-    fi
-
-    ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/
-    ln -sv $out/bin/clang $out/bin/cpp
-  '';
-
-  enableParallelBuilding = true;
-
-  passthru = {
-    isClang = true;
-  } // stdenv.lib.optionalAttrs stdenv.isLinux {
-    inherit gcc;
-  };
-
-  meta = {
-    description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.5/default.nix b/pkgs/development/compilers/llvm/3.5/default.nix
deleted file mode 100644
index b87fa747f145..000000000000
--- a/pkgs/development/compilers/llvm/3.5/default.nix
+++ /dev/null
@@ -1,43 +0,0 @@
-{ pkgs, newScope, stdenv, isl, fetchurl }:
-let
-  callPackage = newScope (self // { inherit stdenv isl version fetch; });
-
-  version = "3.5.2";
-
-  fetch = fetch_v version;
-  fetch_v = ver: name: sha256: fetchurl {
-    url = "https://releases.llvm.org/${ver}/${name}-${ver}.src.tar.xz";
-    inherit sha256;
-  };
-
-  compiler-rt_src = fetch "compiler-rt" "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal";
-  clang-tools-extra_src = fetch "clang-tools-extra" "01607w6hdf1pjgaapn9fy6smk22i3d4ncqjlhk4xi55ifi6kf6pj";
-
-  self = {
-    llvm = callPackage ./llvm.nix rec {
-      version = "3.5.2";
-      fetch = fetch_v version;
-      inherit compiler-rt_src;
-    };
-
-    clang = callPackage ./clang.nix rec {
-      version = "3.5.2";
-      fetch = fetch_v version;
-      inherit clang-tools-extra_src;
-    };
-
-    lld = callPackage ./lld.nix {};
-
-    lldb = callPackage ./lldb.nix {};
-
-    polly = callPackage ./polly.nix {};
-
-    dragonegg = callPackage ./dragonegg.nix {};
-
-    libcxx = callPackage ./libc++ { stdenv = pkgs.clangStdenv; };
-
-    libcxxabi = callPackage ./libc++abi { stdenv = pkgs.clangStdenv; };
-
-    #openmp = callPackage ./openmp {};
-  };
-in self
diff --git a/pkgs/development/compilers/llvm/3.5/dragonegg.nix b/pkgs/development/compilers/llvm/3.5/dragonegg.nix
deleted file mode 100644
index e327fa79c6f0..000000000000
--- a/pkgs/development/compilers/llvm/3.5/dragonegg.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-{stdenv, fetch, llvm, gmp, mpfr, libmpc, ncurses, zlib, version}:
-
-stdenv.mkDerivation rec {
-  pname = "dragonegg";
-  inherit version;
-
-  src = fetch "dragonegg" "1va4wv2b1dj0dpzsksnpnd0jic52q7pqj79w3m9jwdb58h7104dw";
-
-  # The gcc the plugin will be built for (the same used building dragonegg)
-  GCC = "gcc";
-
-  buildInputs = [ llvm gmp mpfr libmpc ncurses zlib ];
-
-  installPhase = ''
-    mkdir -p $out/lib $out/share/doc/${pname}-${version}
-    cp -d dragonegg.so $out/lib
-    cp README COPYING $out/share/doc/${pname}-${version}
-  '';
-
-  meta = {
-    homepage = http://dragonegg.llvm.org/;
-    description = "gcc plugin that replaces gcc's optimizers and code generators by those in LLVM";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.5/fix-15974.patch b/pkgs/development/compilers/llvm/3.5/fix-15974.patch
deleted file mode 100644
index 446004cd9988..000000000000
--- a/pkgs/development/compilers/llvm/3.5/fix-15974.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h
-index f9df378..9d860ec 100644
---- a/include/llvm/ADT/IntrusiveRefCntPtr.h
-+++ b/include/llvm/ADT/IntrusiveRefCntPtr.h
-@@ -134,9 +134,9 @@ public:
- //===----------------------------------------------------------------------===//
-   template <typename T>
-   class IntrusiveRefCntPtr {
-+  public:
-     T* Obj;
- 
--  public:
-     typedef T element_type;
- 
-     explicit IntrusiveRefCntPtr() : Obj(nullptr) {}
diff --git a/pkgs/development/compilers/llvm/3.5/libc++/darwin.patch b/pkgs/development/compilers/llvm/3.5/libc++/darwin.patch
deleted file mode 100644
index bf83f169cfc3..000000000000
--- a/pkgs/development/compilers/llvm/3.5/libc++/darwin.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff -ru -x '*~' libcxx-3.4.2.src-orig/lib/CMakeLists.txt libcxx-3.4.2.src/lib/CMakeLists.txt
---- libcxx-3.4.2.src-orig/lib/CMakeLists.txt	2013-11-15 18:18:57.000000000 +0100
-+++ libcxx-3.4.2.src/lib/CMakeLists.txt	2014-09-24 14:04:01.000000000 +0200
-@@ -56,7 +56,7 @@
-       "-compatibility_version 1"
-       "-current_version ${LIBCXX_VERSION}"
-       "-install_name /usr/lib/libc++.1.dylib"
--      "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
-+      "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
-       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
-       "/usr/lib/libSystem.B.dylib")
-   else()
-@@ -64,14 +64,14 @@
-       list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
-       if (OSX_HAS_ARMV7)
-         set(OSX_RE_EXPORT_LINE
--          "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
-+          "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
-           "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
-       else()
-         set(OSX_RE_EXPORT_LINE
--          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
-+          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib")
-       endif()
-     else()
--      set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
-+      set (OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
-     endif()
- 
-     list(APPEND link_flags
diff --git a/pkgs/development/compilers/llvm/3.5/libc++/default.nix b/pkgs/development/compilers/llvm/3.5/libc++/default.nix
deleted file mode 100644
index 44610a1b11d3..000000000000
--- a/pkgs/development/compilers/llvm/3.5/libc++/default.nix
+++ /dev/null
@@ -1,54 +0,0 @@
-{ lib, stdenv, fetchurl, cmake, libcxxabi, fixDarwinDylibNames }:
-
-let version = "3.5.2"; in
-
-stdenv.mkDerivation {
-  pname = "libc++";
-  inherit version;
-
-  src = fetchurl {
-    url = "http://llvm.org/releases/${version}/libcxx-${version}.src.tar.xz";
-    sha256 = "0irnl54fwzh2hzn9x4jfvnfyq5kd0zn0iwbzdivgwhqzw6fjdwdv";
-  };
-
-  # instead of allowing libc++ to link with /usr/lib/libc++abi.dylib,
-  # force it to link with our copy
-  preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
-    substituteInPlace lib/CMakeLists.txt \
-      --replace 'OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib' \
-                'OSX_RE_EXPORT_LINE "${libcxxabi}/lib/libc++abi.dylib' \
-      --replace '"''${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"' \
-                '"${libcxxabi}/lib/libc++abi.dylib"'
-  '';
-
-  patches = [
-    ./darwin.patch
-    # glibc 2.26 fix
-    ./xlocale-glibc-2.26.patch
-  ];
-
-  buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  cmakeFlags = [
-    "-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include"
-    "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
-    "-DLIBCXX_LIBCPPABI_VERSION=2"
-    "-DLIBCXX_CXX_ABI=libcxxabi"
-  ];
-
-  enableParallelBuilding = true;
-
-  linkCxxAbi = stdenv.isLinux;
-
-  setupHooks = [
-    ../../../../../build-support/setup-hooks/role.bash
-    ./setup-hook.sh
-  ];
-
-  meta = {
-    homepage = http://libcxx.llvm.org/;
-    description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh b/pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh
deleted file mode 100644
index 6611259165ae..000000000000
--- a/pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-# See pkgs/build-support/setup-hooks/role.bash
-getHostRole
-
-linkCxxAbi="@linkCxxAbi@"
-export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
-export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
diff --git a/pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch b/pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch
deleted file mode 100644
index 250bb49fc231..000000000000
--- a/pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-diff --git a/include/__locale b/include/__locale
-index 3daa1f1..cb8e151 100644
---- a/include/__locale
-+++ b/include/__locale
-@@ -29,10 +29,10 @@
- # if __ANDROID_API__ <= 20
- #  include <support/android/locale_bionic.h>
- # endif
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__sun__)   || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
--#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
-+#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
- 
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- #pragma GCC system_header
diff --git a/pkgs/development/compilers/llvm/3.5/libc++abi/default.nix b/pkgs/development/compilers/llvm/3.5/libc++abi/default.nix
deleted file mode 100644
index d295ddbf8a44..000000000000
--- a/pkgs/development/compilers/llvm/3.5/libc++abi/default.nix
+++ /dev/null
@@ -1,60 +0,0 @@
-{ stdenv, cmake, fetchurl, libcxx, libunwind, llvm }:
-
-let
-  version = "3.5.2";
-  cmakeLists = fetchurl {
-    name   = "CMakeLists.txt";
-    url    = "http://llvm.org/svn/llvm-project/libcxxabi/trunk/CMakeLists.txt?p=217324";
-    sha256 = "10idgcbs4pcx6mjsbq1vjm8hzqqdk2p7k86cw9f473jmfyfwgf5j";
-  };
-in stdenv.mkDerivation {
-  pname = "libc++abi";
-  inherit version;
-
-  src = fetchurl {
-    url    = "http://llvm.org/releases/${version}/libcxxabi-${version}.src.tar.xz";
-    sha256 = "1c6rv0zx0na1w4hdmdfq2f6nj7limb7d1krrknwajxxkcn4yws92";
-  };
-
-  buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin) libunwind;
-
-  postUnpack = ''
-    unpackFile ${libcxx.src}
-    unpackFile ${llvm.src}
-    echo cp ${cmakeLists} libcxxabi-*/CMakeLists.txt
-    cp ${cmakeLists} libcxxabi-*/CMakeLists.txt
-    export NIX_CFLAGS_COMPILE+=" -I$PWD/include"
-    export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '';
-
-  installPhase = if stdenv.isDarwin
-    then ''
-      for file in lib/*; do
-        # this should be done in CMake, but having trouble figuring out
-        # the magic combination of necessary CMake variables
-        # if you fancy a try, take a look at
-        # http://www.cmake.org/Wiki/CMake_RPATH_handling
-        install_name_tool -id $out/$file $file
-      done
-      make install
-      install -d 755 $out/include
-      install -m 644 ../include/cxxabi.h $out/include
-    ''
-    else ''
-      install -d -m 755 $out/include $out/lib
-      install -m 644 lib/libc++abi.so.1.0 $out/lib
-      install -m 644 $src/include/cxxabi.h $out/include
-      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
-      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
-    '';
-
-  meta = {
-    homepage = http://libcxxabi.llvm.org/;
-    description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.5/lld.nix b/pkgs/development/compilers/llvm/3.5/lld.nix
deleted file mode 100644
index 8fe4dd6f1d5f..000000000000
--- a/pkgs/development/compilers/llvm/3.5/lld.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{ stdenv, fetch, cmake, llvm, ncurses, zlib, python, version }:
-
-stdenv.mkDerivation {
-  pname = "lld";
-  inherit version;
-
-  src = fetch "lld" "1hpqawg1sc8mdqxqaxqmlzbrn69w1pkj8rxhjgqgmwra6c0xky89";
-
-  preUnpack = ''
-    # !!! Hopefully won't be needed for 3.5
-    unpackFile ${llvm.src}
-    export cmakeFlags="$cmakeFlags -DLLD_PATH_TO_LLVM_SOURCE="`ls -d $PWD/llvm-*`
-  '';
-
-  buildInputs = [ cmake ncurses zlib python ];
-
-  cmakeFlags = [
-    "-DCMAKE_CXX_FLAGS=-std=c++11"
-    "-DLLD_PATH_TO_LLVM_BUILD=${llvm}"
-  ];
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "A set of modular code for creating linker tools";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.5/lldb.nix b/pkgs/development/compilers/llvm/3.5/lldb.nix
deleted file mode 100644
index b4823e9d8c2a..000000000000
--- a/pkgs/development/compilers/llvm/3.5/lldb.nix
+++ /dev/null
@@ -1,45 +0,0 @@
-{ stdenv
-, fetch
-, cmake
-, zlib
-, ncurses
-, swig
-, which
-, libedit
-, llvm
-, clang
-, python
-, version
-}:
-
-stdenv.mkDerivation {
-  pname = "lldb";
-  inherit version;
-
-  src = fetch "lldb" "0ffi9jn4k3yd0hvxs1v4n710x8siq21lb49v3351d7j5qinrpgi7";
-
-  patchPhase = ''
-    sed -i 's|/usr/bin/env||' \
-      scripts/Python/finish-swig-Python-LLDB.sh \
-      scripts/Python/build-swig-Python.sh
-  '';
-
-  buildInputs = [ cmake python which swig ncurses zlib libedit ];
-
-  cmakeFlags = [
-    "-DCMAKE_CXX_FLAGS=-std=c++11"
-    "-DLLDB_PATH_TO_LLVM_BUILD=${llvm}"
-    "-DLLDB_PATH_TO_CLANG_BUILD=${clang}"
-    "-DLLDB_DISABLE_LIBEDIT=1" # https://llvm.org/bugs/show_bug.cgi?id=28898
-  ];
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "A next-generation high-performance debugger";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
-    broken = true;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch b/pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch
deleted file mode 100644
index abfc11513cdc..000000000000
--- a/pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur llvm-3.4-orig/cmake/modules/TableGen.cmake llvm-3.4/cmake/modules/TableGen.cmake
---- llvm-3.4-orig/cmake/modules/TableGen.cmake	2013-10-06 21:00:07.000000000 -0400
-+++ llvm-3.4/cmake/modules/TableGen.cmake	2014-01-20 13:06:55.273022149 -0500
-@@ -78,8 +78,6 @@
- endif()
- 
- macro(add_tablegen target project)
--  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
--
-   set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
-   set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
-   add_llvm_utility(${target} ${ARGN})
diff --git a/pkgs/development/compilers/llvm/3.5/llvm.nix b/pkgs/development/compilers/llvm/3.5/llvm.nix
deleted file mode 100644
index fc53ad266a65..000000000000
--- a/pkgs/development/compilers/llvm/3.5/llvm.nix
+++ /dev/null
@@ -1,97 +0,0 @@
-{ stdenv
-, fetch
-, fetchpatch
-, perl
-, groff
-, cmake
-, python
-, libffi
-, libbfd
-, libxml2
-, valgrind
-, ncurses
-, version
-, zlib
-, compiler-rt_src
-, debugVersion ? false
-, enableSharedLibraries ? !stdenv.isDarwin
-}:
-
-stdenv.mkDerivation {
-  pname = "llvm";
-  inherit version;
-
-  src = fetch "llvm" "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4";
-
-  unpackPhase = ''
-    unpackFile $src
-    mv llvm-${version}.src llvm
-    sourceRoot=$PWD/llvm
-    unpackFile ${compiler-rt_src}
-    mv compiler-rt-* $sourceRoot/projects/compiler-rt
-  '';
-
-  buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind;
-
-  propagatedBuildInputs = [ ncurses zlib ];
-
-  prePatch = ''
-    substituteInPlace CMakeLists.txt \
-      --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \
-      --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' ""
-  '';
-
-  postPatch = stdenv.lib.optionalString (stdenv ? glibc) ''
-    (
-      cd projects/compiler-rt
-      patch -p1 < ${
-        fetchpatch {
-          name = "sigaltstack.patch"; # for glibc-2.26
-          url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
-          sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
-        }
-      }
-
-      sed -i "s,#include <pthread.h>,&\n#include <signal.h>,g" \
-        lib/asan/asan_linux.cc
-    )
-  '';
-
-  # hacky fix: created binaries need to be run before installation
-  preBuild = ''
-    mkdir -p $out/
-    ln -sv $PWD/lib $out
-  '';
-
-  cmakeFlags = with stdenv; [
-    "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
-    "-DLLVM_BUILD_TESTS=ON"
-    "-DLLVM_ENABLE_FFI=ON"
-    "-DLLVM_REQUIRES_RTTI=1"
-  ] ++ stdenv.lib.optional enableSharedLibraries
-    "-DBUILD_SHARED_LIBS=ON"
-    ++ stdenv.lib.optional (!isDarwin)
-    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-    ++ stdenv.lib.optionals ( isDarwin) [
-    "-DCMAKE_CXX_FLAGS=-stdlib=libc++"
-    "-DCAN_TARGET_i386=false"
-  ];
-
-  patches = [ ./fix-15974.patch ] ++
-    stdenv.lib.optionals (!stdenv.isDarwin) [../fix-llvm-config.patch ];
-
-  postBuild = ''
-    rm -fR $out
-  '';
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "Collection of modular and reusable compiler and toolchain technologies";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ];
-    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "armv7l-linux"];
-  };
-}
-
diff --git a/pkgs/development/compilers/llvm/3.5/polly-separate-build.patch b/pkgs/development/compilers/llvm/3.5/polly-separate-build.patch
deleted file mode 100644
index 618dd4dc3b12..000000000000
--- a/pkgs/development/compilers/llvm/3.5/polly-separate-build.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur polly-3.4-orig/CMakeLists.txt polly-3.4/CMakeLists.txt
---- polly-3.4-orig/CMakeLists.txt	2013-11-21 06:51:46.000000000 -0500
-+++ polly-3.4/CMakeLists.txt	2014-01-20 18:49:34.907919933 -0500
-@@ -53,7 +53,7 @@
-   execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --cxxflags
-                   OUTPUT_VARIABLE LLVM_CXX_FLAGS
-                   OUTPUT_STRIP_TRAILING_WHITESPACE)
--  set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS})
-+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}")
- endif(NOT DEFINED LLVM_MAIN_SRC_DIR)
- 
- set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/pkgs/development/compilers/llvm/3.5/polly.nix b/pkgs/development/compilers/llvm/3.5/polly.nix
deleted file mode 100644
index 06bc7490c7b5..000000000000
--- a/pkgs/development/compilers/llvm/3.5/polly.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ stdenv, fetch, cmake, isl, python, gmp, llvm, version }:
-
-stdenv.mkDerivation {
-  pname = "polly";
-  inherit version;
-
-  src =  fetch "polly" "1s6v54czmgq626an4yk2k34lrzkwmz1bjrbiafh7j23yc2w4nalx";
-
-  patches = [ ./polly-separate-build.patch ];
-
-  buildInputs = [ cmake isl python gmp ];
-
-  cmakeFlags = [
-    "-DCMAKE_CXX_FLAGS=-std=c++11"
-    "-DLLVM_INSTALL_ROOT=${llvm}"
-  ];
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "A polyhedral optimizer for llvm";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch b/pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch
deleted file mode 100644
index 1058cd031767..000000000000
--- a/pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-From 7225c7754cc3431d05df367c60f309f27586f188 Mon Sep 17 00:00:00 2001
-From: Maximilian Bosch <maximilian@mbosch.me>
-Date: Mon, 30 Dec 2019 01:42:52 +0100
-Subject: [PATCH] Fix compilation w/gcc9
-
-Build broken with the following errors:
-
-```
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6078:55: error: lambda parameter 'CGF' previously declared as a capture
-clang> 6078 |                          &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) {
-clang> |                                      ~~~~~~~~~~~~~~~~~^~~
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6126:53: error: lambda parameter 'CGF' previously declared as a capture
-clang> 6126 |                        &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) {
-clang> |                                    ~~~~~~~~~~~~~~~~~^~~
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6191:56: error: lambda parameter 'CGF' previously declared as a capture
-clang> 6191 |   auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
-clang> |                                       ~~~~~~~~~~~~~~~~~^~~
-```
-
-This was due to a bug about name-collisions fixed in GCC 9.0[1].
-
-[1] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2211
----
- lib/CodeGen/CGOpenMPRuntime.cpp | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp
-index 6a0edbe..96c281c 100644
---- a/lib/CodeGen/CGOpenMPRuntime.cpp
-+++ b/lib/CodeGen/CGOpenMPRuntime.cpp
-@@ -6073,7 +6073,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(CodeGenFunction &CGF,
-   // Generate the code for the opening of the data environment. Capture all the
-   // arguments of the runtime call by reference because they are used in the
-   // closing of the region.
--  auto &&BeginThenGen = [&D, &CGF, &BasePointersArray, &PointersArray,
-+  auto &&BeginThenGen = [&D, &BasePointersArray, &PointersArray,
-                          &SizesArray, &MapTypesArray, Device,
-                          &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) {
-     // Fill up the arrays with all the mapped variables.
-@@ -6121,7 +6121,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(CodeGenFunction &CGF,
-   };
- 
-   // Generate code for the closing of the data region.
--  auto &&EndThenGen = [&CGF, &BasePointersArray, &PointersArray, &SizesArray,
-+  auto &&EndThenGen = [&BasePointersArray, &PointersArray, &SizesArray,
-                        &MapTypesArray, Device,
-                        &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) {
-     assert(BasePointersArray && PointersArray && SizesArray && MapTypesArray &&
-@@ -6188,7 +6188,7 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
-          "Expecting either target enter, exit data, or update directives.");
- 
-   // Generate the code for the opening of the data environment.
--  auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
-+  auto &&ThenGen = [&D, Device](CodeGenFunction &CGF, PrePostActionTy &) {
-     // Fill up the arrays with all the mapped variables.
-     MappableExprsHandler::MapValuesArrayTy BasePointers;
-     MappableExprsHandler::MapValuesArrayTy Pointers;
--- 
-2.23.1
-
diff --git a/pkgs/development/compilers/llvm/3.9/clang/default.nix b/pkgs/development/compilers/llvm/3.9/clang/default.nix
deleted file mode 100644
index 1666b3d842d9..000000000000
--- a/pkgs/development/compilers/llvm/3.9/clang/default.nix
+++ /dev/null
@@ -1,85 +0,0 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python }:
-
-let
-  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
-  self = stdenv.mkDerivation {
-    pname = "clang";
-    inherit version;
-
-    src = fetch "cfe" "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76";
-
-    unpackPhase = ''
-      unpackFile $src
-      mv cfe-${version}.src clang
-      sourceRoot=$PWD/clang
-      unpackFile ${clang-tools-extra_src}
-      mv clang-tools-extra-* $sourceRoot/tools/extra
-    '';
-
-    nativeBuildInputs = [ cmake ];
-
-    buildInputs = [ libxml2 llvm python ];
-
-    cmakeFlags = [
-      "-DCMAKE_CXX_FLAGS=-std=c++11"
-    ] ++
-    # Maybe with compiler-rt this won't be needed?
-    (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++
-    (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include");
-
-    patches = [
-      ./purity.patch
-      ./0001-Fix-compilation-w-gcc9.patch
-    ];
-
-    postPatch = ''
-      sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp
-      sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
-      sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp
-    '';
-
-    outputs = [ "out" "lib" "python" ];
-
-    # Clang expects to find LLVMgold in its own prefix
-    # Clang expects to find sanitizer libraries in its own prefix
-    postInstall = ''
-      if [ -e ${llvm}/lib/LLVMgold.so ]; then
-        ln -sv ${llvm}/lib/LLVMgold.so $out/lib
-      fi
-
-      ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/
-      ln -sv $out/bin/clang $out/bin/cpp
-
-      # Move libclang to 'lib' output
-      moveToOutput "lib/libclang.*" "$lib"
-      substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
-          --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang."
-
-      mkdir -p $python/bin $python/share/clang/
-      mv $out/bin/{git-clang-format,scan-view} $python/bin
-      if [ -e $out/bin/set-xcode-analyzer ]; then
-        mv $out/bin/set-xcode-analyzer $python/bin
-      fi
-      mv $out/share/clang/*.py $python/share/clang
-
-      rm $out/bin/c-index-test
-    '';
-
-    enableParallelBuilding = true;
-
-    passthru = {
-      isClang = true;
-      inherit llvm;
-    } // stdenv.lib.optionalAttrs stdenv.isLinux {
-      inherit gcc;
-    };
-
-    meta = {
-      description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
-      homepage    = http://llvm.org/;
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
-    };
-  };
-in self
diff --git a/pkgs/development/compilers/llvm/3.9/clang/purity.patch b/pkgs/development/compilers/llvm/3.9/clang/purity.patch
deleted file mode 100644
index f5fb4c73af47..000000000000
--- a/pkgs/development/compilers/llvm/3.9/clang/purity.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/lib/Driver/Tools.cpp	2016-08-25 15:48:05.187553443 +0200
-+++ b/lib/Driver/Tools.cpp	2016-08-25 15:48:47.534468882 +0200
-@@ -9420,13 +9420,6 @@
-   if (!Args.hasArg(options::OPT_static)) {
-     if (Args.hasArg(options::OPT_rdynamic))
-       CmdArgs.push_back("-export-dynamic");
--
--    if (!Args.hasArg(options::OPT_shared)) {
--      const std::string Loader =
--          D.DyldPrefix + ToolChain.getDynamicLinker(Args);
--      CmdArgs.push_back("-dynamic-linker");
--      CmdArgs.push_back(Args.MakeArgString(Loader));
--    }
-   }
- 
-   CmdArgs.push_back("-o");
diff --git a/pkgs/development/compilers/llvm/3.9/default.nix b/pkgs/development/compilers/llvm/3.9/default.nix
deleted file mode 100644
index 752790cdd853..000000000000
--- a/pkgs/development/compilers/llvm/3.9/default.nix
+++ /dev/null
@@ -1,59 +0,0 @@
-{ newScope, stdenv, libstdcxxHook, isl, fetchurl, overrideCC, wrapCCWith
-, buildLlvmTools # tools, but from the previous stage, for cross
-, targetLlvmLibraries # libraries, but from the next stage, for cross
-}:
-
-let
-  version = "3.9.1";
-
-  fetch = fetch_v version;
-  fetch_v = ver: name: sha256: fetchurl {
-    url = "https://releases.llvm.org/${version}/${name}-${ver}.src.tar.xz";
-    inherit sha256;
-  };
-
-  compiler-rt_src = fetch "compiler-rt" "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk";
-  clang-tools-extra_src = fetch "clang-tools-extra" "0d9nh7j7brbh9avigcn69dlaihsl9p3cf9s45mw6fxzzvrdvd999";
-
-  tools = stdenv.lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv isl version fetch; });
-  in {
-    llvm = callPackage ./llvm.nix {
-      inherit compiler-rt_src;
-    };
-
-    clang-unwrapped = callPackage ./clang {
-      inherit clang-tools-extra_src;
-    };
-
-    libclang = tools.clang-unwrapped.lib;
-
-    clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
-
-    libstdcxxClang = wrapCCWith {
-      cc = tools.clang-unwrapped;
-      extraPackages = [ libstdcxxHook ];
-    };
-
-    libcxxClang = wrapCCWith {
-      cc = tools.clang-unwrapped;
-      extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ];
-    };
-
-    lldb = callPackage ./lldb.nix {};
-  });
-
-  libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv isl version fetch; });
-  in {
-
-    stdenv = overrideCC stdenv buildLlvmTools.clang;
-
-    libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
-
-    libcxx = callPackage ./libc++ {};
-
-    libcxxabi = callPackage ./libc++abi.nix {};
-  });
-
-in { inherit tools libraries; } // libraries // tools
diff --git a/pkgs/development/compilers/llvm/3.9/libc++/darwin.patch b/pkgs/development/compilers/llvm/3.9/libc++/darwin.patch
deleted file mode 100644
index 6dd756f01cc2..000000000000
--- a/pkgs/development/compilers/llvm/3.9/libc++/darwin.patch
+++ /dev/null
@@ -1,39 +0,0 @@
---- libcxx-3.8.0.src.org/lib/CMakeLists.txt	2015-12-16 15:41:05.000000000 -0800
-+++ libcxx-3.8.0.src/lib/CMakeLists.txt	2016-06-17 19:40:00.293394500 -0700
-@@ -94,30 +94,30 @@
-     add_definitions(-D__STRICT_ANSI__)
-     add_link_flags(
-       "-compatibility_version 1"
-       "-current_version 1"
--      "-install_name /usr/lib/libc++.1.dylib"
--      "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
-+      "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib"
-+      "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
-       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
-       "/usr/lib/libSystem.B.dylib")
-   else()
-     if ( ${CMAKE_OSX_SYSROOT} )
-       list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
-       if (OSX_HAS_ARMV7)
-         set(OSX_RE_EXPORT_LINE
--          "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
-+          "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
-           "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
-       else()
-         set(OSX_RE_EXPORT_LINE
--          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
-+          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib")
-       endif()
-     else()
--      set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
-+      set(OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
-     endif()
- 
-     add_link_flags(
-       "-compatibility_version 1"
--      "-install_name /usr/lib/libc++.1.dylib"
-+      "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib"
-       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
-       "${OSX_RE_EXPORT_LINE}"
-       "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp"
-       "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp")
diff --git a/pkgs/development/compilers/llvm/3.9/libc++/default.nix b/pkgs/development/compilers/llvm/3.9/libc++/default.nix
deleted file mode 100644
index 9d82aa230357..000000000000
--- a/pkgs/development/compilers/llvm/3.9/libc++/default.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ lib, stdenv, fetch, cmake, libcxxabi, fixDarwinDylibNames, version }:
-
-stdenv.mkDerivation {
-  pname = "libc++";
-  inherit version;
-
-  src = fetch "libcxx" "0qbl3afl2p2h87p977lsqr5kykl6cgjpkzczs0g6a3pn53j1bri5";
-
-  postUnpack = ''
-    unpackFile ${libcxxabi.src}
-  '';
-
-  preConfigure = ''
-    # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
-    cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$NIX_BUILD_TOP/libcxxabi-${version}.src/include")
-  '';
-
-  patches = [
-    # glibc 2.26 fix
-    ./xlocale-glibc-2.26.patch
-  ]
-  ++ lib.optional stdenv.isDarwin ./darwin.patch
-  ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
-    ../../libcxx-0001-musl-hacks.patch
-    ../../libcxx-max_align_t.patch
-  ];
-
-  nativeBuildInputs = [ cmake ];
-  buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  cmakeFlags = [
-    "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
-    "-DLIBCXX_LIBCPPABI_VERSION=2"
-    "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
-
-  enableParallelBuilding = true;
-
-  linkCxxAbi = stdenv.isLinux;
-
-  setupHooks = [
-    ../../../../../build-support/setup-hooks/role.bash
-    ./setup-hook.sh
-  ];
-
-  meta = {
-    homepage = http://libcxx.llvm.org/;
-    description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh b/pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh
deleted file mode 100644
index 6611259165ae..000000000000
--- a/pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-# See pkgs/build-support/setup-hooks/role.bash
-getHostRole
-
-linkCxxAbi="@linkCxxAbi@"
-export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
-export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
diff --git a/pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch b/pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch
deleted file mode 100644
index 4cc042554c85..000000000000
--- a/pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff --git a/include/__locale b/include/__locale
-index 7bc701d..ea75c86 100644
---- a/include/__locale
-+++ b/include/__locale
-@@ -34,12 +34,12 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
- # include <support/musl/xlocale.h>
--#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
-+#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
- 
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- #pragma GCC system_header
diff --git a/pkgs/development/compilers/llvm/3.9/libc++abi.nix b/pkgs/development/compilers/llvm/3.9/libc++abi.nix
deleted file mode 100644
index f799199d449f..000000000000
--- a/pkgs/development/compilers/llvm/3.9/libc++abi.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
-
-stdenv.mkDerivation {
-  pname = "libc++abi";
-  inherit version;
-
-  src = fetch "libcxxabi" "1qi9q06zanqm8awzq83810avmvi52air6gr9zfip8mbg5viqn3cj";
-
-  nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
-
-  postUnpack = ''
-    unpackFile ${libcxx.src}
-    unpackFile ${llvm.src}
-    export NIX_CFLAGS_COMPILE+=" -I$PWD/include"
-    export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
-    patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
-    patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch}
-  '';
-
-  installPhase = if stdenv.isDarwin
-    then ''
-      for file in lib/*.dylib; do
-        # this should be done in CMake, but having trouble figuring out
-        # the magic combination of necessary CMake variables
-        # if you fancy a try, take a look at
-        # http://www.cmake.org/Wiki/CMake_RPATH_handling
-        install_name_tool -id $out/$file $file
-      done
-      make install
-      install -d 755 $out/include
-      install -m 644 ../include/*.h $out/include
-    ''
-    else ''
-      install -d -m 755 $out/include $out/lib
-      install -m 644 lib/libc++abi.so.1.0 $out/lib
-      install -m 644 ../include/cxxabi.h $out/include
-      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
-      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
-    '';
-
-  meta = {
-    homepage = http://libcxxabi.llvm.org/;
-    description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.9/lldb.nix b/pkgs/development/compilers/llvm/3.9/lldb.nix
deleted file mode 100644
index 1a7c9aeead86..000000000000
--- a/pkgs/development/compilers/llvm/3.9/lldb.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-{ stdenv
-, fetch
-, cmake
-, zlib
-, ncurses
-, swig
-, which
-, libedit
-, llvm
-, clang-unwrapped
-, python
-, version
-}:
-
-stdenv.mkDerivation {
-  pname = "lldb";
-  inherit version;
-
-  src = fetch "lldb" "1z30ljmcpp261bjng1i5k3bb9jkrs1cr97z04qs4s3zql6r12cvy";
-
-  postUnpack = ''
-    # Hack around broken standalone build as of 3.8
-    unpackFile ${llvm.src}
-    srcDir="$(ls -d lldb-*.src)"
-    mkdir -p "$srcDir/tools/lib/Support"
-    cp "$(ls -d llvm-*.src)/lib/Support/regex_impl.h" "$srcDir/tools/lib/Support/"
-
-    # Fix up various paths that assume llvm and clang are installed in the same place
-    substituteInPlace $srcDir/cmake/modules/LLDBStandalone.cmake \
-      --replace CheckAtomic $(readlink -f llvm-*.src)/cmake/modules/CheckAtomic.cmake
-    sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \
-      $srcDir/cmake/modules/LLDBStandalone.cmake
-    sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \
-      $srcDir/cmake/modules/LLDBStandalone.cmake
-    sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \
-      $srcDir/cmake/modules/LLDBStandalone.cmake
-  '';
-
-  buildInputs = [ cmake python which swig ncurses zlib libedit llvm ];
-
-  CXXFLAGS = "-fno-rtti";
-  hardeningDisable = [ "format" ];
-
-  cmakeFlags = [
-    "-DLLVM_MAIN_INCLUDE_DIR=${llvm}/include"
-    "-DLLDB_DISABLE_LIBEDIT=1" # https://llvm.org/bugs/show_bug.cgi?id=28898
-  ];
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "A next-generation high-performance debugger";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/3.9/llvm-outputs.patch b/pkgs/development/compilers/llvm/3.9/llvm-outputs.patch
deleted file mode 100644
index 40096fa3497f..000000000000
--- a/pkgs/development/compilers/llvm/3.9/llvm-outputs.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
-index 94d426b..37f7794 100644
---- a/tools/llvm-config/llvm-config.cpp
-+++ b/tools/llvm-config/llvm-config.cpp
-@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
-     ActiveIncludeOption = "-I" + ActiveIncludeDir;
-   }
- 
-+  /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
-+  if (!IsInDevelopmentTree) {
-+    bool WantShared = true;
-+    for (int i = 1; i < argc; ++i) {
-+      StringRef Arg = argv[i];
-+      if (Arg == "--link-shared")
-+        WantShared = true;
-+      else if (Arg == "--link-static")
-+        WantShared = false; // the last one wins
-+    }
-+
-+    if (WantShared)
-+      ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
-+  }
-+
-   /// We only use `shared library` mode in cases where the static library form
-   /// of the components provided are not available; note however that this is
-   /// skipped if we're run from within the build dir. However, once installed,
diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix
deleted file mode 100644
index 474cfcde9c0b..000000000000
--- a/pkgs/development/compilers/llvm/3.9/llvm.nix
+++ /dev/null
@@ -1,174 +0,0 @@
-{ stdenv
-, fetch
-, fetchpatch
-, perl
-, groff
-, cmake
-, python
-, libffi
-, libbfd
-, libxml2
-, ncurses
-, version
-, zlib
-, compiler-rt_src
-, debugVersion ? false
-, enableSharedLibraries ? (stdenv.buildPlatform == stdenv.hostPlatform)
-, buildPackages
-}:
-
-assert (stdenv.hostPlatform != stdenv.buildPlatform) -> !enableSharedLibraries;
-
-let
-  # Used when creating a versioned symlinks of libLLVM.dylib
-  versionSuffixes = with stdenv.lib;
-    let parts = splitVersion version; in
-    imap (i: _: concatStringsSep "." (take i parts)) parts;
-in
-
-stdenv.mkDerivation {
-  pname = "llvm";
-  inherit version;
-
-  src = fetch "llvm" "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z";
-
-  unpackPhase = ''
-    unpackFile $src
-    mv llvm-${version}.src llvm
-    sourceRoot=$PWD/llvm
-    unpackFile ${compiler-rt_src}
-    mv compiler-rt-* $sourceRoot/projects/compiler-rt
-  '';
-
-  outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib";
-
-  nativeBuildInputs = [
-    perl
-    cmake
-    python
-  ];
-
-  buildInputs = [
-    groff
-    libxml2
-    libffi
-  ];
-
-  propagatedBuildInputs = [ ncurses zlib ];
-
-  patches = [
-    # fix output of llvm-config (fixed in llvm 4.0)
-    (fetchpatch {
-      url = https://github.com/llvm-mirror/llvm/commit/5340b5b3d970069aebf3dde49d8964583742e01a.patch;
-      sha256 = "095f8knplwqbc2p7rad1kq8633i34qynni9jna93an7kyc80wdxl";
-   })
-   ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
-     ../TLI-musl.patch
-     ../dynamiclibrary-musl.patch
-   ];
-
-  postPatch = ""
-  + ''
-    patch -p1 --reverse < ${fetchpatch {
-      name = "fix-red-icons.diff"; # https://bugs.freedesktop.org/show_bug.cgi?id=99078
-      url = https://github.com/llvm-mirror/llvm/commit/c280d74837d8.diff;
-      sha256 = "11sq86spw41v72f676igksapdlsgh7fiqp5qkkmgfj0ndqcn9skf";
-    }}
-  ''
-  # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
-  # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-  # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
-  # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
-  # a flag and turn the flag off during the stdenv build. I realize that this LLVM isn't used in the stdenv but I want to
-  # keep it consistent with 4.0. We really shouldn't be copying and pasting all this code around...
-  + stdenv.lib.optionalString stdenv.isDarwin ''
-    substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \
-      --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-
-    substituteInPlace CMakeLists.txt \
-      --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$lib/lib")" \
-      --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' ""
-  ''
-  # Patch llvm-config to return correct library path based on --link-{shared,static}.
-  + stdenv.lib.optionalString (enableSharedLibraries) ''
-    substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
-    patch -p1 < ./llvm-outputs.patch
-  ''
-  + ''
-    (
-      cd projects/compiler-rt
-      patch -p1 < ${
-        fetchpatch {
-          name = "sigaltstack.patch"; # for glibc-2.26
-          url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
-          sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
-        }
-      }
-      substituteInPlace lib/esan/esan_sideline_linux.cpp \
-        --replace 'struct sigaltstack' 'stack_t'
-    )
-  '';
-
-  # hacky fix: created binaries need to be run before installation
-  preBuild = ''
-    mkdir -p $out/
-    ln -sv $PWD/lib $out
-  '';
-
-  cmakeFlags = with stdenv; [
-    "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
-    "-DLLVM_INSTALL_UTILS=ON"  # Needed by rustc
-    "-DLLVM_BUILD_TESTS=ON"
-    "-DLLVM_ENABLE_FFI=ON"
-    "-DLLVM_ENABLE_RTTI=ON"
-    "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code
-
-    "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
-    "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
-    "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optional enableSharedLibraries [
-    "-DLLVM_LINK_LLVM_DYLIB=ON"
-  ] ++ stdenv.lib.optional (!isDarwin)
-    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-    ++ stdenv.lib.optionals (isDarwin) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DCAN_TARGET_i386=false"
-  ] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
-    "-DCMAKE_CROSSCOMPILING=True"
-    "-DLLVM_TABLEGEN=${buildPackages.llvmPackages_39.llvm}/bin/llvm-tblgen"
-  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
-    # Not yet supported
-    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
-    "-DCOMPILER_RT_BUILD_XRAY=OFF"
-
-  ];
-
-  postBuild = ''
-    rm -fR $out
-  '';
-
-  postInstall = ""
-  + stdenv.lib.optionalString (enableSharedLibraries) ''
-    moveToOutput "lib/libLLVM-*" "$lib"
-    moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
-    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \
-      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
-  ''
-  + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
-    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \
-      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
-      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
-    '') versionSuffixes}
-  '';
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "Collection of modular and reusable compiler and toolchain technologies";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ];
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/4/clang/0001-Fix-compilation-w-gcc9.patch b/pkgs/development/compilers/llvm/4/clang/0001-Fix-compilation-w-gcc9.patch
deleted file mode 100644
index ea9342574087..000000000000
--- a/pkgs/development/compilers/llvm/4/clang/0001-Fix-compilation-w-gcc9.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From a2af0b02eba35d0670e3e442ff7c61b3e2304edd Mon Sep 17 00:00:00 2001
-From: Maximilian Bosch <maximilian@mbosch.me>
-Date: Mon, 30 Dec 2019 02:11:35 +0100
-Subject: [PATCH] Fix compilation w/gcc9
-
-Build broken with the following errors:
-
-```
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6275:24: error: lambda parameter 'CGF' previously declared as a capture
-clang> 6275 |       CodeGenFunction &CGF, PrePostActionTy &) {
-clang> |       ~~~~~~~~~~~~~~~~~^~~
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6321:62: error: lambda parameter 'CGF' previously declared as a capture
-clang> 6321 |   auto &&EndThenGen = [&CGF, Device, &Info](CodeGenFunction &CGF,
-clang> |                                             ~~~~~~~~~~~~~~~~~^~~
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
-clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6400:56: error: lambda parameter 'CGF' previously declared as a capture
-clang> 6400 |   auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
-clang> |                                       ~~~~~~~~~~~~~~~~~^~~
-```
----
- lib/CodeGen/CGOpenMPRuntime.cpp | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp
-index 4025217..40a73ef 100644
---- a/lib/CodeGen/CGOpenMPRuntime.cpp
-+++ b/lib/CodeGen/CGOpenMPRuntime.cpp
-@@ -6271,7 +6271,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
-   // Generate the code for the opening of the data environment. Capture all the
-   // arguments of the runtime call by reference because they are used in the
-   // closing of the region.
--  auto &&BeginThenGen = [&D, &CGF, Device, &Info, &CodeGen, &NoPrivAction](
-+  auto &&BeginThenGen = [&D, Device, &Info, &CodeGen, &NoPrivAction](
-       CodeGenFunction &CGF, PrePostActionTy &) {
-     // Fill up the arrays with all the mapped variables.
-     MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
-@@ -6318,7 +6318,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
-   };
- 
-   // Generate code for the closing of the data region.
--  auto &&EndThenGen = [&CGF, Device, &Info](CodeGenFunction &CGF,
-+  auto &&EndThenGen = [Device, &Info](CodeGenFunction &CGF,
-                                             PrePostActionTy &) {
-     assert(Info.isValid() && "Invalid data environment closing arguments.");
- 
-@@ -6397,7 +6397,7 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
-          "Expecting either target enter, exit data, or update directives.");
- 
-   // Generate the code for the opening of the data environment.
--  auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
-+  auto &&ThenGen = [&D, Device](CodeGenFunction &CGF, PrePostActionTy &) {
-     // Fill up the arrays with all the mapped variables.
-     MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
-     MappableExprsHandler::MapValuesArrayTy Pointers;
--- 
-2.23.1
-
diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix
deleted file mode 100644
index a90fbe6ae837..000000000000
--- a/pkgs/development/compilers/llvm/4/clang/default.nix
+++ /dev/null
@@ -1,116 +0,0 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, release_version, clang-tools-extra_src, python
-, fixDarwinDylibNames
-, enableManpages ? false
-}:
-
-let
-  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
-  self = stdenv.mkDerivation ({
-    pname = "clang";
-    inherit version;
-
-    src = fetch "cfe" "16vnv3msnvx33dydd17k2cq0icndi1a06bg5vcxkrhjjb1rqlwv1";
-
-    unpackPhase = ''
-      unpackFile $src
-      mv cfe-${version}* clang
-      sourceRoot=$PWD/clang
-      unpackFile ${clang-tools-extra_src}
-      mv clang-tools-extra-* $sourceRoot/tools/extra
-    '';
-
-    nativeBuildInputs = [ cmake python ]
-      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
-
-    buildInputs = [ libxml2 llvm ]
-      ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-    cmakeFlags = [
-      "-DCMAKE_CXX_FLAGS=-std=c++11"
-    ] ++ stdenv.lib.optionals enableManpages [
-      "-DCLANG_INCLUDE_DOCS=ON"
-      "-DLLVM_ENABLE_SPHINX=ON"
-      "-DSPHINX_OUTPUT_MAN=ON"
-      "-DSPHINX_OUTPUT_HTML=OFF"
-      "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-    ]
-    # Maybe with compiler-rt this won't be needed?
-    ++ stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}"
-    ++ stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include";
-
-    patches = [
-      ./purity.patch
-      ./0001-Fix-compilation-w-gcc9.patch
-    ];
-
-    postPatch = ''
-      sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp
-      sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp
-
-      # Patch for standalone doc building
-      sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
-      sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp
-    '';
-
-    outputs = [ "out" "lib" "python" ];
-
-    # Clang expects to find LLVMgold in its own prefix
-    # Clang expects to find sanitizer libraries in its own prefix
-    postInstall = ''
-      if [ -e ${llvm}/lib/LLVMgold.so ]; then
-        ln -sv ${llvm}/lib/LLVMgold.so $out/lib
-      fi
-
-      ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/
-      ln -sv $out/bin/clang $out/bin/cpp
-
-      # Move libclang to 'lib' output
-      moveToOutput "lib/libclang.*" "$lib"
-      substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
-          --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang."
-
-      mkdir -p $python/bin $python/share/clang/
-      mv $out/bin/{git-clang-format,scan-view} $python/bin
-      if [ -e $out/bin/set-xcode-analyzer ]; then
-        mv $out/bin/set-xcode-analyzer $python/bin
-      fi
-      mv $out/share/clang/*.py $python/share/clang
-      rm $out/bin/c-index-test
-    '';
-
-    enableParallelBuilding = true;
-
-    passthru = {
-      isClang = true;
-      inherit llvm;
-    } // stdenv.lib.optionalAttrs stdenv.isLinux {
-      inherit gcc;
-    };
-
-    meta = {
-      description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
-      homepage    = http://llvm.org/;
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
-    };
-  } // stdenv.lib.optionalAttrs enableManpages {
-    pname = "clang-manpages";
-
-    buildPhase = ''
-      make docs-clang-man
-    '';
-
-    installPhase = ''
-      mkdir -p $out/share/man/man1
-      # Manually install clang manpage
-      cp docs/man/*.1 $out/share/man/man1/
-    '';
-
-    outputs = [ "out" ];
-
-    doCheck = false;
-
-    meta.description = "man page for Clang ${version}";
-  });
-in self
diff --git a/pkgs/development/compilers/llvm/4/clang/purity.patch b/pkgs/development/compilers/llvm/4/clang/purity.patch
deleted file mode 100644
index f5fb4c73af47..000000000000
--- a/pkgs/development/compilers/llvm/4/clang/purity.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/lib/Driver/Tools.cpp	2016-08-25 15:48:05.187553443 +0200
-+++ b/lib/Driver/Tools.cpp	2016-08-25 15:48:47.534468882 +0200
-@@ -9420,13 +9420,6 @@
-   if (!Args.hasArg(options::OPT_static)) {
-     if (Args.hasArg(options::OPT_rdynamic))
-       CmdArgs.push_back("-export-dynamic");
--
--    if (!Args.hasArg(options::OPT_shared)) {
--      const std::string Loader =
--          D.DyldPrefix + ToolChain.getDynamicLinker(Args);
--      CmdArgs.push_back("-dynamic-linker");
--      CmdArgs.push_back(Args.MakeArgString(Loader));
--    }
-   }
- 
-   CmdArgs.push_back("-o");
diff --git a/pkgs/development/compilers/llvm/4/cmdline-help.patch b/pkgs/development/compilers/llvm/4/cmdline-help.patch
deleted file mode 100644
index a693719c2cfa..000000000000
--- a/pkgs/development/compilers/llvm/4/cmdline-help.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From c7a9aa3a697c81432786a5583bf973771c7be15e Mon Sep 17 00:00:00 2001
-From: Don Hinton <hintonda@gmail.com>
-Date: Wed, 12 Jul 2017 01:15:46 +0000
-Subject: [PATCH] Fix minor typo introduced in r276404
-
-Summary:
-A space was added between '-' and 'help' when emitting help output.
-
-See https://reviews.llvm.org/D22621 for details.
-
-Reviewers: MaggieYi, vsk
-
-Reviewed By: vsk
-
-Subscribers: llvm-commits
-
-Differential Revision: https://reviews.llvm.org/D35283
-
-git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307745 91177308-0d34-0410-b5e6-96231b3b80d8
----
- lib/Support/CommandLine.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
-index 3889902eea5..79defa5c36c 100644
---- a/lib/Support/CommandLine.cpp
-+++ b/lib/Support/CommandLine.cpp
-@@ -1236,7 +1236,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
-              << ": Not enough positional command line arguments specified!\n"
-              << "Must specify at least " << NumPositionalRequired
-              << " positional argument" << (NumPositionalRequired > 1 ? "s" : "")
--             << ": See: " << argv[0] << " - help\n";
-+             << ": See: " << argv[0] << " -help\n";
-     }
- 
-     ErrorParsing = true;
--- 
-2.14.0
-
diff --git a/pkgs/development/compilers/llvm/4/default.nix b/pkgs/development/compilers/llvm/4/default.nix
deleted file mode 100644
index 9651dbb72f4d..000000000000
--- a/pkgs/development/compilers/llvm/4/default.nix
+++ /dev/null
@@ -1,74 +0,0 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
-, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith
-, buildLlvmTools # tools, but from the previous stage, for cross
-, targetLlvmLibraries # libraries, but from the next stage, for cross
-}:
-
-let
-  release_version = "4.0.1";
-  version = release_version; # differentiating these is important for rc's
-
-  fetch = name: sha256: fetchurl {
-    url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz";
-    inherit sha256;
-  };
-
-  compiler-rt_src = fetch "compiler-rt" "0h5lpv1z554szi4r4blbskhwrkd78ir50v3ng8xvk1s86fa7gj53";
-  clang-tools-extra_src = fetch "clang-tools-extra" "1dhmp7ccfpr42bmvk3kp37ngjpf3a9m5d4kkpsn7d00hzi7fdl9m";
-
-  tools = stdenv.lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
-  in {
-
-    llvm = callPackage ./llvm.nix {
-      inherit compiler-rt_src;
-    };
-    clang-unwrapped = callPackage ./clang {
-      inherit clang-tools-extra_src;
-    };
-
-    llvm-manpages = lowPrio (tools.llvm.override {
-      enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
-    });
-
-    clang-manpages = lowPrio (tools.clang-unwrapped.override {
-      enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
-    });
-
-    libclang = tools.clang-unwrapped.lib;
-
-    clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
-
-    libstdcxxClang = wrapCCWith {
-      cc = tools.clang-unwrapped;
-      extraPackages = [ libstdcxxHook ];
-    };
-
-    libcxxClang = wrapCCWith {
-      cc = tools.clang-unwrapped;
-      extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ];
-    };
-
-    lld = callPackage ./lld.nix {};
-
-    lldb = callPackage ./lldb.nix {};
-  });
-
-  libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
-  in {
-
-    stdenv = overrideCC stdenv buildLlvmTools.clang;
-
-    libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
-
-    libcxx = callPackage ./libc++ {};
-
-    libcxxabi = callPackage ./libc++abi.nix {};
-
-    openmp = callPackage ./openmp.nix {};
-  });
-
-in { inherit tools libraries; } // libraries // tools
diff --git a/pkgs/development/compilers/llvm/4/fix-gcc9.patch b/pkgs/development/compilers/llvm/4/fix-gcc9.patch
deleted file mode 100644
index 8ea5ca970855..000000000000
--- a/pkgs/development/compilers/llvm/4/fix-gcc9.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-diff --git a/lib/Target/Mips/MipsFastISel.cpp b/lib/Target/Mips/MipsFastISel.cpp
-index f79cb0e6..c6279046 100644
---- a/lib/Target/Mips/MipsFastISel.cpp
-+++ b/lib/Target/Mips/MipsFastISel.cpp
-@@ -32,6 +32,7 @@
- #include "llvm/MC/MCSymbol.h"
- #include "llvm/Target/TargetInstrInfo.h"
- #include "llvm/Support/Debug.h"
-+#include <array>
- 
- #define DEBUG_TYPE "mips-fastisel"
- 
-@@ -1268,13 +1269,13 @@ bool MipsFastISel::fastLowerArguments() {
-     return false;
-   }
- 
--  const ArrayRef<MCPhysReg> GPR32ArgRegs = {Mips::A0, Mips::A1, Mips::A2,
--                                            Mips::A3};
--  const ArrayRef<MCPhysReg> FGR32ArgRegs = {Mips::F12, Mips::F14};
--  const ArrayRef<MCPhysReg> AFGR64ArgRegs = {Mips::D6, Mips::D7};
--  ArrayRef<MCPhysReg>::iterator NextGPR32 = GPR32ArgRegs.begin();
--  ArrayRef<MCPhysReg>::iterator NextFGR32 = FGR32ArgRegs.begin();
--  ArrayRef<MCPhysReg>::iterator NextAFGR64 = AFGR64ArgRegs.begin();
-+   std::array<MCPhysReg, 4> GPR32ArgRegs = {{Mips::A0, Mips::A1, Mips::A2,
-+                                            Mips::A3}};
-+   std::array<MCPhysReg, 2> FGR32ArgRegs = {{Mips::F12, Mips::F14}};
-+   std::array<MCPhysReg, 2> AFGR64ArgRegs = {{Mips::D6, Mips::D7}};
-+   auto NextGPR32 = GPR32ArgRegs.begin();
-+   auto NextFGR32 = FGR32ArgRegs.begin();
-+   auto NextAFGR64 = AFGR64ArgRegs.begin();
- 
-   struct AllocatedReg {
-     const TargetRegisterClass *RC;
diff --git a/pkgs/development/compilers/llvm/4/libc++/default.nix b/pkgs/development/compilers/llvm/4/libc++/default.nix
deleted file mode 100644
index 0213741e3e06..000000000000
--- a/pkgs/development/compilers/llvm/4/libc++/default.nix
+++ /dev/null
@@ -1,59 +0,0 @@
-{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }:
-
-stdenv.mkDerivation {
-  pname = "libc++";
-  inherit version;
-
-  src = fetch "libcxx" "0k6cmjcxnp2pyl8xwy1wkyyckkmdrjddim94yf1gzjbjy9qi22jj";
-
-  postUnpack = ''
-    unpackFile ${libcxxabi.src}
-    export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
-  '';
-
-  patches = [
-    # https://github.com/llvm-mirror/libcxx/commit/bcc92d75df0274b9593ebd097fcae60494e3bffc
-    ./pthread_mach_thread_np.patch
-    # glibc 2.26 fix
-    ./xlocale-glibc-2.26.patch
-  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
-    ../../libcxx-0001-musl-hacks.patch
-    ../../libcxx-max_align_t.patch
-  ];
-
-  prePatch = ''
-    substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
-  '';
-
-  preConfigure = ''
-    # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
-    cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
-  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
-    patchShebangs utils/cat_files.py
-  '';
-  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
-
-  buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  cmakeFlags = [
-    "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
-    "-DLIBCXX_LIBCPPABI_VERSION=2"
-    "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
-
-  enableParallelBuilding = true;
-
-  linkCxxAbi = stdenv.isLinux;
-
-  setupHooks = [
-    ../../../../../build-support/setup-hooks/role.bash
-    ./setup-hook.sh
-  ];
-
-  meta = {
-    homepage = http://libcxx.llvm.org/;
-    description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch b/pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch
deleted file mode 100644
index 8c71f1b815db..000000000000
--- a/pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From bcc92d75df0274b9593ebd097fcae60494e3bffc Mon Sep 17 00:00:00 2001
-From: Asiri Rathnayake <asiri.rathnayake@arm.com>
-Date: Thu, 26 Jan 2017 10:40:17 +0000
-Subject: [PATCH] Fix chromium build (libcxx)
-
-Remove the reference to pthread_mach_thread_np() in libcxx headers.
-
-git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@293167 91177308-0d34-0410-b5e6-96231b3b80d8
----
- include/__threading_support | 11 -----------
- 1 file changed, 11 deletions(-)
-
-diff --git a/include/__threading_support b/include/__threading_support
-index 13ab769..dfe7fe1 100644
---- a/include/__threading_support
-+++ b/include/__threading_support
-@@ -149,11 +149,6 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
-                           void (*init_routine)(void));
- 
- // Thread id
--#if defined(__APPLE__) && !defined(__arm__)
--_LIBCPP_THREAD_ABI_VISIBILITY
--mach_port_t __libcpp_thread_get_port();
--#endif
--
- _LIBCPP_THREAD_ABI_VISIBILITY
- bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
- 
-@@ -297,12 +292,6 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
- }
- 
- // Thread id
--#if defined(__APPLE__) && !defined(__arm__)
--mach_port_t __libcpp_thread_get_port() {
--    return pthread_mach_thread_np(pthread_self());
--}
--#endif
--
- // Returns non-zero if the thread ids are equal, otherwise 0
- bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
- {
diff --git a/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh b/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh
deleted file mode 100644
index 6611259165ae..000000000000
--- a/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-# See pkgs/build-support/setup-hooks/role.bash
-getHostRole
-
-linkCxxAbi="@linkCxxAbi@"
-export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
-export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
diff --git a/pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch b/pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch
deleted file mode 100644
index e411d85066b4..000000000000
--- a/pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff --git a/include/__locale b/include/__locale
-index f4882de..29443b4 100644
---- a/include/__locale
-+++ b/include/__locale
-@@ -34,12 +34,12 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
- # include <support/musl/xlocale.h>
--#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
-+#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
- 
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- #pragma GCC system_header
diff --git a/pkgs/development/compilers/llvm/4/libc++abi.nix b/pkgs/development/compilers/llvm/4/libc++abi.nix
deleted file mode 100644
index 8e36c5ad53a6..000000000000
--- a/pkgs/development/compilers/llvm/4/libc++abi.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
-
-stdenv.mkDerivation {
-  pname = "libc++abi";
-  inherit version;
-
-  src = fetch "libcxxabi" "0cqvzallxh0nwiijsf6i4d5ds9m5ijfzywg7376ncv50i64if24g";
-
-  nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
-
-  postUnpack = ''
-    unpackFile ${libcxx.src}
-    unpackFile ${llvm.src}
-    export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
-    patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
-    patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch}
-  '';
-
-  installPhase = if stdenv.isDarwin
-    then ''
-      for file in lib/*.dylib; do
-        # this should be done in CMake, but having trouble figuring out
-        # the magic combination of necessary CMake variables
-        # if you fancy a try, take a look at
-        # http://www.cmake.org/Wiki/CMake_RPATH_handling
-        install_name_tool -id $out/$file $file
-      done
-      make install
-      install -d 755 $out/include
-      install -m 644 ../include/*.h $out/include
-    ''
-    else ''
-      install -d -m 755 $out/include $out/lib
-      install -m 644 lib/libc++abi.a $out/lib
-      install -m 644 lib/libc++abi.so.1.0 $out/lib
-      install -m 644 ../include/cxxabi.h $out/include
-      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
-      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
-    '';
-
-  meta = {
-    homepage = http://libcxxabi.llvm.org/;
-    description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/4/lld.nix b/pkgs/development/compilers/llvm/4/lld.nix
deleted file mode 100644
index 3ab56677d72f..000000000000
--- a/pkgs/development/compilers/llvm/4/lld.nix
+++ /dev/null
@@ -1,33 +0,0 @@
-{ stdenv
-, fetch
-, cmake
-, llvm
-, version
-}:
-
-stdenv.mkDerivation {
-  pname = "lld";
-  inherit version;
-
-  src = fetch "lld" "1v9nkpr158j4yd4zmi6rpnfxkp78r1fapr8wji9s6v176gji1kk3";
-
-  nativeBuildInputs = [ cmake ];
-  buildInputs = [ llvm ];
-
-  outputs = [ "out" "dev" ];
-
-  enableParallelBuilding = true;
-
-  postInstall = ''
-    moveToOutput include "$dev"
-    moveToOutput lib "$dev"
-  '';
-
-  meta = {
-    description = "The LLVM Linker";
-    homepage    = http://lld.llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
-    badPlatforms = [ "x86_64-darwin" ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/4/lldb-libedit.patch b/pkgs/development/compilers/llvm/4/lldb-libedit.patch
deleted file mode 100644
index 73459ce6c864..000000000000
--- a/pkgs/development/compilers/llvm/4/lldb-libedit.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 94764369222a8e6c65420a6981d7f179a18a5417 Mon Sep 17 00:00:00 2001
-From: Will Dietz <w@wdtz.org>
-Date: Thu, 25 May 2017 15:03:42 -0500
-Subject: [PATCH] EditLine.h: libedit supports wide chars on NixOS
-
----
- include/lldb/Host/Editline.h | 5 +----
- 1 file changed, 1 insertion(+), 4 deletions(-)
-
-diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h
-index faed373bc..b248cdee1 100644
---- a/include/lldb/Host/Editline.h
-+++ b/include/lldb/Host/Editline.h
-@@ -43,12 +43,9 @@
- // will only be
- // used in cases where this is true.  This is a compile time dependecy, for now
- // selected per target Platform
--#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
-+// (libedit on NixOS is always wide-char capable)
- #define LLDB_EDITLINE_USE_WCHAR 1
- #include <codecvt>
--#else
--#define LLDB_EDITLINE_USE_WCHAR 0
--#endif
- 
- #include "lldb/Host/ConnectionFileDescriptor.h"
- #include "lldb/lldb-private.h"
--- 
-2.13.0
-
diff --git a/pkgs/development/compilers/llvm/4/lldb.nix b/pkgs/development/compilers/llvm/4/lldb.nix
deleted file mode 100644
index 8adf11abddda..000000000000
--- a/pkgs/development/compilers/llvm/4/lldb.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{ stdenv
-, fetch
-, cmake
-, zlib
-, ncurses
-, swig
-, which
-, libedit
-, libxml2
-, llvm
-, clang-unwrapped
-, python
-, version
-, darwin
-}:
-
-stdenv.mkDerivation {
-  pname = "lldb";
-  inherit version;
-
-  src = fetch "lldb" "0yy43a27zx3r51b6gkv3v2mdiqcq3mf0ngki47ya0i30v3gx4cl4";
-
-  patches = [ ./lldb-libedit.patch ];
-  postPatch = ''
-    # Fix up various paths that assume llvm and clang are installed in the same place
-    sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \
-      cmake/modules/LLDBStandalone.cmake
-    sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \
-      cmake/modules/LLDBStandalone.cmake
-    sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \
-      cmake/modules/LLDBStandalone.cmake
-  '';
-
-  nativeBuildInputs = [ cmake python which swig ];
-  buildInputs = [ ncurses zlib libedit libxml2 llvm ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
-
-  CXXFLAGS = "-fno-rtti";
-  hardeningDisable = [ "format" ];
-
-  cmakeFlags = [
-    "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
-  ];
-
-  # Add missing include to fix error when using std::bind
-  prePatch = ''
-    sed -i -e '30i#include <functional>' include/lldb/Utility/TaskPool.h
-  '';
-
-  enableParallelBuilding = true;
-
-  postInstall = ''
-    mkdir -p $out/share/man/man1
-    cp ../docs/lldb.1 $out/share/man/man1/
-  '';
-
-  meta = with stdenv.lib; {
-    description = "A next-generation high-performance debugger";
-    homepage    = http://llvm.org/;
-    license     = licenses.ncsa;
-    platforms   = platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/4/llvm-outputs.patch b/pkgs/development/compilers/llvm/4/llvm-outputs.patch
deleted file mode 100644
index 40096fa3497f..000000000000
--- a/pkgs/development/compilers/llvm/4/llvm-outputs.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
-index 94d426b..37f7794 100644
---- a/tools/llvm-config/llvm-config.cpp
-+++ b/tools/llvm-config/llvm-config.cpp
-@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
-     ActiveIncludeOption = "-I" + ActiveIncludeDir;
-   }
- 
-+  /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
-+  if (!IsInDevelopmentTree) {
-+    bool WantShared = true;
-+    for (int i = 1; i < argc; ++i) {
-+      StringRef Arg = argv[i];
-+      if (Arg == "--link-shared")
-+        WantShared = true;
-+      else if (Arg == "--link-static")
-+        WantShared = false; // the last one wins
-+    }
-+
-+    if (WantShared)
-+      ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
-+  }
-+
-   /// We only use `shared library` mode in cases where the static library form
-   /// of the components provided are not available; note however that this is
-   /// skipped if we're run from within the build dir. However, once installed,
diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix
deleted file mode 100644
index 317a5ea06f48..000000000000
--- a/pkgs/development/compilers/llvm/4/llvm.nix
+++ /dev/null
@@ -1,194 +0,0 @@
-{ stdenv
-, fetch
-, fetchpatch
-, cmake
-, python
-, libffi
-, libbfd
-, libxml2
-, ncurses
-, version
-, release_version
-, zlib
-, compiler-rt_src
-, debugVersion ? false
-, enableManpages ? false
-, enableSharedLibraries ? !enableManpages
-}:
-
-let
-  # Used when creating a versioned symlinks of libLLVM.dylib
-  versionSuffixes = with stdenv.lib;
-    let parts = splitVersion release_version; in
-    imap (i: _: concatStringsSep "." (take i parts)) parts;
-in
-
-stdenv.mkDerivation ({
-  pname = "llvm";
-  inherit version;
-
-  src = fetch "llvm" "0l9bf7kdwhlj0kq1hawpyxhna1062z3h7qcz2y8nfl9dz2qksy6s";
-
-  unpackPhase = ''
-    unpackFile $src
-    mv llvm-${version}* llvm
-    sourceRoot=$PWD/llvm
-    unpackFile ${compiler-rt_src}
-    mv compiler-rt-* $sourceRoot/projects/compiler-rt
-  '';
-
-  outputs = [ "out" ]
-    ++ stdenv.lib.optional enableSharedLibraries "lib";
-
-  nativeBuildInputs = [ cmake python ]
-    ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
-
-  buildInputs = [ libxml2 libffi ];
-
-  propagatedBuildInputs = [ ncurses zlib ];
-
-  patches = [
-    (fetchpatch {
-      name = "0001-Fix-return-type-in-ORC-readMem-client-interface.patch";
-      url = "https://bugzilla.redhat.com/attachment.cgi?id=1389687";
-      sha256 = "0ga2123aclq3x9w72d0rm0az12m8c1i4r1106vh701hf4cghgbch";
-    })
-    ./fix-gcc9.patch
-    (fetchpatch {
-      name = "llvm4-avoid-undefined-behavior-in-unittest.patch";
-      url = "https://aur.archlinux.org/cgit/aur.git/plain/D32089-Avoid-undefined-behavior-in-unittest.patch?h=llvm40&id=f459b0bad8aa3b94bc2733d79d176071a32846a6";
-      sha256 = "0x5q6a8lk6xg4ns4qh75fxvvmfnifwvyrq17ck85q8c0753i1irf";
-      extraPrefix = "";
-    })
-  ];
-
-  # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
-  # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
-  # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
-  # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
-  # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
-    substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \
-      --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-
-    substituteInPlace cmake/modules/AddLLVM.cmake \
-      --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
-      --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' ""
-  ''
-  # Patch llvm-config to return correct library path based on --link-{shared,static}.
-  + stdenv.lib.optionalString (enableSharedLibraries) ''
-    substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
-    patch -p1 < ./llvm-outputs.patch
-  ''
-  + ''
-    (
-      cd projects/compiler-rt
-      patch -p1 < ${
-        fetchpatch {
-          name = "sigaltstack.patch"; # for glibc-2.26
-          url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
-          sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
-        }
-      }
-      substituteInPlace lib/esan/esan_sideline_linux.cpp \
-        --replace 'struct sigaltstack' 'stack_t'
-    )
-  '' + # Fix extra space printed in commandline help sometimes, "- help"
-  ''
-    patch -p1 -i ${./cmdline-help.patch}
-  '' + stdenv.lib.optionalString stdenv.isAarch64 ''
-    patch -p0 < ${../aarch64.patch}
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
-    patch -p1 -i ${../TLI-musl.patch}
-    patch -p1 -i ${../dynamiclibrary-musl.patch}
-    patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
-  '';
-
-  # hacky fix: created binaries need to be run before installation
-  preBuild = ''
-    mkdir -p $out/
-    ln -sv $PWD/lib $out
-  '';
-
-  cmakeFlags = with stdenv; [
-    "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
-    "-DLLVM_INSTALL_UTILS=ON"  # Needed by rustc
-    "-DLLVM_BUILD_TESTS=ON"
-    "-DLLVM_ENABLE_FFI=ON"
-    "-DLLVM_ENABLE_RTTI=ON"
-    "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code
-
-    "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
-    "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
-    "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}"
-  ]
-  ++ stdenv.lib.optional enableSharedLibraries
-    "-DLLVM_LINK_LLVM_DYLIB=ON"
-  ++ stdenv.lib.optionals enableManpages [
-    "-DLLVM_BUILD_DOCS=ON"
-    "-DLLVM_ENABLE_SPHINX=ON"
-    "-DSPHINX_OUTPUT_MAN=ON"
-    "-DSPHINX_OUTPUT_HTML=OFF"
-    "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ]
-  ++ stdenv.lib.optional (!isDarwin)
-    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-  ++ stdenv.lib.optionals (isDarwin) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DCAN_TARGET_i386=false"
-  ];
-
-  postBuild = ''
-    rm -fR $out
-  '';
-
-  preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
-  '';
-
-  postInstall = stdenv.lib.optionalString enableSharedLibraries ''
-    moveToOutput "lib/libLLVM-*" "$lib"
-    moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
-    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
-      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
-  ''
-  + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
-    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
-      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
-      ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
-    '') versionSuffixes}
-  '';
-
-  doCheck = stdenv.isLinux && (!stdenv.isi686);
-
-  checkTarget = "check-all";
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "Collection of modular and reusable compiler and toolchain technologies";
-    homepage    = http://llvm.org/;
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
-  };
-} // stdenv.lib.optionalAttrs enableManpages {
-  pname = "llvm-manpages";
-
-  buildPhase = ''
-    make docs-llvm-man
-  '';
-
-  propagatedBuildInputs = [ ];
-
-  installPhase = ''
-    make -C docs install
-  '';
-
-  outputs = [ "out" ];
-
-  doCheck = false;
-
-  meta.description = "man pages for LLVM ${version}";
-})
diff --git a/pkgs/development/compilers/llvm/4/openmp.nix b/pkgs/development/compilers/llvm/4/openmp.nix
deleted file mode 100644
index a69fe286ecc0..000000000000
--- a/pkgs/development/compilers/llvm/4/openmp.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ stdenv
-, fetch
-, cmake
-, llvm
-, perl
-, version
-}:
-
-stdenv.mkDerivation {
-  pname = "openmp";
-  inherit version;
-
-  src = fetch "openmp" "195dykamd39yhi5az7nqj3ksqhb3wq30l93jnfkxl0061qbknsgc";
-
-  nativeBuildInputs = [ cmake perl ];
-  buildInputs = [ llvm ];
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "Components required to build an executable OpenMP program";
-    homepage    = http://openmp.llvm.org/;
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch b/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch
deleted file mode 100644
index 5bd858f8ae79..000000000000
--- a/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch
+++ /dev/null
@@ -1,368 +0,0 @@
-From dac4d3912378069b44340204e5fc6237aa1baf94 Mon Sep 17 00:00:00 2001
-From: Matthias Maier <tamiko@43-1.org>
-Date: Fri, 5 May 2017 17:47:39 +0000
-Subject: [PATCH] Musl patches
-
-Ported to compiler-rt-sanitizers-4.0.0. Taken from
-
-  https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
----
- lib/asan/asan_linux.cc                             |  4 +--
- lib/interception/interception_linux.cc             |  2 +-
- lib/interception/interception_linux.h              |  2 +-
- lib/msan/msan_linux.cc                             |  2 +-
- .../sanitizer_common_interceptors_ioctl.inc        |  4 +--
- lib/sanitizer_common/sanitizer_common_syscalls.inc |  2 +-
- lib/sanitizer_common/sanitizer_linux_libcdep.cc    | 12 +++----
- lib/sanitizer_common/sanitizer_platform.h          |  7 ++++
- .../sanitizer_platform_interceptors.h              |  2 +-
- .../sanitizer_platform_limits_posix.cc             | 39 +++++++++++++---------
- lib/tsan/rtl/tsan_platform_linux.cc                |  2 +-
- 11 files changed, 46 insertions(+), 32 deletions(-)
-
-diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
-index c051573dd..e295f6004 100644
---- a/lib/asan/asan_linux.cc
-+++ b/lib/asan/asan_linux.cc
-@@ -39,7 +39,7 @@
- #include <sys/link_elf.h>
- #endif
- 
--#if SANITIZER_ANDROID || SANITIZER_FREEBSD
-+#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU
- #include <ucontext.h>
- extern "C" void* _DYNAMIC;
- #else
-@@ -80,7 +80,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
-   UNIMPLEMENTED();
- }
- 
--#if SANITIZER_ANDROID
-+#if SANITIZER_ANDROID || SANITIZER_NONGNU
- // FIXME: should we do anything for Android?
- void AsanCheckDynamicRTPrereqs() {}
- void AsanCheckIncompatibleRT() {}
-diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
-index 6e908ac01..8f23d9adc 100644
---- a/lib/interception/interception_linux.cc
-+++ b/lib/interception/interception_linux.cc
-@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
-   return real == wrapper;
- }
- 
--#if !defined(__ANDROID__)  // android does not have dlvsym
-+#if !defined(__ANDROID__) && !SANITIZER_NONGNU  // android does not have dlvsym
- void *GetFuncAddrVer(const char *func_name, const char *ver) {
-   return dlvsym(RTLD_NEXT, func_name, ver);
- }
-diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
-index 27a66c882..3b559a303 100644
---- a/lib/interception/interception_linux.h
-+++ b/lib/interception/interception_linux.h
-@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
-       (::__interception::uptr) & (func),                                   \
-       (::__interception::uptr) & WRAP(func))
- 
--#if !defined(__ANDROID__)  // android does not have dlvsym
-+#if !defined(__ANDROID__) && !SANITIZER_NONGNU  // android does not have dlvsym
- #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
-   (::__interception::real_##func = (func##_f)(                \
-        unsigned long)::__interception::GetFuncAddrVer(#func, symver))
-diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
-index 0a687f620..0852d97d7 100644
---- a/lib/msan/msan_linux.cc
-+++ b/lib/msan/msan_linux.cc
-@@ -13,7 +13,7 @@
- //===----------------------------------------------------------------------===//
- 
- #include "sanitizer_common/sanitizer_platform.h"
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU
- 
- #include "msan.h"
- #include "msan_thread.h"
-diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-index 4ed9afedf..64f584e93 100644
---- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-+++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-@@ -100,7 +100,7 @@ static void ioctl_table_fill() {
-   _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
- #endif
- 
--#if SANITIZER_LINUX
-+#if SANITIZER_LINUX && !SANITIZER_NONGNU
-   // Conflicting request ids.
-   // _(CDROMAUDIOBUFSIZ, NONE, 0);
-   // _(SNDCTL_TMR_CONTINUE, NONE, 0);
-@@ -361,7 +361,7 @@ static void ioctl_table_fill() {
-   _(VT_WAITACTIVE, NONE, 0);
- #endif
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
-   // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
-   _(CYGETDEFTHRESH, WRITE, sizeof(int));
-   _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
-diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
-index 469c8eb7e..24f87867d 100644
---- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
-+++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
-@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
-   }
- }
- 
--#if !SANITIZER_ANDROID
-+#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
- PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
-                        void *old_rlim) {
-   if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
-diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
-index f99f0b594..3a773a94e 100644
---- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
-+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
-@@ -152,7 +152,7 @@ bool SanitizerGetThreadName(char *name, int max_len) {
- #endif
- }
- 
--#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
-+#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
- static uptr g_tls_size;
- 
- #ifdef __i386__
-@@ -180,11 +180,11 @@ void InitTlsSize() {
- }
- #else
- void InitTlsSize() { }
--#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
-+#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU
- 
- #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
-     || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__)) \
--    && SANITIZER_LINUX && !SANITIZER_ANDROID
-+    && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- // sizeof(struct pthread) from glibc.
- static atomic_uintptr_t kThreadDescriptorSize;
- 
-@@ -338,7 +338,7 @@ uptr ThreadSelf() {
- 
- #if !SANITIZER_GO
- static void GetTls(uptr *addr, uptr *size) {
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- # if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
-   *addr = ThreadSelf();
-   *size = GetTlsSize();
-@@ -364,7 +364,7 @@ static void GetTls(uptr *addr, uptr *size) {
-     *addr = (uptr) dtv[2];
-     *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
-   }
--#elif SANITIZER_ANDROID
-+#elif SANITIZER_ANDROID || SANITIZER_NONGNU
-   *addr = 0;
-   *size = 0;
- #else
-@@ -375,7 +375,7 @@ static void GetTls(uptr *addr, uptr *size) {
- 
- #if !SANITIZER_GO
- uptr GetTlsSize() {
--#if SANITIZER_FREEBSD || SANITIZER_ANDROID
-+#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU
-   uptr addr, size;
-   GetTls(&addr, &size);
-   return size;
-diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
-index d9a8e8df1..fe01c5744 100644
---- a/lib/sanitizer_common/sanitizer_platform.h
-+++ b/lib/sanitizer_common/sanitizer_platform.h
-@@ -162,6 +162,13 @@
- # define SANITIZER_PPC64V2 0
- #endif
- 
-+
-+#if defined(__linux__) && !defined(__GLIBC__)
-+# define SANITIZER_NONGNU 1
-+#else
-+# define SANITIZER_NONGNU 0
-+#endif
-+
- // By default we allow to use SizeClassAllocator64 on 64-bit platform.
- // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
- // does not work well and we need to fallback to SizeClassAllocator32.
-diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
-index 62875d11a..212e6e882 100644
---- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
-+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
-@@ -23,7 +23,7 @@
- # define SI_NOT_WINDOWS 0
- #endif
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- # define SI_LINUX_NOT_ANDROID 1
- #else
- # define SI_LINUX_NOT_ANDROID 0
-diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
-index 683f019d7..fd4880962 100644
---- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
-+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
-@@ -14,6 +14,8 @@
- 
- #include "sanitizer_platform.h"
- 
-+#define _LINUX_SYSINFO_H
-+
- #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
- // Tests in this file assume that off_t-dependent data structures match the
- // libc ABI. For example, struct dirent here is what readdir() function (as
-@@ -139,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
- 
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
- #include <glob.h>
--#include <obstack.h>
-+#  if !SANITIZER_NONGNU
-+#    include <obstack.h>
-+#  endif
- #include <mqueue.h>
--#include <net/if_ppp.h>
--#include <netax25/ax25.h>
--#include <netipx/ipx.h>
--#include <netrom/netrom.h>
-+#include <linux/if_ppp.h>
-+#include <linux/ax25.h>
-+#include <linux/ipx.h>
-+#include <linux/netrom.h>
- #if HAVE_RPC_XDR_H
- # include <rpc/xdr.h>
- #elif HAVE_TIRPC_RPC_XDR_H
-@@ -160,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t;
- # include <sys/procfs.h>
- #endif
- #include <sys/user.h>
--#include <sys/ustat.h>
-+// #include <sys/ustat.h>
-+#include <sys/statfs.h>
- #include <linux/cyclades.h>
- #include <linux/if_eql.h>
- #include <linux/if_plip.h>
-@@ -252,7 +257,7 @@ namespace __sanitizer {
-   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
- #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
-   unsigned struct_ustat_sz = sizeof(struct ustat);
-   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
-   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
-@@ -310,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
- unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
- #endif
- 
--#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
-   int glob_nomatch = GLOB_NOMATCH;
-   int glob_altdirfunc = GLOB_ALTDIRFUNC;
- #endif
-@@ -404,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
-   unsigned struct_termios_sz = sizeof(struct termios);
-   unsigned struct_winsize_sz = sizeof(struct winsize);
- 
--#if SANITIZER_LINUX
-+#if SANITIZER_LINUX && !SANITIZER_NONGNU
-   unsigned struct_arpreq_sz = sizeof(struct arpreq);
-   unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
-   unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
-@@ -454,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
-   unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
- #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
-   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
-   unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
- #if EV_VERSION > (0x010000)
-@@ -822,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
-   unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
- #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
-   unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
-   unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
-   unsigned IOCTL_CYGETMON = CYGETMON;
-@@ -985,7 +990,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
- CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
- #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
- 
--#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- CHECK_TYPE_SIZE(glob_t);
- CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
- CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
-@@ -1019,6 +1024,7 @@ CHECK_TYPE_SIZE(iovec);
- CHECK_SIZE_AND_OFFSET(iovec, iov_base);
- CHECK_SIZE_AND_OFFSET(iovec, iov_len);
- 
-+#if !SANITIZER_NONGNU
- CHECK_TYPE_SIZE(msghdr);
- CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
- CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
-@@ -1032,6 +1038,7 @@ CHECK_TYPE_SIZE(cmsghdr);
- CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
- CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
- CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
-+#endif
- 
- COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
- CHECK_SIZE_AND_OFFSET(dirent, d_ino);
-@@ -1134,7 +1141,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
- 
- CHECK_TYPE_SIZE(ether_addr);
- 
--#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- CHECK_TYPE_SIZE(ipc_perm);
- # if SANITIZER_FREEBSD
- CHECK_SIZE_AND_OFFSET(ipc_perm, key);
-@@ -1195,7 +1202,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
- CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
- #endif
- 
--#if SANITIZER_LINUX
-+#if SANITIZER_LINUX && !SANITIZER_NONGNU
- COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
- #endif
- 
-@@ -1245,7 +1252,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
- COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
- #endif
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
- CHECK_SIZE_AND_OFFSET(FILE, _flags);
- CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
-@@ -1264,7 +1271,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
- CHECK_SIZE_AND_OFFSET(FILE, _fileno);
- #endif
- 
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
- COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
- CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
- CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
-diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
-index 3313288a7..103c7b6b9 100644
---- a/lib/tsan/rtl/tsan_platform_linux.cc
-+++ b/lib/tsan/rtl/tsan_platform_linux.cc
-@@ -287,7 +287,7 @@ void InitializePlatform() {
- // This is required to properly "close" the fds, because we do not see internal
- // closes within glibc. The code is a pure hack.
- int ExtractResolvFDs(void *state, int *fds, int nfd) {
--#if SANITIZER_LINUX && !SANITIZER_ANDROID
-+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
-   int cnt = 0;
-   __res_state *statp = (__res_state*)state;
-   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
--- 
-2.16.2
-
diff --git a/pkgs/development/compilers/llvm/5/clang/default.nix b/pkgs/development/compilers/llvm/5/clang/default.nix
index 6695609b8ecd..e391ce046dbc 100644
--- a/pkgs/development/compilers/llvm/5/clang/default.nix
+++ b/pkgs/development/compilers/llvm/5/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 }:
@@ -19,8 +19,8 @@ let
       mv clang-tools-extra-* $sourceRoot/tools/extra
     '';
 
-    nativeBuildInputs = [ cmake python ]
-      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+    nativeBuildInputs = [ cmake python3 ]
+      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
 
     buildInputs = [ libxml2 llvm ]
       ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
diff --git a/pkgs/development/compilers/llvm/5/compiler-rt.nix b/pkgs/development/compilers/llvm/5/compiler-rt.nix
index c87b0f235961..0282591b6e20 100644
--- a/pkgs/development/compilers/llvm/5/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/5/compiler-rt.nix
@@ -1,11 +1,11 @@
-{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
+{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 with stdenv.lib;
 stdenv.mkDerivation {
   pname = "compiler-rt";
   inherit version;
   src = fetch "compiler-rt" "0ipd4jdxpczgr2w6lzrabymz6dhzj69ywmyybjjc1q397zgrvziy";
 
-  nativeBuildInputs = [ cmake python llvm ];
+  nativeBuildInputs = [ cmake python3 llvm ];
   buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   configureFlags = [
diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix
index 6807240df81e..05f4dbf6aa06 100644
--- a/pkgs/development/compilers/llvm/5/default.nix
+++ b/pkgs/development/compilers/llvm/5/default.nix
@@ -1,5 +1,5 @@
 { lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
-, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith
+, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
 }:
@@ -16,7 +16,7 @@ let
   clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3";
 
   tools = stdenv.lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
       mkdir "$rsrc"
@@ -36,12 +36,12 @@ let
 
     llvm-manpages = lowPrio (tools.llvm.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     clang-manpages = lowPrio (tools.clang-unwrapped.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     libclang = tools.clang-unwrapped.lib;
@@ -74,7 +74,7 @@ let
   });
 
   libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix {};
diff --git a/pkgs/development/compilers/llvm/5/libc++/default.nix b/pkgs/development/compilers/llvm/5/libc++/default.nix
index 03d8a2085d0b..b02e09a83a81 100644
--- a/pkgs/development/compilers/llvm/5/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/5/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }:
+{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version }:
 
 stdenv.mkDerivation {
   pname = "libc++";
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
   '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
-  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
+  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
diff --git a/pkgs/development/compilers/llvm/5/lldb.nix b/pkgs/development/compilers/llvm/5/lldb.nix
index cce44c7e50f9..a91a7e4354ef 100644
--- a/pkgs/development/compilers/llvm/5/lldb.nix
+++ b/pkgs/development/compilers/llvm/5/lldb.nix
@@ -9,7 +9,7 @@
 , libxml2
 , llvm
 , clang-unwrapped
-, python
+, python3
 , version
 , darwin
 }:
@@ -30,7 +30,7 @@ stdenv.mkDerivation {
       cmake/modules/LLDBStandalone.cmake
   '';
 
-  nativeBuildInputs = [ cmake python which swig ];
+  nativeBuildInputs = [ cmake python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
diff --git a/pkgs/development/compilers/llvm/5/llvm.nix b/pkgs/development/compilers/llvm/5/llvm.nix
index d26af8438e73..2ce17765d633 100644
--- a/pkgs/development/compilers/llvm/5/llvm.nix
+++ b/pkgs/development/compilers/llvm/5/llvm.nix
@@ -2,7 +2,7 @@
 , fetch
 , fetchpatch
 , cmake
-, python
+, python3
 , libffi
 , libbfd
 , libxml2
@@ -37,8 +37,8 @@ stdenv.mkDerivation ({
   outputs = [ "out" "python" ]
     ++ stdenv.lib.optional enableSharedLibraries "lib";
 
-  nativeBuildInputs = [ cmake python ]
-    ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+  nativeBuildInputs = [ cmake python3 ]
+    ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
 
   buildInputs = [ libxml2 libffi ];
 
@@ -119,7 +119,7 @@ stdenv.mkDerivation ({
   '';
 
   preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
   '';
 
   postInstall = ''
diff --git a/pkgs/development/compilers/llvm/6/clang/default.nix b/pkgs/development/compilers/llvm/6/clang/default.nix
index d093379b3c99..9374fc0bda9f 100644
--- a/pkgs/development/compilers/llvm/6/clang/default.nix
+++ b/pkgs/development/compilers/llvm/6/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 }:
@@ -19,8 +19,8 @@ let
       mv clang-tools-extra-* $sourceRoot/tools/extra
     '';
 
-    nativeBuildInputs = [ cmake python ]
-      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+    nativeBuildInputs = [ cmake python3 ]
+      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
 
     buildInputs = [ libxml2 llvm ]
       ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
diff --git a/pkgs/development/compilers/llvm/6/compiler-rt.nix b/pkgs/development/compilers/llvm/6/compiler-rt.nix
index 4cf79e79569c..b3b6e86fc525 100644
--- a/pkgs/development/compilers/llvm/6/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/6/compiler-rt.nix
@@ -1,11 +1,11 @@
-{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
+{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 with stdenv.lib;
 stdenv.mkDerivation {
   pname = "compiler-rt";
   inherit version;
   src = fetch "compiler-rt" "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl";
 
-  nativeBuildInputs = [ cmake python llvm ];
+  nativeBuildInputs = [ cmake python3 llvm ];
   buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   configureFlags = [
diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix
index ae51c19ec728..d4745930ed3f 100644
--- a/pkgs/development/compilers/llvm/6/default.nix
+++ b/pkgs/development/compilers/llvm/6/default.nix
@@ -1,5 +1,5 @@
 { lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
-, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith
+, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
 }:
@@ -16,7 +16,7 @@ let
   clang-tools-extra_src = fetch "clang-tools-extra" "1w8ml7fyn4vyxmy59n2qm4r1k1kgwgwkaldp6m45fdv4g0kkfbhd";
 
   tools = stdenv.lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
       mkdir "$rsrc"
@@ -36,12 +36,12 @@ let
 
     llvm-manpages = lowPrio (tools.llvm.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     clang-manpages = lowPrio (tools.clang-unwrapped.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     libclang = tools.clang-unwrapped.lib;
@@ -74,7 +74,7 @@ let
   });
 
   libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix {};
diff --git a/pkgs/development/compilers/llvm/6/libc++/default.nix b/pkgs/development/compilers/llvm/6/libc++/default.nix
index 658068cbfaff..831c6c9c7002 100644
--- a/pkgs/development/compilers/llvm/6/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/6/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }:
+{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version }:
 
 stdenv.mkDerivation {
   pname = "libc++";
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
   '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
-  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
+  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
diff --git a/pkgs/development/compilers/llvm/6/lldb.nix b/pkgs/development/compilers/llvm/6/lldb.nix
index d3db8082c963..30d72d944264 100644
--- a/pkgs/development/compilers/llvm/6/lldb.nix
+++ b/pkgs/development/compilers/llvm/6/lldb.nix
@@ -9,7 +9,7 @@
 , libxml2
 , llvm
 , clang-unwrapped
-, python
+, python3
 , version
 , darwin
 }:
@@ -30,7 +30,7 @@ stdenv.mkDerivation {
       cmake/modules/LLDBStandalone.cmake
   '';
 
-  nativeBuildInputs = [ cmake python which swig ];
+  nativeBuildInputs = [ cmake python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
diff --git a/pkgs/development/compilers/llvm/6/llvm.nix b/pkgs/development/compilers/llvm/6/llvm.nix
index c6d2c09c2df6..80acd3fa2fe1 100644
--- a/pkgs/development/compilers/llvm/6/llvm.nix
+++ b/pkgs/development/compilers/llvm/6/llvm.nix
@@ -1,7 +1,7 @@
 { stdenv
 , fetch
 , cmake
-, python
+, python3
 , libffi
 , libbfd
 , libxml2
@@ -40,8 +40,8 @@ stdenv.mkDerivation ({
   outputs = [ "out" "python" ]
     ++ optional enableSharedLibraries "lib";
 
-  nativeBuildInputs = [ cmake python ]
-    ++ optional enableManpages python.pkgs.sphinx;
+  nativeBuildInputs = [ cmake python3 ]
+    ++ optional enableManpages python3.pkgs.sphinx;
 
   buildInputs = [ libxml2 libffi ];
 
@@ -120,7 +120,7 @@ stdenv.mkDerivation ({
   '';
 
   preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
   '';
 
   postInstall = ''
diff --git a/pkgs/development/compilers/llvm/7/clang/default.nix b/pkgs/development/compilers/llvm/7/clang/default.nix
index 5ac9a7a2672a..cc5dcfc160bc 100644
--- a/pkgs/development/compilers/llvm/7/clang/default.nix
+++ b/pkgs/development/compilers/llvm/7/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 , enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -19,8 +19,8 @@ let
       mv clang-tools-extra-* $sourceRoot/tools/extra
     '';
 
-    nativeBuildInputs = [ cmake python ]
-      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+    nativeBuildInputs = [ cmake python3 ]
+      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
 
     buildInputs = [ libxml2 llvm ]
       ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
diff --git a/pkgs/development/compilers/llvm/7/compiler-rt.nix b/pkgs/development/compilers/llvm/7/compiler-rt.nix
index a7d4bcb86962..ae98940adeab 100644
--- a/pkgs/development/compilers/llvm/7/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/7/compiler-rt.nix
@@ -1,10 +1,10 @@
-{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
+{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 stdenv.mkDerivation {
   pname = "compiler-rt";
   inherit version;
   src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
 
-  nativeBuildInputs = [ cmake python llvm ];
+  nativeBuildInputs = [ cmake python3 llvm ];
   buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix
index 621a246225d7..f5dbea58a7db 100644
--- a/pkgs/development/compilers/llvm/7/default.nix
+++ b/pkgs/development/compilers/llvm/7/default.nix
@@ -1,5 +1,5 @@
 { lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
-, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
+, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
 }:
@@ -16,7 +16,7 @@ let
   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; });
+    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
       mkdir "$rsrc"
@@ -42,12 +42,12 @@ let
 
     llvm-manpages = lowPrio (tools.llvm.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     clang-manpages = lowPrio (tools.clang-unwrapped.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     libclang = tools.clang-unwrapped.lib;
@@ -126,7 +126,7 @@ let
   });
 
   libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix {
diff --git a/pkgs/development/compilers/llvm/7/libc++/default.nix b/pkgs/development/compilers/llvm/7/libc++/default.nix
index f6f9970d7a6e..f2cdd2f6f5fa 100644
--- a/pkgs/development/compilers/llvm/7/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/7/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version
+{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
 , enableShared ? ! stdenv.hostPlatform.isMusl }:
 
 stdenv.mkDerivation {
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
   '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
-  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
+  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
diff --git a/pkgs/development/compilers/llvm/7/lldb.nix b/pkgs/development/compilers/llvm/7/lldb.nix
index 44687ead4d1c..ace6ae812fde 100644
--- a/pkgs/development/compilers/llvm/7/lldb.nix
+++ b/pkgs/development/compilers/llvm/7/lldb.nix
@@ -10,7 +10,7 @@
 , llvm
 , clang-unwrapped
 , perl
-, python
+, python3
 , version
 , darwin
 }:
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
 
   src = fetch "lldb" "0klsscg1sczc4nw2l53xggi969k361cng2sjjrfp3bv4g5x14s4v";
 
-  nativeBuildInputs = [ cmake perl python which swig ];
+  nativeBuildInputs = [ cmake perl python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
diff --git a/pkgs/development/compilers/llvm/7/llvm.nix b/pkgs/development/compilers/llvm/7/llvm.nix
index c56bbfd0eab9..d7fb1fe4b93f 100644
--- a/pkgs/development/compilers/llvm/7/llvm.nix
+++ b/pkgs/development/compilers/llvm/7/llvm.nix
@@ -2,7 +2,7 @@
 , fetch
 , fetchpatch
 , cmake
-, python
+, python3
 , libffi
 , libbfd
 , libpfm
@@ -48,8 +48,8 @@ in stdenv.mkDerivation ({
   outputs = [ "out" "python" ]
     ++ optional enableSharedLibraries "lib";
 
-  nativeBuildInputs = [ cmake python ]
-    ++ optional enableManpages python.pkgs.sphinx;
+  nativeBuildInputs = [ cmake python3 ]
+    ++ optional enableManpages python3.pkgs.sphinx;
 
   buildInputs = [ libxml2 libffi ]
     ++ optional enablePFM libpfm; # exegesis
@@ -141,7 +141,7 @@ in stdenv.mkDerivation ({
   '';
 
   preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
   '';
 
   postInstall = ''
diff --git a/pkgs/development/compilers/llvm/8/clang/default.nix b/pkgs/development/compilers/llvm/8/clang/default.nix
index 8c540e45b286..8601f6d06809 100644
--- a/pkgs/development/compilers/llvm/8/clang/default.nix
+++ b/pkgs/development/compilers/llvm/8/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 , enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -19,8 +19,8 @@ let
       mv clang-tools-extra-* $sourceRoot/tools/extra
     '';
 
-    nativeBuildInputs = [ cmake python ]
-      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+    nativeBuildInputs = [ cmake python3 ]
+      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
 
     buildInputs = [ libxml2 llvm ]
       ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
diff --git a/pkgs/development/compilers/llvm/8/compiler-rt.nix b/pkgs/development/compilers/llvm/8/compiler-rt.nix
index 344ff7256755..9c0829146f72 100644
--- a/pkgs/development/compilers/llvm/8/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/8/compiler-rt.nix
@@ -1,10 +1,10 @@
-{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
+{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 stdenv.mkDerivation {
   pname = "compiler-rt";
   inherit version;
   src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
 
-  nativeBuildInputs = [ cmake python llvm ];
+  nativeBuildInputs = [ cmake python3 llvm ];
   buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix
index 36d7a14142b4..8b916e1cda7d 100644
--- a/pkgs/development/compilers/llvm/8/default.nix
+++ b/pkgs/development/compilers/llvm/8/default.nix
@@ -1,5 +1,5 @@
 { lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
-, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
+, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
 }:
@@ -16,7 +16,7 @@ let
   clang-tools-extra_src = fetch "clang-tools-extra" "1qf3097bc5ia8p6cpmbx985rjr3yaah5s8fc0nv7pw742yv7jw8q";
 
   tools = stdenv.lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
       mkdir "$rsrc"
@@ -42,12 +42,12 @@ let
 
     llvm-manpages = lowPrio (tools.llvm.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     clang-manpages = lowPrio (tools.clang-unwrapped.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     libclang = tools.clang-unwrapped.lib;
@@ -162,7 +162,7 @@ let
   });
 
   libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix ({} //
diff --git a/pkgs/development/compilers/llvm/8/libc++/default.nix b/pkgs/development/compilers/llvm/8/libc++/default.nix
index 8ec1c419748d..883d9c8776f3 100644
--- a/pkgs/development/compilers/llvm/8/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/8/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version
+{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
 , enableShared ? true }:
 
 stdenv.mkDerivation {
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python;
+    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
diff --git a/pkgs/development/compilers/llvm/8/lldb.nix b/pkgs/development/compilers/llvm/8/lldb.nix
index 254933c82a09..75be5b993df3 100644
--- a/pkgs/development/compilers/llvm/8/lldb.nix
+++ b/pkgs/development/compilers/llvm/8/lldb.nix
@@ -9,7 +9,7 @@
 , libxml2
 , llvm
 , clang-unwrapped
-, python
+, python3
 , version
 , darwin
 }:
@@ -30,7 +30,7 @@ stdenv.mkDerivation {
       cmake/modules/LLDBStandalone.cmake
   '';
 
-  nativeBuildInputs = [ cmake python which swig ];
+  nativeBuildInputs = [ cmake python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
diff --git a/pkgs/development/compilers/llvm/8/llvm.nix b/pkgs/development/compilers/llvm/8/llvm.nix
index df3d6e796aa0..a9c4a6b0ba25 100644
--- a/pkgs/development/compilers/llvm/8/llvm.nix
+++ b/pkgs/development/compilers/llvm/8/llvm.nix
@@ -1,7 +1,7 @@
 { stdenv
 , fetch
 , cmake
-, python
+, python3
 , libffi
 , libbfd
 , libpfm
@@ -46,8 +46,8 @@ in stdenv.mkDerivation ({
   outputs = [ "out" "python" ]
     ++ optional enableSharedLibraries "lib";
 
-  nativeBuildInputs = [ cmake python ]
-    ++ optionals enableManpages [ python.pkgs.sphinx python.pkgs.recommonmark ];
+  nativeBuildInputs = [ cmake python3 ]
+    ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
 
   buildInputs = [ libxml2 libffi ]
     ++ optional enablePFM libpfm; # exegesis
@@ -117,7 +117,7 @@ in stdenv.mkDerivation ({
   '';
 
   preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
   '';
 
   postInstall = ''
diff --git a/pkgs/development/compilers/llvm/9/clang/default.nix b/pkgs/development/compilers/llvm/9/clang/default.nix
index 1b779b118a7f..5f89c3dc3b71 100644
--- a/pkgs/development/compilers/llvm/9/clang/default.nix
+++ b/pkgs/development/compilers/llvm/9/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
+{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 , enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -19,8 +19,8 @@ let
       mv clang-tools-extra-* $sourceRoot/tools/extra
     '';
 
-    nativeBuildInputs = [ cmake python ]
-      ++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
+    nativeBuildInputs = [ cmake python3 ]
+      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
 
     buildInputs = [ libxml2 llvm ]
       ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
diff --git a/pkgs/development/compilers/llvm/9/compiler-rt.nix b/pkgs/development/compilers/llvm/9/compiler-rt.nix
index 75d0614b5142..037953bb23d8 100644
--- a/pkgs/development/compilers/llvm/9/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/9/compiler-rt.nix
@@ -1,10 +1,10 @@
-{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
+{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 stdenv.mkDerivation rec {
   pname = "compiler-rt";
   inherit version;
   src = fetch pname "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2";
 
-  nativeBuildInputs = [ cmake python llvm ];
+  nativeBuildInputs = [ cmake python3 llvm ];
   buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
diff --git a/pkgs/development/compilers/llvm/9/default.nix b/pkgs/development/compilers/llvm/9/default.nix
index c9e8ce91f0ce..38ab7794018f 100644
--- a/pkgs/development/compilers/llvm/9/default.nix
+++ b/pkgs/development/compilers/llvm/9/default.nix
@@ -1,5 +1,5 @@
 { lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
-, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
+, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
 }:
@@ -16,7 +16,7 @@ let
   clang-tools-extra_src = fetch "clang-tools-extra" "01vgzd4k1q93nfs8gyl83mjlc4x0qsgfqw32lacbjzdxg0mdfvxj";
 
   tools = stdenv.lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
       mkdir "$rsrc"
@@ -42,12 +42,12 @@ let
 
     llvm-manpages = lowPrio (tools.llvm.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     clang-manpages = lowPrio (tools.clang-unwrapped.override {
       enableManpages = true;
-      python = pkgs.python;  # don't use python-boot
+      python3 = pkgs.python3;  # don't use python-boot
     });
 
     libclang = tools.clang-unwrapped.lib;
@@ -162,7 +162,7 @@ let
   });
 
   libraries = stdenv.lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
+    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix ({} //
diff --git a/pkgs/development/compilers/llvm/9/libc++/default.nix b/pkgs/development/compilers/llvm/9/libc++/default.nix
index 1166c7bd76c9..9e3525574d5c 100644
--- a/pkgs/development/compilers/llvm/9/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/9/libc++/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version
+{ lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
 , enableShared ? true }:
 
 stdenv.mkDerivation {
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python;
+    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3;
 
   buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
diff --git a/pkgs/development/compilers/llvm/9/lldb.nix b/pkgs/development/compilers/llvm/9/lldb.nix
index 64f111502cc5..506fc1c3e505 100644
--- a/pkgs/development/compilers/llvm/9/lldb.nix
+++ b/pkgs/development/compilers/llvm/9/lldb.nix
@@ -9,7 +9,7 @@
 , libxml2
 , llvm
 , clang-unwrapped
-, python
+, python3
 , version
 , darwin
 , lit
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
 
   patches = [ ./lldb-procfs.patch ];
 
-  nativeBuildInputs = [ cmake python which swig lit ];
+  nativeBuildInputs = [ cmake python3 which swig lit ];
   buildInputs = [
     ncurses
     zlib
diff --git a/pkgs/development/compilers/llvm/9/llvm.nix b/pkgs/development/compilers/llvm/9/llvm.nix
index acd3ec92897f..2cdc5a5fd066 100644
--- a/pkgs/development/compilers/llvm/9/llvm.nix
+++ b/pkgs/development/compilers/llvm/9/llvm.nix
@@ -1,7 +1,7 @@
 { stdenv
 , fetch
 , cmake
-, python
+, python3
 , libffi
 , libbfd
 , libpfm
@@ -46,8 +46,8 @@ in stdenv.mkDerivation (rec {
   outputs = [ "out" "python" ]
     ++ optional enableSharedLibraries "lib";
 
-  nativeBuildInputs = [ cmake python ]
-    ++ optionals enableManpages [ python.pkgs.sphinx python.pkgs.recommonmark ];
+  nativeBuildInputs = [ cmake python3 ]
+    ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
 
   buildInputs = [ libxml2 libffi ]
     ++ optional enablePFM libpfm; # exegesis
@@ -134,7 +134,7 @@ in stdenv.mkDerivation (rec {
   '';
 
   preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
   '';
 
   postInstall = ''
diff --git a/pkgs/development/compilers/llvm/dynamiclibrary-musl.patch b/pkgs/development/compilers/llvm/dynamiclibrary-musl.patch
deleted file mode 100644
index d5d7f07b5e11..000000000000
--- a/pkgs/development/compilers/llvm/dynamiclibrary-musl.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From d12ecb83d01dcb580dd94f4d57828f33d3eb4c35 Mon Sep 17 00:00:00 2001
-From: Natanael Copa <ncopa@alpinelinux.org>
-Date: Thu, 18 Feb 2016 15:33:21 +0100
-Subject: [PATCH 3/3] Fix DynamicLibrary to build with musl libc
-
-stdin/out/err is part of the libc and not the kernel so we check for the
-specific libc that does the unexpected instead of linux.
-
-This is needed for making it build with musl libc.
----
- lib/Support/DynamicLibrary.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
-index 9a7aeb5..0c1c8f8 100644
---- a/lib/Support/DynamicLibrary.cpp
-+++ b/lib/Support/DynamicLibrary.cpp
-@@ -140,10 +140,10 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
- #define EXPLICIT_SYMBOL(SYM) \
-    if (!strcmp(symbolName, #SYM)) return &SYM
- 
--// On linux we have a weird situation. The stderr/out/in symbols are both
-+// On GNU libc we have a weird situation. The stderr/out/in symbols are both
- // macros and global variables because of standards requirements. So, we
- // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
--#if defined(__linux__) and !defined(__ANDROID__)
-+#if defined(__GLIBC__)
-   {
-     EXPLICIT_SYMBOL(stderr);
-     EXPLICIT_SYMBOL(stdout);
--- 
-2.7.3
-
diff --git a/pkgs/development/compilers/llvm/fix-llvm-config.patch b/pkgs/development/compilers/llvm/fix-llvm-config.patch
deleted file mode 100644
index 772c49609275..000000000000
--- a/pkgs/development/compilers/llvm/fix-llvm-config.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
-index eacefdf60bf..40d25f5cef8 100644
---- a/utils/llvm-build/llvmbuild/main.py
-+++ b/utils/llvm-build/llvmbuild/main.py
-@@ -412,7 +412,7 @@ subdirectories = %s
-             if library_name is None:
-                 library_name_as_cstr = '0'
-             else:
--                library_name_as_cstr = '"lib%s.a"' % library_name
-+                library_name_as_cstr = '"lib%s.so"' % library_name
-             f.write('  { "%s", %s, %d, { %s } },\n' % (
-                 name, library_name_as_cstr, is_installed,
-                 ', '.join('"%s"' % dep
diff --git a/pkgs/development/compilers/llvm/libcxx-max_align_t.patch b/pkgs/development/compilers/llvm/libcxx-max_align_t.patch
deleted file mode 100644
index 060be5b23de8..000000000000
--- a/pkgs/development/compilers/llvm/libcxx-max_align_t.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 917331c88bd2afce0cf0fdbcab55a64541b5bcf0 Mon Sep 17 00:00:00 2001
-From: "David L. Jones" <dlj@google.com>
-Date: Fri, 10 Feb 2017 01:27:42 +0000
-Subject: [PATCH] Check for musl-libc's max_align_t in addition to other
- variants.
-
-Summary:
-Libcxx will define its own max_align_t when it is not available. However, the
-availability checks today only check for Clang's definition and GCC's
-definition. In particular, it does not check for musl's definition, which is the
-same as GCC's but guarded with a different macro.
-
-Reviewers: mclow.lists, EricWF
-
-Reviewed By: EricWF
-
-Subscribers: chandlerc, cfe-commits
-
-Differential Revision: https://reviews.llvm.org/D28478
-
-git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294683 91177308-0d34-0410-b5e6-96231b3b80d8
----
- include/cstddef  | 3 ++-
- include/stddef.h | 3 ++-
- 2 files changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/include/cstddef b/include/cstddef
-index edd106c00..103898b7d 100644
---- a/include/cstddef
-+++ b/include/cstddef
-@@ -48,7 +48,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
- using ::ptrdiff_t;
- using ::size_t;
- 
--#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
-+#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-+    defined(__DEFINED_max_align_t)
- // Re-use the compiler's <stddef.h> max_align_t where possible.
- using ::max_align_t;
- #else
-diff --git a/include/stddef.h b/include/stddef.h
-index 8841bbea2..faf8552d8 100644
---- a/include/stddef.h
-+++ b/include/stddef.h
-@@ -53,7 +53,8 @@ using std::nullptr_t;
- }
- 
- // Re-use the compiler's <stddef.h> max_align_t where possible.
--#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T)
-+#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-+    !defined(__DEFINED_max_align_t)
- typedef long double max_align_t;
- #endif
-