about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/llvm
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-06-23 08:16:49 +0000
committerAlyssa Ross <hi@alyssa.is>2021-06-23 08:16:49 +0000
commit4dc730a187d41f9f2dce4fe2680c32dcecb79b93 (patch)
tree67673deb1649dc0a40962e70e6da302d7b6c4bf0 /nixpkgs/pkgs/development/compilers/llvm
parent633cab0ecb07627706c6b523e219490f019eaab5 (diff)
parent7e567a3d092b7de69cdf5deaeb8d9526de230916 (diff)
downloadnixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.tar
nixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.tar.gz
nixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.tar.bz2
nixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.tar.lz
nixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.tar.xz
nixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.tar.zst
nixlib-4dc730a187d41f9f2dce4fe2680c32dcecb79b93.zip
Merge commit '7e567a3d092b7de69cdf5deaeb8d9526de230916'
# Conflicts:
#	nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm')
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/lldb/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch26
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/11/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/11/lldb/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch26
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/12/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/12/lldb/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch26
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/5/clang/LLVMgold-path.patch14
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/lldb/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch39
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/9/lldb/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch40
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/clang-11-12-LLVMgold-path.patch13
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/clang-6-10-LLVMgold-path.patch15
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/default.nix13
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch91
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch20
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch16
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch120
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix4
-rwxr-xr-xnixpkgs/pkgs/development/compilers/llvm/update-git.py22
31 files changed, 424 insertions, 225 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix
index e0c52651cadc..b42f40b96943 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -46,6 +46,10 @@ let
       # https://reviews.llvm.org/D51899
       ./compiler-rt-baremetal.patch
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ../../clang-6-10-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -64,12 +68,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lldb/default.nix b/nixpkgs/pkgs/development/compilers/llvm/10/lldb/default.nix
index 04b9e06e77a3..a762151a586c 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/10/lldb/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/lldb/default.nix
@@ -13,6 +13,7 @@
 , version
 , darwin
 , lit
+, makeWrapper
 , enableManpages ? false
 }:
 
@@ -30,7 +31,7 @@ stdenv.mkDerivation (rec {
   outputs = [ "out" "lib" "dev" ];
 
   nativeBuildInputs = [
-    cmake python3 which swig lit
+    cmake python3 which swig lit makeWrapper
   ] ++ lib.optionals enableManpages [
     python3.pkgs.sphinx python3.pkgs.recommonmark
   ];
@@ -68,7 +69,15 @@ stdenv.mkDerivation (rec {
 
   doCheck = false;
 
+  installCheckPhase = ''
+    if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then
+        return 1;
+    fi
+  '';
+
   postInstall = ''
+    wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
+
     # Editor support
     # vscode:
     install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
diff --git a/nixpkgs/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch
index 053a580e45ec..0a7539db5e6b 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch
@@ -63,3 +63,29 @@ index aff75d7db334..98a527c5e761 100644
  install(TARGETS lldbIntelFeatures
 -  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX})
 +  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake
+index 752113b..010f187 100644
+--- a/cmake/modules/LLDBStandalone.cmake
++++ b/cmake/modules/LLDBStandalone.cmake
+@@ -62,7 +62,7 @@ endif()
+
+ # They are used as destination of target generators.
+ set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
+-set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
++set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+ if(WIN32 OR CYGWIN)
+   # DLL platform -- put DLLs into bin.
+   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index bf74802..1c98cae 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -222,7 +222,7 @@ if (LLDB_ENABLE_PYTHON)
+   if(LLDB_BUILD_FRAMEWORK)
+     set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+   else()
+-    set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
++    set(LLDB_PYTHON_INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH})
+   endif()
+   if (NOT CMAKE_CFG_INTDIR STREQUAL  ".")
+     string(REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_INSTALL_PATH})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/11/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/11/clang/default.nix
index 74078c1ac667..9eed5269da6b 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/11/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/11/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, fetchpatch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, fetchpatch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -62,6 +62,10 @@ let
         excludes = [ "docs/*" "test/*" ];
         sha256 = "0gxgmi0qbm89mq911dahallhi8m6wa9vpklklqmxafx4rplrr8ph";
       })
+      (substituteAll {
+        src = ../../clang-11-12-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -80,12 +84,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/11/lldb/default.nix b/nixpkgs/pkgs/development/compilers/llvm/11/lldb/default.nix
index 785ac4671ef5..46d6c6628e10 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/11/lldb/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/11/lldb/default.nix
@@ -13,6 +13,7 @@
 , version
 , darwin
 , lit
+, makeWrapper
 , enableManpages ? false
 }:
 
@@ -30,7 +31,7 @@ stdenv.mkDerivation (rec {
   outputs = [ "out" "lib" "dev" ];
 
   nativeBuildInputs = [
-    cmake python3 which swig lit
+    cmake python3 which swig lit makeWrapper
   ] ++ lib.optionals enableManpages [
     python3.pkgs.sphinx python3.pkgs.recommonmark
   ];
@@ -68,7 +69,15 @@ stdenv.mkDerivation (rec {
 
   doCheck = false;
 
+  installCheckPhase = ''
+    if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then
+        return 1;
+    fi
+  '';
+
   postInstall = ''
+    wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
+
     # Editor support
     # vscode:
     install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
diff --git a/nixpkgs/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch
index a4769109523d..fd49be395a3a 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch
@@ -63,3 +63,29 @@ index efba2f74904f..e08413b1dbb1 100644
  install(TARGETS lldbIntelFeatures
 -  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX})
 +  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake
+index 752113b..010f187 100644
+--- a/cmake/modules/LLDBStandalone.cmake
++++ b/cmake/modules/LLDBStandalone.cmake
+@@ -62,7 +62,7 @@ endif()
+
+ # They are used as destination of target generators.
+ set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
+-set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
++set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+ if(WIN32 OR CYGWIN)
+   # DLL platform -- put DLLs into bin.
+   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index bf74802..1c98cae 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -222,7 +222,7 @@ if (LLDB_ENABLE_PYTHON)
+   if(LLDB_BUILD_FRAMEWORK)
+     set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+   else()
+-    set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
++    set(LLDB_PYTHON_INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH})
+   endif()
+   if (NOT CMAKE_CFG_INTDIR STREQUAL  ".")
+     string(REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_INSTALL_PATH})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/12/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/12/clang/default.nix
index 3d1106dbc52c..dbd6ea1e1ac4 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/12/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/12/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -44,6 +44,10 @@ let
       ./purity.patch
       # https://reviews.llvm.org/D51899
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ../../clang-11-12-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -59,12 +63,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/12/lldb/default.nix b/nixpkgs/pkgs/development/compilers/llvm/12/lldb/default.nix
index 07517308b467..0712396cccfa 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/12/lldb/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/12/lldb/default.nix
@@ -19,6 +19,7 @@
 , Carbon
 , Cocoa
 , lit
+, makeWrapper
 , enableManpages ? false
 }:
 
@@ -41,7 +42,7 @@ stdenv.mkDerivation (rec {
   outputs = [ "out" "lib" "dev" ];
 
   nativeBuildInputs = [
-    cmake python3 which swig lit
+    cmake python3 which swig lit makeWrapper
   ] ++ lib.optionals enableManpages [
     python3.pkgs.sphinx python3.pkgs.recommonmark
   ];
@@ -84,7 +85,15 @@ stdenv.mkDerivation (rec {
 
   doCheck = false;
 
+  installCheckPhase = ''
+    if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then
+        return 1;
+    fi
+  '';
+
   postInstall = ''
+    wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
+
     # Editor support
     # vscode:
     install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
diff --git a/nixpkgs/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch
index 98321f4479e6..afc945ce2614 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch
@@ -63,3 +63,29 @@ index 734167e51bc5..f95761b5df58 100644
  install(TARGETS lldbIntelFeatures
 -  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX})
 +  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake
+index 752113b..010f187 100644
+--- a/cmake/modules/LLDBStandalone.cmake
++++ b/cmake/modules/LLDBStandalone.cmake
+@@ -62,7 +62,7 @@ endif()
+
+ # They are used as destination of target generators.
+ set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
+-set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
++set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+ if(WIN32 OR CYGWIN)
+   # DLL platform -- put DLLs into bin.
+   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b5633e2..86e4738 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -79,7 +79,7 @@ if (LLDB_ENABLE_PYTHON)
+   if(LLDB_BUILD_FRAMEWORK)
+     set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
+   else()
+-    set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
++    set(lldb_python_target_dir "${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+   endif()
+   get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
+   finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/clang/LLVMgold-path.patch b/nixpkgs/pkgs/development/compilers/llvm/5/clang/LLVMgold-path.patch
new file mode 100644
index 000000000000..6a09c91b5132
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/5/clang/LLVMgold-path.patch
@@ -0,0 +1,14 @@
+diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
+index 00bd60bc24bb..17416b0bd3c0 100644
+--- a/lib/Driver/ToolChains/CommonArgs.cpp
++++ b/lib/Driver/ToolChains/CommonArgs.cpp
+@@ -376,8 +376,7 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
+   // as gold requires -plugin to come before any -plugin-opt that -Wl might
+   // forward.
+   CmdArgs.push_back("-plugin");
+-  std::string Plugin =
+-      ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
++  std::string Plugin = "@libllvmLibdir@" "/LLVMgold.so";
+   CmdArgs.push_back(Args.MakeArgString(Plugin));
+ 
+   // Try to pass driver level flags relevant to LTO code generation down to
diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix
index b5887a23c65e..df3d26139866 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -43,6 +43,10 @@ let
     patches = [
       ./purity.patch
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ./LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -58,12 +62,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix
index eba9111d9d32..ee8859c159a1 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -43,6 +43,10 @@ let
     patches = [
       ./purity.patch
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ../../clang-6-10-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -58,12 +62,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
index e1b031ad352b..afa1669ace61 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -52,6 +52,10 @@ let
       # needed for our bootstrapping to not interfere with C.
       ./unwindlib.patch
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ../../clang-6-10-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -70,12 +74,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
index c3399dccd1d7..5cb7720d026f 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -59,6 +59,10 @@ let
       # make clang -xhip use $PATH to find executables
       ./HIP-use-PATH-8.patch
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ../../clang-6-10-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -77,12 +81,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/lldb/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/lldb/default.nix
index ee1f678996a6..b6025f722ebb 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/lldb/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/lldb/default.nix
@@ -12,6 +12,7 @@
 , python3
 , version
 , darwin
+, makeWrapper
 }:
 
 stdenv.mkDerivation rec {
@@ -37,7 +38,7 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "lib" "dev" ];
 
   nativeBuildInputs = [
-    cmake python3 which swig
+    cmake python3 which swig makeWrapper
   ];
 
   buildInputs = [
@@ -61,7 +62,15 @@ stdenv.mkDerivation rec {
 
   doCheck = false;
 
+  installCheckPhase = ''
+    if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then
+        return 1;
+    fi
+  '';
+
   postInstall = ''
+    wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
+
     mkdir -p $out/share/man/man1
     cp ../docs/lldb.1 $out/share/man/man1/
 
diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch
index b2e79086beda..08b6fae654e5 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch
@@ -79,3 +79,42 @@ index b5316540fdf3..3c3c882d503f 100644
  install(TARGETS lldbIntelFeatures
 -  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX})
 +  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index cdf22c4..d56fc6a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -146,7 +146,7 @@ if (NOT LLDB_DISABLE_PYTHON)
+                --cfgBldDir=${lldb_scripts_dir}
+                --prefix=${CMAKE_BINARY_DIR}
+                --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
+-               --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
++               --lldbLibDir=${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
+                ${use_python_wrapper_from_src_dir}
+                ${use_six_py_from_system}
+         VERBATIM
+diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake
+index a9059dd..d76a47d 100644
+--- a/cmake/modules/LLDBStandalone.cmake
++++ b/cmake/modules/LLDBStandalone.cmake
+@@ -124,7 +124,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+   link_directories("${LLVM_LIBRARY_DIR}")
+
+   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+-  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
++  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/lib${LLVM_LIBDIR_SUFFIX})
+   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+
+   set(LLDB_BUILT_STANDALONE 1)
+diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
+index 3598247..bd60451 100644
+--- a/scripts/CMakeLists.txt
++++ b/scripts/CMakeLists.txt
+@@ -47,7 +47,7 @@ if(NOT LLDB_BUILD_FRAMEWORK)
+   endif()
+
+   set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir})
+-  set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
++  set(SWIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+
+   # Install the LLDB python module
+   install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix
index 700fcb414fce..c98b4a830c42 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/9/clang/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
 , buildLlvmTools
 , fixDarwinDylibNames
 , enableManpages ? false
@@ -52,6 +52,10 @@ let
       # make clang -xhip use $PATH to find executables
       ./HIP-use-PATH-9.patch
       ./gnu-install-dirs.patch
+      (substituteAll {
+        src = ../../clang-6-10-LLVMgold-path.patch;
+        libllvmLibdir = "${libllvm.lib}/lib";
+      })
     ];
 
     postPatch = ''
@@ -70,12 +74,7 @@ let
 
     outputs = [ "out" "lib" "dev" "python" ];
 
-    # Clang expects to find LLVMgold in its own prefix
     postInstall = ''
-      if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
-        ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
-      fi
-
       ln -sv $out/bin/clang $out/bin/cpp
 
       # Move libclang to 'lib' output
diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/lldb/default.nix b/nixpkgs/pkgs/development/compilers/llvm/9/lldb/default.nix
index 9957a0218da8..63edc60828eb 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/9/lldb/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/9/lldb/default.nix
@@ -12,6 +12,7 @@
 , python3
 , version
 , darwin
+, makeWrapper
 , lit
 }:
 
@@ -29,7 +30,7 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "lib" "dev" ];
 
   nativeBuildInputs = [
-    cmake python3 which swig lit
+    cmake python3 which swig lit makeWrapper
   ];
 
   buildInputs = [
@@ -58,7 +59,15 @@ stdenv.mkDerivation rec {
 
   doCheck = false;
 
+  installCheckPhase = ''
+    if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then
+        return 1;
+    fi
+  '';
+
   postInstall = ''
+    wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
+
     # man page
     mkdir -p $out/share/man/man1
     install ../docs/lldb.1 -t $out/share/man/man1/
diff --git a/nixpkgs/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch
index cb4e400b3678..6ceb29ced92f 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch
@@ -63,3 +63,43 @@ index b5316540fdf3..3c3c882d503f 100644
  install(TARGETS lldbIntelFeatures
 -  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX})
 +  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index cdf22c4..d56fc6a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -146,7 +146,7 @@ if (NOT LLDB_DISABLE_PYTHON)
+                --cfgBldDir=${lldb_scripts_dir}
+                --prefix=${CMAKE_BINARY_DIR}
+                --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
+-               --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
++               --lldbLibDir=${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
+                ${use_python_wrapper_from_src_dir}
+                ${use_six_py_from_system}
+         VERBATIM
+diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake
+index b726797..1f057ac 100644
+--- a/cmake/modules/LLDBStandalone.cmake
++++ b/cmake/modules/LLDBStandalone.cmake
+@@ -95,7 +95,7 @@ include_directories(
+   "${CLANG_INCLUDE_DIRS}")
+
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
++set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/lib${LLVM_LIBDIR_SUFFIX})
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+
+ set(LLDB_BUILT_STANDALONE 1)
+diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
+index 7de7973..b70aecc 100644
+--- a/scripts/CMakeLists.txt
++++ b/scripts/CMakeLists.txt
+@@ -50,7 +50,8 @@ if(NOT LLDB_BUILD_FRAMEWORK)
+     OUTPUT_STRIP_TRAILING_WHITESPACE)
+   execute_process(
+     COMMAND ${PYTHON_EXECUTABLE}
+-        -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
++        -c "import distutils.sysconfig, sys; print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
++        ${CMAKE_INSTALL_LIBDIR}/../
+     OUTPUT_VARIABLE SWIG_INSTALL_DIR
+     OUTPUT_STRIP_TRAILING_WHITESPACE)
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/clang-11-12-LLVMgold-path.patch b/nixpkgs/pkgs/development/compilers/llvm/clang-11-12-LLVMgold-path.patch
new file mode 100644
index 000000000000..8f8991976f33
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/clang-11-12-LLVMgold-path.patch
@@ -0,0 +1,13 @@
+diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
+index 6b6e276b8ce7..7896542a1202 100644
+--- a/lib/Driver/ToolChains/CommonArgs.cpp
++++ b/lib/Driver/ToolChains/CommonArgs.cpp
+@@ -409,7 +409,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
+ 
+     SmallString<1024> Plugin;
+     llvm::sys::path::native(
+-        Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix,
++        Twine("@libllvmLibdir@" "/LLVMgold") + Suffix,
+         Plugin);
+     CmdArgs.push_back(Args.MakeArgString(Plugin));
+   }
diff --git a/nixpkgs/pkgs/development/compilers/llvm/clang-6-10-LLVMgold-path.patch b/nixpkgs/pkgs/development/compilers/llvm/clang-6-10-LLVMgold-path.patch
new file mode 100644
index 000000000000..93504316edf3
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/clang-6-10-LLVMgold-path.patch
@@ -0,0 +1,15 @@
+diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
+index 37ec73468570..b73e75aa6e59 100644
+--- a/lib/Driver/ToolChains/CommonArgs.cpp
++++ b/lib/Driver/ToolChains/CommonArgs.cpp
+@@ -370,8 +370,8 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
+ #endif
+ 
+   SmallString<1024> Plugin;
+-  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+-                              "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
++  llvm::sys::path::native(Twine("@libllvmLibdir@"
++                                "/LLVMgold") +
+                               Suffix,
+                           Plugin);
+   CmdArgs.push_back(Args.MakeArgString(Plugin));
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/default.nix
index 38de0f70cf2e..1bbbbd963f68 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/default.nix
@@ -18,18 +18,19 @@
 }:
 
 let
-  release_version = "12.0.0";
+  release_version = "13.0.0";
   candidate = ""; # empty or "rcN"
   dash-candidate = lib.optionalString (candidate != "") "-${candidate}";
-  rev = ""; # When using a Git commit
-  version = "${release_version}${dash-candidate}"; # differentiating these (variables) is important for RCs
+  rev = "643b6407faf460915679f304420cfbee87c47734"; # When using a Git commit
+  rev-version = "unstable-2021-06-11"; # When using a Git commit
+  version = if rev != "" then rev-version else "${release_version}${dash-candidate}";
   targetConfig = stdenv.targetPlatform.config;
 
   src = fetchFromGitHub {
     owner = "llvm";
     repo = "llvm-project";
     rev = if rev != "" then rev else "llvmorg-${version}";
-    sha256 = "07jz8pywc2qqa1srdnqg5p2y4lx3ki1inpigarzgxc3j20r4gb58";
+    sha256 = "0b06qqbks20m1cy9g1k8y4w8vh9zcbh9ag2bpk9xgg2xkmbq42az";
   };
 
   llvm_meta = {
@@ -256,9 +257,7 @@ let
 
     libunwind = callPackage ./libunwind {
       inherit llvm_meta;
-      stdenv = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
+      stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
     openmp = callPackage ./openmp {
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
index 8fb6b4a7dbd4..f511eba81dc5 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, llvm_meta, src, cmake, python3, libcxxabi, fixDarwinDylibNames, version
+{ lib, stdenv, llvm_meta, src, cmake, python3, fixDarwinDylibNames, version
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -24,10 +24,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake python3 ]
     ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
-  buildInputs = [ libcxxabi ];
-
   cmakeFlags = [
-    "-DLIBCXX_CXX_ABI=libcxxabi"
   ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
     ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
     ++ lib.optional stdenv.hostPlatform.isWasm [
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch
index 1f9de00a9d56..f59d7f8dfafc 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch
@@ -1,5 +1,5 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 9bf1a02f0908..612cd4aab76c 100644
+index 06ee1d74a03e..6c3c6f8f8d47 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -28,6 +28,8 @@ set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
@@ -9,92 +9,73 @@ index 9bf1a02f0908..612cd4aab76c 100644
 +  include(GNUInstallDirs)
 +
    set(PACKAGE_NAME libcxx)
-   set(PACKAGE_VERSION 12.0.0)
+   set(PACKAGE_VERSION 13.0.0git)
    set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -402,7 +404,7 @@ endif ()
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
-   set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR})
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
+@@ -409,7 +411,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+   set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
+   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+-  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
++  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
+   set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1")
+   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
    if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
-     string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
-@@ -410,11 +412,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
- elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
+@@ -420,14 +422,14 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
    set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-   set(LIBCXX_HEADER_DIR  ${LLVM_BINARY_DIR})
+   set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
+   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
 -  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
 +  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
+   set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1")
+   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}")
  else()
    set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-   set(LIBCXX_HEADER_DIR  ${CMAKE_BINARY_DIR})
+   set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
+   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
 -  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
 +  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
+   set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1")
+   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}")
  endif()
- 
- file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
 diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
-index 5d2764e870e9..bb1ec5de6ca2 100644
+index 5a8a4a270a1a..c06bae0001aa 100644
 --- a/cmake/Modules/HandleLibCXXABI.cmake
 +++ b/cmake/Modules/HandleLibCXXABI.cmake
 @@ -63,7 +63,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs)
  
          if (LIBCXX_INSTALL_HEADERS)
            install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
--            DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dstdir}
-+            DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}
+-            DESTINATION include/c++/v1/${dstdir}
++            DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}
              COMPONENT cxx-headers
              PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
              )
-diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
-index 29a317b8ae9a..4747263cfd1b 100644
---- a/include/CMakeLists.txt
-+++ b/include/CMakeLists.txt
-@@ -252,7 +252,7 @@ if (LIBCXX_INSTALL_HEADERS)
-   foreach(file ${files})
-     get_filename_component(dir ${file} DIRECTORY)
-     install(FILES ${file}
--      DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir}
-+      DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dir}
-       COMPONENT cxx-headers
-       PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-     )
-@@ -260,7 +260,7 @@ if (LIBCXX_INSTALL_HEADERS)
- 
-   # Install the generated header as __config.
-   install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
--    DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1
-+    DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1
-     PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-     RENAME __config
-     COMPONENT cxx-headers)
 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
-index 9965104cb5b2..9b55dbb1d822 100644
+index 87b71f7ba334..d20a783079b7 100644
 --- a/src/CMakeLists.txt
 +++ b/src/CMakeLists.txt
-@@ -352,21 +352,21 @@ if (LIBCXX_INSTALL_SHARED_LIBRARY)
+@@ -369,21 +369,21 @@ if (LIBCXX_INSTALL_SHARED_LIBRARY)
    install(TARGETS cxx_shared
-     ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
-     LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
--    RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}bin COMPONENT cxx)
-+    RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
+     ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
+     LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
+-    RUNTIME DESTINATION bin COMPONENT cxx)
++    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
  endif()
  
  if (LIBCXX_INSTALL_STATIC_LIBRARY)
    install(TARGETS cxx_static
-     ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
-     LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
--    RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}bin COMPONENT cxx)
-+    RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
+     ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
+     LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
+-    RUNTIME DESTINATION bin COMPONENT cxx)
++    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
  endif()
  
  if(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
    install(TARGETS cxx_experimental
-     LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
-     ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
--    RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}bin COMPONENT cxx)
-+    RUNTIME DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
+     LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
+     ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
+-    RUNTIME DESTINATION bin COMPONENT cxx)
++    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx)
  endif()
  
  # NOTE: This install command must go after the cxx install command otherwise
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix
index 3bb82d651ec7..7fadc6d6dcac 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, llvm_meta, cmake, python3, src, libunwind, version
 , enableShared ? !stdenv.hostPlatform.isStatic
+, libcxx
 }:
 
 stdenv.mkDerivation rec {
@@ -26,7 +27,9 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake python3 ];
   buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
 
-  cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+  cmakeFlags = [
+    "-DLIBCXXABI_LIBCXX_INCLUDES=${libcxx.dev}/include/c++/v1"
+  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
   ] ++ lib.optionals stdenv.hostPlatform.isWasm [
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch
index b49b1685940f..45641acb0c74 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch
@@ -1,5 +1,5 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 426c855288fc..a9812a994f53 100644
+index 1e8b73aa38cc..6f7b2a25d205 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -27,6 +27,8 @@ set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
@@ -9,26 +9,28 @@ index 426c855288fc..a9812a994f53 100644
 +  include(GNUInstallDirs)
 +
    set(PACKAGE_NAME libcxxabi)
-   set(PACKAGE_VERSION 11.0.0)
+   set(PACKAGE_VERSION 11.0.0git)
    set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -180,17 +182,17 @@ set(CMAKE_MODULE_PATH
- 
+@@ -196,7 +198,7 @@ set(CMAKE_MODULE_PATH
  if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
--  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
+   set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
+   set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+-  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
++  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
    if(LIBCXX_LIBDIR_SUBDIR)
      string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
      string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-   endif()
+@@ -204,11 +206,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
  elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
+   set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
    set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 -  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
 +  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX})
  else()
+   set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
    set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 -  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
 +  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX})
  endif()
  
- set(LIBCXXABI_INSTALL_PREFIX "" CACHE STRING "Define libc++abi destination prefix.")
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch
index a791d6c43231..56231cd31b2a 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch
@@ -1,5 +1,5 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 48cb8e004e08..fec8144fb95a 100644
+index a2c03fd3f8aa..98de2f8ea7c8 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -23,6 +23,8 @@ set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
@@ -9,14 +9,14 @@ index 48cb8e004e08..fec8144fb95a 100644
 +  include(GNUInstallDirs)
 +
    set(PACKAGE_NAME libunwind)
-   set(PACKAGE_VERSION 12.0.0)
+   set(PACKAGE_VERSION 13.0.0git)
    set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -115,17 +117,17 @@ set(CMAKE_MODULE_PATH
+@@ -116,17 +118,17 @@ set(CMAKE_MODULE_PATH
  
  if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
--  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
-+  set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
+   set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+-  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
++  set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
    if(LIBCXX_LIBDIR_SUBDIR)
      string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
      string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
@@ -24,11 +24,11 @@ index 48cb8e004e08..fec8144fb95a 100644
  elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
    set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 -  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
-+  set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX})
++  set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
  else()
    set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
 -  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
-+  set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX})
++  set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
  endif()
  
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix
index f65476a6fddd..daf4cfe808b6 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix
@@ -12,6 +12,7 @@
 , version
 , release_version
 , zlib
+, which
 , buildLlvmTools
 , debugVersion ? false
 , enableManpages ? false
@@ -47,15 +48,10 @@ in stdenv.mkDerivation (rec {
 
   propagatedBuildInputs = [ ncurses zlib ];
 
+  checkInputs = [ which ];
+
   patches = [
     ./gnu-install-dirs.patch
-    # On older CPUs (e.g. Hydra/wendy) we'd be getting an error in this test.
-    (fetchpatch {
-      name = "uops-CMOV16rm-noreg.diff";
-      url = "https://github.com/llvm/llvm-project/commit/9e9f991ac033.diff";
-      sha256 = "sha256:12s8vr6ibri8b48h2z38f3afhwam10arfiqfy4yg37bmc054p5hi";
-      stripLen = 1;
-    })
   ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch;
 
   postPatch = optionalString stdenv.isDarwin ''
@@ -75,6 +71,7 @@ in stdenv.mkDerivation (rec {
     substituteInPlace unittests/IR/CMakeLists.txt \
       --replace "PassBuilderCallbacksTest.cpp" ""
     rm unittests/IR/PassBuilderCallbacksTest.cpp
+    rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
   '' + optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -i ${../../TLI-musl.patch}
     substituteInPlace unittests/Support/CMakeLists.txt \
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch
index da8dc1445171..18fa5fc6d89c 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch
@@ -1,8 +1,8 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 277d0fe54d7b..af69c8be8745 100644
+index 135036f509d2..265c36f8211b 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -256,15 +256,21 @@ if (CMAKE_BUILD_TYPE AND
+@@ -270,15 +270,21 @@ if (CMAKE_BUILD_TYPE AND
    message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
  endif()
  
@@ -25,7 +25,7 @@ index 277d0fe54d7b..af69c8be8745 100644
  # They are used as destination of target generators.
  set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
  set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
-@@ -567,9 +573,9 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
+@@ -581,9 +587,9 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
  option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON)
  option (LLVM_ENABLE_BINDINGS "Build bindings." ON)
  
@@ -37,7 +37,7 @@ index 277d0fe54d7b..af69c8be8745 100644
      CACHE STRING "OCamldoc-generated HTML documentation install directory")
  
  option (LLVM_BUILD_EXTERNAL_COMPILER_RT
-@@ -1027,7 +1033,7 @@ endif()
+@@ -1048,7 +1054,7 @@ endif()
  
  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
    install(DIRECTORY include/llvm include/llvm-c
@@ -46,7 +46,7 @@ index 277d0fe54d7b..af69c8be8745 100644
      COMPONENT llvm-headers
      FILES_MATCHING
      PATTERN "*.def"
-@@ -1038,7 +1044,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+@@ -1059,7 +1065,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
      )
  
    install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c
@@ -55,7 +55,7 @@ index 277d0fe54d7b..af69c8be8745 100644
      COMPONENT llvm-headers
      FILES_MATCHING
      PATTERN "*.def"
-@@ -1052,13 +1058,13 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+@@ -1073,13 +1079,13 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
  
    if (LLVM_INSTALL_MODULEMAPS)
      install(DIRECTORY include/llvm include/llvm-c
@@ -72,11 +72,11 @@ index 277d0fe54d7b..af69c8be8745 100644
              RENAME "module.extern.modulemap"
              )
 diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
-index 97c9980c7de3..409e8b615f75 100644
+index 9c2b85374307..5531ceeb2eeb 100644
 --- a/cmake/modules/AddLLVM.cmake
 +++ b/cmake/modules/AddLLVM.cmake
-@@ -804,9 +804,9 @@ macro(add_llvm_library name)
- 
+@@ -818,9 +818,9 @@ macro(add_llvm_library name)
+       get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella})
        install(TARGETS ${name}
                ${export_to_llvmexports}
 -              LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
@@ -88,7 +88,7 @@ index 97c9980c7de3..409e8b615f75 100644
  
        if (NOT LLVM_ENABLE_IDE)
          add_llvm_install_targets(install-${name}
-@@ -1022,7 +1022,7 @@ function(process_llvm_pass_plugins)
+@@ -1036,7 +1036,7 @@ function(process_llvm_pass_plugins)
            "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
        install(FILES
            ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake
@@ -97,7 +97,7 @@ index 97c9980c7de3..409e8b615f75 100644
            COMPONENT cmake-exports)
  
        set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
-@@ -1242,7 +1242,7 @@ macro(add_llvm_example name)
+@@ -1250,7 +1250,7 @@ macro(add_llvm_example name)
    endif()
    add_llvm_executable(${name} ${ARGN})
    if( LLVM_BUILD_EXAMPLES )
@@ -106,7 +106,7 @@ index 97c9980c7de3..409e8b615f75 100644
    endif()
    set_target_properties(${name} PROPERTIES FOLDER "Examples")
  endmacro(add_llvm_example name)
-@@ -1854,7 +1854,7 @@ function(llvm_install_library_symlink name dest type)
+@@ -1868,7 +1868,7 @@ function(llvm_install_library_symlink name dest type)
    set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
    set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
  
@@ -115,8 +115,8 @@ index 97c9980c7de3..409e8b615f75 100644
    if(WIN32 AND "${type}" STREQUAL "SHARED")
      set(output_dir bin)
    endif()
-@@ -1871,7 +1871,7 @@ function(llvm_install_library_symlink name dest type)
-   endif()
+@@ -1879,7 +1879,7 @@ function(llvm_install_library_symlink name dest type)
+ 
  endfunction()
  
 -function(llvm_install_symlink name dest)
@@ -124,7 +124,7 @@ index 97c9980c7de3..409e8b615f75 100644
    cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
    foreach(path ${CMAKE_MODULE_PATH})
      if(EXISTS ${path}/LLVMInstallSymlink.cmake)
-@@ -1894,7 +1894,7 @@ function(llvm_install_symlink name dest)
+@@ -1902,7 +1902,7 @@ function(llvm_install_symlink name dest)
    set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
  
    install(SCRIPT ${INSTALL_SYMLINK}
@@ -133,7 +133,7 @@ index 97c9980c7de3..409e8b615f75 100644
            COMPONENT ${component})
  
    if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
-@@ -1977,7 +1977,8 @@ function(add_llvm_tool_symlink link_name target)
+@@ -1985,7 +1985,8 @@ function(add_llvm_tool_symlink link_name target)
      endif()
  
      if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
@@ -143,12 +143,12 @@ index 97c9980c7de3..409e8b615f75 100644
      endif()
    endif()
  endfunction()
-@@ -2100,9 +2101,9 @@ function(llvm_setup_rpath name)
- 
-   if (APPLE)
-     set(_install_name_dir INSTALL_NAME_DIR "@rpath")
--    set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
-+    set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+@@ -2114,9 +2115,9 @@ function(llvm_setup_rpath name)
+     # Since BUILD_SHARED_LIBS is only recommended for use by developers,
+     # hardcode the rpath to build/install lib dir first in this mode.
+     # FIXME: update this when there is better solution.
+-    set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
    elseif(UNIX)
 -    set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
 +    set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
@@ -185,16 +185,18 @@ index e80c3b5c1cac..482f6d715ef5 100644
  
          # '/.' indicates: copy the contents of the directory directly into
 diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
-index 505dc9a29d70..36e6c63af3f4 100644
+index 51b6a4fdc284..4adc2acfc074 100644
 --- a/cmake/modules/CMakeLists.txt
 +++ b/cmake/modules/CMakeLists.txt
-@@ -1,4 +1,4 @@
+@@ -1,6 +1,6 @@
+ include(LLVMDistributionSupport)
+ 
 -set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
 +set(LLVM_INSTALL_PACKAGE_DIR ${LLVM_INSTALL_CMAKE_DIR} CACHE STRING "Path for CMake subdirectory (defaults to 'cmake/llvm')")
  set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
  
  # First for users who use an installed LLVM, create the LLVMExports.cmake file.
-@@ -107,13 +107,13 @@ foreach(p ${_count})
+@@ -109,13 +109,13 @@ foreach(p ${_count})
    set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
  get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
  endforeach(p)
@@ -212,32 +214,32 @@ index 505dc9a29d70..36e6c63af3f4 100644
  # Generate a default location for lit
  if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
 diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
-index 09fed8085c23..aa79f192abf0 100644
+index 3e6a2c9a2648..52e14d955c60 100644
 --- a/cmake/modules/LLVMInstallSymlink.cmake
 +++ b/cmake/modules/LLVMInstallSymlink.cmake
-@@ -10,7 +10,7 @@ function(install_symlink name target outdir)
-     set(LINK_OR_COPY copy)
-   endif()
+@@ -4,7 +4,7 @@
  
+ function(install_symlink name target outdir)
+   set(DESTDIR $ENV{DESTDIR})
 -  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
 +  set(bindir "${DESTDIR}${outdir}/")
  
    message(STATUS "Creating ${name}")
  
 diff --git a/docs/CMake.rst b/docs/CMake.rst
-index bb821b417ad9..6a528f7c2ad3 100644
+index f1ac2c7d4934..c6e1469b5e13 100644
 --- a/docs/CMake.rst
 +++ b/docs/CMake.rst
-@@ -196,7 +196,7 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``.
+@@ -202,7 +202,7 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``.
  **LLVM_LIBDIR_SUFFIX**:STRING
    Extra suffix to append to the directory where libraries are to be
    installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64``
 -  to install libraries to ``/usr/lib64``.
 +  to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``.
  
- **CMAKE_C_FLAGS**:STRING
-   Extra flags to use when compiling C source files.
-@@ -550,8 +550,8 @@ LLVM-specific variables
+ Rarely-used CMake variables
+ ---------------------------
+@@ -551,8 +551,8 @@ LLVM-specific variables
  
  **LLVM_INSTALL_DOXYGEN_HTML_DIR**:STRING
    The path to install Doxygen-generated HTML documentation to. This path can
@@ -246,47 +248,9 @@ index bb821b417ad9..6a528f7c2ad3 100644
 +  either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
 +  `${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html`.
  
- **LLVM_ENABLE_SPHINX**:BOOL
-   If specified, CMake will search for the ``sphinx-build`` executable and will make
-@@ -582,13 +582,33 @@ LLVM-specific variables
- 
- **LLVM_INSTALL_SPHINX_HTML_DIR**:STRING
-   The path to install Sphinx-generated HTML documentation to. This path can
--  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
--  `share/doc/llvm/html`.
-+  either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
-+  `${CMAKE_INSTALL_DOCDIR}/${project}/html`.
- 
- **LLVM_INSTALL_OCAMLDOC_HTML_DIR**:STRING
-   The path to install OCamldoc-generated HTML documentation to. This path can
--  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
--  `share/doc/llvm/ocaml-html`.
-+  either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
-+  `${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html`.
-+
-+**CMAKE_INSTALL_BINDIR**:STRING
-+  The path to install binary tools, relative to the ``CMAKE_INSTALL_PREFIX``.
-+  Defaults to `bin`.
-+
-+**CMAKE_INSTALL_LIBDIR**:STRING
-+  The path to install libraries, relative to the ``CMAKE_INSTALL_PREFIX``.
-+  Defaults to `lib`.
-+
-+**CMAKE_INSTALL_INCLUDEDIR**:STRING
-+  The path to install header files, relative to the ``CMAKE_INSTALL_PREFIX``.
-+  Defaults to `include`.
-+
-+**CMAKE_INSTALL_DOCDIR**:STRING
-+  The path to install documentation, relative to the ``CMAKE_INSTALL_PREFIX``.
-+  Defaults to `share/doc`.
-+
-+**CMAKE_INSTALL_MANDIR**:STRING
-+  The path to install manpage files, relative to the ``CMAKE_INSTALL_PREFIX``.
-+  Defaults to `share/man`.
- 
- **LLVM_CREATE_XCODE_TOOLCHAIN**:BOOL
-   macOS Only: If enabled CMake will generate a target named
-@@ -786,9 +806,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
+ **LLVM_LINK_LLVM_DYLIB**:BOOL
+   If enabled, tools will be linked with the libLLVM shared library. Defaults
+@@ -792,9 +792,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
  
  This file is available in two different locations.
  
@@ -377,11 +341,11 @@ index 1a2f04552d13..44fa7d3eec6b 100644
    }
  
 diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
-index 2963f97cad88..69d66c9c9ca1 100644
+index 0af29ad762c5..37b99b83e35c 100644
 --- a/tools/lto/CMakeLists.txt
 +++ b/tools/lto/CMakeLists.txt
-@@ -25,7 +25,7 @@ add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS
-     intrinsics_gen)
+@@ -33,7 +33,7 @@ add_llvm_library(${LTO_LIBRARY_NAME} ${LTO_LIBRARY_TYPE} INSTALL_WITH_TOOLCHAIN
+     ${SOURCES} DEPENDS intrinsics_gen)
  
  install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
 -  DESTINATION include/llvm-c
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix
index 07488c1c33f4..c5a33df97560 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix
@@ -18,6 +18,10 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake perl ];
   buildInputs = [ llvm ];
 
+  cmakeFlags = [
+    "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL currently fails
+  ];
+
   meta = llvm_meta // {
     homepage = "https://openmp.llvm.org/";
     description = "Support for the OpenMP language";
diff --git a/nixpkgs/pkgs/development/compilers/llvm/update-git.py b/nixpkgs/pkgs/development/compilers/llvm/update-git.py
index ec1a30c6b0ff..880cad1c72b1 100755
--- a/nixpkgs/pkgs/development/compilers/llvm/update-git.py
+++ b/nixpkgs/pkgs/development/compilers/llvm/update-git.py
@@ -7,12 +7,16 @@ import json
 import os
 import re
 import subprocess
+import sys
 
 from codecs import iterdecode
 from datetime import datetime
 from urllib.request import urlopen, Request
 
 
+DEFAULT_NIX = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'git/default.nix')
+
+
 def get_latest_chromium_build():
     HISTORY_URL = 'https://omahaproxy.appspot.com/history?os=linux'
     print(f'GET {HISTORY_URL}')
@@ -39,6 +43,16 @@ def get_commit(ref):
         return json.loads(http_response.read().decode())
 
 
+def get_current_revision():
+    """Get the current revision of llvmPackages_git."""
+    with open(DEFAULT_NIX) as f:
+        for line in f:
+            rev = re.search(r'^  rev = "(.*)";', line)
+            if rev:
+                return rev.group(1)
+    sys.exit(1)
+
+
 def nix_prefetch_url(url, algo='sha256'):
     """Prefetches the content of the given URL."""
     print(f'nix-prefetch-url {url}')
@@ -55,16 +69,18 @@ clang_revision = re.search(r"^CLANG_REVISION = '(.+)'$", clang_update_script, re
 clang_commit_short = re.search(r"llvmorg-[0-9]+-init-[0-9]+-g([0-9a-f]{8})", clang_revision).group(1)
 release_version = re.search(r"^RELEASE_VERSION = '(.+)'$", clang_update_script, re.MULTILINE).group(1)
 commit = get_commit(clang_commit_short)
+if get_current_revision() == commit["sha"]:
+    print('No new update available.')
+    sys.exit(0)
 date = datetime.fromisoformat(commit['commit']['committer']['date'].rstrip('Z')).date().isoformat()
 version = f'unstable-{date}'
 print('Prefetching source tarball...')
 hash = nix_prefetch_url(f'https://github.com/llvm/llvm-project/archive/{commit["sha"]}.tar.gz')
 print('Updating default.nix...')
-default_nix = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'git/default.nix')
-with fileinput.FileInput(default_nix, inplace=True) as f:
+with fileinput.FileInput(DEFAULT_NIX, inplace=True) as f:
     for line in f:
         result = re.sub(r'^  release_version = ".+";', f'  release_version = "{release_version}";', line)
-        result = re.sub(r'^  version = ".+";', f'  version = "{version}";', result)
         result = re.sub(r'^  rev = ".*";', f'  rev = "{commit["sha"]}";', result)
+        result = re.sub(r'^  rev-version = ".+";', f'  rev-version = "{version}";', result)
         result = re.sub(r'^    sha256 = ".+";', f'    sha256 = "{hash}";', result)
         print(result, end='')