about summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/abcl/default.nix4
-rw-r--r--pkgs/development/compilers/acme/default.nix1
-rw-r--r--pkgs/development/compilers/ante/default.nix1
-rw-r--r--pkgs/development/compilers/arachne-pnr/default.nix1
-rw-r--r--pkgs/development/compilers/armips/default.nix1
-rw-r--r--pkgs/development/compilers/as31/default.nix1
-rw-r--r--pkgs/development/compilers/avra/default.nix1
-rw-r--r--pkgs/development/compilers/ballerina/default.nix5
-rw-r--r--pkgs/development/compilers/bfc/default.nix8
-rw-r--r--pkgs/development/compilers/blueprint/default.nix1
-rw-r--r--pkgs/development/compilers/cakelisp/default.nix1
-rw-r--r--pkgs/development/compilers/chicken/4/egg2nix.nix1
-rw-r--r--pkgs/development/compilers/chicken/5/egg2nix.nix1
-rw-r--r--pkgs/development/compilers/ciao/default.nix4
-rw-r--r--pkgs/development/compilers/circt/default.nix4
-rw-r--r--pkgs/development/compilers/closure/default.nix1
-rw-r--r--pkgs/development/compilers/colm/default.nix1
-rw-r--r--pkgs/development/compilers/cone/default.nix1
-rw-r--r--pkgs/development/compilers/crystal/default.nix3
-rw-r--r--pkgs/development/compilers/crystal2nix/default.nix1
-rw-r--r--pkgs/development/compilers/dart/package-source-builders/default.nix1
-rw-r--r--pkgs/development/compilers/dart/package-source-builders/media_kit_libs_linux/default.nix33
-rw-r--r--pkgs/development/compilers/dart/sources.nix12
-rw-r--r--pkgs/development/compilers/dictu/default.nix1
-rw-r--r--pkgs/development/compilers/dmd/generic.nix1
-rw-r--r--pkgs/development/compilers/elm/default.nix4
-rw-r--r--pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix17
-rw-r--r--pkgs/development/compilers/elm/packages/elm-instrument.nix1
-rw-r--r--pkgs/development/compilers/elm/packages/elm-json.nix1
-rw-r--r--pkgs/development/compilers/elm/packages/elm-test-rs.nix1
-rw-r--r--pkgs/development/compilers/elm/packages/elm-test.nix1
-rwxr-xr-xpkgs/development/compilers/elm/update.sh2
-rw-r--r--pkgs/development/compilers/erg/default.nix7
-rw-r--r--pkgs/development/compilers/fasmg/default.nix1
-rw-r--r--pkgs/development/compilers/fbc/default.nix1
-rw-r--r--pkgs/development/compilers/firrtl/default.nix1
-rw-r--r--pkgs/development/compilers/flasm/default.nix1
-rw-r--r--pkgs/development/compilers/flix/default.nix1
-rw-r--r--pkgs/development/compilers/flutter/artifacts/overrides/darwin.nix10
-rw-r--r--pkgs/development/compilers/flutter/flutter-tools.nix4
-rw-r--r--pkgs/development/compilers/flux/default.nix1
-rw-r--r--pkgs/development/compilers/gbforth/default.nix1
-rw-r--r--pkgs/development/compilers/gcl/default.nix1
-rw-r--r--pkgs/development/compilers/ghc/8.10.7.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.0.2.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.2.5.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.2.6.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.2.7.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.2.8.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.4.5.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.4.6.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.4.7.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.4.8.nix2
-rw-r--r--pkgs/development/compilers/ghc/9.6.3-binary.nix410
-rw-r--r--pkgs/development/compilers/ghc/9.8.2.nix4
-rw-r--r--pkgs/development/compilers/ghc/common-hadrian.nix4
-rw-r--r--pkgs/development/compilers/ghdl/default.nix4
-rw-r--r--pkgs/development/compilers/gleam/default.nix1
-rw-r--r--pkgs/development/compilers/glslang/default.nix4
-rw-r--r--pkgs/development/compilers/gmqcc/default.nix1
-rw-r--r--pkgs/development/compilers/go/1.20.nix189
-rw-r--r--pkgs/development/compilers/go/1.21.nix4
-rw-r--r--pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix1
-rw-r--r--pkgs/development/compilers/graalvm/community-edition/graalpy/hashes.nix18
-rw-r--r--pkgs/development/compilers/graalvm/community-edition/graalvm-ce/hashes.nix18
-rw-r--r--pkgs/development/compilers/graalvm/community-edition/truffleruby/hashes.nix18
-rw-r--r--pkgs/development/compilers/hvm/default.nix1
-rw-r--r--pkgs/development/compilers/idris2/idris2-lsp.nix1
-rw-r--r--pkgs/development/compilers/idris2/idris2.nix1
-rw-r--r--pkgs/development/compilers/inform7/default.nix1
-rw-r--r--pkgs/development/compilers/inklecate/default.nix1
-rw-r--r--pkgs/development/compilers/ispc/default.nix1
-rw-r--r--pkgs/development/compilers/jasmin/default.nix4
-rw-r--r--pkgs/development/compilers/julia/generic.nix1
-rw-r--r--pkgs/development/compilers/juniper/default.nix1
-rw-r--r--pkgs/development/compilers/kind2/default.nix1
-rw-r--r--pkgs/development/compilers/koka/default.nix13
-rw-r--r--pkgs/development/compilers/lesscpy/default.nix1
-rw-r--r--pkgs/development/compilers/ligo/default.nix1
-rw-r--r--pkgs/development/compilers/llvm/11/clang/default.nix138
-rw-r--r--pkgs/development/compilers/llvm/11/clang/gnu-install-dirs.patch235
-rw-r--r--pkgs/development/compilers/llvm/11/clang/purity.patch28
-rw-r--r--pkgs/development/compilers/llvm/11/compiler-rt/X86-support-extension.patch23
-rw-r--r--pkgs/development/compilers/llvm/11/compiler-rt/armv7l.patch32
-rw-r--r--pkgs/development/compilers/llvm/11/compiler-rt/default.nix140
-rw-r--r--pkgs/development/compilers/llvm/11/compiler-rt/gnu-install-dirs.patch129
-rw-r--r--pkgs/development/compilers/llvm/11/compiler-rt/normalize-var.patch16
-rw-r--r--pkgs/development/compilers/llvm/11/default.nix285
-rw-r--r--pkgs/development/compilers/llvm/11/libcxx/default.nix104
-rw-r--r--pkgs/development/compilers/llvm/11/libcxx/gnu-install-dirs.patch100
-rw-r--r--pkgs/development/compilers/llvm/11/libcxxabi/default.nix89
-rw-r--r--pkgs/development/compilers/llvm/11/libcxxabi/gnu-install-dirs.patch34
-rw-r--r--pkgs/development/compilers/llvm/11/libunwind/default.nix31
-rw-r--r--pkgs/development/compilers/llvm/11/libunwind/gnu-install-dirs.patch34
-rw-r--r--pkgs/development/compilers/llvm/11/lld/default.nix46
-rw-r--r--pkgs/development/compilers/llvm/11/lld/gnu-install-dirs.patch68
-rw-r--r--pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch91
-rw-r--r--pkgs/development/compilers/llvm/11/lldb/procfs.patch31
-rw-r--r--pkgs/development/compilers/llvm/11/llvm/default.nix365
-rw-r--r--pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs-polly.patch106
-rw-r--r--pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs.patch417
-rw-r--r--pkgs/development/compilers/llvm/11/openmp/default.nix47
-rw-r--r--pkgs/development/compilers/llvm/12/compiler-rt/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/12/default.nix17
-rw-r--r--pkgs/development/compilers/llvm/12/libcxx/default.nix144
-rw-r--r--pkgs/development/compilers/llvm/12/libcxx/gnu-install-dirs.patch100
-rw-r--r--pkgs/development/compilers/llvm/12/libcxxabi/default.nix87
-rw-r--r--pkgs/development/compilers/llvm/12/libcxxabi/gnu-install-dirs.patch34
-rw-r--r--pkgs/development/compilers/llvm/12/libunwind/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/12/llvm/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/13/compiler-rt/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/13/default.nix26
-rw-r--r--pkgs/development/compilers/llvm/13/libcxx/default.nix155
-rw-r--r--pkgs/development/compilers/llvm/13/libcxx/gnu-install-dirs.patch82
-rw-r--r--pkgs/development/compilers/llvm/13/libcxxabi/default.nix84
-rw-r--r--pkgs/development/compilers/llvm/13/libcxxabi/gnu-install-dirs.patch37
-rw-r--r--pkgs/development/compilers/llvm/14/compiler-rt/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/14/default.nix20
-rw-r--r--pkgs/development/compilers/llvm/14/libcxx/default.nix153
-rw-r--r--pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch21
-rw-r--r--pkgs/development/compilers/llvm/14/libcxxabi/default.nix103
-rw-r--r--pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/15/compiler-rt/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/15/default.nix42
-rw-r--r--pkgs/development/compilers/llvm/15/libcxx/default.nix176
-rw-r--r--pkgs/development/compilers/llvm/15/libcxx/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/15/libcxxabi/default.nix113
-rw-r--r--pkgs/development/compilers/llvm/15/libcxxabi/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/16/compiler-rt/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/16/default.nix42
-rw-r--r--pkgs/development/compilers/llvm/16/libcxx/default.nix167
-rw-r--r--pkgs/development/compilers/llvm/16/libcxx/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/16/libcxxabi/default.nix114
-rw-r--r--pkgs/development/compilers/llvm/16/libcxxabi/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/16/llvm/default.nix5
-rw-r--r--pkgs/development/compilers/llvm/17/compiler-rt/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/17/default.nix42
-rw-r--r--pkgs/development/compilers/llvm/17/libcxx/default.nix169
-rw-r--r--pkgs/development/compilers/llvm/17/libcxxabi/default.nix114
-rw-r--r--pkgs/development/compilers/llvm/17/libcxxabi/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/17/llvm/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/common/libclc.nix1
-rw-r--r--pkgs/development/compilers/llvm/git/compiler-rt/default.nix5
-rw-r--r--pkgs/development/compilers/llvm/git/default.nix42
-rw-r--r--pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch8
-rw-r--r--pkgs/development/compilers/llvm/git/libcxx/default.nix167
-rw-r--r--pkgs/development/compilers/llvm/git/libcxxabi/default.nix130
-rw-r--r--pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch22
-rw-r--r--pkgs/development/compilers/llvm/git/llvm/default.nix4
-rw-r--r--pkgs/development/compilers/lobster/default.nix1
-rw-r--r--pkgs/development/compilers/lunarml/default.nix1
-rw-r--r--pkgs/development/compilers/manticore/default.nix1
-rw-r--r--pkgs/development/compilers/mcpp/default.nix1
-rw-r--r--pkgs/development/compilers/microscheme/default.nix1
-rw-r--r--pkgs/development/compilers/mint/default.nix1
-rw-r--r--pkgs/development/compilers/mrustc/default.nix1
-rw-r--r--pkgs/development/compilers/mrustc/minicargo.nix1
-rw-r--r--pkgs/development/compilers/ocaml/4.14.nix4
-rw-r--r--pkgs/development/compilers/odin/default.nix1
-rw-r--r--pkgs/development/compilers/open-watcom/v2.nix3
-rw-r--r--pkgs/development/compilers/openspin/default.nix1
-rw-r--r--pkgs/development/compilers/opensycl/default.nix4
-rw-r--r--pkgs/development/compilers/ophis/default.nix1
-rw-r--r--pkgs/development/compilers/paco/default.nix1
-rw-r--r--pkgs/development/compilers/passerine/default.nix1
-rw-r--r--pkgs/development/compilers/pforth/default.nix1
-rw-r--r--pkgs/development/compilers/picat/default.nix1
-rw-r--r--pkgs/development/compilers/purescript/psc-package/default.nix1
-rw-r--r--pkgs/development/compilers/rasm/default.nix1
-rw-r--r--pkgs/development/compilers/rust/cargo-auditable.nix7
-rw-r--r--pkgs/development/compilers/rust/cargo.nix1
-rw-r--r--pkgs/development/compilers/sbcl/default.nix6
-rw-r--r--pkgs/development/compilers/scryer-prolog/default.nix1
-rw-r--r--pkgs/development/compilers/serpent/default.nix1
-rw-r--r--pkgs/development/compilers/sjasmplus/default.nix1
-rw-r--r--pkgs/development/compilers/spasm-ng/default.nix1
-rw-r--r--pkgs/development/compilers/spirv-llvm-translator/default.nix6
-rw-r--r--pkgs/development/compilers/stanc/default.nix44
-rw-r--r--pkgs/development/compilers/swift/compiler/default.nix1
-rw-r--r--pkgs/development/compilers/swift/compiler/patches/swift-darwin-link-cxxabi.patch14
-rw-r--r--pkgs/development/compilers/swift/default.nix18
-rw-r--r--pkgs/development/compilers/swift/foundation/default.nix1
-rw-r--r--pkgs/development/compilers/swift/sourcekit-lsp/default.nix1
-rw-r--r--pkgs/development/compilers/swift/swift-docc/default.nix1
-rw-r--r--pkgs/development/compilers/typescript/default.nix6
-rw-r--r--pkgs/development/compilers/uasm/default.nix1
-rw-r--r--pkgs/development/compilers/urn/default.nix1
-rw-r--r--pkgs/development/compilers/urweb/default.nix1
-rw-r--r--pkgs/development/compilers/xa/dxa.nix1
-rw-r--r--pkgs/development/compilers/zasm/default.nix1
-rw-r--r--pkgs/development/compilers/zulu/16.nix26
-rw-r--r--pkgs/development/compilers/zz/default.nix1
192 files changed, 1366 insertions, 4871 deletions
diff --git a/pkgs/development/compilers/abcl/default.nix b/pkgs/development/compilers/abcl/default.nix
index e36d8975e26b..317d0d92266d 100644
--- a/pkgs/development/compilers/abcl/default.nix
+++ b/pkgs/development/compilers/abcl/default.nix
@@ -6,7 +6,7 @@
 , jdk
 , jre
 , makeWrapper
-, canonicalize-jars-hook
+, stripJavaArchivesHook
 }:
 
 let
@@ -30,7 +30,7 @@ stdenv.mkDerivation (finalAttrs: {
     jdk
     fakeHostname
     makeWrapper
-    canonicalize-jars-hook
+    stripJavaArchivesHook
   ];
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/acme/default.nix b/pkgs/development/compilers/acme/default.nix
index 3f8110b5b5a4..cc6426a309a5 100644
--- a/pkgs/development/compilers/acme/default.nix
+++ b/pkgs/development/compilers/acme/default.nix
@@ -23,6 +23,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "A multi-platform cross assembler for 6502/6510/65816 CPUs";
+    mainProgram = "acme";
     homepage = "https://sourceforge.net/projects/acme-crossass/";
     license = licenses.gpl2Plus;
     platforms = platforms.all;
diff --git a/pkgs/development/compilers/ante/default.nix b/pkgs/development/compilers/ante/default.nix
index ebd70475d0fa..906ee0f16c2a 100644
--- a/pkgs/development/compilers/ante/default.nix
+++ b/pkgs/development/compilers/ante/default.nix
@@ -52,6 +52,7 @@ rustPlatform.buildRustPackage {
   meta = with lib; {
     homepage = "https://antelang.org/";
     description = "A low-level functional language for exploring refinement types, lifetime inference, and algebraic effects";
+    mainProgram = "ante";
     license = with licenses; [ mit ];
     maintainers = with maintainers; [ ehllie ];
   };
diff --git a/pkgs/development/compilers/arachne-pnr/default.nix b/pkgs/development/compilers/arachne-pnr/default.nix
index a08ad91c4a1c..37b7158c6284 100644
--- a/pkgs/development/compilers/arachne-pnr/default.nix
+++ b/pkgs/development/compilers/arachne-pnr/default.nix
@@ -24,6 +24,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Place and route tool for FPGAs";
+    mainProgram = "arachne-pnr";
     longDescription = ''
       Arachne-pnr implements the place and route step of
       the hardware compilation process for FPGAs. It
diff --git a/pkgs/development/compilers/armips/default.nix b/pkgs/development/compilers/armips/default.nix
index b6fbb5ef34c8..6e3a3ef4d964 100644
--- a/pkgs/development/compilers/armips/default.nix
+++ b/pkgs/development/compilers/armips/default.nix
@@ -25,6 +25,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "https://github.com/Kingcom/armips";
     description = "Assembler for various ARM and MIPS platforms.";
+    mainProgram = "armips";
     license = licenses.mit;
     maintainers = with maintainers; [ marius851000 ];
   };
diff --git a/pkgs/development/compilers/as31/default.nix b/pkgs/development/compilers/as31/default.nix
index c76b8a03312e..9cff12dd306d 100644
--- a/pkgs/development/compilers/as31/default.nix
+++ b/pkgs/development/compilers/as31/default.nix
@@ -36,6 +36,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "http://wiki.erazor-zone.de/wiki:projects:linux:as31";
     description = "An 8031/8051 assembler";
+    mainProgram = "as31";
     license = licenses.gpl2Plus;
     maintainers = with maintainers; [ AndersonTorres ];
     platforms = platforms.unix;
diff --git a/pkgs/development/compilers/avra/default.nix b/pkgs/development/compilers/avra/default.nix
index f3bc33516a3f..8e2d2558c571 100644
--- a/pkgs/development/compilers/avra/default.nix
+++ b/pkgs/development/compilers/avra/default.nix
@@ -17,6 +17,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Assembler for the Atmel AVR microcontroller family";
+    mainProgram = "avra";
     homepage = "https://github.com/Ro5bert/avra";
     license = licenses.gpl2Plus;
     platforms = platforms.all;
diff --git a/pkgs/development/compilers/ballerina/default.nix b/pkgs/development/compilers/ballerina/default.nix
index 5f2e4d88b0ce..5a58d9afd9a8 100644
--- a/pkgs/development/compilers/ballerina/default.nix
+++ b/pkgs/development/compilers/ballerina/default.nix
@@ -1,6 +1,6 @@
 { ballerina, lib, writeText, runCommand, makeWrapper, fetchzip, stdenv, openjdk }:
 let
-  version = "2201.8.5";
+  version = "2201.8.6";
   codeName = "swan-lake";
 in stdenv.mkDerivation {
   pname = "ballerina";
@@ -8,7 +8,7 @@ in stdenv.mkDerivation {
 
   src = fetchzip {
     url = "https://dist.ballerina.io/downloads/${version}/ballerina-${version}-${codeName}.zip";
-    hash = "sha256-xqgLEMlc8s7qsrjz9kDBvwmfS0ytTqP4yOaet6xog8A=";
+    hash = "sha256-/oYyYziUTt4OqQfYJdDuRVy9xmMDfhpj24lbisQFfAU=";
   };
 
   nativeBuildInputs = [ makeWrapper ];
@@ -37,6 +37,7 @@ in stdenv.mkDerivation {
 
   meta = with lib; {
     description = "An open-source programming language for the cloud";
+    mainProgram = "bal";
     license = licenses.asl20;
     platforms = openjdk.meta.platforms;
     maintainers = with maintainers; [ eigengrau ];
diff --git a/pkgs/development/compilers/bfc/default.nix b/pkgs/development/compilers/bfc/default.nix
index 2ebf02b18138..c6d351e4c191 100644
--- a/pkgs/development/compilers/bfc/default.nix
+++ b/pkgs/development/compilers/bfc/default.nix
@@ -27,18 +27,14 @@ rustPlatform.buildRustPackage rec {
     zlib
   ];
 
-  env = {
-    LLVM_SYS_130_PREFIX = llvmPackages_13.llvm.dev;
-  } // lib.optionalAttrs stdenv.cc.isClang {
-    # Work around https://github.com/NixOS/nixpkgs/issues/166205.
-    NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
-  };
+  env.LLVM_SYS_130_PREFIX = llvmPackages_13.llvm.dev;
 
   # process didn't exit successfully: <...> SIGSEGV
   doCheck = false;
 
   meta = with lib; {
     description = "An industrial-grade brainfuck compiler";
+    mainProgram = "bfc";
     homepage = "https://bfc.wilfred.me.uk";
     license = licenses.gpl2Plus;
     maintainers = with maintainers; [ figsoda ];
diff --git a/pkgs/development/compilers/blueprint/default.nix b/pkgs/development/compilers/blueprint/default.nix
index 856fcaa5d5ab..14a901d785fe 100644
--- a/pkgs/development/compilers/blueprint/default.nix
+++ b/pkgs/development/compilers/blueprint/default.nix
@@ -64,6 +64,7 @@ stdenv.mkDerivation (finalAttrs: {
 
   meta = with lib; {
     description = "A markup language for GTK user interface files";
+    mainProgram = "blueprint-compiler";
     homepage = "https://gitlab.gnome.org/jwestman/blueprint-compiler";
     license = licenses.lgpl3Plus;
     maintainers = with maintainers; [ benediktbroich ranfdev ];
diff --git a/pkgs/development/compilers/cakelisp/default.nix b/pkgs/development/compilers/cakelisp/default.nix
index b6541619b9f9..9f8939708cec 100644
--- a/pkgs/development/compilers/cakelisp/default.nix
+++ b/pkgs/development/compilers/cakelisp/default.nix
@@ -44,6 +44,7 @@ stdenv.mkDerivation {
 
   meta = with lib; {
     description = "A performance-oriented Lisp-like language";
+    mainProgram = "cakelisp";
     homepage = "https://macoy.me/code/macoy/cakelisp";
     license = licenses.gpl3Plus;
     platforms = platforms.darwin ++ platforms.linux;
diff --git a/pkgs/development/compilers/chicken/4/egg2nix.nix b/pkgs/development/compilers/chicken/4/egg2nix.nix
index dfbec7442ed4..e175f17e1ab7 100644
--- a/pkgs/development/compilers/chicken/4/egg2nix.nix
+++ b/pkgs/development/compilers/chicken/4/egg2nix.nix
@@ -20,6 +20,7 @@ eggDerivation rec {
 
   meta = {
     description = "Generate nix-expression from CHICKEN scheme eggs";
+    mainProgram = "egg2nix";
     homepage = "https://github.com/the-kenny/egg2nix";
     license = lib.licenses.bsd3;
     platforms = lib.platforms.unix;
diff --git a/pkgs/development/compilers/chicken/5/egg2nix.nix b/pkgs/development/compilers/chicken/5/egg2nix.nix
index 62b634eb6370..3e2cc49a2669 100644
--- a/pkgs/development/compilers/chicken/5/egg2nix.nix
+++ b/pkgs/development/compilers/chicken/5/egg2nix.nix
@@ -21,6 +21,7 @@ eggDerivation {
 
   meta = {
     description = "Generate nix-expression from CHICKEN scheme eggs";
+    mainProgram = "egg2nix";
     homepage = "https://github.com/the-kenny/egg2nix";
     license = lib.licenses.bsd3;
     platforms = lib.platforms.unix;
diff --git a/pkgs/development/compilers/ciao/default.nix b/pkgs/development/compilers/ciao/default.nix
index bc85f6e1009f..98c26b3e9a08 100644
--- a/pkgs/development/compilers/ciao/default.nix
+++ b/pkgs/development/compilers/ciao/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   pname = "ciao";
-  version = "1.22.0-m7";
+  version = "1.23.0-m1";
   src = fetchFromGitHub {
     owner = "ciao-lang";
     repo = "ciao";
     rev = "v${version}";
-    sha256 = "sha256-5LX+NVDAtdffQeLTD4Camp5aNm0K3Cwmavh7OF5XcZU=";
+    sha256 = "sha256-JMHln0nYveEEfEr4AMyrEL9KlCDiqV53BWRNMUL8nN0=";
   };
 
   configurePhase = ''
diff --git a/pkgs/development/compilers/circt/default.nix b/pkgs/development/compilers/circt/default.nix
index 551a325852dd..4d1814c4a3a9 100644
--- a/pkgs/development/compilers/circt/default.nix
+++ b/pkgs/development/compilers/circt/default.nix
@@ -17,12 +17,12 @@ let
 in
 stdenv.mkDerivation rec {
   pname = "circt";
-  version = "1.67.0";
+  version = "1.70.0";
   src = fetchFromGitHub {
     owner = "llvm";
     repo = "circt";
     rev = "firtool-${version}";
-    hash = "sha256-ftKtqKIgGVqiETTsirhydjmFiozqHoMRdu+IBZc8iMI=";
+    hash = "sha256-OELkfyN0fxnQIGQxfwuRM/+DYdb+8m5wlT/H+eQNjq0=";
     fetchSubmodules = true;
   };
 
diff --git a/pkgs/development/compilers/closure/default.nix b/pkgs/development/compilers/closure/default.nix
index 39dfa67d23e4..ee560d876301 100644
--- a/pkgs/development/compilers/closure/default.nix
+++ b/pkgs/development/compilers/closure/default.nix
@@ -23,6 +23,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "A tool for making JavaScript download and run faster";
+    mainProgram = "closure-compiler";
     homepage = "https://developers.google.com/closure/compiler/";
     sourceProvenance = with sourceTypes; [ binaryBytecode ];
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/colm/default.nix b/pkgs/development/compilers/colm/default.nix
index d7a0953a8035..b1540ff63072 100644
--- a/pkgs/development/compilers/colm/default.nix
+++ b/pkgs/development/compilers/colm/default.nix
@@ -22,6 +22,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "A programming language for the analysis and transformation of computer languages";
+    mainProgram = "colm";
     homepage = "http://www.colm.net/open-source/colm";
     license = licenses.gpl2;
     platforms = platforms.unix;
diff --git a/pkgs/development/compilers/cone/default.nix b/pkgs/development/compilers/cone/default.nix
index d94432be12d3..b13ac8de868e 100644
--- a/pkgs/development/compilers/cone/default.nix
+++ b/pkgs/development/compilers/cone/default.nix
@@ -34,6 +34,7 @@ llvmPackages.stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Cone Programming Language";
+    mainProgram = "conec";
     homepage = "https://cone.jondgoodwin.com";
     license = licenses.mit;
     maintainers = with maintainers; [ luc65r ];
diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix
index c9ffed829b2d..fb031eba18cb 100644
--- a/pkgs/development/compilers/crystal/default.nix
+++ b/pkgs/development/compilers/crystal/default.nix
@@ -152,7 +152,7 @@ let
         # Darwin links against libc++ not libstdc++. Newer versions of clang (12+) require
         # libc++abi to be linked explicitly (see https://github.com/NixOS/nixpkgs/issues/166205).
         substituteInPlace src/llvm/lib_llvm.cr \
-          --replace '@[Link("stdc++")]' '@[Link("c++", "-l${stdenv.cc.libcxx.cxxabi.libName}")]'
+          --replace '@[Link("stdc++")]' '@[Link("c++")]'
       '';
 
       # Defaults are 4
@@ -250,6 +250,7 @@ let
       meta = with lib; {
         inherit (binary.meta) platforms;
         description = "A compiled language with Ruby like syntax and type inference";
+        mainProgram = "crystal";
         homepage = "https://crystal-lang.org/";
         license = licenses.asl20;
         maintainers = with maintainers; [ david50407 manveru peterhoeg donovanglover ];
diff --git a/pkgs/development/compilers/crystal2nix/default.nix b/pkgs/development/compilers/crystal2nix/default.nix
index 3a53525b4771..2ba0fefd6aba 100644
--- a/pkgs/development/compilers/crystal2nix/default.nix
+++ b/pkgs/development/compilers/crystal2nix/default.nix
@@ -29,6 +29,7 @@ crystal.buildCrystalPackage rec {
 
   meta = with lib; {
     description = "Utility to convert Crystal's shard.lock files to a Nix file";
+    mainProgram = "crystal2nix";
     license = licenses.mit;
     maintainers = with maintainers; [ manveru peterhoeg ];
   };
diff --git a/pkgs/development/compilers/dart/package-source-builders/default.nix b/pkgs/development/compilers/dart/package-source-builders/default.nix
index e015d423a1ca..38d07c40ec2a 100644
--- a/pkgs/development/compilers/dart/package-source-builders/default.nix
+++ b/pkgs/development/compilers/dart/package-source-builders/default.nix
@@ -4,6 +4,7 @@
   flutter_secure_storage_linux = callPackage ./flutter-secure-storage-linux { };
   handy_window = callPackage ./handy-window { };
   matrix = callPackage ./matrix { };
+  media_kit_libs_linux = callPackage ./media_kit_libs_linux { };
   olm = callPackage ./olm { };
   system_tray = callPackage ./system-tray { };
 }
diff --git a/pkgs/development/compilers/dart/package-source-builders/media_kit_libs_linux/default.nix b/pkgs/development/compilers/dart/package-source-builders/media_kit_libs_linux/default.nix
new file mode 100644
index 000000000000..92bfc7e7fa60
--- /dev/null
+++ b/pkgs/development/compilers/dart/package-source-builders/media_kit_libs_linux/default.nix
@@ -0,0 +1,33 @@
+{ stdenv
+}:
+
+# Implementation notes
+
+# The patch exploits the fact that the download part is enclosed with "# ---"
+# To use this module you will need to pass the CMake variable MIMALLOC_LIB
+# example: -DMIMALLOC_LIB=${pkgs.mimalloc}/lib/mimalloc.o
+
+# Direct link for the original CMakeLists.txt: https://raw.githubusercontent.com/media-kit/media-kit/main/libs/linux/media_kit_libs_linux/linux/CMakeLists.txt
+
+{version, src, ...}:
+
+stdenv.mkDerivation {
+  pname = "media_kit_libs_linux";
+  inherit version src;
+  inherit (src) passthru;
+
+  doBuild = false;
+
+  postPatch = ''
+    awk -i inplace 'BEGIN {opened = 0}; /# --*[^$]*/ { print (opened ? "]===]" : "#[===["); opened = !opened }; {print $0}' linux/CMakeLists.txt
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p "$out"
+    cp -r ./* "$out"
+
+    runHook postInstall
+  '';
+}
diff --git a/pkgs/development/compilers/dart/sources.nix b/pkgs/development/compilers/dart/sources.nix
index 0c8167ca790a..d12394c37bbc 100644
--- a/pkgs/development/compilers/dart/sources.nix
+++ b/pkgs/development/compilers/dart/sources.nix
@@ -1,24 +1,24 @@
-let version = "3.3.1"; in
+let version = "3.3.2"; in
 { fetchurl }: {
   versionUsed = version;
   "${version}-x86_64-darwin" = fetchurl {
     url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/dartsdk-macos-x64-release.zip";
-    sha256 = "1jihiryf8lm4mc5wrnhjwlyazpmhk3n40f8z7r25xnz7glafwvg5";
+    sha256 = "0ii494ffj5vkxnpq3aykxmn54cw4jlf45slwlg9g1crm6j3lcwak";
   };
   "${version}-aarch64-darwin" = fetchurl {
     url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/dartsdk-macos-arm64-release.zip";
-    sha256 = "1d6404r9vhp8q5r4nf3hlcgyvxlyxv63jzd4zlmdxghvm68kkv01";
+    sha256 = "0ffqwbmwx737hrq04rbpyxqfm86mqhfayq2i1ssjkjgqyzzrpmy7";
   };
   "${version}-aarch64-linux" = fetchurl {
     url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/dartsdk-linux-arm64-release.zip";
-    sha256 = "08amw2mw2zfpd7savydxsv8ncy8yk76ak1aixgb1csyh8pn4pagc";
+    sha256 = "079jq4sp8sw8y4khw8j8l2q38149bjmn8j5yibmnzyxpwyc4ysx2";
   };
   "${version}-x86_64-linux" = fetchurl {
     url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/dartsdk-linux-x64-release.zip";
-    sha256 = "0mnplv2vzzfvg7a7xj8vrc75lvsj9xksbwzd3cc7s0xjxvyic40v";
+    sha256 = "07ixd7qj78y6m27cv9mjlkr2kdnmld6cxc23x4dip3a02drs8990";
   };
   "${version}-i686-linux" = fetchurl {
     url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/dartsdk-linux-ia32-release.zip";
-    sha256 = "1ndj3nlw6qd94w3h4kw7jyihm71jlp3y0kc0ybgwh2r22dd2r2yd";
+    sha256 = "1jwjiyxcr2ii4f7rlb4hsjq9hlmdhv9f41wa5camhy74x56z5fhn";
   };
 }
diff --git a/pkgs/development/compilers/dictu/default.nix b/pkgs/development/compilers/dictu/default.nix
index 113f9291df2c..5bce969edb8b 100644
--- a/pkgs/development/compilers/dictu/default.nix
+++ b/pkgs/development/compilers/dictu/default.nix
@@ -76,6 +76,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "High-level dynamically typed, multi-paradigm, interpreted programming language";
+    mainProgram = "dictu";
     homepage = "https://dictu-lang.com";
     license = licenses.mit;
     maintainers = with maintainers; [ luc65r ];
diff --git a/pkgs/development/compilers/dmd/generic.nix b/pkgs/development/compilers/dmd/generic.nix
index eec43a6a82a7..88fabd9c83fb 100644
--- a/pkgs/development/compilers/dmd/generic.nix
+++ b/pkgs/development/compilers/dmd/generic.nix
@@ -216,6 +216,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Official reference compiler for the D language";
+    mainProgram = "dmd";
     homepage = "https://dlang.org/";
     # Everything is now Boost licensed, even the backend.
     # https://github.com/dlang/dmd/pull/6680
diff --git a/pkgs/development/compilers/elm/default.nix b/pkgs/development/compilers/elm/default.nix
index 9ae361ddf442..44e1459af84d 100644
--- a/pkgs/development/compilers/elm/default.nix
+++ b/pkgs/development/compilers/elm/default.nix
@@ -36,6 +36,10 @@ let
     };
     in elmPkgs // {
       inherit elmPkgs;
+
+      ansi-wl-pprint = overrideCabal (drv: {
+        jailbreak = true;
+      }) (self.callPackage ./packages/ansi-wl-pprint.nix {});
     };
   };
 
diff --git a/pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix b/pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix
new file mode 100644
index 000000000000..392ca5ab31b1
--- /dev/null
+++ b/pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix
@@ -0,0 +1,17 @@
+{ mkDerivation, ansi-terminal, base, fetchgit, lib }:
+mkDerivation {
+  pname = "ansi-wl-pprint";
+  version = "0.6.8.1";
+  src = fetchgit {
+    url = "https://github.com/ekmett/ansi-wl-pprint";
+    sha256 = "00pgxgkramz6y1bgdlm00rsh6gd6mdaqllh6riax2rc2sa35kip4";
+    rev = "d16e2f6896d76b87b72af7220c2e93ba15c53280";
+    fetchSubmodules = true;
+  };
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [ ansi-terminal base ];
+  homepage = "http://github.com/ekmett/ansi-wl-pprint";
+  description = "The Wadler/Leijen Pretty Printer for colored ANSI terminal output";
+  license = lib.licenses.bsd3;
+}
diff --git a/pkgs/development/compilers/elm/packages/elm-instrument.nix b/pkgs/development/compilers/elm/packages/elm-instrument.nix
index 18f4d3aff196..02593b855077 100644
--- a/pkgs/development/compilers/elm/packages/elm-instrument.nix
+++ b/pkgs/development/compilers/elm/packages/elm-instrument.nix
@@ -40,4 +40,5 @@ mkDerivation {
   homepage = "https://elm-lang.org";
   description = "Instrumentation library for Elm";
   license = lib.licenses.bsd3;
+  mainProgram = "elm-instrument";
 }
diff --git a/pkgs/development/compilers/elm/packages/elm-json.nix b/pkgs/development/compilers/elm/packages/elm-json.nix
index 6eb5d10cd471..5b988244cc97 100644
--- a/pkgs/development/compilers/elm/packages/elm-json.nix
+++ b/pkgs/development/compilers/elm/packages/elm-json.nix
@@ -32,6 +32,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "Install, upgrade and uninstall Elm dependencies";
+    mainProgram = "elm-json";
     homepage = "https://github.com/zwilias/elm-json";
     license = licenses.mit;
     maintainers = [ maintainers.turbomack ];
diff --git a/pkgs/development/compilers/elm/packages/elm-test-rs.nix b/pkgs/development/compilers/elm/packages/elm-test-rs.nix
index 5e2a5502b211..02f69c2d2f03 100644
--- a/pkgs/development/compilers/elm/packages/elm-test-rs.nix
+++ b/pkgs/development/compilers/elm/packages/elm-test-rs.nix
@@ -23,6 +23,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "Fast and portable executable to run your Elm tests";
+    mainProgram = "elm-test-rs";
     homepage = "https://github.com/mpizenberg/elm-test-rs";
     license = licenses.bsd3;
     maintainers = [ maintainers.jpagex ];
diff --git a/pkgs/development/compilers/elm/packages/elm-test.nix b/pkgs/development/compilers/elm/packages/elm-test.nix
index fc943a80a3fa..eca45395c3df 100644
--- a/pkgs/development/compilers/elm/packages/elm-test.nix
+++ b/pkgs/development/compilers/elm/packages/elm-test.nix
@@ -25,6 +25,7 @@ buildNpmPackage rec {
   meta = {
     changelog = "https://github.com/rtfeldman/node-test-runner/blob/${src.rev}/CHANGELOG.md";
     description = "Runs elm-test suites from Node.js";
+    mainProgram = "elm-test";
     homepage = "https://github.com/rtfeldman/node-test-runner";
     license = lib.licenses.bsd3;
     maintainers = with lib.maintainers; [ turbomack ];
diff --git a/pkgs/development/compilers/elm/update.sh b/pkgs/development/compilers/elm/update.sh
index ecd24de46f67..4de11bd8ff5d 100755
--- a/pkgs/development/compilers/elm/update.sh
+++ b/pkgs/development/compilers/elm/update.sh
@@ -1,6 +1,8 @@
 #!/usr/bin/env nix-shell
 #!nix-shell -p cabal2nix elm2nix -i bash ../../..
 
+cabal2nix https://github.com/ekmett/ansi-wl-pprint --revision d16e2f6896d76b87b72af7220c2e93ba15c53280 > packages/ansi-wl-pprint.nix
+
 # We're building binaries from commit that npm installer is using since
 # November 1st release called 0.19.1-6 in npm registry.
 # These binaries are built with newer ghc version and also support Aarch64 for Linux and Darwin.
diff --git a/pkgs/development/compilers/erg/default.nix b/pkgs/development/compilers/erg/default.nix
index ab5458855423..0ad4320c046a 100644
--- a/pkgs/development/compilers/erg/default.nix
+++ b/pkgs/development/compilers/erg/default.nix
@@ -9,16 +9,16 @@
 
 rustPlatform.buildRustPackage rec {
   pname = "erg";
-  version = "0.6.30";
+  version = "0.6.32";
 
   src = fetchFromGitHub {
     owner = "erg-lang";
     repo = "erg";
     rev = "v${version}";
-    hash = "sha256-lStTLDXgdaaqyzdzU1V2JnKX8jt27Z1A23fkuZU8dt0=";
+    hash = "sha256-l+I6ue824dvZ1AmSS/y+Sh43OstJ5c+8xIXvoVpMFws=";
   };
 
-  cargoHash = "sha256-MsDan3wL9RhH0uhAuq0Lg8IRBXR8a3ooEBx6n2CMAVk=";
+  cargoHash = "sha256-SRltpqTviC+Dq9pPBuLjctOXOKTYw+zVlvA9wi0iFWg=";
 
   nativeBuildInputs = [
     makeWrapper
@@ -57,6 +57,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "A statically typed language that can deeply improve the Python ecosystem";
+    mainProgram = "erg";
     homepage = "https://github.com/erg-lang/erg";
     changelog = "https://github.com/erg-lang/erg/releases/tag/${src.rev}";
     license = with licenses; [ asl20 mit ];
diff --git a/pkgs/development/compilers/fasmg/default.nix b/pkgs/development/compilers/fasmg/default.nix
index ec915bcb04bc..b62c114c77e4 100644
--- a/pkgs/development/compilers/fasmg/default.nix
+++ b/pkgs/development/compilers/fasmg/default.nix
@@ -50,6 +50,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "x86(-64) macro assembler to binary, MZ, PE, COFF, and ELF";
+    mainProgram = "fasmg";
     homepage = "https://flatassembler.net";
     license = licenses.bsd3;
     maintainers = with maintainers; [ orivej luc65r ];
diff --git a/pkgs/development/compilers/fbc/default.nix b/pkgs/development/compilers/fbc/default.nix
index 631bf9c7bfe0..f2a223fb6b8a 100644
--- a/pkgs/development/compilers/fbc/default.nix
+++ b/pkgs/development/compilers/fbc/default.nix
@@ -123,6 +123,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "https://www.freebasic.net/";
     description = "A multi-platform BASIC Compiler";
+    mainProgram = "fbc";
     longDescription = ''
       FreeBASIC is a completely free, open-source, multi-platform BASIC compiler (fbc),
       with syntax similar to (and support for) MS-QuickBASIC, that adds new features
diff --git a/pkgs/development/compilers/firrtl/default.nix b/pkgs/development/compilers/firrtl/default.nix
index 5a59060b6f21..54138a6d3de8 100644
--- a/pkgs/development/compilers/firrtl/default.nix
+++ b/pkgs/development/compilers/firrtl/default.nix
@@ -49,6 +49,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Flexible Intermediate Representation for RTL";
+    mainProgram = "firrtl";
     longDescription = ''
       Firrtl is an intermediate representation (IR) for digital circuits
       designed as a platform for writing circuit-level transformations.
diff --git a/pkgs/development/compilers/flasm/default.nix b/pkgs/development/compilers/flasm/default.nix
index c1d2cfedc984..e1da977b0039 100644
--- a/pkgs/development/compilers/flasm/default.nix
+++ b/pkgs/development/compilers/flasm/default.nix
@@ -32,6 +32,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Assembler and disassembler for Flash (SWF) bytecode";
+    mainProgram = "flasm";
     homepage = "https://flasm.sourceforge.net/";
     license = licenses.bsd2;
     maintainers = with maintainers; [ siraben ];
diff --git a/pkgs/development/compilers/flix/default.nix b/pkgs/development/compilers/flix/default.nix
index 53897054979f..c0f32438db14 100644
--- a/pkgs/development/compilers/flix/default.nix
+++ b/pkgs/development/compilers/flix/default.nix
@@ -26,6 +26,7 @@ stdenvNoCC.mkDerivation rec {
 
   meta = with lib; {
     description = "The Flix Programming Language";
+    mainProgram = "flix";
     homepage = "https://github.com/flix/flix";
     sourceProvenance = with sourceTypes; [ binaryBytecode ];
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/flutter/artifacts/overrides/darwin.nix b/pkgs/development/compilers/flutter/artifacts/overrides/darwin.nix
index b03b14f68c8b..83257d4e34d5 100644
--- a/pkgs/development/compilers/flutter/artifacts/overrides/darwin.nix
+++ b/pkgs/development/compilers/flutter/artifacts/overrides/darwin.nix
@@ -1,14 +1,12 @@
-{ darwin }:
-{
-  buildInputs ? [ ],
-  ...
+{}:
+{ buildInputs ? [ ]
+, ...
 }:
 {
   postPatch = ''
     if [ "$pname" == "flutter-tools" ]; then
-      # Remove impure references to `arch` and use arm64 instead of arm64e.
+      # Use arm64 instead of arm64e.
       substituteInPlace lib/src/ios/xcodeproj.dart \
-        --replace-fail /usr/bin/arch '${darwin.adv_cmds}/bin/arch' \
         --replace-fail arm64e arm64
     fi
   '';
diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix
index f4bf84ad366f..cf35ed8cbc45 100644
--- a/pkgs/development/compilers/flutter/flutter-tools.nix
+++ b/pkgs/development/compilers/flutter/flutter-tools.nix
@@ -9,7 +9,6 @@
 , flutterSrc
 , patches ? [ ]
 , pubspecLock
-, darwin
 }:
 
 buildDartApplication.override { inherit dart; } rec {
@@ -27,10 +26,9 @@ buildDartApplication.override { inherit dart; } rec {
   postPatch = ''
     popd
   ''
-  # Remove impure references to `arch` and use arm64 instead of arm64e.
+  # Use arm64 instead of arm64e.
   + lib.optionalString stdenv.isDarwin ''
     substituteInPlace lib/src/ios/xcodeproj.dart \
-      --replace-fail /usr/bin/arch '${darwin.adv_cmds}/bin/arch' \
       --replace-fail arm64e arm64
   '';
 
diff --git a/pkgs/development/compilers/flux/default.nix b/pkgs/development/compilers/flux/default.nix
index 75386f21f743..bb3c0da52c61 100644
--- a/pkgs/development/compilers/flux/default.nix
+++ b/pkgs/development/compilers/flux/default.nix
@@ -15,6 +15,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "An interface description language used by DirectFB";
+    mainProgram = "fluxcomp";
     homepage = "https://github.com/deniskropp/flux";
     license = licenses.mit;
   };
diff --git a/pkgs/development/compilers/gbforth/default.nix b/pkgs/development/compilers/gbforth/default.nix
index e85e621cff16..882a25cdae07 100644
--- a/pkgs/development/compilers/gbforth/default.nix
+++ b/pkgs/development/compilers/gbforth/default.nix
@@ -42,6 +42,7 @@ stdenv.mkDerivation {
   meta = with lib; {
     homepage = "https://gbforth.org/";
     description = "A Forth-based Game Boy development kit";
+    mainProgram = "gbforth";
     longDescription = ''
       A Forth-based Game Boy development kit.
       It features a Forth-based assembler, a cross-compiler with support for
diff --git a/pkgs/development/compilers/gcl/default.nix b/pkgs/development/compilers/gcl/default.nix
index 8ef2cedbf076..64d36ea67a73 100644
--- a/pkgs/development/compilers/gcl/default.nix
+++ b/pkgs/development/compilers/gcl/default.nix
@@ -29,6 +29,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "GNU Common Lisp compiler working via GCC";
+    mainProgram = "gcl";
     maintainers = lib.teams.lisp.members;
     license = licenses.gpl2;
     platforms = platforms.linux;
diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix
index c49c274c67d4..4a770d993a67 100644
--- a/pkgs/development/compilers/ghc/8.10.7.nix
+++ b/pkgs/development/compilers/ghc/8.10.7.nix
@@ -103,7 +103,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix
index bdfff2b795a4..175d1fe2450b 100644
--- a/pkgs/development/compilers/ghc/9.0.2.nix
+++ b/pkgs/development/compilers/ghc/9.0.2.nix
@@ -105,7 +105,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix
index 034a09511b2b..6c86e05ebbd4 100644
--- a/pkgs/development/compilers/ghc/9.2.5.nix
+++ b/pkgs/development/compilers/ghc/9.2.5.nix
@@ -105,7 +105,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix
index 83cd1e051c6a..6ff58f087f8a 100644
--- a/pkgs/development/compilers/ghc/9.2.6.nix
+++ b/pkgs/development/compilers/ghc/9.2.6.nix
@@ -105,7 +105,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix
index 4bf7252643de..f605bfda1981 100644
--- a/pkgs/development/compilers/ghc/9.2.7.nix
+++ b/pkgs/development/compilers/ghc/9.2.7.nix
@@ -105,7 +105,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix
index 0d469f733525..72cfdd242f42 100644
--- a/pkgs/development/compilers/ghc/9.2.8.nix
+++ b/pkgs/development/compilers/ghc/9.2.8.nix
@@ -105,7 +105,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix
index 9670d4a4fd57..298af6596e71 100644
--- a/pkgs/development/compilers/ghc/9.4.5.nix
+++ b/pkgs/development/compilers/ghc/9.4.5.nix
@@ -107,7 +107,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix
index f971f4e5a309..310787e477b2 100644
--- a/pkgs/development/compilers/ghc/9.4.6.nix
+++ b/pkgs/development/compilers/ghc/9.4.6.nix
@@ -107,7 +107,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix
index ac060dce91d0..e87f8fc3a907 100644
--- a/pkgs/development/compilers/ghc/9.4.7.nix
+++ b/pkgs/development/compilers/ghc/9.4.7.nix
@@ -107,7 +107,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix
index db79b72830d5..5ac2b60b1cd7 100644
--- a/pkgs/development/compilers/ghc/9.4.8.nix
+++ b/pkgs/development/compilers/ghc/9.4.8.nix
@@ -107,7 +107,7 @@ let
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
   '' + lib.optionalString (!enableProfiledLibs) ''
-    GhcLibWays = "v dyn"
+    BUILD_PROF_LIBS = NO
   '' +
   # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
   # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
diff --git a/pkgs/development/compilers/ghc/9.6.3-binary.nix b/pkgs/development/compilers/ghc/9.6.3-binary.nix
new file mode 100644
index 000000000000..b8ad3c1192eb
--- /dev/null
+++ b/pkgs/development/compilers/ghc/9.6.3-binary.nix
@@ -0,0 +1,410 @@
+{ lib, stdenv
+, fetchurl, perl, gcc
+, ncurses5
+, ncurses6, gmp, libiconv, numactl, libffi
+, llvmPackages
+, coreutils
+, targetPackages
+
+  # minimal = true; will remove files that aren't strictly necessary for
+  # regular builds and GHC bootstrapping.
+  # This is "useful" for staying within hydra's output limits for at least the
+  # aarch64-linux architecture.
+, minimal ? false
+}:
+
+# Prebuilt only does native
+assert stdenv.targetPlatform == stdenv.hostPlatform;
+
+let
+  downloadsUrl = "https://downloads.haskell.org/ghc";
+
+  # Copy sha256 from https://downloads.haskell.org/~ghc/9.6.3/SHA256SUMS
+  version = "9.6.3";
+
+  # Information about available bindists that we use in the build.
+  #
+  # # Bindist library checking
+  #
+  # The field `archSpecificLibraries` also provides a way for us get notified
+  # early when the upstream bindist changes its dependencies (e.g. because a
+  # newer Debian version is used that uses a new `ncurses` version).
+  #
+  # Usage:
+  #
+  # * You can find the `fileToCheckFor` of libraries by running `readelf -d`
+  #   on the compiler binary (`exePathForLibraryCheck`).
+  # * To skip library checking for an architecture,
+  #   set `exePathForLibraryCheck = null`.
+  # * To skip file checking for a specific arch specfic library,
+  #   set `fileToCheckFor = null`.
+  ghcBinDists = {
+    # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
+    # nixpkgs uses for the respective system.
+    defaultLibc = {
+      i686-linux = {
+        variantSuffix = "";
+        src = {
+          url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
+          sha256 = "58be26f8b8f6b5bd8baf5c32abb03e2c4621646b2142fab10e5c7de5af5c50f8";
+        };
+        exePathForLibraryCheck = "bin/ghc";
+        archSpecificLibraries = [
+          { nixPackage = gmp; fileToCheckFor = null; }
+          # The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
+          # which link it against `libtinfo.so.5` (ncurses 5).
+          # Other bindists are linked `libtinfo.so.6` (ncurses 6).
+          { nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
+        ];
+      };
+      x86_64-linux = {
+        variantSuffix = "";
+        src = {
+          url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb11-linux.tar.xz";
+          sha256 = "c4c0124857265926f1cf22a09d950d7ba989ff94053a4ddf3dcdab5359f4cab7";
+        };
+        exePathForLibraryCheck = "bin/ghc";
+        archSpecificLibraries = [
+          { nixPackage = gmp; fileToCheckFor = null; }
+          { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
+        ];
+      };
+      aarch64-linux = {
+        variantSuffix = "";
+        src = {
+          url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
+          sha256 = "03c389859319f09452081310fc13af7525063ea8930830ef76be2a14b312271e";
+        };
+        exePathForLibraryCheck = "bin/ghc";
+        archSpecificLibraries = [
+          { nixPackage = gmp; fileToCheckFor = null; }
+          { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
+          { nixPackage = numactl; fileToCheckFor = null; }
+        ];
+      };
+      x86_64-darwin = {
+        variantSuffix = "";
+        src = {
+          url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
+          sha256 = "dde46118ab8388fb1066312c097123e93b1dcf6ae366e3370f88ea456382c9db";
+        };
+        exePathForLibraryCheck = null; # we don't have a library check for darwin yet
+        archSpecificLibraries = [
+          { nixPackage = gmp; fileToCheckFor = null; }
+          { nixPackage = ncurses6; fileToCheckFor = null; }
+          { nixPackage = libiconv; fileToCheckFor = null; }
+        ];
+      };
+      aarch64-darwin = {
+        variantSuffix = "";
+        src = {
+          url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
+          sha256 = "e1cdf458926b2eaf52d2a8287d99a965040ff9051171f5c3b7467049cf0eb213";
+        };
+        exePathForLibraryCheck = null; # we don't have a library check for darwin yet
+        archSpecificLibraries = [
+          { nixPackage = gmp; fileToCheckFor = null; }
+          { nixPackage = ncurses6; fileToCheckFor = null; }
+          { nixPackage = libiconv; fileToCheckFor = null; }
+        ];
+      };
+    };
+    # Binary distributions for the musl libc for the respective system.
+    musl = {
+      x86_64-linux = {
+        variantSuffix = "-musl";
+        src = {
+          url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3_12-linux.tar.xz";
+          sha256 = "8f457af0aa40127049c11134c8793f64351a446e87da1f8ec256e1279b5ab61f";
+        };
+        exePathForLibraryCheck = "bin/ghc";
+        archSpecificLibraries = [
+          { nixPackage = gmp; fileToCheckFor = null; }
+          { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
+        ];
+      };
+    };
+  };
+
+  distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
+
+  binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
+    or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
+
+  gmpUsed = (builtins.head (
+    builtins.filter (
+      drv: lib.hasPrefix "gmp" (drv.nixPackage.name or "")
+    ) binDistUsed.archSpecificLibraries
+  )).nixPackage;
+
+  # GHC has other native backends (like PowerPC), but here only the ones
+  # we ship bindists for matter.
+  useLLVM = !(stdenv.targetPlatform.isx86
+    || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin));
+
+  libPath =
+    lib.makeLibraryPath (
+      # Add arch-specific libraries.
+      map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
+    );
+
+  libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+    + "LD_LIBRARY_PATH";
+
+  runtimeDeps = [
+    targetPackages.stdenv.cc
+    targetPackages.stdenv.cc.bintools
+    coreutils # for cat
+  ]
+  ++ lib.optionals useLLVM [
+    (lib.getBin llvmPackages.llvm)
+  ]
+  # On darwin, we need unwrapped bintools as well (for otool)
+  ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
+    targetPackages.stdenv.cc.bintools.bintools
+  ];
+
+in
+
+stdenv.mkDerivation rec {
+  inherit version;
+  pname = "ghc-binary${binDistUsed.variantSuffix}";
+
+  src = fetchurl binDistUsed.src;
+
+  nativeBuildInputs = [ perl ];
+
+  # Set LD_LIBRARY_PATH or equivalent so that the programs running as part
+  # of the bindist installer can find the libraries they expect.
+  # Cannot patchelf beforehand due to relative RPATHs that anticipate
+  # the final install location.
+  ${libEnvVar} = libPath;
+
+  postUnpack =
+    # Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
+    # so that we know when ghc bindists upgrade that and we need to update the
+    # version used in `libPath`.
+    lib.optionalString
+      (binDistUsed.exePathForLibraryCheck != null)
+      # Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
+      # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
+      # As a result, don't shell-quote this glob when splicing the string.
+      (let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
+        lib.concatStringsSep "\n" [
+          (''
+            shopt -u nullglob
+            echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
+            if ! test -e ${buildExeGlob}; then
+              echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
+            fi
+          '')
+          (lib.concatMapStringsSep
+            "\n"
+            ({ fileToCheckFor, nixPackage }:
+              lib.optionalString (fileToCheckFor != null) ''
+                echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
+                if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
+                  echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
+                fi
+
+                echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
+                if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
+                  echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
+                fi
+              ''
+            )
+            binDistUsed.archSpecificLibraries
+          )
+        ])
+    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
+    # during linking
+    + lib.optionalString stdenv.isDarwin ''
+      export NIX_LDFLAGS+=" -no_dtrace_dof"
+      # not enough room in the object files for the full path to libiconv :(
+      for exe in $(find . -type f -executable); do
+        isMachO $exe || continue
+        ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+        install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+      done
+    ''
+
+    # We have to patch the GMP paths for the ghc-bignum package, for hadrian by
+    # modifying the package-db directly
+    + ''
+      find . -name 'ghc-bignum*.conf' \
+          -exec sed -e '/^[a-z-]*library-dirs/a \    ${lib.getLib gmpUsed}/lib' -i {} \;
+    ''
+    # Similar for iconv and libffi on darwin
+    + lib.optionalString stdenv.isDarwin ''
+      find . -name 'base*.conf' \
+          -exec sed -e '/^[a-z-]*library-dirs/a \    ${lib.getLib libiconv}/lib' -i {} \;
+
+      # To link RTS in the end we also need libffi now
+      find . -name 'rts*.conf' \
+          -exec sed -e '/^[a-z-]*library-dirs/a \    ${lib.getLib libffi}/lib' \
+                    -e 's@/Library/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \
+                    -i {} \;
+    '' +
+    # aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
+    # FFI_LIB_DIR is a good indication of places it must be needed.
+    lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) ''
+      find . -name package.conf.in \
+          -exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
+    '' +
+    # Rename needed libraries and binaries, fix interpreter
+    lib.optionalString stdenv.isLinux ''
+      find . -type f -executable -exec patchelf \
+          --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
+    '';
+
+  # fix for `configure: error: Your linker is affected by binutils #16177`
+  preConfigure = lib.optionalString
+    stdenv.targetPlatform.isAarch32
+    "LD=ld.gold";
+
+  # GHC has a patched config.sub and bindists' platforms should always work
+  dontUpdateAutotoolsGnuConfigScripts = true;
+
+  configurePlatforms = [ ];
+  configureFlags =
+    lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
+    # From: https://github.com/NixOS/nixpkgs/pull/43369/commits
+    ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+
+  # No building is necessary, but calling make without flags ironically
+  # calls install-strip ...
+  dontBuild = true;
+
+  # Patch scripts to include runtime dependencies in $PATH.
+  postInstall = ''
+    for i in "$out/bin/"*; do
+      test ! -h "$i" || continue
+      isScript "$i" || continue
+      sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
+    done
+  '';
+
+  # Apparently necessary for the ghc Alpine (musl) bindist:
+  # When we strip, and then run the
+  #     patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
+  # below, running ghc (e.g. during `installCheckPhase)` gives some apparently
+  # corrupted rpath or whatever makes the loader work on nonsensical strings:
+  #     running install tests
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found
+  #     Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
+  # This is extremely bogus and should be investigated.
+  dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
+
+  # On Linux, use patchelf to modify the executables so that they can
+  # find editline/gmp.
+  postFixup = lib.optionalString (stdenv.isLinux && !(binDistUsed.isStatic or false))
+    (if stdenv.hostPlatform.isAarch64 then
+      # Keep rpath as small as possible on aarch64 for patchelf#244.  All Elfs
+      # are 2 directories deep from $out/lib, so pooling symlinks there makes
+      # a short rpath.
+      ''
+      (cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
+      (cd $out/lib; ln -s ${lib.getLib gmpUsed}/lib/libgmp.so.10)
+      (cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
+      for p in $(find "$out/lib" -type f -name "*\.so*"); do
+        (cd $out/lib; ln -s $p)
+      done
+
+      for p in $(find "$out/lib" -type f -executable); do
+        if isELF "$p"; then
+          echo "Patchelfing $p"
+          patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
+        fi
+      done
+      ''
+    else
+      ''
+      for p in $(find "$out" -type f -executable); do
+        if isELF "$p"; then
+          echo "Patchelfing $p"
+          patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
+        fi
+      done
+    '') + lib.optionalString stdenv.isDarwin ''
+    # not enough room in the object files for the full path to libiconv :(
+    for exe in $(find "$out" -type f -executable); do
+      isMachO $exe || continue
+      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+    done
+
+    for file in $(find "$out" -name setup-config); do
+      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
+    done
+  ''
+  # Recache package db which needs to happen for Hadrian bindists
+  # where we modify the package db before installing
+  + ''
+    package_db=("$out"/lib/ghc-*/lib/package.conf.d)
+    "$out/bin/ghc-pkg" --package-db="$package_db" recache
+  '';
+
+  # In nixpkgs, musl based builds currently enable `pie` hardening by default
+  # (see `defaultHardeningFlags` in `make-derivation.nix`).
+  # But GHC cannot currently produce outputs that are ready for `-pie` linking.
+  # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
+  # See:
+  # * https://github.com/NixOS/nixpkgs/issues/129247
+  # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
+  hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    # Sanity check, can ghc create executables?
+    cd $TMP
+    mkdir test-ghc; cd test-ghc
+    cat > main.hs << EOF
+      {-# LANGUAGE TemplateHaskell #-}
+      module Main where
+      main = putStrLn \$([|"yes"|])
+    EOF
+    env -i $out/bin/ghc --make main.hs || exit 1
+    echo compilation ok
+    [ $(./main) == "yes" ]
+  '';
+
+  passthru = {
+    targetPrefix = "";
+    enableShared = true;
+
+    inherit llvmPackages;
+
+    # Our Cabal compiler name
+    haskellCompilerName = "ghc-${version}";
+
+    # Normal GHC derivations expose the hadrian derivation used to build them
+    # here. In the case of bindists we just make sure that the attribute exists,
+    # as it is used for checking if a GHC derivation has been built with hadrian.
+    hadrian = null;
+  };
+
+  meta = rec {
+    homepage = "http://haskell.org/ghc";
+    description = "The Glasgow Haskell Compiler";
+    license = lib.licenses.bsd3;
+    # HACK: since we can't encode the libc / abi in platforms, we need
+    # to make the platform list dependent on the evaluation platform
+    # in order to avoid eval errors with musl which supports less
+    # platforms than the default libcs (i. e. glibc / libSystem).
+    # This is done for the benefit of Hydra, so `packagePlatforms`
+    # won't return any platforms that would cause an evaluation
+    # failure for `pkgsMusl.haskell.compiler.ghc922Binary`, as
+    # long as the evaluator runs on a platform that supports
+    # `pkgsMusl`.
+    platforms = builtins.attrNames ghcBinDists.${distSetName};
+    maintainers = lib.teams.haskell.members;
+    # packages involving hsc2hs (clock) produce libraries our
+    # ld can't link against
+    broken = stdenv.hostPlatform.isDarwin;
+  };
+}
diff --git a/pkgs/development/compilers/ghc/9.8.2.nix b/pkgs/development/compilers/ghc/9.8.2.nix
new file mode 100644
index 000000000000..0a7b109013bf
--- /dev/null
+++ b/pkgs/development/compilers/ghc/9.8.2.nix
@@ -0,0 +1,4 @@
+import ./common-hadrian.nix rec {
+  version = "9.8.2";
+  sha256 = "4vt6fddGEjfSLoNlqD7dnhp30uFdBF85RTloRah3gck=";
+}
diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix
index f4d2a279a678..465db3a25296 100644
--- a/pkgs/development/compilers/ghc/common-hadrian.nix
+++ b/pkgs/development/compilers/ghc/common-hadrian.nix
@@ -528,6 +528,10 @@ stdenv.mkDerivation ({
     ] ++ lib.teams.haskell.members;
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
+    # https://github.com/NixOS/nixpkgs/issues/208959
+    broken =
+      (lib.versionAtLeast version "9.6" && lib.versionOlder version "9.8")
+      && stdenv.targetPlatform.isStatic;
   };
 
   dontStrip = targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm;
diff --git a/pkgs/development/compilers/ghdl/default.nix b/pkgs/development/compilers/ghdl/default.nix
index e00294cf1845..be6c3f7e98ef 100644
--- a/pkgs/development/compilers/ghdl/default.nix
+++ b/pkgs/development/compilers/ghdl/default.nix
@@ -13,13 +13,13 @@ assert backend == "mcode" || backend == "llvm";
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "ghdl-${backend}";
-  version = "3.0.0";
+  version = "4.0.0";
 
   src = fetchFromGitHub {
     owner  = "ghdl";
     repo   = "ghdl";
     rev    = "v${finalAttrs.version}";
-    hash   = "sha256-94RNtHbOpbC2q/Z+PsQplrLxXmpS3LXOCXyTBB+n9c4=";
+    hash   = "sha256-KQwesrj2g8cDCyiEb5j4bkM5O3fGPuXzGUOEEGw6zRI=";
   };
 
   LIBRARY_PATH = "${stdenv.cc.libc}/lib";
diff --git a/pkgs/development/compilers/gleam/default.nix b/pkgs/development/compilers/gleam/default.nix
index d21c4d48f33f..5dc3976025a8 100644
--- a/pkgs/development/compilers/gleam/default.nix
+++ b/pkgs/development/compilers/gleam/default.nix
@@ -32,6 +32,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "A statically typed language for the Erlang VM";
+    mainProgram = "gleam";
     homepage = "https://gleam.run/";
     license = licenses.asl20;
     maintainers = teams.beam.members;
diff --git a/pkgs/development/compilers/glslang/default.nix b/pkgs/development/compilers/glslang/default.nix
index 5387eb15b713..1f84487239d2 100644
--- a/pkgs/development/compilers/glslang/default.nix
+++ b/pkgs/development/compilers/glslang/default.nix
@@ -9,13 +9,13 @@
 }:
 stdenv.mkDerivation rec {
   pname = "glslang";
-  version = "14.0.0";
+  version = "14.1.0";
 
   src = fetchFromGitHub {
     owner = "KhronosGroup";
     repo = "glslang";
     rev = version;
-    hash = "sha256-7kIIU45pe+IF7lGltpIKSvQBmcXR+TWFvmx7ztMNrpc=";
+    hash = "sha256-trm5bR3/2w+oQppHQBB+b6l0N0sLjTk5+rRGDfnGb+8=";
   };
 
   # These get set at all-packages, keep onto them for child drvs
diff --git a/pkgs/development/compilers/gmqcc/default.nix b/pkgs/development/compilers/gmqcc/default.nix
index f3b25e2dbd4a..a030133fba52 100644
--- a/pkgs/development/compilers/gmqcc/default.nix
+++ b/pkgs/development/compilers/gmqcc/default.nix
@@ -27,6 +27,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "https://graphitemaster.github.io/gmqcc/";
     description = "A modern QuakeC compiler";
+    mainProgram = "gmqcc";
     longDescription = ''
       For an enduring period of time the options for a decent compiler for
       the Quake C programming language were confined to a specific compiler
diff --git a/pkgs/development/compilers/go/1.20.nix b/pkgs/development/compilers/go/1.20.nix
deleted file mode 100644
index 5b3cbdd4cc81..000000000000
--- a/pkgs/development/compilers/go/1.20.nix
+++ /dev/null
@@ -1,189 +0,0 @@
-{ lib
-, stdenv
-, fetchurl
-, tzdata
-, substituteAll
-, iana-etc
-, Security
-, Foundation
-, xcbuild
-, mailcap
-, buildPackages
-, pkgsBuildTarget
-, threadsCross
-, testers
-, skopeo
-, buildGo120Module
-}:
-
-let
-  useGccGoBootstrap = stdenv.buildPlatform.isMusl || stdenv.buildPlatform.isRiscV;
-  goBootstrap = if useGccGoBootstrap then buildPackages.gccgo12 else buildPackages.callPackage ./bootstrap117.nix { };
-
-  skopeoTest = skopeo.override { buildGoModule = buildGo120Module; };
-
-  goarch = platform: {
-    "aarch64" = "arm64";
-    "arm" = "arm";
-    "armv5tel" = "arm";
-    "armv6l" = "arm";
-    "armv7l" = "arm";
-    "i686" = "386";
-    "mips" = "mips";
-    "mips64el" = "mips64le";
-    "mipsel" = "mipsle";
-    "powerpc64le" = "ppc64le";
-    "riscv64" = "riscv64";
-    "s390x" = "s390x";
-    "x86_64" = "amd64";
-  }.${platform.parsed.cpu.name} or (throw "Unsupported system: ${platform.parsed.cpu.name}");
-
-  # We need a target compiler which is still runnable at build time,
-  # to handle the cross-building case where build != host == target
-  targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
-
-  isCross = stdenv.buildPlatform != stdenv.targetPlatform;
-in
-stdenv.mkDerivation (finalAttrs: {
-  pname = "go";
-  version = "1.20.14";
-
-  src = fetchurl {
-    url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
-    hash = "sha256-Gu8yGg4+OLfpHS1+tkBAZmyr3Md9OD3jyVItDWm2f04=";
-  };
-
-  strictDeps = true;
-  buildInputs = [ ]
-    ++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ]
-    ++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
-
-  depsTargetTargetPropagated = lib.optionals stdenv.targetPlatform.isDarwin [ Foundation Security xcbuild ];
-
-  depsBuildTarget = lib.optional isCross targetCC;
-
-  depsTargetTarget = lib.optional stdenv.targetPlatform.isWindows threadsCross.package;
-
-  postPatch = ''
-    patchShebangs .
-  '';
-
-  patches = [
-    (substituteAll {
-      src = ./iana-etc-1.17.patch;
-      iana = iana-etc;
-    })
-    # Patch the mimetype database location which is missing on NixOS.
-    # but also allow static binaries built with NixOS to run outside nix
-    (substituteAll {
-      src = ./mailcap-1.17.patch;
-      inherit mailcap;
-    })
-    # prepend the nix path to the zoneinfo files but also leave the original value for static binaries
-    # that run outside a nix server
-    (substituteAll {
-      src = ./tzdata-1.19.patch;
-      inherit tzdata;
-    })
-    ./remove-tools-1.11.patch
-    ./go_no_vendor_checks-1.16.patch
-  ];
-
-  GOOS = stdenv.targetPlatform.parsed.kernel.name;
-  GOARCH = goarch stdenv.targetPlatform;
-  # GOHOSTOS/GOHOSTARCH must match the building system, not the host system.
-  # Go will nevertheless build a for host system that we will copy over in
-  # the install phase.
-  GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name;
-  GOHOSTARCH = goarch stdenv.buildPlatform;
-
-  # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
-  # to be different from CC/CXX
-  CC_FOR_TARGET =
-    if isCross then
-      "${targetCC}/bin/${targetCC.targetPrefix}cc"
-    else
-      null;
-  CXX_FOR_TARGET =
-    if isCross then
-      "${targetCC}/bin/${targetCC.targetPrefix}c++"
-    else
-      null;
-
-  GOARM = toString (lib.intersectLists [ (stdenv.hostPlatform.parsed.cpu.version or "") ] [ "5" "6" "7" ]);
-  GO386 = "softfloat"; # from Arch: don't assume sse2 on i686
-  CGO_ENABLED = 1;
-
-  GOROOT_BOOTSTRAP = if useGccGoBootstrap then goBootstrap else "${goBootstrap}/share/go";
-
-  buildPhase = ''
-    runHook preBuild
-    export GOCACHE=$TMPDIR/go-cache
-    # this is compiled into the binary
-    export GOROOT_FINAL=$out/share/go
-
-    export PATH=$(pwd)/bin:$PATH
-
-    ${lib.optionalString isCross ''
-    # Independent from host/target, CC should produce code for the building system.
-    # We only set it when cross-compiling.
-    export CC=${buildPackages.stdenv.cc}/bin/cc
-    ''}
-    ulimit -a
-
-    pushd src
-    ./make.bash
-    popd
-    runHook postBuild
-  '';
-
-  preInstall = ''
-    # Contains the wrong perl shebang when cross compiling,
-    # since it is not used for anything we can deleted as well.
-    rm src/regexp/syntax/make_perl_groups.pl
-  '' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then ''
-    mv bin/*_*/* bin
-    rmdir bin/*_*
-    ${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) ''
-      rm -rf pkg/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH} pkg/tool/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH}
-    ''}
-  '' else lib.optionalString (stdenv.hostPlatform.system != stdenv.targetPlatform.system) ''
-    rm -rf bin/*_*
-    ${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) ''
-      rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH}
-    ''}
-  '');
-
-  installPhase = ''
-    runHook preInstall
-    mkdir -p $GOROOT_FINAL
-    cp -a bin pkg src lib misc api doc $GOROOT_FINAL
-    mkdir -p $out/bin
-    ln -s $GOROOT_FINAL/bin/* $out/bin
-    runHook postInstall
-  '';
-
-  disallowedReferences = [ goBootstrap ];
-
-  passthru = {
-    inherit goBootstrap skopeoTest;
-    tests = {
-      skopeo = testers.testVersion { package = skopeoTest; };
-      version = testers.testVersion {
-        package = finalAttrs.finalPackage;
-        command = "go version";
-        version = "go${finalAttrs.version}";
-      };
-    };
-  };
-
-  meta = with lib; {
-    changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
-    description = "The Go Programming language";
-    homepage = "https://go.dev/";
-    license = licenses.bsd3;
-    maintainers = teams.golang.members;
-    platforms = platforms.darwin ++ platforms.linux;
-    mainProgram = "go";
-  };
-})
diff --git a/pkgs/development/compilers/go/1.21.nix b/pkgs/development/compilers/go/1.21.nix
index 1debcd433b9b..8250cf9515b9 100644
--- a/pkgs/development/compilers/go/1.21.nix
+++ b/pkgs/development/compilers/go/1.21.nix
@@ -46,11 +46,11 @@ let
 in
 stdenv.mkDerivation (finalAttrs: {
   pname = "go";
-  version = "1.21.7";
+  version = "1.21.8";
 
   src = fetchurl {
     url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
-    hash = "sha256-ABl6sg8zgTgyv/Yv2TzKHEKgjMaJoypmcspJWRlZv/Y=";
+    hash = "sha256-3IBs91qH4UFLW0w9y53T6cyY9M/M7EK3r2F9WmWKPEM=";
   };
 
   strictDeps = true;
diff --git a/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix b/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix
index 579e40580802..907441ff68c4 100644
--- a/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix
+++ b/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix
@@ -72,5 +72,6 @@ stdenv.mkDerivation ({
   meta = ({
     inherit (graalvm-ce.meta) homepage license sourceProvenance maintainers platforms;
     description = "High-Performance Polyglot VM (Product: ${product})";
+    mainProgram = "js";
   } // (args.meta or { }));
 } // extraArgs)
diff --git a/pkgs/development/compilers/graalvm/community-edition/graalpy/hashes.nix b/pkgs/development/compilers/graalvm/community-edition/graalpy/hashes.nix
index 84bb1660f7b5..1d76cfdbdd80 100644
--- a/pkgs/development/compilers/graalvm/community-edition/graalpy/hashes.nix
+++ b/pkgs/development/compilers/graalvm/community-edition/graalpy/hashes.nix
@@ -1,22 +1,22 @@
 # Generated by update.sh script
 {
-  "version" = "23.1.2";
+  "version" = "24.0.0";
   "hashes" = {
     "aarch64-linux" = {
-      sha256 = "0ypzhi22q2d1dfl3qf3yfsaqdsrj8sksc2spa79rdqdr690li4y9";
-      url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.2/graalpy-community-23.1.2-linux-aarch64.tar.gz";
+      sha256 = "1hz56nvl7av3xvwm7bxrzyri289h6hbawxsacn4zr7nm1snjn7i0";
+      url = "https://github.com/oracle/graalpython/releases/download/graal-24.0.0/graalpy-community-24.0.0-linux-aarch64.tar.gz";
     };
     "x86_64-linux" = {
-      sha256 = "1n99hzf1sidacv4qr5j2b3dpwrc6qb71alwfkdxjqx6xv7g7nmr7";
-      url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.2/graalpy-community-23.1.2-linux-amd64.tar.gz";
+      sha256 = "1ngqwrx1bc22jm12gmwqmqjfhhccpim1pai6885vg5xqsvc94y57";
+      url = "https://github.com/oracle/graalpython/releases/download/graal-24.0.0/graalpy-community-24.0.0-linux-amd64.tar.gz";
     };
     "x86_64-darwin" = {
-      sha256 = "0g2xj5hiq8idacdm0jlg5lvvv98f38p6fjb839gfacsb25pmhkg7";
-      url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.2/graalpy-community-23.1.2-macos-amd64.tar.gz";
+      sha256 = "07bh2fgk3l7vpws91ah48dsbrvvlq8wzfq88wq6ywilbikmnp0bw";
+      url = "https://github.com/oracle/graalpython/releases/download/graal-24.0.0/graalpy-community-24.0.0-macos-amd64.tar.gz";
     };
     "aarch64-darwin" = {
-      sha256 = "0qinxqkkm9bfnzr43p3yhs3alfnl4pppca6yahsk5bp8ngyzasfj";
-      url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.2/graalpy-community-23.1.2-macos-aarch64.tar.gz";
+      sha256 = "00kljb24835l51jrnzdfblbhf2psdfw3wg00rllcdhpmiji40mbz";
+      url = "https://github.com/oracle/graalpython/releases/download/graal-24.0.0/graalpy-community-24.0.0-macos-aarch64.tar.gz";
     };
   };
 }
diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/hashes.nix b/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/hashes.nix
index 45028f3d544b..1ce3b864a6bf 100644
--- a/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/hashes.nix
+++ b/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/hashes.nix
@@ -1,22 +1,22 @@
 # Generated by update.sh script
 {
-  "version" = "21.0.2";
+  "version" = "22.0.0";
   "hashes" = {
     "aarch64-linux" = {
-      sha256 = "0yndazvc4kyr9widfn8ql5vd57m4m5inqz2wcpsarw38rs8ycjx3";
-      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-aarch64_bin.tar.gz";
+      sha256 = "01097qag9kjjwh3q11j76bn79x80dm8h5rdd6gzwrsqhn48hx6ns";
+      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.0/graalvm-community-jdk-22.0.0_linux-aarch64_bin.tar.gz";
     };
     "x86_64-linux" = {
-      sha256 = "0j5ffszcaqv3fq159hyb611jm8w1q4n1cywmbd7vi69smad0cj5h";
-      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz";
+      sha256 = "0mq6vdsfgas8lhz1vdiz8qya37fy7qn0078q30zpa09ila3b9vp5";
+      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.0/graalvm-community-jdk-22.0.0_linux-x64_bin.tar.gz";
     };
     "x86_64-darwin" = {
-      sha256 = "1qfrn1068idnkzd6mdpw1x17sqrj59rz9avphj8225sxlhzsk2ks";
-      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_macos-x64_bin.tar.gz";
+      sha256 = "1l8h9ai7s4km8wx1x43s3barnbq7b6hzfr1mbbmiksng1d2p26v9";
+      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.0/graalvm-community-jdk-22.0.0_macos-x64_bin.tar.gz";
     };
     "aarch64-darwin" = {
-      sha256 = "1dssa3nhix7bqygdkkfp0b9myjg5f91dlgm8mf6r7qf7mj9klpji";
-      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_macos-aarch64_bin.tar.gz";
+      sha256 = "11ncf4wd5asr3jz21fs0j5w49zxrsdw3j42mpcczjy2z1j813cc7";
+      url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.0/graalvm-community-jdk-22.0.0_macos-aarch64_bin.tar.gz";
     };
   };
 }
diff --git a/pkgs/development/compilers/graalvm/community-edition/truffleruby/hashes.nix b/pkgs/development/compilers/graalvm/community-edition/truffleruby/hashes.nix
index 331db1caf9b9..40e44e22954d 100644
--- a/pkgs/development/compilers/graalvm/community-edition/truffleruby/hashes.nix
+++ b/pkgs/development/compilers/graalvm/community-edition/truffleruby/hashes.nix
@@ -1,22 +1,22 @@
 # Generated by update.sh script
 {
-  "version" = "23.1.2";
+  "version" = "24.0.0";
   "hashes" = {
     "aarch64-linux" = {
-      sha256 = "0bmrpp88zny0hbq4hqhs4xajqr96qxj6p5nj12m7kcr8hzh2vkf3";
-      url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.2/truffleruby-community-23.1.2-linux-aarch64.tar.gz";
+      sha256 = "0nq2wnc7kb3x37m68b2ylay6c341fzv4453k150a47fnj0p4d85p";
+      url = "https://github.com/oracle/truffleruby/releases/download/graal-24.0.0/truffleruby-community-24.0.0-linux-aarch64.tar.gz";
     };
     "x86_64-linux" = {
-      sha256 = "0hrab1jrs59swpx33zg111wa4nv2215ygyckv47x6mmjibf30c86";
-      url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.2/truffleruby-community-23.1.2-linux-amd64.tar.gz";
+      sha256 = "1h8zqf9clxg3azma86gdm6yl8mif2sgmyhnvqdilap28vmj4mpns";
+      url = "https://github.com/oracle/truffleruby/releases/download/graal-24.0.0/truffleruby-community-24.0.0-linux-amd64.tar.gz";
     };
     "x86_64-darwin" = {
-      sha256 = "1y68wz6rv2vksbnhmf57zlk8smgv9954np07d8ywdls99a92217z";
-      url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.2/truffleruby-community-23.1.2-macos-amd64.tar.gz";
+      sha256 = "03c4bxdzdz5m7n1kkmzsb8x0m1h4ms6ah29p9m4wrz8pjsb8682l";
+      url = "https://github.com/oracle/truffleruby/releases/download/graal-24.0.0/truffleruby-community-24.0.0-macos-amd64.tar.gz";
     };
     "aarch64-darwin" = {
-      sha256 = "0za4ff3wlj2fgl2z3vzp2p4jf9x0fkvd98qwk1dm7lmffghfb14n";
-      url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.2/truffleruby-community-23.1.2-macos-aarch64.tar.gz";
+      sha256 = "0ph6ki66w4kqwnznbpgfd8k85xx6cgqslzy07v4sywhp9k246qld";
+      url = "https://github.com/oracle/truffleruby/releases/download/graal-24.0.0/truffleruby-community-24.0.0-macos-aarch64.tar.gz";
     };
   };
 }
diff --git a/pkgs/development/compilers/hvm/default.nix b/pkgs/development/compilers/hvm/default.nix
index 03dcdcae6724..8342f0ee05b1 100644
--- a/pkgs/development/compilers/hvm/default.nix
+++ b/pkgs/development/compilers/hvm/default.nix
@@ -28,6 +28,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "A pure functional compile target that is lazy, non-garbage-collected, and parallel";
+    mainProgram = "hvm";
     homepage = "https://github.com/higherorderco/hvm";
     license = licenses.mit;
     maintainers = with maintainers; [ figsoda ];
diff --git a/pkgs/development/compilers/idris2/idris2-lsp.nix b/pkgs/development/compilers/idris2/idris2-lsp.nix
index a9587588417a..095b973cc0cb 100644
--- a/pkgs/development/compilers/idris2/idris2-lsp.nix
+++ b/pkgs/development/compilers/idris2/idris2-lsp.nix
@@ -43,6 +43,7 @@ let
 
     meta = with lib; {
       description = "Language Server for Idris2";
+      mainProgram = "idris2-lsp";
       homepage = "https://github.com/idris-community/idris2-lsp";
       license = licenses.bsd3;
       maintainers = with maintainers; [ mattpolzin ];
diff --git a/pkgs/development/compilers/idris2/idris2.nix b/pkgs/development/compilers/idris2/idris2.nix
index 88c4d05703cf..421fb93cf03b 100644
--- a/pkgs/development/compilers/idris2/idris2.nix
+++ b/pkgs/development/compilers/idris2/idris2.nix
@@ -89,6 +89,7 @@ in stdenv.mkDerivation rec {
 
   meta = {
     description = "A purely functional programming language with first class types";
+    mainProgram = "idris2";
     homepage = "https://github.com/idris-lang/Idris2";
     license = lib.licenses.bsd3;
     maintainers = with lib.maintainers; [ fabianhjr wchresta mattpolzin ];
diff --git a/pkgs/development/compilers/inform7/default.nix b/pkgs/development/compilers/inform7/default.nix
index 24bc14c0b3a9..0fba6d7c4a49 100644
--- a/pkgs/development/compilers/inform7/default.nix
+++ b/pkgs/development/compilers/inform7/default.nix
@@ -23,6 +23,7 @@ in stdenv.mkDerivation {
 
   meta = with lib; {
     description = "A design system for interactive fiction";
+    mainProgram = "i7";
     homepage = "http://inform7.com/";
     license = licenses.artistic2;
     maintainers = with maintainers; [ mbbx6spp ];
diff --git a/pkgs/development/compilers/inklecate/default.nix b/pkgs/development/compilers/inklecate/default.nix
index ac32e2954937..fa701d8fd269 100644
--- a/pkgs/development/compilers/inklecate/default.nix
+++ b/pkgs/development/compilers/inklecate/default.nix
@@ -29,6 +29,7 @@ buildDotnetModule rec {
 
   meta = with lib; {
     description = "Compiler for ink, inkle's scripting language";
+    mainProgram = "inklecate";
     longDescription = ''
       Inklecate is a command-line compiler for ink, inkle's open source
       scripting language for writing interactive narrative
diff --git a/pkgs/development/compilers/ispc/default.nix b/pkgs/development/compilers/ispc/default.nix
index 0c710b0736a3..b7f2ad1228b7 100644
--- a/pkgs/development/compilers/ispc/default.nix
+++ b/pkgs/development/compilers/ispc/default.nix
@@ -68,6 +68,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage    = "https://ispc.github.io/";
     description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
+    mainProgram = "ispc";
     license     = licenses.bsd3;
     platforms   = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; # TODO: buildable on more platforms?
     maintainers = with maintainers; [ aristid thoughtpolice athas alexfmpe ];
diff --git a/pkgs/development/compilers/jasmin/default.nix b/pkgs/development/compilers/jasmin/default.nix
index db58f48b97bb..685e6aa9537e 100644
--- a/pkgs/development/compilers/jasmin/default.nix
+++ b/pkgs/development/compilers/jasmin/default.nix
@@ -5,7 +5,7 @@
 , ant
 , jdk8
 , makeWrapper
-, canonicalize-jars-hook
+, stripJavaArchivesHook
 , callPackage
 }:
 
@@ -27,7 +27,7 @@ in stdenv.mkDerivation (finalAttrs: {
     ant
     jdk
     makeWrapper
-    canonicalize-jars-hook
+    stripJavaArchivesHook
   ];
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/julia/generic.nix b/pkgs/development/compilers/julia/generic.nix
index 4ab317618a41..7f690d44e163 100644
--- a/pkgs/development/compilers/julia/generic.nix
+++ b/pkgs/development/compilers/julia/generic.nix
@@ -83,6 +83,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "High-level performance-oriented dynamical language for technical computing";
+    mainProgram = "julia";
     homepage = "https://julialang.org/";
     license = licenses.mit;
     maintainers = with maintainers; [ nickcao joshniemela thomasjm ];
diff --git a/pkgs/development/compilers/juniper/default.nix b/pkgs/development/compilers/juniper/default.nix
index ff6751104ac0..edf3e4b6374c 100644
--- a/pkgs/development/compilers/juniper/default.nix
+++ b/pkgs/development/compilers/juniper/default.nix
@@ -28,6 +28,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Functional reactive programming language for programming Arduino";
+    mainProgram = "juniper";
     longDescription = ''
       Juniper targets Arduino and supports many features typical of functional programming languages, including algebraic data types, tuples, records,
       pattern matching, immutable data structures, parametric polymorphic functions, and anonymous functions (lambdas).
diff --git a/pkgs/development/compilers/kind2/default.nix b/pkgs/development/compilers/kind2/default.nix
index 182e4cb1a0e9..95eedb80670f 100644
--- a/pkgs/development/compilers/kind2/default.nix
+++ b/pkgs/development/compilers/kind2/default.nix
@@ -25,6 +25,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "A functional programming language and proof assistant";
+    mainProgram = "kind2";
     homepage = "https://github.com/higherorderco/kind";
     license = licenses.mit;
     maintainers = with maintainers; [ figsoda ];
diff --git a/pkgs/development/compilers/koka/default.nix b/pkgs/development/compilers/koka/default.nix
index 4057ec157eba..4dcc772ab55f 100644
--- a/pkgs/development/compilers/koka/default.nix
+++ b/pkgs/development/compilers/koka/default.nix
@@ -2,6 +2,7 @@
 , pkgsHostTarget
 , cmake
 , makeWrapper
+, fetchpatch
 , mkDerivation
 , fetchFromGitHub
 , alex
@@ -19,7 +20,7 @@
 , FloatingHex
 , isocline
 , lens
-, lsp
+, lsp_2_4_0_0
 , mtl
 , network
 , network-simple
@@ -64,6 +65,14 @@ mkDerivation rec {
   isLibrary = false;
   isExecutable = true;
   libraryToolDepends = [ hpack ];
+  patches = [
+    (fetchpatch {
+      name = "koka-stackage-22.patch";
+      url = "https://github.com/koka-lang/koka/commit/95f9b360544996e06d4bb33321a83a6b9605d092.patch";
+      sha256 = "1a1sv1r393wkhsnj56awsi8mqxakqdy86p7dg9i9xfv13q2g4h6x";
+      includes = [ "src/**" ];
+    })
+  ];
   executableHaskellDepends = [
     aeson
     array
@@ -77,7 +86,7 @@ mkDerivation rec {
     FloatingHex
     isocline
     lens
-    lsp
+    lsp_2_4_0_0
     mtl
     network
     network-simple
diff --git a/pkgs/development/compilers/lesscpy/default.nix b/pkgs/development/compilers/lesscpy/default.nix
index d85b36da8918..52372bb1edce 100644
--- a/pkgs/development/compilers/lesscpy/default.nix
+++ b/pkgs/development/compilers/lesscpy/default.nix
@@ -17,6 +17,7 @@ python3Packages.buildPythonApplication rec {
 
   meta = with lib; {
     description = "Python LESS Compiler";
+    mainProgram = "lesscpy";
     homepage    = "https://github.com/lesscpy/lesscpy";
     license     = licenses.mit;
     maintainers = with maintainers; [ s1341 ];
diff --git a/pkgs/development/compilers/ligo/default.nix b/pkgs/development/compilers/ligo/default.nix
index 3027aa52c5e4..9443f7a8cc08 100644
--- a/pkgs/development/compilers/ligo/default.nix
+++ b/pkgs/development/compilers/ligo/default.nix
@@ -127,6 +127,7 @@ ocamlPackages.buildDunePackage rec {
     homepage = "https://ligolang.org/";
     downloadPage = "https://ligolang.org/docs/intro/installation";
     description = "A friendly Smart Contract Language for Tezos";
+    mainProgram = "ligo";
     license = licenses.mit;
     platforms = ocamlPackages.ocaml.meta.platforms;
     broken = stdenv.isLinux && stdenv.isAarch64;
diff --git a/pkgs/development/compilers/llvm/11/clang/default.nix b/pkgs/development/compilers/llvm/11/clang/default.nix
deleted file mode 100644
index a31d0422f52b..000000000000
--- a/pkgs/development/compilers/llvm/11/clang/default.nix
+++ /dev/null
@@ -1,138 +0,0 @@
-{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
-, buildLlvmTools
-, fixDarwinDylibNames
-, enableManpages ? false
-, enablePolly ? false
-}:
-
-let
-  self = stdenv.mkDerivation ({
-    pname = "clang";
-    inherit version;
-
-    src = fetch "clang" "12sm91qx2m79cvj75a9aazf2x8xybjbd593dv6v7rxficpq8i0ha";
-    inherit clang-tools-extra_src;
-
-    unpackPhase = ''
-      unpackFile $src
-      mv clang-* clang
-      sourceRoot=$PWD/clang
-      unpackFile ${clang-tools-extra_src}
-      mv clang-tools-extra-* $sourceRoot/tools/extra
-    '';
-
-    nativeBuildInputs = [ cmake python3 ]
-      ++ lib.optional enableManpages python3.pkgs.sphinx
-      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
-
-    buildInputs = [ libxml2 libllvm ];
-
-    cmakeFlags = [
-      "-DCLANGD_BUILD_XPC=OFF"
-      "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ lib.optionals enableManpages [
-      "-DCLANG_INCLUDE_DOCS=ON"
-      "-DLLVM_ENABLE_SPHINX=ON"
-      "-DSPHINX_OUTPUT_MAN=ON"
-      "-DSPHINX_OUTPUT_HTML=OFF"
-      "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-    ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
-      "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
-      "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
-    ] ++ lib.optionals enablePolly [
-      "-DWITH_POLLY=ON"
-      "-DLINK_POLLY_INTO_TOOLS=ON"
-    ];
-
-
-    patches = [
-      ./purity.patch
-      # https://reviews.llvm.org/D51899
-      ./gnu-install-dirs.patch
-      (substituteAll {
-        src = ../../common/clang/clang-11-15-LLVMgold-path.patch;
-        libllvmLibdir = "${libllvm.lib}/lib";
-      })
-    ];
-
-    postPatch = ''
-      sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
-             -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
-             lib/Driver/ToolChains/*.cpp
-    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
-      sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
-    '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
-      substituteInPlace tools/extra/clangd/CMakeLists.txt \
-        --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
-    '';
-
-    outputs = [ "out" "lib" "dev" "python" ];
-
-    postInstall = ''
-      ln -sv $out/bin/clang $out/bin/cpp
-
-      # Move libclang to 'lib' output
-      moveToOutput "lib/libclang.*" "$lib"
-      moveToOutput "lib/libclang-cpp.*" "$lib"
-      substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
-          --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
-          --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
-
-      mkdir -p $python/bin $python/share/{clang,scan-view}
-      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
-      mv $out/share/scan-view/*.py $python/share/scan-view
-      rm $out/bin/c-index-test
-      patchShebangs $python/bin
-
-      mkdir -p $dev/bin
-      cp bin/clang-tblgen $dev/bin
-    '';
-
-    passthru = {
-      inherit libllvm;
-      isClang = true;
-      hardeningUnsupportedFlags = [ "fortify3" "zerocallusedregs" ];
-    };
-
-    meta = llvm_meta // {
-      homepage = "https://clang.llvm.org/";
-      description = "A C language family frontend for LLVM";
-      longDescription = ''
-        The Clang project provides a language front-end and tooling
-        infrastructure for languages in the C language family (C, C++, Objective
-        C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
-        It aims to deliver amazingly fast compiles, extremely useful error and
-        warning messages and to provide a platform for building great source
-        level tools. The Clang Static Analyzer and clang-tidy are tools that
-        automatically find bugs in your code, and are great examples of the sort
-        of tools that can be built using the Clang frontend as a library to
-        parse C/C++ code.
-      '';
-      mainProgram = "clang";
-    };
-  } // 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 = llvm_meta // {
-      description = "man page for Clang ${version}";
-    };
-  });
-in self
diff --git a/pkgs/development/compilers/llvm/11/clang/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/clang/gnu-install-dirs.patch
deleted file mode 100644
index 98ea97e05808..000000000000
--- a/pkgs/development/compilers/llvm/11/clang/gnu-install-dirs.patch
+++ /dev/null
@@ -1,235 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index bb4b801f01c8..77a8b43b22c8 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -9,6 +9,8 @@ endif()
- if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
-   project(Clang)
- 
-+  include(GNUInstallDirs)
-+
-   set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
-   set(CMAKE_CXX_STANDARD_REQUIRED YES)
-   set(CMAKE_CXX_EXTENSIONS NO)
-@@ -447,7 +449,7 @@ include_directories(BEFORE
- 
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-   install(DIRECTORY include/clang include/clang-c
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     COMPONENT clang-headers
-     FILES_MATCHING
-     PATTERN "*.def"
-@@ -457,7 +459,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-     )
- 
-   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     COMPONENT clang-headers
-     FILES_MATCHING
-     PATTERN "CMakeFiles" EXCLUDE
-@@ -477,7 +479,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
- 
-   add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
-   install(PROGRAMS utils/bash-autocomplete.sh
--          DESTINATION share/clang
-+          DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-           COMPONENT bash-autocomplete)
-   if(NOT LLVM_ENABLE_IDE)
-     add_llvm_install_targets(install-bash-autocomplete
-diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
-index 704278a0e93b..d25c8d325c71 100644
---- a/cmake/modules/AddClang.cmake
-+++ b/cmake/modules/AddClang.cmake
-@@ -123,9 +123,9 @@ macro(add_clang_library name)
-         install(TARGETS ${lib}
-           COMPONENT ${lib}
-           ${export_to_clangtargets}
--          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
--          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
--          RUNTIME DESTINATION bin)
-+          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
-+          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
-+          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
- 
-         if (NOT LLVM_ENABLE_IDE)
-           add_llvm_install_targets(install-${lib}
-@@ -170,7 +170,7 @@ macro(add_clang_tool name)
- 
-     install(TARGETS ${name}
-       ${export_to_clangtargets}
--      RUNTIME DESTINATION bin
-+      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-       COMPONENT ${name})
- 
-     if(NOT LLVM_ENABLE_IDE)
-@@ -185,7 +185,7 @@ endmacro()
- macro(add_clang_symlink name dest)
-   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
-   # Always generate install targets
--  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
-+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
- endmacro()
- 
- function(clang_target_link_libraries target type)
-diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
-index 0692fe75a441..6f201e7207d0 100644
---- a/lib/Headers/CMakeLists.txt
-+++ b/lib/Headers/CMakeLists.txt
-@@ -208,7 +208,7 @@ set_target_properties(clang-resource-headers PROPERTIES
-   FOLDER "Misc"
-   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
- 
--set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
-+set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
- 
- install(
-   FILES ${files} ${generated_files}
-diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt
-index ceef4b08637c..8efad5520ca4 100644
---- a/tools/c-index-test/CMakeLists.txt
-+++ b/tools/c-index-test/CMakeLists.txt
-@@ -54,7 +54,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-     set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH
-        "@executable_path/../../lib")
-   else()
--    set(INSTALL_DESTINATION bin)
-+    set(INSTALL_DESTINATION ${CMAKE_INSTALL_BINDIR})
-   endif()
- 
-   install(TARGETS c-index-test
-diff --git a/tools/clang-format/CMakeLists.txt b/tools/clang-format/CMakeLists.txt
-index 35ecdb11253c..d77d75de0094 100644
---- a/tools/clang-format/CMakeLists.txt
-+++ b/tools/clang-format/CMakeLists.txt
-@@ -21,20 +21,20 @@ if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
- endif()
- 
- install(PROGRAMS clang-format-bbedit.applescript
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-format)
- install(PROGRAMS clang-format-diff.py
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-format)
- install(PROGRAMS clang-format-sublime.py
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-format)
- install(PROGRAMS clang-format.el
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-format)
- install(PROGRAMS clang-format.py
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-format)
- install(PROGRAMS git-clang-format
--  DESTINATION bin
-+  DESTINATION ${CMAKE_INSTALL_BINDIR}
-   COMPONENT clang-format)
-diff --git a/tools/clang-rename/CMakeLists.txt b/tools/clang-rename/CMakeLists.txt
-index cda8e29ec5b1..0134d8ccd70b 100644
---- a/tools/clang-rename/CMakeLists.txt
-+++ b/tools/clang-rename/CMakeLists.txt
-@@ -19,8 +19,8 @@ clang_target_link_libraries(clang-rename
-   )
- 
- install(PROGRAMS clang-rename.py
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-rename)
- install(PROGRAMS clang-rename.el
--  DESTINATION share/clang
-+  DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
-   COMPONENT clang-rename)
-diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
-index 5cd9ac5cddc1..a197676fedbd 100644
---- a/tools/libclang/CMakeLists.txt
-+++ b/tools/libclang/CMakeLists.txt
-@@ -165,7 +165,7 @@ endif()
- if(INTERNAL_INSTALL_PREFIX)
-   set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include")
- else()
--  set(LIBCLANG_HEADERS_INSTALL_DESTINATION include)
-+  set(LIBCLANG_HEADERS_INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
- endif()
- 
- install(DIRECTORY ../../include/clang-c
-@@ -196,7 +196,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS})
-           COMPONENT
-             libclang-python-bindings
-           DESTINATION
--            "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
-+            "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
- endforeach()
- if(NOT LLVM_ENABLE_IDE)
-   add_custom_target(libclang-python-bindings)
-diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt
-index ec0702d76f18..d25d982f51da 100644
---- a/tools/scan-build/CMakeLists.txt
-+++ b/tools/scan-build/CMakeLists.txt
-@@ -47,7 +47,7 @@ if(CLANG_INSTALL_SCANBUILD)
-                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
-     list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-     install(PROGRAMS bin/${BinFile}
--            DESTINATION bin
-+            DESTINATION ${CMAKE_INSTALL_BINDIR}
-             COMPONENT scan-build)
-   endforeach()
- 
-@@ -61,7 +61,7 @@ if(CLANG_INSTALL_SCANBUILD)
-                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
-     list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
-     install(PROGRAMS libexec/${LibexecFile}
--            DESTINATION libexec
-+            DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}
-             COMPONENT scan-build)
-   endforeach()
- 
-@@ -89,7 +89,7 @@ if(CLANG_INSTALL_SCANBUILD)
-                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
-     list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
-     install(FILES share/scan-build/${ShareFile}
--            DESTINATION share/scan-build
-+            DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-build
-             COMPONENT scan-build)
-   endforeach()
- 
-diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt
-index 22edb974bac7..9f140a9a4538 100644
---- a/tools/scan-view/CMakeLists.txt
-+++ b/tools/scan-view/CMakeLists.txt
-@@ -22,7 +22,7 @@ if(CLANG_INSTALL_SCANVIEW)
-                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
-     list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-     install(PROGRAMS bin/${BinFile}
--            DESTINATION bin
-+            DESTINATION ${CMAKE_INSTALL_BINDIR}
-             COMPONENT scan-view)
-   endforeach()
- 
-@@ -36,7 +36,7 @@ if(CLANG_INSTALL_SCANVIEW)
-                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
-     list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
-     install(FILES share/${ShareFile}
--            DESTINATION share/scan-view
-+            DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-view
-             COMPONENT scan-view)
-   endforeach()
- 
-diff --git a/utils/hmaptool/CMakeLists.txt b/utils/hmaptool/CMakeLists.txt
-index 62f2de0cb15c..6aa66825b6ec 100644
---- a/utils/hmaptool/CMakeLists.txt
-+++ b/utils/hmaptool/CMakeLists.txt
-@@ -10,7 +10,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HM
- 
- list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
- install(PROGRAMS ${CLANG_HMAPTOOL}
--        DESTINATION bin
-+        DESTINATION ${CMAKE_INSTALL_BINDIR}
-         COMPONENT hmaptool)
- 
- add_custom_target(hmaptool ALL DEPENDS ${Depends})
diff --git a/pkgs/development/compilers/llvm/11/clang/purity.patch b/pkgs/development/compilers/llvm/11/clang/purity.patch
deleted file mode 100644
index deb230a36c5b..000000000000
--- a/pkgs/development/compilers/llvm/11/clang/purity.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
-From: Will Dietz <w@wdtz.org>
-Date: Thu, 18 May 2017 11:56:12 -0500
-Subject: [PATCH] "purity" patch for 5.0
-
----
- lib/Driver/ToolChains/Gnu.cpp | 7 -------
- 1 file changed, 7 deletions(-)
-
-diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
-index fe3c0191bb..c6a482bece 100644
---- a/lib/Driver/ToolChains/Gnu.cpp
-+++ b/lib/Driver/ToolChains/Gnu.cpp
-@@ -487,12 +487,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
-   if (!IsStatic) {
-     if (Args.hasArg(options::OPT_rdynamic))
-       CmdArgs.push_back("-export-dynamic");
--
--    if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
--      CmdArgs.push_back("-dynamic-linker");
--      CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
--                                           ToolChain.getDynamicLinker(Args)));
--    }
-   }
- 
-   CmdArgs.push_back("-o");
--- 
-2.11.0
diff --git a/pkgs/development/compilers/llvm/11/compiler-rt/X86-support-extension.patch b/pkgs/development/compilers/llvm/11/compiler-rt/X86-support-extension.patch
deleted file mode 100644
index f6f9336ad5ad..000000000000
--- a/pkgs/development/compilers/llvm/11/compiler-rt/X86-support-extension.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt
-index 3a66dd9c3fb..7efc85d9f9f 100644
---- a/lib/builtins/CMakeLists.txt
-+++ b/lib/builtins/CMakeLists.txt
-@@ -301,6 +301,10 @@ if (NOT MSVC)
-     i386/umoddi3.S
-   )
- 
-+  set(i486_SOURCES ${i386_SOURCES})
-+  set(i586_SOURCES ${i386_SOURCES})
-+  set(i686_SOURCES ${i386_SOURCES})
-+
-   if (WIN32)
-     set(i386_SOURCES
-       ${i386_SOURCES}
-@@ -608,6 +612,7 @@ else ()
-   endif()
- 
-   foreach (arch ${BUILTIN_SUPPORTED_ARCH})
-+      message("arch: ${arch}")
-     if (CAN_TARGET_${arch})
-       # For ARM archs, exclude any VFP builtins if VFP is not supported
-       if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
diff --git a/pkgs/development/compilers/llvm/11/compiler-rt/armv7l.patch b/pkgs/development/compilers/llvm/11/compiler-rt/armv7l.patch
deleted file mode 100644
index 120cfe6feb2a..000000000000
--- a/pkgs/development/compilers/llvm/11/compiler-rt/armv7l.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-diff -ur compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake
---- compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake	2020-03-24 00:01:02.000000000 +0900
-+++ compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake	2020-05-10 03:42:00.883450706 +0900
-@@ -24,7 +24,7 @@
- 
- 
- set(ARM64 aarch64)
--set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)
-+set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l)
- set(HEXAGON hexagon)
- set(X86 i386)
- set(X86_64 x86_64)
-diff -ur compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt
---- compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt	2020-03-24 00:01:02.000000000 +0900
-+++ compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt	2020-05-10 03:44:49.468579650 +0900
-@@ -474,6 +474,7 @@
- set(armv7_SOURCES ${arm_SOURCES})
- set(armv7s_SOURCES ${arm_SOURCES})
- set(armv7k_SOURCES ${arm_SOURCES})
-+set(armv7l_SOURCES ${arm_SOURCES})
- set(arm64_SOURCES ${aarch64_SOURCES})
- 
- # macho_embedded archs
-@@ -595,7 +596,7 @@
-   foreach (arch ${BUILTIN_SUPPORTED_ARCH})
-     if (CAN_TARGET_${arch})
-       # For ARM archs, exclude any VFP builtins if VFP is not supported
--      if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
-+      if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$")
-         string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
-         check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP)
-         if(NOT COMPILER_RT_HAS_${arch}_VFP)
diff --git a/pkgs/development/compilers/llvm/11/compiler-rt/default.nix b/pkgs/development/compilers/llvm/11/compiler-rt/default.nix
deleted file mode 100644
index 7fddc6e924b9..000000000000
--- a/pkgs/development/compilers/llvm/11/compiler-rt/default.nix
+++ /dev/null
@@ -1,140 +0,0 @@
-{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, xcbuild, libllvm, libcxxabi, libxcrypt
-, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
-}:
-
-let
-
-  useLLVM = stdenv.hostPlatform.useLLVM or false;
-  isNewDarwinBootstrap = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;
-  bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
-  haveLibc = stdenv.cc.libc != null;
-  inherit (stdenv.hostPlatform) isMusl;
-
-in
-
-stdenv.mkDerivation {
-  pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
-  inherit version;
-  src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy";
-
-  nativeBuildInputs = [ cmake python3 libllvm.dev ]
-     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
-
-  env.NIX_CFLAGS_COMPILE = toString [
-    "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
-  ];
-
-  cmakeFlags = [
-    "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
-    "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-    "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ lib.optionals (haveLibc && stdenv.hostPlatform.isGnu) [
-    "-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include"
-  ] ++ lib.optionals (useLLVM || bareMetal || isMusl || isNewDarwinBootstrap) [
-    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
-    "-DCOMPILER_RT_BUILD_XRAY=OFF"
-    "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
-  ] ++ lib.optionals (useLLVM || bareMetal) [
-    "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ lib.optionals (!haveLibc || bareMetal) [
-    "-DCMAKE_C_COMPILER_WORKS=ON"
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
-    "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ lib.optionals (useLLVM || isNewDarwinBootstrap) [
-    "-DCOMPILER_RT_BUILD_BUILTINS=ON"
-    #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
-    "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ lib.optionals (bareMetal) [
-    "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
-    "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
-    "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
-    "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  patches = [
-    ../../common/compiler-rt/7-12-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
-    ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
-    ./gnu-install-dirs.patch
-    # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
-    # extra `/`.
-    ./normalize-var.patch
-    ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch
-    ../../common/compiler-rt/darwin-plistbuddy-workaround.patch
-    ./armv7l.patch
-    # Fix build on armv6l
-    ../../common/compiler-rt/armv6-mcr-dmb.patch
-    ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch
-    ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch
-  ];
-
-  preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
-    cmakeFlagsArray+=("-DCMAKE_LIPO=$(command -v ${stdenv.cc.targetPrefix}lipo)")
-  '' + lib.optionalString (!haveLibc) ''
-    cmakeFlagsArray+=("-DCMAKE_C_FLAGS=-nodefaultlibs -ffreestanding")
-  '';
-
-  # 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 = lib.optionalString (!stdenv.isDarwin) ''
-    substituteInPlace cmake/builtin-config-ix.cmake \
-      --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-    substituteInPlace cmake/config-ix.cmake \
-      --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace cmake/config-ix.cmake \
-      --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + lib.optionalString (useLLVM) ''
-    substituteInPlace lib/builtins/int_util.c \
-      --replace "#include <stdlib.h>" ""
-    substituteInPlace lib/builtins/clear_cache.c \
-      --replace "#include <assert.h>" ""
-    substituteInPlace lib/builtins/cpu_model.c \
-      --replace "#include <assert.h>" ""
-  '';
-
-  # Hack around weird upsream RPATH bug
-  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
-    ln -s "$out/lib"/*/* "$out/lib"
-  '' + lib.optionalString (useLLVM) ''
-    ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
-    ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
-    ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o
-    ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o
-    ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
-    ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
-  ''
-  # See https://reviews.llvm.org/D37278 for why android exception
-  + lib.optionalString (stdenv.hostPlatform.isx86_32 && !stdenv.hostPlatform.isAndroid) ''
-    for f in $out/lib/*/*builtins-i?86*; do
-      ln -s "$f" $(echo "$f" | sed -e 's/builtins-i.86/builtins-i386/')
-    done
-  '' + lib.optionalString doFakeLibgcc ''
-    ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a
-  '';
-
-  meta = llvm_meta // {
-    homepage = "https://compiler-rt.llvm.org/";
-    description = "Compiler runtime libraries";
-    longDescription = ''
-      The compiler-rt project provides highly tuned implementations of the
-      low-level code generator support routines like "__fixunsdfdi" and other
-      calls generated when a target doesn't have a short sequence of native
-      instructions to implement a core IR operation. It also provides
-      implementations of run-time libraries for dynamic testing tools such as
-      AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
-    '';
-    # "All of the code in the compiler-rt project is dual licensed under the MIT
-    # license and the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    # compiler-rt requires a Clang stdenv on 32-bit RISC-V:
-    # https://reviews.llvm.org/D43106#1019077
-    broken = stdenv.hostPlatform.isRiscV32 && !stdenv.cc.isClang;
-  };
-}
diff --git a/pkgs/development/compilers/llvm/11/compiler-rt/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/compiler-rt/gnu-install-dirs.patch
deleted file mode 100644
index 91e208829295..000000000000
--- a/pkgs/development/compilers/llvm/11/compiler-rt/gnu-install-dirs.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index fa62814b635d..6328614d829e 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -12,6 +12,7 @@ endif()
- # Check if compiler-rt is built as a standalone project.
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD)
-   project(CompilerRT C CXX ASM)
-+  include(GNUInstallDirs)
-   set(COMPILER_RT_STANDALONE_BUILD TRUE)
-   set_property(GLOBAL PROPERTY USE_FOLDERS ON)
- endif()
-diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
-index 7c127a93dfa7..6a95a65b70a7 100644
---- a/cmake/Modules/AddCompilerRT.cmake
-+++ b/cmake/Modules/AddCompilerRT.cmake
-@@ -524,7 +524,7 @@ macro(add_compiler_rt_resource_file target_name file_name component)
-   add_custom_target(${target_name} DEPENDS ${dst_file})
-   # Install in Clang resource directory.
-   install(FILES ${file_name}
--    DESTINATION ${COMPILER_RT_INSTALL_PATH}/share
-+    DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_DATADIR}
-     COMPONENT ${component})
-   add_dependencies(${component} ${target_name})
- 
-@@ -541,7 +541,7 @@ macro(add_compiler_rt_script name)
-   add_custom_target(${name} DEPENDS ${dst})
-   install(FILES ${dst}
-     PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
--    DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin)
-+    DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_BINDIR})
- endmacro(add_compiler_rt_script src name)
- 
- # Builds custom version of libc++ and installs it in <prefix>.
-diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake
-index be8d7e733c7a..ab256bdff26c 100644
---- a/cmake/Modules/CompilerRTDarwinUtils.cmake
-+++ b/cmake/Modules/CompilerRTDarwinUtils.cmake
-@@ -498,7 +498,7 @@ macro(darwin_add_embedded_builtin_libraries)
-     set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
-       ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
-     set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
--      ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
-+      ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/macho_embedded)
-       
-     set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
-     set(CFLAGS_i386 "-march=pentium")
-diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
-index 99b9f0e4af44..c5183ffa746e 100644
---- a/cmake/Modules/CompilerRTUtils.cmake
-+++ b/cmake/Modules/CompilerRTUtils.cmake
-@@ -375,7 +375,7 @@ endfunction()
- function(get_compiler_rt_install_dir arch install_dir)
-   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-     get_compiler_rt_target(${arch} target)
--    set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE)
-+    set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/${target} PARENT_SCOPE)
-   else()
-     set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
-   endif()
-diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake
-index 964dd598f102..2acaab87d349 100644
---- a/cmake/base-config-ix.cmake
-+++ b/cmake/base-config-ix.cmake
-@@ -66,11 +66,11 @@ if (LLVM_TREE_AVAILABLE)
- else()
-     # Take output dir and install path from the user.
-   set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH
--    "Path where built compiler-rt libraries should be stored.")
-+    "Path where built compiler-rt build artifacts should be stored.")
-   set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH
-     "Path where built compiler-rt executables should be stored.")
--  set(COMPILER_RT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH
--    "Path where built compiler-rt libraries should be installed.")
-+  set(COMPILER_RT_INSTALL_PATH "" CACHE PATH
-+    "Prefix where built compiler-rt artifacts should be installed, comes before CMAKE_INSTALL_PREFIX.")
-   option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." OFF)
-   option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" OFF)
-   # Use a host compiler to compile/link tests.
-@@ -98,7 +98,7 @@ else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
-   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
-     ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
-   set(COMPILER_RT_LIBRARY_INSTALL_DIR
--    ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
-+    ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/${COMPILER_RT_OS_DIR})
- endif()
- 
- if(APPLE)
-diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
-index d47d7baeb118..507c8e5c713e 100644
---- a/include/CMakeLists.txt
-+++ b/include/CMakeLists.txt
-@@ -62,22 +62,22 @@ set_target_properties(compiler-rt-headers PROPERTIES FOLDER "Compiler-RT Misc")
- install(FILES ${SANITIZER_HEADERS}
-   COMPONENT compiler-rt-headers
-   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
--  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer)
-+  DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_INCLUDEDIR}/sanitizer)
- # Install fuzzer headers.
- install(FILES ${FUZZER_HEADERS}
-   COMPONENT compiler-rt-headers
-   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
--  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer)
-+  DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_INCLUDEDIR}/fuzzer)
- # Install xray headers.
- install(FILES ${XRAY_HEADERS}
-   COMPONENT compiler-rt-headers
-   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
--  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray)
-+  DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_INCLUDEDIR}/xray)
- # Install profile headers.
- install(FILES ${PROFILE_HEADERS}
-   COMPONENT compiler-rt-headers
-   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
--  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/profile)
-+  DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_INCLUDEDIR}/profile)
- 
- if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs.
-   add_custom_target(install-compiler-rt-headers
-diff --git a/lib/dfsan/CMakeLists.txt b/lib/dfsan/CMakeLists.txt
-index 051215edbeb7..ecce1f52efb0 100644
---- a/lib/dfsan/CMakeLists.txt
-+++ b/lib/dfsan/CMakeLists.txt
-@@ -56,4 +56,4 @@ add_custom_command(OUTPUT ${dfsan_abilist_filename}
-                    DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
- add_dependencies(dfsan dfsan_abilist)
- install(FILES ${dfsan_abilist_filename}
--        DESTINATION ${COMPILER_RT_INSTALL_PATH}/share)
-+        DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_DATADIR})
diff --git a/pkgs/development/compilers/llvm/11/compiler-rt/normalize-var.patch b/pkgs/development/compilers/llvm/11/compiler-rt/normalize-var.patch
deleted file mode 100644
index b9986910e516..000000000000
--- a/pkgs/development/compilers/llvm/11/compiler-rt/normalize-var.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
-index c5183ffa746e..e4e4a007335d 100644
---- a/cmake/Modules/CompilerRTUtils.cmake
-+++ b/cmake/Modules/CompilerRTUtils.cmake
-@@ -299,8 +299,9 @@ macro(load_llvm_config)
-     # Get some LLVM variables from LLVMConfig.
-     include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
- 
--    set(LLVM_LIBRARY_OUTPUT_INTDIR
--      ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
-+    get_filename_component(LLVM_LIBRARY_OUTPUT_INTDIR
-+      ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}
-+      REALPATH)
-   endif()
- endmacro()
- 
diff --git a/pkgs/development/compilers/llvm/11/default.nix b/pkgs/development/compilers/llvm/11/default.nix
deleted file mode 100644
index 3044199e2811..000000000000
--- a/pkgs/development/compilers/llvm/11/default.nix
+++ /dev/null
@@ -1,285 +0,0 @@
-{ lowPrio, newScope, pkgs, lib, stdenv, cmake
-, preLibcCrossHeaders
-, 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
-, targetLlvm
-# This is the default binutils, but with *this* version of LLD rather
-# than the default LLVM version's, if LLD is the choice. We use these for
-# the `useLLVM` bootstrapping below.
-, bootBintoolsNoLibc ?
-    if stdenv.targetPlatform.linker == "lld"
-    then null
-    else pkgs.bintoolsNoLibc
-, bootBintools ?
-    if stdenv.targetPlatform.linker == "lld"
-    then null
-    else pkgs.bintools
-}:
-
-let
-  release_version = "11.1.0";
-  candidate = ""; # empty or "rcN"
-  dash-candidate = lib.optionalString (candidate != "") "-${candidate}";
-  version = "${release_version}${dash-candidate}"; # differentiating these (variables) is important for RCs
-
-  fetch = name: sha256: fetchurl {
-    url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/${name}-${release_version}${candidate}.src.tar.xz";
-    inherit sha256;
-  };
-
-  clang-tools-extra_src = fetch "clang-tools-extra" "18n1w1hkv931xzq02b34wglbv6zd6sd0r5kb8piwvag7klj7qw3n";
-
-  inherit (import ../common/common-let.nix { inherit lib release_version; }) llvm_meta;
-
-  tools = lib.makeExtensible (tools: let
-    callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
-    mkExtraBuildCommands0 = cc: ''
-      rsrc="$out/resource-root"
-      mkdir "$rsrc"
-      ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc"
-      echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '';
-    mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
-      ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
-      ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
-    '';
-
-  bintoolsNoLibc' =
-    if bootBintoolsNoLibc == null
-    then tools.bintoolsNoLibc
-    else bootBintoolsNoLibc;
-  bintools' =
-    if bootBintools == null
-    then tools.bintools
-    else bootBintools;
-
-  in {
-
-    libllvm = callPackage ./llvm {
-      inherit llvm_meta;
-    };
-
-    # `llvm` historically had the binaries.  When choosing an output explicitly,
-    # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
-    llvm = tools.libllvm;
-
-    libllvm-polly = callPackage ./llvm {
-      inherit llvm_meta;
-      enablePolly = true;
-    };
-
-    llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; };
-
-    libclang = callPackage ./clang {
-      inherit clang-tools-extra_src llvm_meta;
-    };
-
-    clang-unwrapped = tools.libclang;
-
-    clang-polly-unwrapped = callPackage ./clang {
-      inherit llvm_meta;
-      inherit clang-tools-extra_src;
-      libllvm = tools.libllvm-polly;
-      enablePolly = true;
-    };
-
-    llvm-manpages = lowPrio (tools.libllvm.override {
-      enableManpages = true;
-      python3 = pkgs.python3;  # don't use python-boot
-    });
-
-    clang-manpages = lowPrio (tools.libclang.override {
-      enableManpages = true;
-      python3 = pkgs.python3;  # don't use python-boot
-    });
-
-    # disabled until recommonmark supports sphinx 3
-    # lldb-manpages = lowPrio (tools.lldb.override {
-    #   enableManpages = true;
-    #   python3 = pkgs.python3;  # don't use python-boot
-    # });
-
-    # pick clang appropriate for package set we are targeting
-    clang =
-      /**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
-      else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
-      else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
-      else tools.libcxxClang;
-
-    libstdcxxClang = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      # libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
-      libcxx = null;
-      extraPackages = [
-        targetLlvmLibraries.compiler-rt
-      ];
-      extraBuildCommands = mkExtraBuildCommands cc;
-    };
-
-    libcxxClang = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      libcxx = targetLlvmLibraries.libcxx;
-      extraPackages = [
-        libcxx.cxxabi
-        targetLlvmLibraries.compiler-rt
-      ];
-      extraBuildCommands = mkExtraBuildCommands cc;
-    };
-
-    lld = callPackage ./lld {
-      inherit llvm_meta;
-    };
-
-    lldb = callPackage ../common/lldb.nix {
-      src = fetch "lldb" "1vlyg015dyng43xqb8cg2l6r9ix8klibxsajazbfnckdnh54hwxj";
-      patches = [
-        ./lldb/procfs.patch
-        ./lldb/gnu-install-dirs.patch
-      ];
-      inherit llvm_meta;
-    };
-
-    # Below, is the LLVM bootstrapping logic. It handles building a
-    # fully LLVM toolchain from scratch. No GCC toolchain should be
-    # pulled in. As a consequence, it is very quick to build different
-    # targets provided by LLVM and we can also build for what GCC
-    # doesn’t support like LLVM. Probably we should move to some other
-    # file.
-
-    bintools-unwrapped = callPackage ../common/bintools.nix { };
-
-    bintoolsNoLibc = wrapBintoolsWith {
-      bintools = tools.bintools-unwrapped;
-      libc = preLibcCrossHeaders;
-    };
-
-    bintools = wrapBintoolsWith {
-      bintools = tools.bintools-unwrapped;
-    };
-
-    clangUseLLVM = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      libcxx = targetLlvmLibraries.libcxx;
-      bintools = bintools';
-      extraPackages = [
-        libcxx.cxxabi
-        targetLlvmLibraries.compiler-rt
-      ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
-        targetLlvmLibraries.libunwind
-      ];
-      extraBuildCommands = ''
-        echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
-        echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
-        echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
-        echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags
-      '' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) ''
-        echo "-lunwind" >> $out/nix-support/cc-ldflags
-      '' + lib.optionalString stdenv.targetPlatform.isWasm ''
-        echo "-fno-exceptions" >> $out/nix-support/cc-cflags
-      '' + mkExtraBuildCommands cc;
-    };
-
-    clangNoLibcxx = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      libcxx = null;
-      bintools = bintools';
-      extraPackages = [
-        targetLlvmLibraries.compiler-rt
-      ];
-      extraBuildCommands = ''
-        echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
-        echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-        echo "-nostdlib++" >> $out/nix-support/cc-cflags
-      '' + mkExtraBuildCommands cc;
-    };
-
-    clangNoLibc = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      libcxx = null;
-      bintools = bintoolsNoLibc';
-      extraPackages = [
-        targetLlvmLibraries.compiler-rt
-      ];
-      extraBuildCommands = ''
-        echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
-        echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + mkExtraBuildCommands cc;
-    };
-
-    clangNoCompilerRt = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      libcxx = null;
-      bintools = bintoolsNoLibc';
-      extraPackages = [ ];
-      extraBuildCommands = ''
-        echo "-nostartfiles" >> $out/nix-support/cc-cflags
-      '' + mkExtraBuildCommands0 cc;
-    };
-
-    clangNoCompilerRtWithLibc = wrapCCWith rec {
-      cc = tools.clang-unwrapped;
-      libcxx = null;
-      bintools = bintools';
-      extraPackages = [ ];
-      extraBuildCommands = mkExtraBuildCommands0 cc;
-    };
-
-  });
-
-  libraries = lib.makeExtensible (libraries: let
-    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
-  in {
-
-    compiler-rt-libc = callPackage ./compiler-rt {
-      inherit llvm_meta;
-      stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) || (stdenv.hostPlatform.isRiscV && stdenv.hostPlatform.is32bit)
-               then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
-               else stdenv;
-    };
-
-    compiler-rt-no-libc = callPackage ./compiler-rt {
-      inherit llvm_meta;
-      stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
-               then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
-               else stdenv;
-    };
-
-    # N.B. condition is safe because without useLLVM both are the same.
-    compiler-rt = if stdenv.hostPlatform.isAndroid || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) || (stdenv.hostPlatform.libc == "newlib")
-      then libraries.compiler-rt-libc
-      else libraries.compiler-rt-no-libc;
-
-    stdenv = overrideCC stdenv buildLlvmTools.clang;
-
-    libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
-
-    libcxx = callPackage ./libcxx {
-      inherit llvm_meta;
-      stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-    };
-
-    libcxxabi = callPackage ./libcxxabi {
-      inherit llvm_meta;
-      stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-    };
-
-    libunwind = callPackage ./libunwind {
-      inherit llvm_meta;
-      stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-    };
-
-    openmp = callPackage ./openmp {
-      inherit llvm_meta targetLlvm;
-    };
-  });
-  noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
-
-in { inherit tools libraries release_version; } // (noExtend libraries) // (noExtend tools)
diff --git a/pkgs/development/compilers/llvm/11/libcxx/default.nix b/pkgs/development/compilers/llvm/11/libcxx/default.nix
deleted file mode 100644
index 10b8c00dd16a..000000000000
--- a/pkgs/development/compilers/llvm/11/libcxx/default.nix
+++ /dev/null
@@ -1,104 +0,0 @@
-{ lib, stdenv, llvm_meta, fetch, fetchpatch, cmake, python3, llvm, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
-
-stdenv.mkDerivation {
-  pname = "libcxx";
-  inherit version;
-
-  src = fetch "libcxx" "1rgqsqpgi0vkga5d7hy0iyfsqgzfz7q1xy7afdfa1snp1qjks8xv";
-
-  postUnpack = ''
-    unpackFile ${libcxxabi.src}
-    mv libcxxabi-* libcxxabi
-    unpackFile ${llvm.src}
-    mv llvm-* llvm
-  '';
-
-  outputs = [ "out" "dev" ];
-
-  patches = [
-    (fetchpatch {
-      # Backported from LLVM 12, avoids clashes with commonly used "block.h" header.
-      url = "https://github.com/llvm/llvm-project/commit/19bc9ea480b60b607a3e303f20c7a3a2ea553369.patch";
-      sha256 = "sha256-aWa66ogmPkG0xHzSfcpD0qZyZQcNKwLV44js4eiun78=";
-      stripLen = 1;
-    })
-    ./gnu-install-dirs.patch
-  ] ++ lib.optionals stdenv.hostPlatform.isMusl [
-    ../../common/libcxx/libcxx-0001-musl-hacks.patch
-  ];
-
-  # Prevent errors like "error: 'foo' is unavailable: introduced in macOS yy.zz"
-  postPatch = ''
-    substituteInPlace include/__config \
-      --replace "#    define _LIBCPP_USE_AVAILABILITY_APPLE" ""
-  '';
-
-  preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
-    patchShebangs utils/cat_files.py
-  '';
-
-  nativeBuildInputs = [ cmake python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  buildInputs = [ cxxabi ];
-
-  cmakeFlags = [
-    "-DLIBCXX_CXX_ABI=${cxxabi.pname}"
-  ] ++ 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.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
-
-    # TODO: this is a bit of a hack to cross compile to Apple Silicon.  libcxx
-    # starting with 11 enables CMAKE_BUILD_WITH_INSTALL_NAME_DIR which requires
-    # platform setup for rpaths. In cmake, this is enabled when macos is newer
-    # than 10.5. However CMAKE_SYSTEM_VERSION is set to empty (TODO: why?)
-    # which prevents the conditional configuration, and configure fails.  The
-    # value here corresponds to `uname -r`. If stdenv.hostPlatform.release is
-    # not null, then this property will be set via mkDerivation (TODO: how can
-    # we set this?).
-    ++ lib.optional (
-      stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 &&
-      stdenv.hostPlatform != stdenv.buildPlatform
-    ) "-DCMAKE_SYSTEM_VERSION=20.1.0";
-
-  preInstall = lib.optionalString (stdenv.isDarwin) ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
-
-      baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
-      installName="$out/lib/$baseName"
-      abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
-
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
-      done
-    done
-  '';
-
-  passthru = {
-    isLLVM = true;
-    inherit cxxabi;
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxx.llvm.org/";
-    description = "C++ standard library";
-    longDescription = ''
-      libc++ is an implementation of the C++ standard library, targeting C++11,
-      C++14 and above.
-    '';
-    # "All of the code in libc++ is dual licensed under the MIT license and the
-    # UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/11/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/libcxx/gnu-install-dirs.patch
deleted file mode 100644
index 2b95d6a85d8f..000000000000
--- a/pkgs/development/compilers/llvm/11/libcxx/gnu-install-dirs.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 910d04b54b6d..80ef692d83eb 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -31,6 +31,8 @@ set(CMAKE_MODULE_PATH
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD)
-   project(libcxx CXX C)
- 
-+  include(GNUInstallDirs)
-+
-   set(PACKAGE_NAME libcxx)
-   set(PACKAGE_VERSION 11.1.0)
-   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -418,7 +420,7 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
- 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++)
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
-     string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
-@@ -426,11 +428,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
- elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
-   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-   set(LIBCXX_HEADER_DIR  ${LLVM_BINARY_DIR})
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
- else()
-   set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-   set(LIBCXX_HEADER_DIR  ${CMAKE_BINARY_DIR})
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
- endif()
- 
- file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
-diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
-index c5aa26739e36..8841c4a5252d 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}
-             COMPONENT cxx-headers
-             PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-             )
-diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
-index be8141c98166..93847e5758cc 100644
---- a/include/CMakeLists.txt
-+++ b/include/CMakeLists.txt
-@@ -257,7 +257,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_HEADER_TARGET}
-       PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-     )
-@@ -265,7 +265,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_HEADER_TARGET})
-diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
-index 2001c09761d9..5bd11ea6b400 100644
---- a/src/CMakeLists.txt
-+++ b/src/CMakeLists.txt
-@@ -344,21 +344,21 @@ if (LIBCXX_INSTALL_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)
-   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)
-   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)
-   endif()
- 
-   # NOTE: This install command must go after the cxx install command otherwise
diff --git a/pkgs/development/compilers/llvm/11/libcxxabi/default.nix b/pkgs/development/compilers/llvm/11/libcxxabi/default.nix
deleted file mode 100644
index 6c8487a2eb99..000000000000
--- a/pkgs/development/compilers/llvm/11/libcxxabi/default.nix
+++ /dev/null
@@ -1,89 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-, standalone ? stdenv.hostPlatform.useLLVM or false
-, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm
-}:
-
-stdenv.mkDerivation {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = fetch "libcxxabi" "1azcf31mxw59hb1x17xncnm3dyw90ylh8rqx462lvypqh3nr6c8l";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = ''
-    unpackFile ${libcxx.src}
-    mv libcxx-* libcxx
-    unpackFile ${llvm.src}
-    mv llvm-* llvm
-  '' + lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
-    patch -p1 -d libcxx -i ${../../common/libcxx/libcxx-0001-musl-hacks.patch}
-  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
-    patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
-  '';
-
-  patches = [
-    ../../common/libcxxabi/no-threads.patch
-    ./gnu-install-dirs.patch
-  ];
-
-  nativeBuildInputs = [ cmake ];
-  buildInputs = lib.optional withLibunwind libunwind;
-
-  cmakeFlags = lib.optionals standalone [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-  ] ++ lib.optionals (standalone && withLibunwind) [
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
-
-      # Fix up the install name. Preserve the basename, just replace the path.
-      installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
-
-      # 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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
-
-      # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
-      # libcxxabi to sometimes link against a different version of itself.
-      # Here we simply make that second reference point to ourselves.
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
-      done
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/11/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index 10651c1255ef..000000000000
--- a/pkgs/development/compilers/llvm/11/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 36c6b2249e2b..a93c13ccaed9 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -24,6 +24,8 @@ set(CMAKE_MODULE_PATH
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
-   project(libcxxabi CXX C)
- 
-+  include(GNUInstallDirs)
-+
-   set(PACKAGE_NAME libcxxabi)
-   set(PACKAGE_VERSION 11.1.0)
-   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -160,17 +162,17 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
- 
- 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++)
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-     string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-   endif()
- elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
-   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_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.")
diff --git a/pkgs/development/compilers/llvm/11/libunwind/default.nix b/pkgs/development/compilers/llvm/11/libunwind/default.nix
deleted file mode 100644
index 4cd39e379601..000000000000
--- a/pkgs/development/compilers/llvm/11/libunwind/default.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ lib, stdenv, llvm_meta, version, fetch, cmake, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libunwind";
-  inherit version;
-
-  src = fetch pname "1vpqs2c358v8fbr1r8jmzkfqk12jllimjcfmgxga127ksq9b37nj";
-
-  patches = [
-    ./gnu-install-dirs.patch
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ cmake ];
-
-  cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
-
-  meta = llvm_meta // {
-    # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
-    homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
-    description = "LLVM's unwinder library";
-    longDescription = ''
-      The unwind library provides a family of _Unwind_* functions implementing
-      the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
-      I). It is a dependency of the C++ ABI library, and sometimes is a
-      dependency of other runtimes.
-    '';
-  };
-}
diff --git a/pkgs/development/compilers/llvm/11/libunwind/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/libunwind/gnu-install-dirs.patch
deleted file mode 100644
index b5b9c209278e..000000000000
--- a/pkgs/development/compilers/llvm/11/libunwind/gnu-install-dirs.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index e44a103648f9..aaf1f9555d7f 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -18,6 +18,8 @@ set(CMAKE_MODULE_PATH
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_BUILD)
-   project(libunwind LANGUAGES C CXX ASM)
- 
-+  include(GNUInstallDirs)
-+
-   # Rely on llvm-config.
-   set(CONFIG_OUTPUT)
-   if(NOT LLVM_CONFIG_PATH)
-@@ -192,17 +194,17 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
- 
- 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++)
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
-     string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
-   endif()
- 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})
- 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})
- endif()
- 
- set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
diff --git a/pkgs/development/compilers/llvm/11/lld/default.nix b/pkgs/development/compilers/llvm/11/lld/default.nix
deleted file mode 100644
index dbcd96a3edce..000000000000
--- a/pkgs/development/compilers/llvm/11/lld/default.nix
+++ /dev/null
@@ -1,46 +0,0 @@
-{ lib, stdenv, llvm_meta
-, buildLlvmTools
-, fetch
-, cmake
-, libxml2
-, libllvm
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "lld";
-  inherit version;
-
-  src = fetch pname "1kk61i7z5bi9i11rzsd2b388d42if1c7a45zkaa4mk0yps67hyh1";
-
-  patches = [
-    ./gnu-install-dirs.patch
-  ];
-
-  nativeBuildInputs = [ cmake ];
-  buildInputs = [ libllvm libxml2 ];
-
-  cmakeFlags = [
-    "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
-  ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
-    "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
-  ];
-
-  # Musl's default stack size is too small for lld to be able to link Firefox.
-  LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152";
-
-  outputs = [ "out" "lib" "dev" ];
-
-  meta = llvm_meta // {
-    homepage = "https://lld.llvm.org/";
-    description = "The LLVM linker (unwrapped)";
-    longDescription = ''
-      LLD is a linker from the LLVM project that is a drop-in replacement for
-      system linkers and runs much faster than them. It also provides features
-      that are useful for toolchain developers.
-      The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
-      WebAssembly in descending order of completeness. Internally, LLD consists
-      of several different linkers.
-    '';
-  };
-}
diff --git a/pkgs/development/compilers/llvm/11/lld/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/lld/gnu-install-dirs.patch
deleted file mode 100644
index 19cf5526aa50..000000000000
--- a/pkgs/development/compilers/llvm/11/lld/gnu-install-dirs.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 040bb2c8f6d7..f765f0096d97 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -6,6 +6,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-   set(CMAKE_INCLUDE_CURRENT_DIR ON)
-   set(LLD_BUILT_STANDALONE TRUE)
- 
-+  include(GNUInstallDirs)
-+
-   find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary")
-   if(NOT LLVM_CONFIG_PATH)
-     message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
-@@ -205,7 +207,7 @@ include_directories(BEFORE
- 
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-   install(DIRECTORY include/
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     FILES_MATCHING
-     PATTERN "*.h"
-     PATTERN ".svn" EXCLUDE
-diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake
-index 23df41312403..d62372c88de7 100644
---- a/cmake/modules/AddLLD.cmake
-+++ b/cmake/modules/AddLLD.cmake
-@@ -20,9 +20,9 @@ macro(add_lld_library name)
-     install(TARGETS ${name}
-       COMPONENT ${name}
-       ${export_to_lldtargets}
--      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
--      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
--      RUNTIME DESTINATION bin)
-+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
-+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
-+      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
- 
-     if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-       add_llvm_install_targets(install-${name}
-@@ -54,7 +54,7 @@ macro(add_lld_tool name)
- 
-     install(TARGETS ${name}
-       ${export_to_lldtargets}
--      RUNTIME DESTINATION bin
-+      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-       COMPONENT ${name})
- 
-     if(NOT CMAKE_CONFIGURATION_TYPES)
-@@ -69,5 +69,5 @@ endmacro()
- macro(add_lld_symlink name dest)
-   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
-   # Always generate install targets
--  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
-+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
- endmacro()
-diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt
-index e6f72fcd3488..d903609e6e4f 100644
---- a/tools/lld/CMakeLists.txt
-+++ b/tools/lld/CMakeLists.txt
-@@ -21,7 +21,7 @@ target_link_libraries(lld
-   )
- 
- install(TARGETS lld
--  RUNTIME DESTINATION bin)
-+  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
- 
- if(NOT LLD_SYMLINKS_TO_CREATE)
-   set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld wasm-ld)
diff --git a/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch
deleted file mode 100644
index fd49be395a3a..000000000000
--- a/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index bf748020ea40..34103d2b5e1a 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -17,6 +17,8 @@ set(CMAKE_MODULE_PATH
- # If we are not building as part of LLVM, build LLDB as a standalone project,
- # using LLVM as an external library.
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-+  include(GNUInstallDirs)
-+
-   project(lldb)
-   include(LLDBStandalone)
- 
-diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake
-index 4ed5c647c5d2..89f96e710d55 100644
---- a/cmake/modules/AddLLDB.cmake
-+++ b/cmake/modules/AddLLDB.cmake
-@@ -107,13 +107,13 @@ function(add_lldb_library name)
-   endif()
- 
-   if(PARAM_SHARED)
--    set(install_dest lib${LLVM_LIBDIR_SUFFIX})
-+    set(install_dest ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
-     if(PARAM_INSTALL_PREFIX)
-       set(install_dest ${PARAM_INSTALL_PREFIX})
-     endif()
-     # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS
-     install(TARGETS ${name} COMPONENT ${name}
--      RUNTIME DESTINATION bin
-+      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-       LIBRARY DESTINATION ${install_dest}
-       ARCHIVE DESTINATION ${install_dest}
-       FRAMEWORK DESTINATION ${install_dest})
-diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake
-index 8465cfe3b7b7..01b7eae136e2 100644
---- a/cmake/modules/LLDBConfig.cmake
-+++ b/cmake/modules/LLDBConfig.cmake
-@@ -245,7 +245,7 @@ include_directories(BEFORE
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-   install(DIRECTORY include/
-     COMPONENT lldb-headers
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     FILES_MATCHING
-     PATTERN "*.h"
-     PATTERN ".svn" EXCLUDE
-@@ -254,7 +254,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
- 
-   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
-     COMPONENT lldb-headers
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     FILES_MATCHING
-     PATTERN "*.h"
-     PATTERN ".svn" EXCLUDE
-diff --git a/tools/intel-features/CMakeLists.txt b/tools/intel-features/CMakeLists.txt
-index efba2f74904f..e08413b1dbb1 100644
---- a/tools/intel-features/CMakeLists.txt
-+++ b/tools/intel-features/CMakeLists.txt
-@@ -65,4 +65,4 @@ if (LLDB_ENABLE_PYTHON AND LLDB_BUILD_INTEL_PT)
- endif()
- 
- 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/pkgs/development/compilers/llvm/11/lldb/procfs.patch b/pkgs/development/compilers/llvm/11/lldb/procfs.patch
deleted file mode 100644
index b075dbaeee0a..000000000000
--- a/pkgs/development/compilers/llvm/11/lldb/procfs.patch
+++ /dev/null
@@ -1,31 +0,0 @@
---- a/source/Plugins/Process/Linux/Procfs.h
-+++ b/source/Plugins/Process/Linux/Procfs.h
-@@ -11,21 +11,12 @@
- // sys/procfs.h on Android/Linux for all supported architectures.
- 
- #include <sys/ptrace.h>
-+#include <asm/ptrace.h>
- 
--#ifdef __ANDROID__
--#if defined(__arm64__) || defined(__aarch64__)
--typedef unsigned long elf_greg_t;
--typedef elf_greg_t
--    elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
--typedef struct user_fpsimd_state elf_fpregset_t;
--#ifndef NT_FPREGSET
--#define NT_FPREGSET NT_PRFPREG
--#endif // NT_FPREGSET
--#elif defined(__mips__)
--#ifndef NT_FPREGSET
--#define NT_FPREGSET NT_PRFPREG
--#endif // NT_FPREGSET
--#endif
--#else // __ANDROID__
-+#if !defined(__GLIBC__) && defined(__powerpc__)
-+#define pt_regs musl_pt_regs
-+#include <sys/procfs.h>
-+#undef pt_regs
-+#else
- #include <sys/procfs.h>
--#endif // __ANDROID__
-+#endif
diff --git a/pkgs/development/compilers/llvm/11/llvm/default.nix b/pkgs/development/compilers/llvm/11/llvm/default.nix
deleted file mode 100644
index 5e22d3f4af16..000000000000
--- a/pkgs/development/compilers/llvm/11/llvm/default.nix
+++ /dev/null
@@ -1,365 +0,0 @@
-{ lib, stdenv, llvm_meta
-, pkgsBuildBuild
-, fetch
-, fetchpatch
-, cmake
-, python3
-, libffi
-, enableGoldPlugin ? libbfd.hasPluginAPI
-, libbfd
-, libpfm
-, libxml2
-, ncurses
-, version
-, release_version
-, zlib
-, buildLlvmTools
-, debugVersion ? false
-, doCheck ? stdenv.isLinux && (!stdenv.isx86_32) && (!stdenv.hostPlatform.isMusl) && (!stdenv.hostPlatform.isRiscV)
-  && (stdenv.hostPlatform == stdenv.buildPlatform)
-, enableManpages ? false
-, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
-# broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
-# broken for the armv7l builder
-, enablePFM ? stdenv.isLinux && !stdenv.hostPlatform.isAarch
-, enablePolly ? false # TODO should be on by default
-}:
-
-let
-  inherit (lib) optional optionals optionalString;
-
-  # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with lib;
-    concatStringsSep "." (take 1 (splitString "." release_version));
-
-  # Ordinarily we would just the `doCheck` and `checkDeps` functionality
-  # `mkDerivation` gives us to manage our test dependencies (instead of breaking
-  # out `doCheck` as a package level attribute).
-  #
-  # Unfortunately `lit` does not forward `$PYTHONPATH` to children processes, in
-  # particular the children it uses to do feature detection.
-  #
-  # This means that python deps we add to `checkDeps` (which the python
-  # interpreter is made aware of via `$PYTHONPATH` – populated by the python
-  # setup hook) are not picked up by `lit` which causes it to skip tests.
-  #
-  # Adding `python3.withPackages (ps: [ ... ])` to `checkDeps` also doesn't work
-  # because this package is shadowed in `$PATH` by the regular `python3`
-  # package.
-  #
-  # So, we "manually" assemble one python derivation for the package to depend
-  # on, taking into account whether checks are enabled or not:
-  python = if doCheck then
-    let
-      checkDeps = ps: with ps; [ psutil ];
-    in python3.withPackages checkDeps
-  else python3;
-
-in stdenv.mkDerivation (rec {
-  pname = "llvm";
-  inherit version;
-
-  src = fetch pname "199yq3a214avcbi4kk2q0ajriifkvsr0l2dkx3a666m033ihi1ff";
-  polly_src = fetch "polly" "031r23ijhx7v93a5n33m2nc0x9xyqmx0d8xg80z7q971p6qd63sq";
-
-  unpackPhase = ''
-    unpackFile $src
-    mv llvm-${release_version}* llvm
-    sourceRoot=$PWD/llvm
-  '' + optionalString enablePolly ''
-    unpackFile $polly_src
-    mv polly-* $sourceRoot/tools/polly
-  '';
-
-  outputs = [ "out" "lib" "dev" "python" ];
-
-  nativeBuildInputs = [ cmake python ]
-    ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
-
-  buildInputs = [ libxml2 libffi ]
-    ++ optional enablePFM libpfm; # exegesis
-
-  propagatedBuildInputs = [ ncurses zlib ];
-
-  patches = [
-    # When cross-compiling we configure llvm-config-native with an approximation
-    # of the flags used for the normal LLVM build. To avoid the need for building
-    # a native libLLVM.so (which would fail) we force llvm-config to be linked
-    # statically against the necessary LLVM components always.
-    ../../common/llvm/llvm-config-link-static.patch
-
-    ./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;
-    })
-    # gcc-11 compat upstream patch
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/b498303066a63a203d24f739b2d2e0e56dca70d1.patch";
-      sha256 = "sha256:0nh123kld0dgz2h941lng331dkj3wbm5lfxm375k1f569gv83hlk";
-      stripLen = 1;
-    })
-
-    # Fix invalid std::string(nullptr) for GCC 12
-    (fetchpatch {
-      name = "nvptx-gcc-12.patch";
-      url = "https://github.com/llvm/llvm-project/commit/99e64623ec9b31def9375753491cc6093c831809.patch";
-      sha256 = "0zjfjgavqzi2ypqwqnlvy6flyvdz8hi1anwv0ybwnm2zqixg7za3";
-      stripLen = 1;
-    })
-    (fetchpatch {
-      name = "dfaemitter-gcc-12.patch";
-      url = "https://github.com/llvm/llvm-project/commit/0841916e87a39e3c223c986e8da31e4a9a1432e3.patch";
-      sha256 = "1kckghvsngs51mqm82asy0s9vr19h8aqbw43a0w44mccqw6bzrwf";
-      stripLen = 1;
-    })
-
-    # Fix musl build.
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch";
-      relative = "llvm";
-      hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA=";
-    })
-
-    # Backport gcc-13 fixes with missing includes.
-    (fetchpatch {
-      name = "signals-gcc-13.patch";
-      url = "https://github.com/llvm/llvm-project/commit/ff1681ddb303223973653f7f5f3f3435b48a1983.patch";
-      hash = "sha256-CXwYxQezTq5vdmc8Yn88BUAEly6YZ5VEIA6X3y5NNOs=";
-      stripLen = 1;
-    })
-    (fetchpatch {
-      name = "base64-gcc-13.patch";
-      url = "https://github.com/llvm/llvm-project/commit/5e9be93566f39ee6cecd579401e453eccfbe81e5.patch";
-      hash = "sha256-PAwrVrvffPd7tphpwCkYiz+67szPRzRB2TXBvKfzQ7U=";
-      stripLen = 1;
-    })
-  ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch;
-
-  postPatch = optionalString stdenv.isDarwin ''
-    substituteInPlace cmake/modules/AddLLVM.cmake \
-      --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
-      --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
-  '' + ''
-    # FileSystem permissions tests fail with various special bits
-    substituteInPlace unittests/Support/CMakeLists.txt \
-      --replace "Path.cpp" ""
-    rm unittests/Support/Path.cpp
-  '' + optionalString stdenv.hostPlatform.isMusl ''
-    patch -p1 -i ${../../common/llvm/TLI-musl.patch}
-    substituteInPlace unittests/Support/CMakeLists.txt \
-      --replace "add_subdirectory(DynamicLibrary)" ""
-    rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
-    # valgrind unhappy with musl or glibc, but fails w/musl only
-    rm test/CodeGen/AArch64/wineh4.mir
-  '' + optionalString stdenv.hostPlatform.isAarch32 ''
-    # skip failing X86 test cases on 32-bit ARM
-    rm test/DebugInfo/X86/convert-debugloc.ll
-    rm test/DebugInfo/X86/convert-inlined.ll
-    rm test/DebugInfo/X86/convert-linked.ll
-    rm test/tools/dsymutil/X86/op-convert.test
-    rm test/tools/gold/X86/split-dwarf.ll
-    rm test/tools/llvm-readobj/ELF/dependent-libraries.test
-  '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
-    # Seems to require certain floating point hardware (NEON?)
-    rm test/ExecutionEngine/frem.ll
-  '' + ''
-    patchShebangs test/BugPoint/compile-custom.ll.py
-  '' + ''
-    # Tweak tests to ignore namespace part of type to support
-    # gcc-12: https://gcc.gnu.org/PR103598.
-    # The change below mangles strings like:
-    #    CHECK-NEXT: Starting llvm::Function pass manager run.
-    # to:
-    #    CHECK-NEXT: Starting {{.*}}Function pass manager run.
-    for f in \
-      test/Other/new-pass-manager.ll \
-      test/Other/new-pm-defaults.ll \
-      test/Other/new-pm-lto-defaults.ll \
-      test/Other/new-pm-thinlto-defaults.ll \
-      test/Other/pass-pipeline-parsing.ll \
-      test/Transforms/Inline/cgscc-incremental-invalidate.ll \
-      test/Transforms/Inline/clear-analyses.ll \
-      test/Transforms/LoopUnroll/unroll-loop-invalidation.ll \
-      test/Transforms/SCCP/ipsccp-preserve-analysis.ll \
-      test/Transforms/SCCP/preserve-analysis.ll \
-      test/Transforms/SROA/dead-inst.ll \
-      test/tools/gold/X86/new-pm.ll \
-      ; do
-      echo "PATCH: $f"
-      substituteInPlace $f \
-        --replace 'Starting llvm::' 'Starting {{.*}}' \
-        --replace 'Finished llvm::' 'Finished {{.*}}'
-    done
-  '';
-
-  preConfigure = ''
-    # Workaround for configure flags that need to have spaces
-    cmakeFlagsArray+=(
-      -DLLVM_LIT_ARGS='-svj''${NIX_BUILD_CORES} --no-progress-bar'
-    )
-  '';
-
-  # hacky fix: created binaries need to be run before installation
-  preBuild = ''
-    mkdir -p $out/
-    ln -sv $PWD/lib $out
-  '';
-
-  # E.g. mesa.drivers use the build-id as a cache key (see #93946):
-  LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";
-
-  hardeningDisable = [ "trivialautovarinit" ];
-
-  cmakeBuildType = if debugVersion then "Debug" else "Release";
-
-  cmakeFlags = with stdenv; let
-    # These flags influence llvm-config's BuildVariables.inc in addition to the
-    # general build. We need to make sure these are also passed via
-    # CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native
-    # will return different results from the cross llvm-config.
-    #
-    # Some flags don't need to be repassed because LLVM already does so (like
-    # CMAKE_BUILD_TYPE), others are irrelevant to the result.
-    flagsForLlvmConfig = [
-      "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/"
-      "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ optionals enableSharedLibraries [
-      "-DLLVM_LINK_LLVM_DYLIB=ON"
-    ];
-  in flagsForLlvmConfig ++ [
-    "-DLLVM_INSTALL_UTILS=ON"  # Needed by rustc
-    "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
-    "-DLLVM_ENABLE_FFI=ON"
-    "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
-    "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
-    "-DLLVM_ENABLE_DUMP=ON"
-  ] ++ optionals stdenv.hostPlatform.isStatic [
-    # Disables building of shared libs, -fPIC is still injected by cc-wrapper
-    "-DLLVM_ENABLE_PIC=OFF"
-    "-DLLVM_BUILD_STATIC=ON"
-    # libxml2 needs to be disabled because the LLVM build system ignores its .la
-    # file and doesn't link zlib as well.
-    # https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812
-    "-DLLVM_ENABLE_LIBXML2=OFF"
-    # This is a Shared Library not tied to LLVM_ENABLE_PIC
-    "-DLLVM_TOOL_REMARKS_SHLIB_BUILD=OFF"
-  ] ++ optionals enableManpages [
-    "-DLLVM_BUILD_DOCS=ON"
-    "-DLLVM_ENABLE_SPHINX=ON"
-    "-DSPHINX_OUTPUT_MAN=ON"
-    "-DSPHINX_OUTPUT_HTML=OFF"
-    "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (enableGoldPlugin) [
-    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-  ] ++ optionals isDarwin [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DCAN_TARGET_i386=false"
-  ] ++ optionals ((stdenv.hostPlatform != stdenv.buildPlatform) && !(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) [
-    "-DCMAKE_CROSSCOMPILING=True"
-    "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen"
-    (
-      let
-        nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc;
-        nativeBintools = nativeCC.bintools.bintools;
-        nativeToolchainFlags = [
-          "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
-          "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
-          "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
-          "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
-          "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
-        ];
-        # We need to repass the custom GNUInstallDirs values, otherwise CMake
-        # will choose them for us, leading to wrong results in llvm-config-native
-        nativeInstallFlags = [
-          "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
-          "-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin"
-          "-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include"
-          "-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib"
-          "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec"
-        ];
-      in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list="
-      + lib.concatStringsSep ";" (lib.concatLists [
-        flagsForLlvmConfig
-        nativeToolchainFlags
-        nativeInstallFlags
-      ])
-    )
-  ];
-
-  postBuild = ''
-    rm -fR $out
-  '';
-
-  preCheck = ''
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
-  '';
-
-  postInstall = ''
-    mkdir -p $python/share
-    mv $out/share/opt-viewer $python/share/opt-viewer
-    moveToOutput "bin/llvm-config*" "$dev"
-    substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
-      --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \
-      --replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
-    substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
-      --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")'
-  ''
-  + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
-  ''
-  + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
-    cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
-  '';
-
-  inherit doCheck;
-
-  checkTarget = "check-all";
-
-  requiredSystemFeatures = [ "big-parallel" ];
-  meta = llvm_meta // {
-    homepage = "https://llvm.org/";
-    description = "A collection of modular and reusable compiler and toolchain technologies";
-    longDescription = ''
-      The LLVM Project is a collection of modular and reusable compiler and
-      toolchain technologies. Despite its name, LLVM has little to do with
-      traditional virtual machines. The name "LLVM" itself is not an acronym; it
-      is the full name of the project.
-      LLVM began as a research project at the University of Illinois, with the
-      goal of providing a modern, SSA-based compilation strategy capable of
-      supporting both static and dynamic compilation of arbitrary programming
-      languages. Since then, LLVM has grown to be an umbrella project consisting
-      of a number of subprojects, many of which are being used in production by
-      a wide variety of commercial and open source projects as well as being
-      widely used in academic research. Code in the LLVM project is licensed
-      under the "Apache 2.0 License with LLVM exceptions".
-    '';
-  };
-} // lib.optionalAttrs enableManpages {
-  pname = "llvm-manpages";
-
-  buildPhase = ''
-    make docs-llvm-man
-  '';
-
-  propagatedBuildInputs = [];
-
-  installPhase = ''
-    make -C docs install
-  '';
-
-  postPatch = null;
-  postInstall = null;
-
-  outputs = [ "out" ];
-
-  doCheck = false;
-
-  meta = llvm_meta // {
-    description = "man pages for LLVM ${version}";
-  };
-})
diff --git a/pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs-polly.patch b/pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs-polly.patch
deleted file mode 100644
index fff2d4953e94..000000000000
--- a/pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs-polly.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt
-index 9939097f743e..8cc538da912a 100644
---- a/tools/polly/CMakeLists.txt
-+++ b/tools/polly/CMakeLists.txt
-@@ -2,7 +2,11 @@
- if (NOT DEFINED LLVM_MAIN_SRC_DIR)
-   project(Polly)
-   cmake_minimum_required(VERSION 3.4.3)
-+endif()
-+
-+include(GNUInstallDirs)
- 
-+if (NOT DEFINED LLVM_MAIN_SRC_DIR)
-   # Where is LLVM installed?
-   find_package(LLVM CONFIG REQUIRED)
-   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
-@@ -145,14 +149,14 @@ include_directories(
- 
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-   install(DIRECTORY include/
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     FILES_MATCHING
-     PATTERN "*.h"
-     PATTERN ".svn" EXCLUDE
-     )
- 
-   install(DIRECTORY ${POLLY_BINARY_DIR}/include/
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     FILES_MATCHING
-     PATTERN "*.h"
-     PATTERN "CMakeFiles" EXCLUDE
-diff --git a/tools/polly/cmake/CMakeLists.txt b/tools/polly/cmake/CMakeLists.txt
-index 211f95512717..f9e04a4844b6 100644
---- a/tools/polly/cmake/CMakeLists.txt
-+++ b/tools/polly/cmake/CMakeLists.txt
-@@ -79,18 +79,18 @@ file(GENERATE
- 
- # Generate PollyConfig.cmake for the install tree.
- unset(POLLY_EXPORTS)
--set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
-+set(POLLY_INSTALL_PREFIX "")
- set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
--set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
--set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
-+set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
-+set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
- if (POLLY_BUNDLED_ISL)
-   set(POLLY_CONFIG_INCLUDE_DIRS
--    "${POLLY_INSTALL_PREFIX}/include"
--    "${POLLY_INSTALL_PREFIX}/include/polly"
-+    "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}"
-+    "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}/polly"
-     )
- else()
-   set(POLLY_CONFIG_INCLUDE_DIRS
--    "${POLLY_INSTALL_PREFIX}/include"
-+    "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_INCLUDEDIR}"
-     ${ISL_INCLUDE_DIRS}
-     )
- endif()
-@@ -100,12 +100,12 @@ endif()
- foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
-   get_target_property(tgt_type ${tgt} TYPE)
-   if (tgt_type STREQUAL "EXECUTABLE")
--    set(tgt_prefix "bin/")
-+    set(tgt_prefix "${CMAKE_INSTALL_BINDIR}/")
-   else()
--    set(tgt_prefix "lib/")
-+    set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}/")
-   endif()
- 
--  set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
-+  set(tgt_path "${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
-   file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
- 
-   if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
-diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake
-index 86de6f10686e..91f30891ccbe 100644
---- a/tools/polly/cmake/polly_macros.cmake
-+++ b/tools/polly/cmake/polly_macros.cmake
-@@ -44,8 +44,8 @@ macro(add_polly_library name)
-   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
-     install(TARGETS ${name}
-       EXPORT LLVMExports
--      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
--      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
-+	  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
-+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
-   endif()
-   set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
- endmacro(add_polly_library)
-diff --git a/tools/polly/lib/External/CMakeLists.txt b/tools/polly/lib/External/CMakeLists.txt
-index 1039079cb49c..28b499ae1e9e 100644
---- a/tools/polly/lib/External/CMakeLists.txt
-+++ b/tools/polly/lib/External/CMakeLists.txt
-@@ -275,7 +275,7 @@ if (POLLY_BUNDLED_ISL)
-     install(DIRECTORY
-       ${ISL_SOURCE_DIR}/include/
-       ${ISL_BINARY_DIR}/include/
--      DESTINATION include/polly
-+      DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
-       FILES_MATCHING
-       PATTERN "*.h"
-       PATTERN "CMakeFiles" EXCLUDE
diff --git a/pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs.patch
deleted file mode 100644
index 29df98a693f0..000000000000
--- a/pkgs/development/compilers/llvm/11/llvm/gnu-install-dirs.patch
+++ /dev/null
@@ -1,417 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 247ad36d3845..815e2c4ba955 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -269,15 +269,21 @@ if (CMAKE_BUILD_TYPE AND
-   message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
- endif()
- 
-+include(GNUInstallDirs)
-+
- set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
- 
--set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')")
-+set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
-+    "Path for binary subdirectory (defaults to 'bin')")
- mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
- 
- set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING
-     "Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)")
- mark_as_advanced(LLVM_UTILS_INSTALL_DIR)
- 
-+set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING
-+	"Path for CMake subdirectory (defaults to lib/cmake/llvm)" )
-+
- # 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})
-@@ -559,9 +565,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)
- 
--set(LLVM_INSTALL_DOXYGEN_HTML_DIR "share/doc/llvm/doxygen-html"
-+set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html"
-     CACHE STRING "Doxygen-generated HTML documentation install directory")
--set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html"
-+set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html"
-     CACHE STRING "OCamldoc-generated HTML documentation install directory")
- 
- option (LLVM_BUILD_EXTERNAL_COMPILER_RT
-@@ -1107,7 +1113,7 @@ endif()
- 
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-   install(DIRECTORY include/llvm include/llvm-c
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     COMPONENT llvm-headers
-     FILES_MATCHING
-     PATTERN "*.def"
-@@ -1119,7 +1125,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-     )
- 
-   install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c
--    DESTINATION include
-+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-     COMPONENT llvm-headers
-     FILES_MATCHING
-     PATTERN "*.def"
-@@ -1134,13 +1140,13 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
- 
-   if (LLVM_INSTALL_MODULEMAPS)
-     install(DIRECTORY include/llvm include/llvm-c
--            DESTINATION include
-+            DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-             COMPONENT llvm-headers
-             FILES_MATCHING
-             PATTERN "module.modulemap"
-             )
-     install(FILES include/llvm/module.install.modulemap
--            DESTINATION include/llvm
-+            DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm
-             COMPONENT llvm-headers
-             RENAME "module.extern.modulemap"
-             )
-diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
-index b74adc11ade9..a5aa258cde30 100644
---- a/cmake/modules/AddLLVM.cmake
-+++ b/cmake/modules/AddLLVM.cmake
-@@ -766,9 +766,9 @@ macro(add_llvm_library name)
- 
-       install(TARGETS ${name}
-               ${export_to_llvmexports}
--              LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
--              ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
--              RUNTIME DESTINATION bin COMPONENT ${name})
-+              LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
-+              ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
-+              RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${name})
- 
-       if (NOT LLVM_ENABLE_IDE)
-         add_llvm_install_targets(install-${name}
-@@ -981,7 +981,7 @@ function(process_llvm_pass_plugins)
-           "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
-       install(FILES
-           ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake
--          DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
-+          DESTINATION ${LLVM_INSTALL_CMAKE_DIR}
-           COMPONENT cmake-exports)
- 
-       set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
-@@ -1201,7 +1201,7 @@ macro(add_llvm_example name)
-   endif()
-   add_llvm_executable(${name} ${ARGN})
-   if( LLVM_BUILD_EXAMPLES )
--    install(TARGETS ${name} RUNTIME DESTINATION examples)
-+    install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
-   endif()
-   set_target_properties(${name} PROPERTIES FOLDER "Examples")
- endmacro(add_llvm_example name)
-@@ -1819,7 +1819,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})
- 
--  set(output_dir lib${LLVM_LIBDIR_SUFFIX})
-+  set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
-   if(WIN32 AND "${type}" STREQUAL "SHARED")
-     set(output_dir bin)
-   endif()
-@@ -1836,7 +1836,7 @@ function(llvm_install_library_symlink name dest type)
-   endif()
- endfunction()
- 
--function(llvm_install_symlink name dest)
-+function(llvm_install_symlink name dest output_dir)
-   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
-   foreach(path ${CMAKE_MODULE_PATH})
-     if(EXISTS ${path}/LLVMInstallSymlink.cmake)
-@@ -1859,7 +1859,7 @@ function(llvm_install_symlink name dest)
-   set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
- 
-   install(SCRIPT ${INSTALL_SYMLINK}
--          CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
-+          CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
-           COMPONENT ${component})
- 
-   if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
-@@ -1942,7 +1942,8 @@ function(add_llvm_tool_symlink link_name target)
-     endif()
- 
-     if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
--      llvm_install_symlink(${link_name} ${target})
-+      GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR)
-+      llvm_install_symlink(${link_name} ${target} ${output_dir})
-     endif()
-   endif()
- endfunction()
-@@ -2064,9 +2065,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})
-   elseif(UNIX)
--    set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
-+    set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
-     if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
-       set_property(TARGET ${name} APPEND_STRING PROPERTY
-                    LINK_FLAGS " -Wl,-z,origin ")
-diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
-index 554046b20edf..4d1ad980641e 100644
---- a/cmake/modules/AddOCaml.cmake
-+++ b/cmake/modules/AddOCaml.cmake
-@@ -144,9 +144,9 @@ function(add_ocaml_library name)
-   endforeach()
- 
-   if( APPLE )
--    set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
-+    set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
-   elseif( UNIX )
--    set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
-+    set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
-   endif()
-   list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
- 
-diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake
-index b5babb30abcf..190b1222a9f9 100644
---- a/cmake/modules/AddSphinxTarget.cmake
-+++ b/cmake/modules/AddSphinxTarget.cmake
-@@ -84,7 +84,7 @@ function (add_sphinx_target builder project)
-         endif()
-       elseif (builder STREQUAL html)
-         string(TOUPPER "${project}" project_upper)
--        set(${project_upper}_INSTALL_SPHINX_HTML_DIR "share/doc/${project}/html"
-+        set(${project_upper}_INSTALL_SPHINX_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/html"
-             CACHE STRING "HTML documentation install directory for ${project}")
- 
-         # '/.' indicates: copy the contents of the directory directly into
-diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
-index 4b8879f65fe4..f01920bcc60f 100644
---- a/cmake/modules/CMakeLists.txt
-+++ b/cmake/modules/CMakeLists.txt
-@@ -1,4 +1,4 @@
--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.
-@@ -108,13 +108,13 @@ foreach(p ${_count})
-   set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
- get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
- endforeach(p)
--set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
-+set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
- set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
- set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
--set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
-+set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}")
- set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
- set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
--set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
-+set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
- 
- # 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
---- 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()
- 
--  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 1f908d3e95b1..1315e0aa40e1 100644
---- a/docs/CMake.rst
-+++ b/docs/CMake.rst
-@@ -196,7 +196,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.
-@@ -516,8 +516,8 @@ LLVM-specific variables
- 
- **LLVM_INSTALL_DOXYGEN_HTML_DIR**:STRING
-   The path to install Doxygen-generated HTML documentation to. This path can
--  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
--  `share/doc/llvm/doxygen-html`.
-+  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
-@@ -548,13 +548,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
-@@ -752,9 +772,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
- 
- This file is available in two different locations.
- 
--* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where
--  ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
--  On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
-+* ``<LLVM_INSTALL_PACKAGE_DIR>LLVMConfig.cmake`` where
-+  ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are
-+  installed as part of an installed version of LLVM. This is typically
-+  ``cmake/llvm/`` within the lib directory. On Linux, this is typically
-+  ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
- 
- * ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where
-   ``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only
-diff --git a/examples/Bye/CMakeLists.txt b/examples/Bye/CMakeLists.txt
-index bb96edb4b4bf..678c22fb43c8 100644
---- a/examples/Bye/CMakeLists.txt
-+++ b/examples/Bye/CMakeLists.txt
-@@ -14,6 +14,6 @@ if (NOT WIN32)
-     BUILDTREE_ONLY
-    )
- 
--  install(TARGETS ${name} RUNTIME DESTINATION examples)
-+  install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
-   set_target_properties(${name} PROPERTIES FOLDER "Examples")
- endif()
-diff --git a/include/llvm/CMakeLists.txt b/include/llvm/CMakeLists.txt
-index b46319f24fc8..2feabd1954e4 100644
---- a/include/llvm/CMakeLists.txt
-+++ b/include/llvm/CMakeLists.txt
-@@ -5,5 +5,5 @@ add_subdirectory(Frontend)
- # If we're doing an out-of-tree build, copy a module map for generated
- # header files into the build area.
- if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
--  configure_file(module.modulemap.build module.modulemap COPYONLY)
-+  configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY)
- endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
-diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
-index 63cef75368b7..6295478b1f3d 100644
---- a/tools/llvm-config/BuildVariables.inc.in
-+++ b/tools/llvm-config/BuildVariables.inc.in
-@@ -23,6 +23,10 @@
- #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
- #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
- #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
-+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
-+#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"
-+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
-+#define LLVM_INSTALL_CMAKEDIR "@LLVM_INSTALL_CMAKE_DIR@"
- #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
- #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
- #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
-diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
-index 7e74b7c90816..f185e9283f83 100644
---- a/tools/llvm-config/llvm-config.cpp
-+++ b/tools/llvm-config/llvm-config.cpp
-@@ -358,12 +358,26 @@ int main(int argc, char **argv) {
-         ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
-   } else {
-     ActivePrefix = CurrentExecPrefix;
--    ActiveIncludeDir = ActivePrefix + "/include";
--    SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
--    sys::fs::make_absolute(ActivePrefix, path);
--    ActiveBinDir = std::string(path.str());
--    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
--    ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
-+    {
-+      SmallString<256> path(StringRef(LLVM_INSTALL_INCLUDEDIR));
-+      sys::fs::make_absolute(ActivePrefix, path);
-+      ActiveIncludeDir = std::string(path.str());
-+    }
-+    {
-+      SmallString<256> path(StringRef(LLVM_INSTALL_BINDIR));
-+      sys::fs::make_absolute(ActivePrefix, path);
-+      ActiveBinDir = std::string(path.str());
-+    }
-+    {
-+      SmallString<256> path(StringRef(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX));
-+      sys::fs::make_absolute(ActivePrefix, path);
-+      ActiveLibDir = std::string(path.str());
-+    }
-+    {
-+      SmallString<256> path(StringRef(LLVM_INSTALL_CMAKEDIR));
-+      sys::fs::make_absolute(ActivePrefix, path);
-+      ActiveCMakeDir = std::string(path.str());
-+    }
-     ActiveIncludeOption = "-I" + ActiveIncludeDir;
-   }
- 
-diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
-index 2963f97cad88..69d66c9c9ca1 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)
- 
- install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
--  DESTINATION include/llvm-c
-+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c
-   COMPONENT LTO)
- 
- if (APPLE)
-diff --git a/tools/opt-viewer/CMakeLists.txt b/tools/opt-viewer/CMakeLists.txt
-index ead73ec13a8f..250362021f17 100644
---- a/tools/opt-viewer/CMakeLists.txt
-+++ b/tools/opt-viewer/CMakeLists.txt
-@@ -8,7 +8,7 @@ set (files
- 
- foreach (file ${files})
-   install(PROGRAMS ${file}
--    DESTINATION share/opt-viewer
-+    DESTINATION ${CMAKE_INSTALL_DATADIR}/opt-viewer
-     COMPONENT opt-viewer)
- endforeach (file)
- 
-diff --git a/tools/remarks-shlib/CMakeLists.txt b/tools/remarks-shlib/CMakeLists.txt
-index e948496c603a..1f4df8a98b10 100644
---- a/tools/remarks-shlib/CMakeLists.txt
-+++ b/tools/remarks-shlib/CMakeLists.txt
-@@ -11,7 +11,7 @@ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports)
- add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES})
- 
- install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
--  DESTINATION include/llvm-c
-+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c
-   COMPONENT Remarks)
- 
- if (APPLE)
diff --git a/pkgs/development/compilers/llvm/11/openmp/default.nix b/pkgs/development/compilers/llvm/11/openmp/default.nix
deleted file mode 100644
index 6c2dd9ac9577..000000000000
--- a/pkgs/development/compilers/llvm/11/openmp/default.nix
+++ /dev/null
@@ -1,47 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, fetch
-, fetchpatch
-, cmake
-, llvm
-, targetLlvm
-, perl
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = fetch pname "0bh5cswgpc79awlq8j5i7hp355adaac7s6zaz0zwp6mkflxli1yi";
-
-  patches = [
-    # Fix compilation on aarch64-darwin, remove after the next release.
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/7b5254223acbf2ef9cd278070c5a84ab278d7e5f.patch";
-      sha256 = "sha256-A+9/IVIoazu68FK5H5CiXcOEYe1Hpp4xTx2mIw7m8Es=";
-      stripLen = 1;
-    })
-  ];
-
-  nativeBuildInputs = [ cmake perl ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/12/compiler-rt/default.nix b/pkgs/development/compilers/llvm/12/compiler-rt/default.nix
index 4b2bdad454ae..e11a1b397e76 100644
--- a/pkgs/development/compilers/llvm/12/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/12/compiler-rt/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, llvm_meta, version, fetch
-, cmake, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -20,8 +20,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -113,6 +112,7 @@ stdenv.mkDerivation {
   meta = llvm_meta // {
     homepage = "https://compiler-rt.llvm.org/";
     description = "Compiler runtime libraries";
+    mainProgram = "hwasan_symbolize";
     longDescription = ''
       The compiler-rt project provides highly tuned implementations of the
       low-level code generator support routines like "__fixunsdfdi" and other
diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix
index a38e35e91f6d..bd87dc5f34f0 100644
--- a/pkgs/development/compilers/llvm/12/default.nix
+++ b/pkgs/development/compilers/llvm/12/default.nix
@@ -109,7 +109,6 @@ let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -163,7 +162,6 @@ let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -257,24 +255,13 @@ let
 
     libcxx = callPackage ./libcxx {
       inherit llvm_meta;
-      stdenv = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-    };
-
-    libcxxabi = callPackage ./libcxxabi {
-      inherit llvm_meta;
-      stdenv = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
+      stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
     libunwind = callPackage ./libunwind {
       inherit llvm_meta;
       inherit (buildLlvmTools) llvm;
-      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/pkgs/development/compilers/llvm/12/libcxx/default.nix b/pkgs/development/compilers/llvm/12/libcxx/default.nix
index 67e2aed35cb6..7c6174711456 100644
--- a/pkgs/development/compilers/llvm/12/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/12/libcxx/default.nix
@@ -1,68 +1,128 @@
-{ lib, stdenv, llvm_meta, fetch, cmake, python3, llvm, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt
+{ lib, stdenv, llvm_meta
+, fetchFromGitHub, runCommand, substitute
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
-assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
+let
+  basename = "libcxx";
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
 
-stdenv.mkDerivation {
-  pname = "libcxx";
-  inherit version;
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
 
-  src = fetch "libcxx" "05cx39ldlxchck454lgfly1xj0c7x65iyx4hqhiihrlg6p6qj854";
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
 
-  postUnpack = ''
-    unpackFile ${libcxxabi.src}
-    mv libcxxabi-* libcxxabi
-    unpackFile ${llvm.src}
-    mv llvm-* llvm
-  '';
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
+
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
+    # but that does not appear to be the case for example when building
+    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
+    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
+    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
+
+in
+
+stdenv.mkDerivation rec {
+  pname = basename;
+  inherit version cmakeFlags;
+
+  src = fetchFromGitHub {
+    owner = "llvm";
+    repo = "llvm-project";
+    rev = "refs/tags/llvmorg-${version}";
+    sparseCheckout = [
+      "libcxx"
+      "libcxxabi"
+      "llvm/cmake"
+      "llvm/utils"
+      "runtimes"
+    ];
+    hash = "sha256-etxgXIdWxMTmbZ83Hsc0w6Jt5OSQSUEPVEWqLkHsNBY=";
+  };
 
   outputs = [ "out" "dev" ];
 
   patches = [
-    ./gnu-install-dirs.patch
+    (substitute {
+      src = ../../common/libcxxabi/wasm.patch;
+      replacements = [
+        "--replace-fail" "/cmake/" "/llvm/cmake/"
+      ];
+    })
   ] ++ lib.optionals stdenv.hostPlatform.isMusl [
-    ../../common/libcxx/libcxx-0001-musl-hacks.patch
+    (substitute {
+      src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
+      replacements = [
+        "--replace-fail" "/include/" "/libcxx/include/"
+      ];
+    })
   ];
 
+  postPatch = ''
+    cd runtimes
+  '';
+
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
 
-  nativeBuildInputs = [ cmake python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+  nativeBuildInputs = [ cmake ninja python3 ]
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
 
-  buildInputs = [ cxxabi ];
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
 
-  cmakeFlags = [
-    "-DLIBCXX_CXX_ABI=${cxxabi.pname}"
-  ] ++ 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.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
-
-  preInstall = lib.optionalString (stdenv.isDarwin) ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
-
-      baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
-      installName="$out/lib/$baseName"
-      abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
-
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
-      done
-    done
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include $out/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib $out/lib
   '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
diff --git a/pkgs/development/compilers/llvm/12/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/12/libcxx/gnu-install-dirs.patch
deleted file mode 100644
index 1f9de00a9d56..000000000000
--- a/pkgs/development/compilers/llvm/12/libcxx/gnu-install-dirs.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 9bf1a02f0908..612cd4aab76c 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -28,6 +28,8 @@ set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD)
-   project(libcxx CXX C)
- 
-+  include(GNUInstallDirs)
-+
-   set(PACKAGE_NAME libcxx)
-   set(PACKAGE_VERSION 12.0.0)
-   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++)
-   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)
-   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-   set(LIBCXX_HEADER_DIR  ${LLVM_BINARY_DIR})
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
- else()
-   set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-   set(LIBCXX_HEADER_DIR  ${CMAKE_BINARY_DIR})
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX})
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX})
- endif()
- 
- file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
-diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
-index 5d2764e870e9..bb1ec5de6ca2 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}
-             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
---- a/src/CMakeLists.txt
-+++ b/src/CMakeLists.txt
-@@ -352,21 +352,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)
- 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)
- 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)
- endif()
- 
- # NOTE: This install command must go after the cxx install command otherwise
diff --git a/pkgs/development/compilers/llvm/12/libcxxabi/default.nix b/pkgs/development/compilers/llvm/12/libcxxabi/default.nix
deleted file mode 100644
index 5ebb77ad3880..000000000000
--- a/pkgs/development/compilers/llvm/12/libcxxabi/default.nix
+++ /dev/null
@@ -1,87 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, python3, fetch, libcxx, libunwind, llvm, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-, standalone ? stdenv.hostPlatform.useLLVM or false
-, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm
-}:
-
-stdenv.mkDerivation {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = fetch "libcxxabi" "1l4idd8npbkm168d26kqn529yv3npsd8f2dm8a7iwyknj7iyivw8";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = ''
-    unpackFile ${libcxx.src}
-    mv libcxx-* libcxx
-    unpackFile ${llvm.src}
-    mv llvm-* llvm
-  '' + lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
-    patch -p1 -d libcxx -i ${../../common/libcxx/libcxx-0001-musl-hacks.patch}
-  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
-    patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-  ];
-
-  nativeBuildInputs = [ cmake python3 ];
-  buildInputs = lib.optional withLibunwind libunwind;
-
-  cmakeFlags = lib.optionals standalone [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
-
-      # Fix up the install name. Preserve the basename, just replace the path.
-      installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
-
-      # 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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
-
-      # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
-      # libcxxabi to sometimes link against a different version of itself.
-      # Here we simply make that second reference point to ourselves.
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
-      done
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/12/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/12/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index b49b1685940f..000000000000
--- a/pkgs/development/compilers/llvm/12/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 426c855288fc..a9812a994f53 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -27,6 +27,8 @@ set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
-   project(libcxxabi CXX C)
- 
-+  include(GNUInstallDirs)
-+
-   set(PACKAGE_NAME libcxxabi)
-   set(PACKAGE_VERSION 11.0.0)
-   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -180,17 +182,17 @@ 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++)
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-     string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-   endif()
- elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
-   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_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.")
diff --git a/pkgs/development/compilers/llvm/12/libunwind/default.nix b/pkgs/development/compilers/llvm/12/libunwind/default.nix
index 8ed246876959..95e0962b4689 100644
--- a/pkgs/development/compilers/llvm/12/libunwind/default.nix
+++ b/pkgs/development/compilers/llvm/12/libunwind/default.nix
@@ -9,10 +9,8 @@ stdenv.mkDerivation rec {
   src = fetch pname "192ww6n81lj2mb9pj4043z79jp3cf58a9c2qrxjwm5c3a64n1shb";
 
   postUnpack = ''
-    unpackFile ${libcxx.src}
-    mv libcxx-* libcxx
-    unpackFile ${llvm.src}
-    mv llvm-* llvm
+    ln -s ${libcxx.src}/libcxx .
+    ln -s ${libcxx.src}/llvm .
   '';
 
   patches = [
diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
index d75ce3b3b052..4745345a3f71 100644
--- a/pkgs/development/compilers/llvm/12/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
@@ -184,6 +184,10 @@ in stdenv.mkDerivation (rec {
         --replace 'Starting llvm::' 'Starting {{.*}}' \
         --replace 'Finished llvm::' 'Finished {{.*}}'
     done
+  '' + ''
+    # gcc-13 fix
+    sed -i '/#include <string>/i#include <cstdint>' \
+      include/llvm/DebugInfo/Symbolize/DIPrinter.h
   '';
 
   preConfigure = ''
diff --git a/pkgs/development/compilers/llvm/13/compiler-rt/default.nix b/pkgs/development/compilers/llvm/13/compiler-rt/default.nix
index b6a9c13ba943..3c83e4e58a17 100644
--- a/pkgs/development/compilers/llvm/13/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/13/compiler-rt/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, llvm_meta, version, src
-, cmake, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -22,8 +22,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -120,6 +119,7 @@ stdenv.mkDerivation {
   meta = llvm_meta // {
     homepage = "https://compiler-rt.llvm.org/";
     description = "Compiler runtime libraries";
+    mainProgram = "hwasan_symbolize";
     longDescription = ''
       The compiler-rt project provides highly tuned implementations of the
       low-level code generator support routines like "__fixunsdfdi" and other
diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix
index c811b24c48ef..cd96231e62c3 100644
--- a/pkgs/development/compilers/llvm/13/default.nix
+++ b/pkgs/development/compilers/llvm/13/default.nix
@@ -137,7 +137,6 @@ in let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -203,7 +202,6 @@ in let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -297,28 +295,8 @@ in let
 
     libcxx = callPackage ./libcxx {
       inherit llvm_meta;
-      stdenv = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else (
-                 # libcxx >= 13 does not build on gcc9
-                 if stdenv.cc.isGNU && lib.versionOlder stdenv.cc.version "10"
-                 then pkgs.gcc10Stdenv
-                 else stdenv
-               );
-    };
-
-    libcxxabi = let
-      stdenv_ = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-      cxx-headers = callPackage ./libcxx {
-        inherit llvm_meta;
-        stdenv = stdenv_;
-        headersOnly = true;
-      };
-    in callPackage ./libcxxabi {
-      stdenv = stdenv_;
-      inherit llvm_meta cxx-headers;
+      stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
+      monorepoSrc = src;
     };
 
     libunwind = callPackage ./libunwind {
diff --git a/pkgs/development/compilers/llvm/13/libcxx/default.nix b/pkgs/development/compilers/llvm/13/libcxx/default.nix
index 2974fc80e191..b39b4f37ff1c 100644
--- a/pkgs/development/compilers/llvm/13/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/13/libcxx/default.nix
@@ -1,80 +1,124 @@
-{ lib, stdenv, llvm_meta, src, cmake, python3, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt
+{ lib, stdenv, llvm_meta
+, monorepoSrc, runCommand, substitute
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
-
-# If headersOnly is true, the resulting package would only include the headers.
-# Use this to break the circular dependency between libcxx and libcxxabi.
-#
-# Some context:
-# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
-, headersOnly ? false
 }:
 
-assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
+let
+  basename = "libcxx";
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
+
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
+    # but that does not appear to be the case for example when building
+    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
+    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
+    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
+
+in
 
 stdenv.mkDerivation rec {
-  pname = if headersOnly then "cxx-headers" else "libcxx";
-  inherit version;
+  pname = basename;
+  inherit version cmakeFlags;
 
-  inherit src;
-  sourceRoot = "${src.name}/libcxx";
+  src = runCommand "${pname}-src-${version}" {} (''
+    mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/libcxx "$out"
+    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
+    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
+    cp -r ${monorepoSrc}/runtimes "$out"
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
 
-  outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
+  outputs = [ "out" "dev" ];
 
   patches = [
-    ./gnu-install-dirs.patch
+    (substitute {
+      src = ../../common/libcxxabi/wasm.patch;
+      replacements = [
+        "--replace-fail" "/cmake/" "/llvm/cmake/"
+      ];
+    })
   ] ++ lib.optionals stdenv.hostPlatform.isMusl [
-    ../../common/libcxx/libcxx-0001-musl-hacks.patch
+    (substitute {
+      src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
+      replacements = [
+        "--replace-fail" "/include/" "/libcxx/include/"
+      ];
+    })
   ];
 
+  postPatch = ''
+    cd runtimes
+  '';
+
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
 
-  nativeBuildInputs = [ cmake python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+  nativeBuildInputs = [ cmake ninja python3 ]
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
 
-  buildInputs = lib.optionals (!headersOnly) [ cxxabi ];
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
 
-  cmakeFlags = [ "-DLIBCXX_CXX_ABI=${cxxabi.pname}" ]
-    ++ 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.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
-
-  buildFlags = lib.optional headersOnly "generate-cxx-headers";
-  installTargets = lib.optional headersOnly "install-cxx-headers";
-
-  preInstall = lib.optionalString (stdenv.isDarwin && !headersOnly) ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
-
-      baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
-      installName="$out/lib/$baseName"
-      abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
-
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
-      done
-    done
-  '';
-
-  # At this point, cxxabi headers would be installed in the dev output, which
-  # prevents moveToOutput from doing its job later in the build process.
-  postInstall = lib.optionalString (!headersOnly) ''
-    mv "$dev/include/c++/v1/"* "$out/include/c++/v1/"
-    pushd "$dev"
-    rmdir -p include/c++/v1
-    popd
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
   '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
@@ -84,7 +128,6 @@ stdenv.mkDerivation rec {
       libc++ is an implementation of the C++ standard library, targeting C++11,
       C++14 and above.
     '';
-
     # "All of the code in libc++ is dual licensed under the MIT license and the
     # UIUC License (a BSD-like license)":
     license = with lib.licenses; [ mit ncsa ];
diff --git a/pkgs/development/compilers/llvm/13/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/13/libcxx/gnu-install-dirs.patch
deleted file mode 100644
index 744967a6ee0b..000000000000
--- a/pkgs/development/compilers/llvm/13/libcxx/gnu-install-dirs.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index b1e25358d41a..7fe1f4d85401 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -26,6 +26,8 @@ set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD)
-   project(libcxx CXX C)
- 
-+  include(GNUInstallDirs)
-+
-   set(PACKAGE_NAME libcxx)
-   set(PACKAGE_VERSION 13.0.0git)
-   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -412,7 +414,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} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH
-       "Path where target-agnostic libc++ headers should be installed.")
-@@ -426,7 +428,7 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
-   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-   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} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH
-       "Path where target-agnostic libc++ headers should be installed.")
-@@ -436,7 +438,7 @@ else()
-   set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-   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} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH
-       "Path where target-agnostic libc++ headers should be installed.")
-diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
-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 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/src/CMakeLists.txt b/src/CMakeLists.txt
-index 496429f3841e..1a0c9c0a3159 100644
---- a/src/CMakeLists.txt
-+++ b/src/CMakeLists.txt
-@@ -376,21 +376,21 @@ if (LIBCXX_INSTALL_SHARED_LIBRARY)
-   install(TARGETS cxx_shared
-     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_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_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/pkgs/development/compilers/llvm/13/libcxxabi/default.nix b/pkgs/development/compilers/llvm/13/libcxxabi/default.nix
deleted file mode 100644
index 50f09831e974..000000000000
--- a/pkgs/development/compilers/llvm/13/libcxxabi/default.nix
+++ /dev/null
@@ -1,84 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, python3, src, cxx-headers, libunwind, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-, standalone ? stdenv.hostPlatform.useLLVM or false
-, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libcxxabi";
-  inherit version;
-
-  inherit src;
-  sourceRoot = "${src.name}/${pname}";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
-    patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-  ];
-
-  nativeBuildInputs = [ cmake python3 ];
-  buildInputs = lib.optional withLibunwind libunwind;
-
-  cmakeFlags = [
-    "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
-  ] ++ lib.optionals standalone [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-  ] ++ lib.optionals (standalone && withLibunwind) [
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
-
-      # Fix up the install name. Preserve the basename, just replace the path.
-      installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
-
-      # 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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
-
-      # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
-      # libcxxabi to sometimes link against a different version of itself.
-      # Here we simply make that second reference point to ourselves.
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
-      done
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/13/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/13/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index 5d562dd59a99..000000000000
--- a/pkgs/development/compilers/llvm/13/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 9fb35860d483..5739d9e8af62 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -27,6 +27,8 @@ set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
-   project(libcxxabi CXX C)
- 
-+  include(GNUInstallDirs)
-+
-   set(PACKAGE_NAME libcxxabi)
-   set(PACKAGE_VERSION 11.0.0git)
-   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-@@ -195,7 +197,7 @@ set(CMAKE_MODULE_PATH
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   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} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-@@ -204,12 +206,12 @@ 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} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- 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} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- endif()
- 
diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/default.nix b/pkgs/development/compilers/llvm/14/compiler-rt/default.nix
index 1652b3a7fac0..3482ed343c5a 100644
--- a/pkgs/development/compilers/llvm/14/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/14/compiler-rt/default.nix
@@ -1,6 +1,6 @@
 { lib, stdenv, llvm_meta, version
 , monorepoSrc, runCommand
-, cmake, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -30,8 +30,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -128,6 +127,7 @@ stdenv.mkDerivation {
   meta = llvm_meta // {
     homepage = "https://compiler-rt.llvm.org/";
     description = "Compiler runtime libraries";
+    mainProgram = "hwasan_symbolize";
     longDescription = ''
       The compiler-rt project provides highly tuned implementations of the
       low-level code generator support routines like "__fixunsdfdi" and other
diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix
index 090eec234886..66f5c7385a15 100644
--- a/pkgs/development/compilers/llvm/14/default.nix
+++ b/pkgs/development/compilers/llvm/14/default.nix
@@ -134,7 +134,6 @@ in let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -200,7 +199,6 @@ in let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -296,23 +294,7 @@ in let
 
     libcxx = callPackage ./libcxx {
       inherit llvm_meta;
-      stdenv = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-    };
-
-    libcxxabi = let
-      stdenv_ = if stdenv.hostPlatform.useLLVM or false
-               then overrideCC stdenv buildLlvmTools.clangNoLibcxx
-               else stdenv;
-      cxx-headers = callPackage ./libcxx {
-        inherit llvm_meta;
-        stdenv = stdenv_;
-        headersOnly = true;
-      };
-    in callPackage ./libcxxabi {
-      stdenv = stdenv_;
-      inherit llvm_meta cxx-headers;
+      stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
     libunwind = callPackage ./libunwind {
diff --git a/pkgs/development/compilers/llvm/14/libcxx/default.nix b/pkgs/development/compilers/llvm/14/libcxx/default.nix
index ad9e82291cde..79eeadb1c593 100644
--- a/pkgs/development/compilers/llvm/14/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/14/libcxx/default.nix
@@ -1,87 +1,130 @@
 { lib, stdenv, llvm_meta
-, monorepoSrc, runCommand
-, cmake, python3, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt
+, monorepoSrc, runCommand, substitute
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
-
-# If headersOnly is true, the resulting package would only include the headers.
-# Use this to break the circular dependency between libcxx and libcxxabi.
-#
-# Some context:
-# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
-, headersOnly ? false
 }:
 
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
 let
   basename = "libcxx";
-in
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
 
-assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
+    # but that does not appear to be the case for example when building
+    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
+    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
+    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
+
+in
 
 stdenv.mkDerivation rec {
-  pname = basename + lib.optionalString headersOnly "-headers";
-  inherit version;
+  pname = basename;
+  inherit version cmakeFlags;
 
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${basename} "$out"
-    mkdir -p "$out/libcxxabi"
-    cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
+  src = runCommand "${pname}-src-${version}" {} (''
     mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/libcxx "$out"
     cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
     cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
-  '';
-
-  sourceRoot = "${src.name}/${basename}";
+    cp -r ${monorepoSrc}/third-party "$out"
+    cp -r ${monorepoSrc}/runtimes "$out"
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
 
-  outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
+  outputs = [ "out" "dev" ];
 
   patches = [
-    ./gnu-install-dirs.patch
+    (substitute {
+      src = ../../common/libcxxabi/wasm.patch;
+      replacements = [
+        "--replace-fail" "/cmake/" "/llvm/cmake/"
+      ];
+    })
   ] ++ lib.optionals stdenv.hostPlatform.isMusl [
-    ../../common/libcxx/libcxx-0001-musl-hacks.patch
+    (substitute {
+      src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
+      replacements = [
+        "--replace-fail" "/include/" "/libcxx/include/"
+      ];
+    })
   ];
 
+  postPatch = ''
+    # fix CMake error when static and LIBCXXABI_USE_LLVM_UNWINDER=ON. aren't
+    # building unwind so don't need to depend on it
+    substituteInPlace libcxx/src/CMakeLists.txt \
+      --replace-fail "add_dependencies(cxx_static unwind)" "# add_dependencies(cxx_static unwind)"
+    cd runtimes
+  '';
+
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
 
-  nativeBuildInputs = [ cmake python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  buildInputs = lib.optionals (!headersOnly) [ cxxabi ];
-
-  cmakeFlags = [ "-DLIBCXX_CXX_ABI=${cxxabi.pname}" ]
-    ++ 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.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
-
-  buildFlags = lib.optional headersOnly "generate-cxx-headers";
-  installTargets = lib.optional headersOnly "install-cxx-headers";
-
-  preInstall = lib.optionalString (stdenv.isDarwin && !headersOnly) ''
-    for file in lib/*.dylib; do
-      if [ -L "$file" ]; then continue; fi
+  nativeBuildInputs = [ cmake ninja python3 ]
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
 
-      baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
-      installName="$out/lib/$baseName"
-      abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
 
-      for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-        ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
-      done
-    done
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
   '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
diff --git a/pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch
deleted file mode 100644
index bddf55d1e605..000000000000
--- a/pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -436,7 +436,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} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
-       "Path where target-specific libc++ headers should be installed.")
-@@ -453,7 +453,7 @@ else()
-     set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-   endif()
-   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
-       "Path where target-specific libc++ headers should be installed.")
diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix
deleted file mode 100644
index 0f7cec3695d6..000000000000
--- a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix
+++ /dev/null
@@ -1,103 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, python3
-, monorepoSrc, runCommand
-, cxx-headers, libunwind, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-    mkdir -p "$out/libcxx/src"
-    cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
-    mkdir -p "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
-  '';
-
-  sourceRoot = "${src.name}/${pname}";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
-    patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-  ];
-
-  nativeBuildInputs = [ cmake python3 ];
-  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
-
-  cmakeFlags = [
-    "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
-  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  installPhase = if stdenv.isDarwin
-    then ''
-      for file in lib/*.dylib; do
-        if [ -L "$file" ]; then continue; fi
-
-        # Fix up the install name. Preserve the basename, just replace the path.
-        installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
-
-        # 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
-        # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-        ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
-
-        # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
-        # libcxxabi to sometimes link against a different version of itself.
-        # Here we simply make that second reference point to ourselves.
-        for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
-          ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
-        done
-      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 ../include/cxxabi.h $out/include
-    '' + lib.optionalString enableShared ''
-      install -m 644 lib/libc++abi.so.1.0 $out/lib
-      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
-    '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index bd25c903d5bc..000000000000
--- a/pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index ecbc7091864e..53ba2dbc3bd1 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -216,7 +216,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   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} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-@@ -230,7 +230,7 @@ else()
-     set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
-     set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-   endif()
--  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- endif()
- 
diff --git a/pkgs/development/compilers/llvm/15/compiler-rt/default.nix b/pkgs/development/compilers/llvm/15/compiler-rt/default.nix
index fbf25786efee..d257c69cbcd0 100644
--- a/pkgs/development/compilers/llvm/15/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/15/compiler-rt/default.nix
@@ -1,6 +1,6 @@
 { lib, stdenv, llvm_meta, version
 , monorepoSrc, runCommand
-, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -30,8 +30,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -127,6 +126,7 @@ stdenv.mkDerivation {
   meta = llvm_meta // {
     homepage = "https://compiler-rt.llvm.org/";
     description = "Compiler runtime libraries";
+    mainProgram = "hwasan_symbolize";
     longDescription = ''
       The compiler-rt project provides highly tuned implementations of the
       low-level code generator support routines like "__fixunsdfdi" and other
diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix
index d9ca0819f2e0..0ccb9c449a8d 100644
--- a/pkgs/development/compilers/llvm/15/default.nix
+++ b/pkgs/development/compilers/llvm/15/default.nix
@@ -139,7 +139,6 @@ in let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -205,7 +204,6 @@ in let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -309,45 +307,7 @@ in let
 
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
-    libcxxabi = let
-      # CMake will "require" a compiler capable of compiling C++ programs
-      # cxx-header's build does not actually use one so it doesn't really matter
-      # what stdenv we use here, as long as CMake is happy.
-      cxx-headers = callPackage ./libcxx {
-        inherit llvm_meta;
-        # Note that if we use the regular stdenv here we'll get cycle errors
-        # when attempting to use this compiler in the stdenv.
-        #
-        # The final stdenv pulls `cxx-headers` from the package set where
-        # hostPlatform *is* the target platform which means that `stdenv` at
-        # that point attempts to use this toolchain.
-        #
-        # So, we use `stdenv_` (the stdenv containing `clang` from this package
-        # set, defined below) to sidestep this issue.
-        #
-        # Because we only use `cxx-headers` in `libcxxabi` (which depends on the
-        # clang stdenv _anyways_), this is okay.
-        stdenv = stdenv_;
-        headersOnly = true;
-      };
-
-      # `libcxxabi` *doesn't* need a compiler with a working C++ stdlib but it
-      # *does* need a relatively modern C++ compiler (see:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support).
-      #
-      # So, we use the clang from this LLVM package set, like libc++
-      # "boostrapping builds" do:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/BuildingLibcxx.html#bootstrapping-build
-      #
-      # We cannot use `clangNoLibcxx` because that contains `compiler-rt` which,
-      # on macOS, depends on `libcxxabi`, thus forming a cycle.
-      stdenv_ = overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc;
-    in callPackage ./libcxxabi {
-      stdenv = stdenv_;
-      inherit llvm_meta cxx-headers;
-    };
-
-    # Like `libcxxabi` above, `libcxx` requires a fairly modern C++ compiler,
+    # `libcxx` requires a fairly modern C++ compiler,
     # so: we use the clang from this LLVM package set instead of the regular
     # stdenv's compiler.
     libcxx = callPackage ./libcxx {
diff --git a/pkgs/development/compilers/llvm/15/libcxx/default.nix b/pkgs/development/compilers/llvm/15/libcxx/default.nix
index 6a055581fffd..89181bcbdbbf 100644
--- a/pkgs/development/compilers/llvm/15/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/15/libcxx/default.nix
@@ -1,75 +1,111 @@
 { lib, stdenv, llvm_meta
-, monorepoSrc, runCommand, fetchpatch
-, cmake, ninja, python3, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt, libunwind
+, monorepoSrc, runCommand, fetchpatch, substitute
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
-
-# If headersOnly is true, the resulting package would only include the headers.
-# Use this to break the circular dependency between libcxx and libcxxabi.
-#
-# Some context:
-# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
-, headersOnly ? false
 }:
 
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
 let
   basename = "libcxx";
-in
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
+
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
+    # but that does not appear to be the case for example when building
+    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
+    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
+    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
 
-assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
+in
 
 stdenv.mkDerivation rec {
-  pname = basename + lib.optionalString headersOnly "-headers";
-  inherit version;
+  pname = basename;
+  inherit version cmakeFlags;
 
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${basename} "$out"
-    mkdir -p "$out/libcxxabi"
-    cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
+  src = runCommand "${pname}-src-${version}" {} (''
     mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/libcxx "$out"
     cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
     cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
     cp -r ${monorepoSrc}/third-party "$out"
     cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
-
-  outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
 
-  prePatch = ''
-    cd ../${basename}
-    chmod -R u+w .
-  '';
+  outputs = [ "out" "dev" ];
 
   patches = [
-    ./gnu-install-dirs.patch
     # See:
     #   - https://reviews.llvm.org/D133566
     #   - https://github.com/NixOS/nixpkgs/issues/214524#issuecomment-1429146432
     # !!! Drop in LLVM 16+
     (fetchpatch {
       url = "https://github.com/llvm/llvm-project/commit/57c7bb3ec89565c68f858d316504668f9d214d59.patch";
-      hash = "sha256-AaM9A6tQ4YAw7uDqCIV4VaiUyLZv+unwcOqbakwW9/k=";
-      relative = "libcxx";
+      hash = "sha256-B07vHmSjy5BhhkGSj3e1E0XmMv5/9+mvC/k70Z29VwY=";
     })
-    # fix for https://github.com/NixOS/nixpkgs/issues/269548
-    # https://github.com/llvm/llvm-project/pull/77218
-    (fetchpatch {
-      name = "darwin-system-libcxxabi-link-flags.patch";
-      url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
-      hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
-      relative = "libcxx";
+    (substitute {
+      src = ../../common/libcxxabi/wasm.patch;
+      replacements = [
+        "--replace-fail" "/cmake/" "/llvm/cmake/"
+      ];
     })
   ] ++ lib.optionals stdenv.hostPlatform.isMusl [
-    ../../common/libcxx/libcxx-0001-musl-hacks.patch
+    (substitute {
+      src = ../../common/libcxx/libcxx-0001-musl-hacks.patch;
+      replacements = [
+        "--replace-fail" "/include/" "/libcxx/include/"
+      ];
+    })
   ];
 
   postPatch = ''
-    cd ../runtimes
+    cd runtimes
   '';
 
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
@@ -77,52 +113,22 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ cmake ninja python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  buildInputs =
-    lib.optionals (!headersOnly) [ cxxabi ]
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ];
-
-  cmakeFlags = let
-    # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
-    libcxx_cxx_abi_opt = {
-      "c++abi" = "system-libcxxabi";
-      "cxxrt" = "libcxxrt";
-    }.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
-  in [
-    "-DLLVM_ENABLE_RUNTIMES=libcxx"
-    "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
-  ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
-    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
-      "-DLIBCXX_USE_COMPILER_RT=ON"
-      # (Backport fix from 16, which has LIBCXX_ADDITIONAL_LIBRARIES, but 15
-      # does not appear to)
-      # There's precedent for this in llvm-project/libcxx/cmake/caches.
-      # In a monorepo build you might do the following in the libcxxabi build:
-      #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwind
-      #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
-      # libcxx appears to require unwind and doesn't pull it in via other means.
-      # "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
-      "-DCMAKE_SHARED_LINKER_FLAGS=-lunwind"
-    ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
-    # If we're only building the headers we don't actually *need* a functioning
-    # C/C++ compiler:
-    ++ lib.optionals (headersOnly) [
-      "-DCMAKE_C_COMPILER_WORKS=ON"
-      "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    ];
-
-  ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
-  installTargets = lib.optional headersOnly "install-cxx-headers";
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
+
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
+
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
+  '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
diff --git a/pkgs/development/compilers/llvm/15/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/15/libcxx/gnu-install-dirs.patch
deleted file mode 100644
index daee5bdd0ed3..000000000000
--- a/pkgs/development/compilers/llvm/15/libcxx/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 74eff2002fc9..c935d10878bb 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -419,7 +419,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} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
-       "Path where target-specific libc++ headers should be installed.")
-@@ -436,7 +436,7 @@ else()
-     set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-   endif()
-   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
-       "Path where target-specific libc++ headers should be installed.")
diff --git a/pkgs/development/compilers/llvm/15/libcxxabi/default.nix b/pkgs/development/compilers/llvm/15/libcxxabi/default.nix
deleted file mode 100644
index 04bfee14aa18..000000000000
--- a/pkgs/development/compilers/llvm/15/libcxxabi/default.nix
+++ /dev/null
@@ -1,113 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, ninja, python3
-, monorepoSrc, runCommand, fetchpatch
-, cxx-headers, libunwind, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-    mkdir -p "$out/libcxx/src"
-    cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
-    mkdir -p "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
-    cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
-    patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch}
-  '';
-
-  prePatch = ''
-    cd ../${pname}
-    chmod -R u+w .
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-
-    # https://reviews.llvm.org/D132298, Allow building libcxxabi alone
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
-      sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
-      stripLen = 1;
-    })
-  ];
-
-  postPatch = ''
-    cd ../runtimes
-  '';
-
-  nativeBuildInputs = [ cmake ninja python3 ];
-  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
-
-  cmakeFlags = [
-    "-DLLVM_ENABLE_RUNTIMES=libcxxabi"
-    "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
-
-    # `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached
-    # (we specify the headers it should use explicitly above).
-    #
-    # CMake however checks for this anyways; this flag tells it not to. See:
-    # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
-    # but that does not appear to be the case for example when building
-    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
-    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
-    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      install_name_tool -id $out/$file $file
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/15/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/15/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index fa587612aaf6..000000000000
--- a/pkgs/development/compilers/llvm/15/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index b8326d08d23a..a1e36f713161 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -187,7 +187,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   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} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-@@ -201,7 +201,7 @@ else()
-     set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
-     set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-   endif()
--  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- endif()
- 
diff --git a/pkgs/development/compilers/llvm/16/compiler-rt/default.nix b/pkgs/development/compilers/llvm/16/compiler-rt/default.nix
index 0f15a9e12cde..2a15e5302b46 100644
--- a/pkgs/development/compilers/llvm/16/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/16/compiler-rt/default.nix
@@ -1,6 +1,6 @@
 { lib, stdenv, llvm_meta, version
 , monorepoSrc, runCommand
-, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -31,8 +31,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString ([
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -141,6 +140,7 @@ stdenv.mkDerivation {
   meta = llvm_meta // {
     homepage = "https://compiler-rt.llvm.org/";
     description = "Compiler runtime libraries";
+    mainProgram = "hwasan_symbolize";
     longDescription = ''
       The compiler-rt project provides highly tuned implementations of the
       low-level code generator support routines like "__fixunsdfdi" and other
diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix
index 143076c3f76e..66185071f22b 100644
--- a/pkgs/development/compilers/llvm/16/default.nix
+++ b/pkgs/development/compilers/llvm/16/default.nix
@@ -139,7 +139,6 @@ in let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -214,7 +213,6 @@ in let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -324,45 +322,7 @@ in let
 
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
-    libcxxabi = let
-      # CMake will "require" a compiler capable of compiling C++ programs
-      # cxx-header's build does not actually use one so it doesn't really matter
-      # what stdenv we use here, as long as CMake is happy.
-      cxx-headers = callPackage ./libcxx {
-        inherit llvm_meta;
-        # Note that if we use the regular stdenv here we'll get cycle errors
-        # when attempting to use this compiler in the stdenv.
-        #
-        # The final stdenv pulls `cxx-headers` from the package set where
-        # hostPlatform *is* the target platform which means that `stdenv` at
-        # that point attempts to use this toolchain.
-        #
-        # So, we use `stdenv_` (the stdenv containing `clang` from this package
-        # set, defined below) to sidestep this issue.
-        #
-        # Because we only use `cxx-headers` in `libcxxabi` (which depends on the
-        # clang stdenv _anyways_), this is okay.
-        stdenv = stdenv_;
-        headersOnly = true;
-      };
-
-      # `libcxxabi` *doesn't* need a compiler with a working C++ stdlib but it
-      # *does* need a relatively modern C++ compiler (see:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support).
-      #
-      # So, we use the clang from this LLVM package set, like libc++
-      # "boostrapping builds" do:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/BuildingLibcxx.html#bootstrapping-build
-      #
-      # We cannot use `clangNoLibcxx` because that contains `compiler-rt` which,
-      # on macOS, depends on `libcxxabi`, thus forming a cycle.
-      stdenv_ = overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc;
-    in callPackage ./libcxxabi {
-      stdenv = stdenv_;
-      inherit llvm_meta cxx-headers;
-    };
-
-    # Like `libcxxabi` above, `libcxx` requires a fairly modern C++ compiler,
+    # `libcxx` requires a fairly modern C++ compiler,
     # so: we use the clang from this LLVM package set instead of the regular
     # stdenv's compiler.
     libcxx = callPackage ./libcxx {
diff --git a/pkgs/development/compilers/llvm/16/libcxx/default.nix b/pkgs/development/compilers/llvm/16/libcxx/default.nix
index d6c8c57c1743..146424113ec4 100644
--- a/pkgs/development/compilers/llvm/16/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/16/libcxx/default.nix
@@ -1,115 +1,114 @@
 { lib, stdenv, llvm_meta
 , monorepoSrc, runCommand, fetchpatch
-, cmake, ninja, python3, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt, libunwind
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
-
-# If headersOnly is true, the resulting package would only include the headers.
-# Use this to break the circular dependency between libcxx and libcxxabi.
-#
-# Some context:
-# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
-, headersOnly ? false
 }:
 
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
 let
   basename = "libcxx";
-in
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    # There's precedent for this in llvm-project/libcxx/cmake/caches.
+    # In a monorepo build you might do the following in the libcxxabi build:
+    #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
+    #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
+    # libcxx appears to require unwind and doesn't pull it in via other means.
+    "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
 
-assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
+    # but that does not appear to be the case for example when building
+    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
+    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
+    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
+
+in
 
 stdenv.mkDerivation rec {
-  pname = basename + lib.optionalString headersOnly "-headers";
-  inherit version;
+  pname = basename;
+  inherit version cmakeFlags;
 
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${basename} "$out"
-    mkdir -p "$out/libcxxabi"
-    cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
+  src = runCommand "${pname}-src-${version}" {} (''
     mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/libcxx "$out"
     cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
     cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
     cp -r ${monorepoSrc}/third-party "$out"
     cp -r ${monorepoSrc}/runtimes "$out"
-  '';
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
 
   sourceRoot = "${src.name}/runtimes";
 
-  outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
-
-  prePatch = ''
-    cd ../${basename}
-    chmod -R u+w .
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-    # fix for https://github.com/NixOS/nixpkgs/issues/269548
-    # https://github.com/llvm/llvm-project/pull/77218
-    (fetchpatch {
-      name = "darwin-system-libcxxabi-link-flags.patch";
-      url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
-      hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
-      relative = "libcxx";
-    })
-  ];
-
-  postPatch = ''
-    cd ../runtimes
-  '';
+  outputs = [ "out" "dev" ];
 
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
   '';
 
   nativeBuildInputs = [ cmake ninja python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  buildInputs =
-    lib.optionals (!headersOnly) [ cxxabi ]
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ];
-
-  cmakeFlags = let
-    # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
-    libcxx_cxx_abi_opt = {
-      "c++abi" = "system-libcxxabi";
-      "cxxrt" = "libcxxrt";
-    }.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
-  in [
-    "-DLLVM_ENABLE_RUNTIMES=libcxx"
-    "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
-  ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
-    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
-      "-DLIBCXX_USE_COMPILER_RT=ON"
-      # There's precedent for this in llvm-project/libcxx/cmake/caches.
-      # In a monorepo build you might do the following in the libcxxabi build:
-      #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
-      #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
-      # libcxx appears to require unwind and doesn't pull it in via other means.
-      "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
-    ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-      "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
-    # If we're only building the headers we don't actually *need* a functioning
-    # C/C++ compiler:
-    ++ lib.optionals (headersOnly) [
-      "-DCMAKE_C_COMPILER_WORKS=ON"
-      "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    ];
-
-  ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
-  installTargets = lib.optional headersOnly "install-cxx-headers";
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
+
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
+
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
+  '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
diff --git a/pkgs/development/compilers/llvm/16/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/16/libcxx/gnu-install-dirs.patch
deleted file mode 100644
index daee5bdd0ed3..000000000000
--- a/pkgs/development/compilers/llvm/16/libcxx/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 74eff2002fc9..c935d10878bb 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -419,7 +419,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} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
-       "Path where target-specific libc++ headers should be installed.")
-@@ -436,7 +436,7 @@ else()
-     set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-   endif()
-   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
--  set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-+  set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++ libraries should be installed.")
-   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
-       "Path where target-specific libc++ headers should be installed.")
diff --git a/pkgs/development/compilers/llvm/16/libcxxabi/default.nix b/pkgs/development/compilers/llvm/16/libcxxabi/default.nix
deleted file mode 100644
index 90c57dc52a2d..000000000000
--- a/pkgs/development/compilers/llvm/16/libcxxabi/default.nix
+++ /dev/null
@@ -1,114 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, ninja, python3
-, monorepoSrc, runCommand, fetchpatch
-, cxx-headers, libunwind, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-    mkdir -p "$out/libcxx/src"
-    cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
-    mkdir -p "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
-    cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '';
-
-  prePatch = ''
-    cd ../${pname}
-    chmod -R u+w .
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-
-    # https://reviews.llvm.org/D132298, Allow building libcxxabi alone
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
-      sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
-      stripLen = 1;
-    })
-  ];
-
-  postPatch = ''
-    cd ../runtimes
-  '';
-
-  nativeBuildInputs = [ cmake ninja python3 ];
-  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
-
-  cmakeFlags = [
-    "-DLLVM_ENABLE_RUNTIMES=libcxxabi"
-    "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
-
-    # `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached
-    # (we specify the headers it should use explicitly above).
-    #
-    # CMake however checks for this anyways; this flag tells it not to. See:
-    # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
-    # but that does not appear to be the case for example when building
-    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
-    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
-    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DCMAKE_C_COMPILER_WORKS=ON"
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      install_name_tool -id $out/$file $file
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/16/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/16/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index fa587612aaf6..000000000000
--- a/pkgs/development/compilers/llvm/16/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index b8326d08d23a..a1e36f713161 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -187,7 +187,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   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} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-@@ -201,7 +201,7 @@ else()
-     set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
-     set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-   endif()
--  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- endif()
- 
diff --git a/pkgs/development/compilers/llvm/16/llvm/default.nix b/pkgs/development/compilers/llvm/16/llvm/default.nix
index aed9c367d1ad..0a8d877ba83c 100644
--- a/pkgs/development/compilers/llvm/16/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/16/llvm/default.nix
@@ -220,6 +220,11 @@ in
       --replace "PassBuilderCallbacksTest.cpp" ""
     rm unittests/IR/PassBuilderCallbacksTest.cpp
     rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
+
+    # Fails in the presence of anti-virus software or other intrusion-detection software that
+    # modifies the atime when run. See #284056.
+    rm test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
+
     # timing-based tests are trouble
     rm utils/lit/tests/googletest-timeout.py
   '' + optionalString stdenv.hostPlatform.isMusl ''
diff --git a/pkgs/development/compilers/llvm/17/compiler-rt/default.nix b/pkgs/development/compilers/llvm/17/compiler-rt/default.nix
index 0f15a9e12cde..2a15e5302b46 100644
--- a/pkgs/development/compilers/llvm/17/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/17/compiler-rt/default.nix
@@ -1,6 +1,6 @@
 { lib, stdenv, llvm_meta, version
 , monorepoSrc, runCommand
-, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -31,8 +31,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString ([
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -141,6 +140,7 @@ stdenv.mkDerivation {
   meta = llvm_meta // {
     homepage = "https://compiler-rt.llvm.org/";
     description = "Compiler runtime libraries";
+    mainProgram = "hwasan_symbolize";
     longDescription = ''
       The compiler-rt project provides highly tuned implementations of the
       low-level code generator support routines like "__fixunsdfdi" and other
diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix
index 60cae920945b..a9138e3c79b6 100644
--- a/pkgs/development/compilers/llvm/17/default.nix
+++ b/pkgs/development/compilers/llvm/17/default.nix
@@ -134,7 +134,6 @@ in let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -199,7 +198,6 @@ in let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -308,45 +306,7 @@ in let
 
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
-    libcxxabi = let
-      # CMake will "require" a compiler capable of compiling C++ programs
-      # cxx-header's build does not actually use one so it doesn't really matter
-      # what stdenv we use here, as long as CMake is happy.
-      cxx-headers = callPackage ./libcxx {
-        inherit llvm_meta;
-        # Note that if we use the regular stdenv here we'll get cycle errors
-        # when attempting to use this compiler in the stdenv.
-        #
-        # The final stdenv pulls `cxx-headers` from the package set where
-        # hostPlatform *is* the target platform which means that `stdenv` at
-        # that point attempts to use this toolchain.
-        #
-        # So, we use `stdenv_` (the stdenv containing `clang` from this package
-        # set, defined below) to sidestep this issue.
-        #
-        # Because we only use `cxx-headers` in `libcxxabi` (which depends on the
-        # clang stdenv _anyways_), this is okay.
-        stdenv = stdenv_;
-        headersOnly = true;
-      };
-
-      # `libcxxabi` *doesn't* need a compiler with a working C++ stdlib but it
-      # *does* need a relatively modern C++ compiler (see:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support).
-      #
-      # So, we use the clang from this LLVM package set, like libc++
-      # "boostrapping builds" do:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/BuildingLibcxx.html#bootstrapping-build
-      #
-      # We cannot use `clangNoLibcxx` because that contains `compiler-rt` which,
-      # on macOS, depends on `libcxxabi`, thus forming a cycle.
-      stdenv_ = overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc;
-    in callPackage ./libcxxabi {
-      stdenv = stdenv_;
-      inherit llvm_meta cxx-headers;
-    };
-
-    # Like `libcxxabi` above, `libcxx` requires a fairly modern C++ compiler,
+    # `libcxx` requires a fairly modern C++ compiler,
     # so: we use the clang from this LLVM package set instead of the regular
     # stdenv's compiler.
     libcxx = callPackage ./libcxx {
diff --git a/pkgs/development/compilers/llvm/17/libcxx/default.nix b/pkgs/development/compilers/llvm/17/libcxx/default.nix
index 8f4b0cec8d40..9ee4fd180d4b 100644
--- a/pkgs/development/compilers/llvm/17/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/17/libcxx/default.nix
@@ -1,71 +1,102 @@
 { lib, stdenv, llvm_meta
 , monorepoSrc, runCommand, fetchpatch
-, cmake, ninja, python3, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt, libunwind
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
-
-# If headersOnly is true, the resulting package would only include the headers.
-# Use this to break the circular dependency between libcxx and libcxxabi.
-#
-# Some context:
-# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
-, headersOnly ? false
 }:
 
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
 let
   basename = "libcxx";
-in
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    # There's precedent for this in llvm-project/libcxx/cmake/caches.
+    # In a monorepo build you might do the following in the libcxxabi build:
+    #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
+    #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
+    # libcxx appears to require unwind and doesn't pull it in via other means.
+    "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
+
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
+    # but that does not appear to be the case for example when building
+    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
+    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
+    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
 
-assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
+in
 
 stdenv.mkDerivation rec {
-  pname = basename + lib.optionalString headersOnly "-headers";
-  inherit version;
+  pname = basename;
+  inherit version cmakeFlags;
 
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${basename} "$out"
-    mkdir -p "$out/libcxxabi"
-    cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
+  src = runCommand "${pname}-src-${version}" {} (''
     mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/libcxx "$out"
     cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
     cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
     cp -r ${monorepoSrc}/third-party "$out"
     cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
-
-  outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
 
-  prePatch = ''
-    cd ../${basename}
-    chmod -R u+w .
-  '';
+  outputs = [ "out" "dev" ];
 
-  patches = [
-    # fix for https://github.com/NixOS/nixpkgs/issues/269548
-    # https://github.com/llvm/llvm-project/pull/77218
-    (fetchpatch {
-      name = "darwin-system-libcxxabi-link-flags.patch";
-      url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
-      hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
-      relative = "libcxx";
-    })
-  ] ++ lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
+  patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
     # https://github.com/llvm/llvm-project/issues/64226
     (fetchpatch {
       name = "0042-mbstate_t-not-defined.patch";
       url = "https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch";
-      relative = "libcxx";
-      hash = "sha256-fVbX99W1gQrSaMFeBkzsJmNWNy0xVSw+oFvDe4AYXL0=";
+      hash = "sha256-jo+DYA6zuSv9OH3A0bYwY5TlkWprup4OKQ7rfK1WHBI=";
     })
   ];
 
   postPatch = ''
-    cd ../runtimes
+    cd runtimes
   '';
 
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
@@ -73,50 +104,22 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ cmake ninja python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  buildInputs =
-    lib.optionals (!headersOnly) [ cxxabi ]
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ];
-
-  cmakeFlags = let
-    # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
-    libcxx_cxx_abi_opt = {
-      "c++abi" = "system-libcxxabi";
-      "cxxrt" = "libcxxrt";
-    }.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
-  in [
-    "-DLLVM_ENABLE_RUNTIMES=libcxx"
-    "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
-  ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
-    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
-      "-DLIBCXX_USE_COMPILER_RT=ON"
-      # There's precedent for this in llvm-project/libcxx/cmake/caches.
-      # In a monorepo build you might do the following in the libcxxabi build:
-      #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
-      #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
-      # libcxx appears to require unwind and doesn't pull it in via other means.
-      "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
-    ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-      "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
-    # If we're only building the headers we don't actually *need* a functioning
-    # C/C++ compiler:
-    ++ lib.optionals (headersOnly) [
-      "-DCMAKE_C_COMPILER_WORKS=ON"
-      "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    ];
-
-  ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
-  installTargets = lib.optional headersOnly "install-cxx-headers";
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
+
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
+
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
+  '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
diff --git a/pkgs/development/compilers/llvm/17/libcxxabi/default.nix b/pkgs/development/compilers/llvm/17/libcxxabi/default.nix
deleted file mode 100644
index 30ca99b20fd7..000000000000
--- a/pkgs/development/compilers/llvm/17/libcxxabi/default.nix
+++ /dev/null
@@ -1,114 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, ninja, python3
-, monorepoSrc, runCommand, fetchpatch
-, cxx-headers, libunwind, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-    mkdir -p "$out/libcxx/src"
-    cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
-    mkdir -p "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
-    cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '';
-
-  prePatch = ''
-    cd ../${pname}
-    chmod -R u+w .
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-
-    # https://reviews.llvm.org/D132298, Allow building libcxxabi alone
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
-      sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
-      stripLen = 1;
-    })
-  ];
-
-  postPatch = ''
-    cd ../runtimes
-  '';
-
-  nativeBuildInputs = [ cmake ninja python3 ];
-  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
-
-  cmakeFlags = [
-    "-DLLVM_ENABLE_RUNTIMES=libcxxabi"
-    "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
-
-    # `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached
-    # (we specify the headers it should use explicitly above).
-    #
-    # CMake however checks for this anyways; this flag tells it not to. See:
-    # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
-    # but that does not appear to be the case for example when building
-    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
-    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
-    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DCMAKE_C_COMPILER_WORKS=ON"
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-    "-DUNIX=ON"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      install_name_tool -id $out/$file $file
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/17/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/17/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index 51382fcefed2..000000000000
--- a/pkgs/development/compilers/llvm/17/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
-index f380fe6b6b92..a9656258c38e 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -188,7 +188,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   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} CACHE STRING
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-@@ -202,7 +202,7 @@ else()
-     set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
-     set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-   endif()
--  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE STRING
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- endif()
- 
diff --git a/pkgs/development/compilers/llvm/17/llvm/default.nix b/pkgs/development/compilers/llvm/17/llvm/default.nix
index 2c5d6aeb5cec..ec2edabe4ec5 100644
--- a/pkgs/development/compilers/llvm/17/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/17/llvm/default.nix
@@ -219,6 +219,10 @@ stdenv.mkDerivation (rec {
       --replace "PassBuilderCallbacksTest.cpp" ""
     rm unittests/IR/PassBuilderCallbacksTest.cpp
     rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
+
+    # Fails in the presence of anti-virus software or other intrusion-detection software that
+    # modifies the atime when run. See #284056.
+    rm test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
   '' + optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -i ${../../common/llvm/TLI-musl.patch}
     substituteInPlace unittests/Support/CMakeLists.txt \
diff --git a/pkgs/development/compilers/llvm/common/libclc.nix b/pkgs/development/compilers/llvm/common/libclc.nix
index c91930963b20..4c2081e693c1 100644
--- a/pkgs/development/compilers/llvm/common/libclc.nix
+++ b/pkgs/development/compilers/llvm/common/libclc.nix
@@ -47,6 +47,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "http://libclc.llvm.org/";
     description = "Implementation of the library requirements of the OpenCL C programming language";
+    mainProgram = "prepare_builtins";
     license = licenses.mit;
     platforms = platforms.all;
   };
diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix b/pkgs/development/compilers/llvm/git/compiler-rt/default.nix
index 7b44a872adc4..51f4e95ef2b5 100644
--- a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix
+++ b/pkgs/development/compilers/llvm/git/compiler-rt/default.nix
@@ -1,6 +1,6 @@
 { lib, stdenv, llvm_meta, version
 , monorepoSrc, runCommand
-, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libcxxabi, libxcrypt
+, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
 , doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
 }:
 
@@ -31,8 +31,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
     ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
   buildInputs =
-    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
-    ++ lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
 
   env.NIX_CFLAGS_COMPILE = toString ([
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix
index f968ebecb2c8..6ebb2ea9fcc2 100644
--- a/pkgs/development/compilers/llvm/git/default.nix
+++ b/pkgs/development/compilers/llvm/git/default.nix
@@ -134,7 +134,6 @@ in let
       cc = tools.clang-unwrapped;
       libcxx = targetLlvmLibraries.libcxx;
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ];
       extraBuildCommands = mkExtraBuildCommands cc;
@@ -199,7 +198,6 @@ in let
       libcxx = targetLlvmLibraries.libcxx;
       bintools = bintools';
       extraPackages = [
-        libcxx.cxxabi
         targetLlvmLibraries.compiler-rt
       ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
@@ -309,45 +307,7 @@ in let
 
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
-    libcxxabi = let
-      # CMake will "require" a compiler capable of compiling C++ programs
-      # cxx-header's build does not actually use one so it doesn't really matter
-      # what stdenv we use here, as long as CMake is happy.
-      cxx-headers = callPackage ./libcxx {
-        inherit llvm_meta;
-        # Note that if we use the regular stdenv here we'll get cycle errors
-        # when attempting to use this compiler in the stdenv.
-        #
-        # The final stdenv pulls `cxx-headers` from the package set where
-        # hostPlatform *is* the target platform which means that `stdenv` at
-        # that point attempts to use this toolchain.
-        #
-        # So, we use `stdenv_` (the stdenv containing `clang` from this package
-        # set, defined below) to sidestep this issue.
-        #
-        # Because we only use `cxx-headers` in `libcxxabi` (which depends on the
-        # clang stdenv _anyways_), this is okay.
-        stdenv = stdenv_;
-        headersOnly = true;
-      };
-
-      # `libcxxabi` *doesn't* need a compiler with a working C++ stdlib but it
-      # *does* need a relatively modern C++ compiler (see:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support).
-      #
-      # So, we use the clang from this LLVM package set, like libc++
-      # "boostrapping builds" do:
-      # https://releases.llvm.org/15.0.0/projects/libcxx/docs/BuildingLibcxx.html#bootstrapping-build
-      #
-      # We cannot use `clangNoLibcxx` because that contains `compiler-rt` which,
-      # on macOS, depends on `libcxxabi`, thus forming a cycle.
-      stdenv_ = overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc;
-    in callPackage ./libcxxabi {
-      stdenv = stdenv_;
-      inherit llvm_meta cxx-headers;
-    };
-
-    # Like `libcxxabi` above, `libcxx` requires a fairly modern C++ compiler,
+    # `libcxx` requires a fairly modern C++ compiler,
     # so: we use the clang from this LLVM package set instead of the regular
     # stdenv's compiler.
     libcxx = callPackage ./libcxx {
diff --git a/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch b/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch
index 0a2e8db07391..29942f8ed03d 100644
--- a/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch
+++ b/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch
@@ -9,13 +9,13 @@ removes space from
 https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch
 so it applies cleanly
 ---
- include/__mbstate_t.h | 3 +++
+ libcxx/include/__mbstate_t.h | 3 +++
  1 file changed, 3 insertions(+)
 
-diff --git a/include/__mbstate_t.h b/include/__mbstate_t.h
+diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h
 index bfa6d61..5f51112 100644
---- a/include/__mbstate_t.h
-+++ b/include/__mbstate_t.h
+--- a/libcxx/include/__mbstate_t.h
++++ b/libcxx/include/__mbstate_t.h
 @@ -42,6 +42,9 @@
  #elif __has_include(<bits/types/mbstate_t.h>)
  #  include <bits/types/mbstate_t.h> // works on most Unixes
diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix
index 11f4c6fe5fd1..4e3404dbe194 100644
--- a/pkgs/development/compilers/llvm/git/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix
@@ -1,57 +1,108 @@
 { lib, stdenv, llvm_meta
 , monorepoSrc, runCommand, fetchpatch
-, cmake, ninja, python3, fixDarwinDylibNames, version
-, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
-, libcxxabi, libcxxrt, libunwind
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
 , enableShared ? !stdenv.hostPlatform.isStatic
-
-# If headersOnly is true, the resulting package would only include the headers.
-# Use this to break the circular dependency between libcxx and libcxxabi.
-#
-# Some context:
-# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb
-, headersOnly ? false
 }:
 
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
 let
   basename = "libcxx";
-in
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
+  ] ++ lib.optionals (lib.versionAtLeast version "18" && !(useLLVM && !stdenv.hostPlatform.isWasm)) [
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals (lib.versionAtLeast version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
+    "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    # There's precedent for this in llvm-project/libcxx/cmake/caches.
+    # In a monorepo build you might do the following in the libcxxabi build:
+    #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
+    #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
+    # libcxx appears to require unwind and doesn't pull it in via other means.
+    "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
 
-assert stdenv.isDarwin -> cxxabi.libName == "c++abi";
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
+
+in
 
 stdenv.mkDerivation rec {
-  pname = basename + lib.optionalString headersOnly "-headers";
-  inherit version;
+  pname = basename;
+  inherit version cmakeFlags;
 
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${basename} "$out"
-    mkdir -p "$out/libcxxabi"
-    cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi"
+  src = runCommand "${pname}-src-${version}" {} (''
     mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/libcxx "$out"
     cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
     cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
     cp -r ${monorepoSrc}/third-party "$out"
     cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
 
-  outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev";
-
-  prePatch = ''
-    cd ../${basename}
-    chmod -R u+w .
-  '';
+  outputs = [ "out" "dev" ];
 
   patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
     # https://github.com/llvm/llvm-project/issues/64226
     ./0001-darwin-10.12-mbstate_t-fix.patch
+  ] ++ lib.optionals (cxxabi == null && lib.versionAtLeast version "18") [
+    # Allow building libcxxabi alone when using LLVM unwinder
+    (fetchpatch {
+      url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
+      revert = true;
+      hash = "sha256-jFbC3vBY3nKfjknJ7UzaPyoy0iSYdD3+jUmOFeOaVcA=";
+    })
+    (fetchpatch {
+      url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
+      revert = true;
+      hash = "sha256-WN63L4T3GxVozPZb6kx21AgNe4rwwSUOeeryIGsvQYY=";
+    })
   ];
 
   postPatch = ''
-    cd ../runtimes
+    cd runtimes
   '';
 
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
@@ -59,52 +110,22 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ cmake ninja python3 ]
-    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  buildInputs =
-    lib.optionals (!headersOnly) [ cxxabi ]
-    ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ];
-
-  cmakeFlags = let
-    # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string
-    libcxx_cxx_abi_opt = {
-      "c++abi" = "system-libcxxabi";
-      "cxxrt" = "libcxxrt";
-    }.${cxxabi.libName} or (throw "unknown cxxabi: ${cxxabi.libName} (${cxxabi.pname})");
-  in [
-    "-DLLVM_ENABLE_RUNTIMES=libcxx"
-    "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}"
-  ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1"
-    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ lib.optionals (lib.versionAtLeast version "18" && !(stdenv.hostPlatform.useLLVM or false) && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
-    "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
-  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
-      "-DLIBCXX_USE_COMPILER_RT=ON"
-      # There's precedent for this in llvm-project/libcxx/cmake/caches.
-      # In a monorepo build you might do the following in the libcxxabi build:
-      #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
-      #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
-      # libcxx appears to require unwind and doesn't pull it in via other means.
-      "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
-    ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-      "-DLIBCXX_ENABLE_THREADS=OFF"
-      "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
-      "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-      "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
-    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
-    # If we're only building the headers we don't actually *need* a functioning
-    # C/C++ compiler:
-    ++ lib.optionals (headersOnly) [
-      "-DCMAKE_C_COMPILER_WORKS=ON"
-      "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    ];
-
-  ninjaFlags = lib.optional headersOnly "generate-cxx-headers";
-  installTargets = lib.optional headersOnly "install-cxx-headers";
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
+
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
+
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
+  '';
 
   passthru = {
     isLLVM = true;
-    inherit cxxabi;
   };
 
   meta = llvm_meta // {
diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix
deleted file mode 100644
index 8e1979654325..000000000000
--- a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix
+++ /dev/null
@@ -1,130 +0,0 @@
-{ lib, stdenv, llvm_meta, cmake, ninja, python3
-, monorepoSrc, runCommand, fetchpatch
-, cxx-headers, libunwind, version
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-stdenv.mkDerivation rec {
-  pname = "libcxxabi";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-    mkdir -p "$out/libcxx/src"
-    cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/include "$out/libcxx"
-    cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src"
-    mkdir -p "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
-    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
-    cp -r ${monorepoSrc}/runtimes "$out"
-  '';
-
-  sourceRoot = "${src.name}/runtimes";
-
-  outputs = [ "out" "dev" ];
-
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    export TRIPLE=x86_64-apple-darwin
-  '';
-
-  prePatch = ''
-    cd ../${pname}
-    chmod -R u+w .
-  '';
-
-  patches = [
-    ./gnu-install-dirs.patch
-
-    # https://reviews.llvm.org/D132298, Allow building libcxxabi alone
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch";
-      sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a";
-      stripLen = 1;
-    })
-  ] ++ lib.optionals (lib.versionAtLeast version "18") [
-    # Allow building libcxxabi alone when using LLVM unwinder
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
-      stripLen = 1;
-      revert = true;
-      hash = "sha256-Jogx/cvTJ6fdyprTD1QzMIeRWcBlZZMWE/y9joOtVH0=";
-    })
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
-      stripLen = 1;
-      revert = true;
-      hash = "sha256-7VeBFjG7CnEMWn0hpBvyNOyhRfz50PnD3zyQNDhNChk=";
-    })
-  ];
-
-  postPatch = ''
-    cd ../runtimes
-  '';
-
-  nativeBuildInputs = [ cmake ninja python3 ];
-  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind;
-
-  cmakeFlags = [
-    "-DLLVM_ENABLE_RUNTIMES=libcxxabi"
-    "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1"
-
-    # `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached
-    # (we specify the headers it should use explicitly above).
-    #
-    # CMake however checks for this anyways; this flag tells it not to. See:
-    # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-  ] ++ lib.optionals (lib.versionAtLeast version "18" && !(stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm)) [
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
-  ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [
-    "-DLLVM_ENABLE_LIBCXX=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-    # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
-    # but that does not appear to be the case for example when building
-    # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
-    "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
-    "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
-  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
-    "-DCMAKE_C_COMPILER_WORKS=ON"
-    "-DCMAKE_CXX_COMPILER_WORKS=ON"
-    "-DLIBCXXABI_ENABLE_THREADS=OFF"
-    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-    "-DUNIX=ON"
-  ] ++ lib.optionals (!enableShared) [
-    "-DLIBCXXABI_ENABLE_SHARED=OFF"
-  ];
-
-  preInstall = lib.optionalString stdenv.isDarwin ''
-    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
-      # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
-      install_name_tool -id $out/$file $file
-    done
-  '';
-
-  postInstall = ''
-    mkdir -p "$dev/include"
-    install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
-  '';
-
-  passthru = {
-    libName = "c++abi";
-  };
-
-  meta = llvm_meta // {
-    homepage = "https://libcxxabi.llvm.org/";
-    description = "Provides C++ standard library support";
-    longDescription = ''
-      libc++abi is a new implementation of low level support for a standard C++ library.
-    '';
-    # "All of the code in libc++abi is dual licensed under the MIT license and
-    # the UIUC License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-    maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch
deleted file mode 100644
index 51382fcefed2..000000000000
--- a/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
-index f380fe6b6b92..a9656258c38e 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -188,7 +188,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   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} CACHE STRING
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
-   if(LIBCXX_LIBDIR_SUBDIR)
-     string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
-@@ -202,7 +202,7 @@ else()
-     set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
-     set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-   endif()
--  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE STRING
-+  set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
-       "Path where built libc++abi libraries should be installed.")
- endif()
- 
diff --git a/pkgs/development/compilers/llvm/git/llvm/default.nix b/pkgs/development/compilers/llvm/git/llvm/default.nix
index 6dc2b51aaf9a..b8715228ab1c 100644
--- a/pkgs/development/compilers/llvm/git/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/git/llvm/default.nix
@@ -223,6 +223,10 @@ stdenv.mkDerivation (rec {
       --replace "PassBuilderCallbacksTest.cpp" ""
     rm unittests/IR/PassBuilderCallbacksTest.cpp
     rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
+
+    # Fails in the presence of anti-virus software or other intrusion-detection software that
+    # modifies the atime when run. See #284056.
+    rm test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
   '' + optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -i ${../../common/llvm/TLI-musl.patch}
     substituteInPlace unittests/Support/CMakeLists.txt \
diff --git a/pkgs/development/compilers/lobster/default.nix b/pkgs/development/compilers/lobster/default.nix
index 02748546d5aa..131fdbfef98f 100644
--- a/pkgs/development/compilers/lobster/default.nix
+++ b/pkgs/development/compilers/lobster/default.nix
@@ -53,6 +53,7 @@ stdenv.mkDerivation (finalAttrs: {
     broken = stdenv.isDarwin;
     homepage = "https://strlen.com/lobster/";
     description = "The Lobster programming language";
+    mainProgram = "lobster";
     longDescription = ''
       Lobster is a programming language that tries to combine the advantages of
       very static typing and memory management with a very lightweight,
diff --git a/pkgs/development/compilers/lunarml/default.nix b/pkgs/development/compilers/lunarml/default.nix
index 558a4e435a41..d47801181701 100644
--- a/pkgs/development/compilers/lunarml/default.nix
+++ b/pkgs/development/compilers/lunarml/default.nix
@@ -49,6 +49,7 @@ stdenvNoCC.mkDerivation {
 
   meta = {
     description = "Standard ML compiler that produces Lua/JavaScript";
+    mainProgram = "lunarml";
     homepage = "https://github.com/minoki/LunarML";
     license = lib.licenses.mit;
     maintainers = with lib.maintainers; [ toastal ratsclub ];
diff --git a/pkgs/development/compilers/manticore/default.nix b/pkgs/development/compilers/manticore/default.nix
index b767ccf150a6..030e13165631 100644
--- a/pkgs/development/compilers/manticore/default.nix
+++ b/pkgs/development/compilers/manticore/default.nix
@@ -39,6 +39,7 @@ in stdenv.mkDerivation {
 
   meta = {
     description = "A parallel, pure variant of Standard ML";
+    mainProgram = "pmlc";
 
     longDescription = ''
       Manticore is a high-level parallel programming language aimed at
diff --git a/pkgs/development/compilers/mcpp/default.nix b/pkgs/development/compilers/mcpp/default.nix
index e8eb62a15f13..9db55e29ccdb 100644
--- a/pkgs/development/compilers/mcpp/default.nix
+++ b/pkgs/development/compilers/mcpp/default.nix
@@ -23,6 +23,7 @@ stdenv.mkDerivation (finalAttrs: {
   meta = with lib; {
     homepage = "https://github.com/museoa/mcpp";
     description = "Matsui's C preprocessor";
+    mainProgram = "mcpp";
     license = licenses.bsd2;
     maintainers = with maintainers; [ AndersonTorres ];
     platforms = platforms.unix;
diff --git a/pkgs/development/compilers/microscheme/default.nix b/pkgs/development/compilers/microscheme/default.nix
index fa65622ba0cd..c9f3a1847066 100644
--- a/pkgs/development/compilers/microscheme/default.nix
+++ b/pkgs/development/compilers/microscheme/default.nix
@@ -22,6 +22,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "https://ryansuchocki.github.io/microscheme/";
     description = "A Scheme subset for Atmel microcontrollers";
+    mainProgram = "microscheme";
     longDescription = ''
       Microscheme is a Scheme subset/variant designed for Atmel
       microcontrollers, especially as found on Arduino boards.
diff --git a/pkgs/development/compilers/mint/default.nix b/pkgs/development/compilers/mint/default.nix
index b1baf88c936c..3a81f17fd538 100644
--- a/pkgs/development/compilers/mint/default.nix
+++ b/pkgs/development/compilers/mint/default.nix
@@ -26,6 +26,7 @@ crystal.buildCrystalPackage rec {
 
   meta = with lib; {
     description = "A refreshing language for the front-end web";
+    mainProgram = "mint";
     homepage = "https://www.mint-lang.com/";
     license = licenses.bsd3;
     maintainers = with maintainers; [ manveru ];
diff --git a/pkgs/development/compilers/mrustc/default.nix b/pkgs/development/compilers/mrustc/default.nix
index eae17cbce91f..1305843a7fa7 100644
--- a/pkgs/development/compilers/mrustc/default.nix
+++ b/pkgs/development/compilers/mrustc/default.nix
@@ -41,6 +41,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Mutabah's Rust Compiler";
+    mainProgram = "mrustc";
     longDescription = ''
       In-progress alternative rust compiler, written in C++.
       Capable of building a fully-working copy of rustc,
diff --git a/pkgs/development/compilers/mrustc/minicargo.nix b/pkgs/development/compilers/mrustc/minicargo.nix
index 76d19d4d96d7..c7d5da1f9049 100644
--- a/pkgs/development/compilers/mrustc/minicargo.nix
+++ b/pkgs/development/compilers/mrustc/minicargo.nix
@@ -26,6 +26,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "A minimalist builder for Rust";
+    mainProgram = "minicargo";
     longDescription = ''
       A minimalist builder for Rust, similar to Cargo but written in C++.
       Designed to work with mrustc to build Rust projects
diff --git a/pkgs/development/compilers/ocaml/4.14.nix b/pkgs/development/compilers/ocaml/4.14.nix
index 8ce7967853e7..e7dc4d2f5d41 100644
--- a/pkgs/development/compilers/ocaml/4.14.nix
+++ b/pkgs/development/compilers/ocaml/4.14.nix
@@ -1,6 +1,6 @@
 import ./generic.nix {
   major_version = "4";
   minor_version = "14";
-  patch_version = "1";
-  sha256 = "sha256-wSeXTQJCV2z0cGGyCqnIbRe+DWqpaH9uyYNd5nvnu28";
+  patch_version = "2";
+  sha256 = "sha256-eBn2hpPjKUb5M1jfRqjqb1FyImgfzG98uWIUIWz+x2Q=";
 }
diff --git a/pkgs/development/compilers/odin/default.nix b/pkgs/development/compilers/odin/default.nix
index ff3efcb8a6ef..6d4ddf61da31 100644
--- a/pkgs/development/compilers/odin/default.nix
+++ b/pkgs/development/compilers/odin/default.nix
@@ -71,6 +71,7 @@ in stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "A fast, concise, readable, pragmatic and open sourced programming language";
+    mainProgram = "odin";
     homepage = "https://odin-lang.org/";
     license = licenses.bsd3;
     maintainers = with maintainers; [ luc65r astavie znaniye ];
diff --git a/pkgs/development/compilers/open-watcom/v2.nix b/pkgs/development/compilers/open-watcom/v2.nix
index 80ee2ee5e45d..37503496c917 100644
--- a/pkgs/development/compilers/open-watcom/v2.nix
+++ b/pkgs/development/compilers/open-watcom/v2.nix
@@ -47,9 +47,6 @@ stdenv.mkDerivation rec {
     ghostscript
   ];
 
-  # Work around https://github.com/NixOS/nixpkgs/issues/166205
-  env.NIX_LDFLAGS = lib.optionalString (stdenv.cc.isClang && stdenv.cc.libcxx != null) "-l${stdenv.cc.libcxx.cxxabi.libName}";
-
   configurePhase = ''
     runHook preConfigure
 
diff --git a/pkgs/development/compilers/openspin/default.nix b/pkgs/development/compilers/openspin/default.nix
index abf5623b5821..5bf0ff64d354 100644
--- a/pkgs/development/compilers/openspin/default.nix
+++ b/pkgs/development/compilers/openspin/default.nix
@@ -18,6 +18,7 @@ stdenv.mkDerivation {
 
   meta = with lib; {
     description = "Compiler for SPIN/PASM languages for Parallax Propeller MCU";
+    mainProgram = "openspin";
     homepage = "https://github.com/parallaxinc/OpenSpin";
     license = licenses.mit;
     maintainers = [ maintainers.redvers ];
diff --git a/pkgs/development/compilers/opensycl/default.nix b/pkgs/development/compilers/opensycl/default.nix
index c406d4c9d5c2..cdf9a5b9d22c 100644
--- a/pkgs/development/compilers/opensycl/default.nix
+++ b/pkgs/development/compilers/opensycl/default.nix
@@ -9,11 +9,13 @@
 , libffi
 , makeWrapper
 , config
-, rocmPackages
+, rocmPackages_5
 , rocmSupport ? config.rocmSupport
 }:
 let
   inherit (llvmPackages_15) stdenv;
+  # move to newer ROCm version once supported
+  rocmPackages = rocmPackages_5;
 in
 stdenv.mkDerivation rec {
   pname = "OpenSYCL";
diff --git a/pkgs/development/compilers/ophis/default.nix b/pkgs/development/compilers/ophis/default.nix
index 2ddfa849b664..0eebdce820ee 100644
--- a/pkgs/development/compilers/ophis/default.nix
+++ b/pkgs/development/compilers/ophis/default.nix
@@ -16,6 +16,7 @@ buildPythonApplication rec {
   meta = with lib; {
     homepage = "http://michaelcmartin.github.io/Ophis/";
     description = "A cross-assembler for the 6502 series of microprocessors";
+    mainProgram = "ophis";
     longDescription = ''
       Ophis is an assembler for the 6502 microprocessor - the famous chip used
       in the vast majority of the classic 8-bit computers and consoles. Its
diff --git a/pkgs/development/compilers/paco/default.nix b/pkgs/development/compilers/paco/default.nix
index d8014dd8e51b..195a67da023a 100644
--- a/pkgs/development/compilers/paco/default.nix
+++ b/pkgs/development/compilers/paco/default.nix
@@ -27,6 +27,7 @@ buildGoModule rec {
 
   meta = with lib; {
     description = "A simple compiled programming language";
+    mainProgram = "paco";
     homepage = "https://github.com/pacolang/paco";
     license = licenses.mit;
     maintainers = with maintainers; [ hugolgst ];
diff --git a/pkgs/development/compilers/passerine/default.nix b/pkgs/development/compilers/passerine/default.nix
index e5f88e586746..858356657326 100644
--- a/pkgs/development/compilers/passerine/default.nix
+++ b/pkgs/development/compilers/passerine/default.nix
@@ -15,6 +15,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "A small extensible programming language designed for concise expression with little code";
+    mainProgram = "passerine";
     homepage = "https://www.passerine.io/";
     license = licenses.mit;
     maintainers = with maintainers; [ siraben ];
diff --git a/pkgs/development/compilers/pforth/default.nix b/pkgs/development/compilers/pforth/default.nix
index aadc72c174e2..91efc25fc1e0 100644
--- a/pkgs/development/compilers/pforth/default.nix
+++ b/pkgs/development/compilers/pforth/default.nix
@@ -40,6 +40,7 @@ stdenv.mkDerivation (finalAttrs: {
   meta = {
     homepage = "https://www.softsynth.com/pforth/";
     description = "Portable Portable ANS-like Forth written in ANSI 'C'";
+    mainProgram = "pforth";
     changelog = "https://github.com/philburk/pforth/blob/v${finalAttrs.version}/RELEASES.md";
     license = lib.licenses.bsd0;
     maintainers = with lib.maintainers; [ AndersonTorres yrashk ];
diff --git a/pkgs/development/compilers/picat/default.nix b/pkgs/development/compilers/picat/default.nix
index 76d1ebdb4102..f52eed6ddf8d 100644
--- a/pkgs/development/compilers/picat/default.nix
+++ b/pkgs/development/compilers/picat/default.nix
@@ -28,6 +28,7 @@ stdenv.mkDerivation {
 
   meta = with lib; {
     description = "Logic-based programming langage";
+    mainProgram = "picat";
     homepage    = "http://picat-lang.org/";
     license     = licenses.mpl20;
     platforms   = platforms.linux;
diff --git a/pkgs/development/compilers/purescript/psc-package/default.nix b/pkgs/development/compilers/purescript/psc-package/default.nix
index d291b1f3cfee..2d6631938546 100644
--- a/pkgs/development/compilers/purescript/psc-package/default.nix
+++ b/pkgs/development/compilers/purescript/psc-package/default.nix
@@ -52,6 +52,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "A package manager for PureScript based on package sets";
+    mainProgram = "psc-package";
     license = licenses.bsd3;
     maintainers = with maintainers; [ ];
     platforms = [ "x86_64-darwin" "x86_64-linux" ];
diff --git a/pkgs/development/compilers/rasm/default.nix b/pkgs/development/compilers/rasm/default.nix
index 0f617d0f6618..3246e014145f 100644
--- a/pkgs/development/compilers/rasm/default.nix
+++ b/pkgs/development/compilers/rasm/default.nix
@@ -25,6 +25,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "http://www.roudoudou.com/rasm/";
     description = "Z80 assembler";
+    mainProgram = "rasm";
     # use -n option to display all licenses
     license = licenses.mit; # expat version
     maintainers = [ ];
diff --git a/pkgs/development/compilers/rust/cargo-auditable.nix b/pkgs/development/compilers/rust/cargo-auditable.nix
index b86ed5d7d4e1..34d877501c3b 100644
--- a/pkgs/development/compilers/rust/cargo-auditable.nix
+++ b/pkgs/development/compilers/rust/cargo-auditable.nix
@@ -3,16 +3,16 @@
 let
   args = rec {
     pname = "cargo-auditable";
-    version = "0.6.1";
+    version = "0.6.2";
 
     src = fetchFromGitHub {
       owner = "rust-secure-code";
       repo = pname;
       rev = "v${version}";
-      sha256 = "sha256-MKMPLv8jeST0l4tq+MMPC18qfZMmBixdj6Ng19YKepU=";
+      sha256 = "sha256-ERIzx9Fveanq7/aWcB2sviTxIahvSu0sTwgpGf/aYE8=";
     };
 
-    cargoSha256 = "sha256-6/f7pNaTL+U6bI6jMakU/lfwYYxN/EM3WkKZcydsyLk=";
+    cargoHash = "sha256-4o3ctun/8VcBRuj+j0Yaawdkyn6Z6LPp+FTyhPxQWU8=";
 
     # Cargo.lock is outdated
     preConfigure = ''
@@ -21,6 +21,7 @@ let
 
     meta = with lib; {
       description = "A tool to make production Rust binaries auditable";
+      mainProgram = "cargo-auditable";
       homepage = "https://github.com/rust-secure-code/cargo-auditable";
       changelog = "https://github.com/rust-secure-code/cargo-auditable/blob/v${version}/cargo-auditable/CHANGELOG.md";
       license = with licenses; [ mit /* or */ asl20 ];
diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix
index b57ad0c811c2..b0c40c5760cb 100644
--- a/pkgs/development/compilers/rust/cargo.nix
+++ b/pkgs/development/compilers/rust/cargo.nix
@@ -72,6 +72,7 @@ rustPlatform.buildRustPackage.override {
   meta = with lib; {
     homepage = "https://crates.io";
     description = "Downloads your Rust project's dependencies and builds your project";
+    mainProgram = "cargo";
     maintainers = teams.rust.members;
     license = [ licenses.mit licenses.asl20 ];
     platforms = platforms.unix;
diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix
index 78b3ed07602b..2371ed651950 100644
--- a/pkgs/development/compilers/sbcl/default.nix
+++ b/pkgs/development/compilers/sbcl/default.nix
@@ -146,6 +146,12 @@ stdenv.mkDerivation (self: rec {
         --replace-quiet /bin/uname "${coreutils}/bin/uname" \
         --replace-quiet /bin/sh "${stdenv.shell}"
     )
+    # Official source release tarballs will have a version.lispexpr, but if you
+    # want to override { src = ... } it might not exist. It’s required for
+    # building, so create a mock version as a backup.
+    if [[ ! -a version.lisp-expr ]]; then
+      echo '"${version}.nixos"' > version.lisp-expr
+    fi
   '';
 
   preBuild = ''
diff --git a/pkgs/development/compilers/scryer-prolog/default.nix b/pkgs/development/compilers/scryer-prolog/default.nix
index a0247c265e80..02383e6b4a51 100644
--- a/pkgs/development/compilers/scryer-prolog/default.nix
+++ b/pkgs/development/compilers/scryer-prolog/default.nix
@@ -30,6 +30,7 @@ rustPlatform.buildRustPackage rec {
   meta = with lib; {
     broken = stdenv.isDarwin;
     description = "A modern Prolog implementation written mostly in Rust";
+    mainProgram = "scryer-prolog";
     homepage = "https://github.com/mthom/scryer-prolog";
     license = with licenses; [ bsd3 ];
     maintainers = with maintainers; [ malbarbo wkral ];
diff --git a/pkgs/development/compilers/serpent/default.nix b/pkgs/development/compilers/serpent/default.nix
index 227e8037eaee..31f6b0709da3 100644
--- a/pkgs/development/compilers/serpent/default.nix
+++ b/pkgs/development/compilers/serpent/default.nix
@@ -25,6 +25,7 @@ stdenv.mkDerivation {
 
   meta = with lib; {
     description = "Compiler for the Serpent language for Ethereum";
+    mainProgram = "serpent";
     longDescription = ''
       Serpent is one of the high-level programming languages used to
       write Ethereum contracts. The language, as suggested by its name,
diff --git a/pkgs/development/compilers/sjasmplus/default.nix b/pkgs/development/compilers/sjasmplus/default.nix
index 6ef3d11c712f..61d85b95c452 100644
--- a/pkgs/development/compilers/sjasmplus/default.nix
+++ b/pkgs/development/compilers/sjasmplus/default.nix
@@ -25,6 +25,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "https://z00m128.github.io/sjasmplus/";
     description = "A Z80 assembly language cross compiler. It is based on the SjASM source code by Sjoerd Mastijn";
+    mainProgram = "sjasmplus";
     license = licenses.bsd3;
     platforms = platforms.all;
     maintainers = with maintainers; [ electrified ];
diff --git a/pkgs/development/compilers/spasm-ng/default.nix b/pkgs/development/compilers/spasm-ng/default.nix
index bd31719731e9..9045710dc770 100644
--- a/pkgs/development/compilers/spasm-ng/default.nix
+++ b/pkgs/development/compilers/spasm-ng/default.nix
@@ -25,6 +25,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage    = "https://github.com/alberthdev/spasm-ng";
     description = "Z80 assembler with extra features to support development for TI calculators";
+    mainProgram = "spasm";
     license     = licenses.gpl2Plus;
     maintainers = with maintainers; [ siraben ];
     platforms   = platforms.unix;
diff --git a/pkgs/development/compilers/spirv-llvm-translator/default.nix b/pkgs/development/compilers/spirv-llvm-translator/default.nix
index 80e4620c7dc6..9dde7e475171 100644
--- a/pkgs/development/compilers/spirv-llvm-translator/default.nix
+++ b/pkgs/development/compilers/spirv-llvm-translator/default.nix
@@ -7,7 +7,6 @@
 , llvm
 , spirv-headers
 , spirv-tools
-, disable-warnings-if-gcc13
 }:
 
 let
@@ -42,7 +41,7 @@ let
       hash = "sha256-NoIoa20+2sH41rEnr8lsMhtfesrtdPINiXtUnxYVm8s=";
     } else throw "Incompatible LLVM version.";
 in
-disable-warnings-if-gcc13 (stdenv.mkDerivation {
+stdenv.mkDerivation {
   pname = "SPIRV-LLVM-Translator";
   inherit (branch) version;
 
@@ -114,8 +113,9 @@ disable-warnings-if-gcc13 (stdenv.mkDerivation {
   meta = with lib; {
     homepage    = "https://github.com/KhronosGroup/SPIRV-LLVM-Translator";
     description = "A tool and a library for bi-directional translation between SPIR-V and LLVM IR";
+    mainProgram = "llvm-spirv";
     license     = licenses.ncsa;
     platforms   = platforms.unix;
     maintainers = with maintainers; [ gloaming ];
   };
-})
+}
diff --git a/pkgs/development/compilers/stanc/default.nix b/pkgs/development/compilers/stanc/default.nix
deleted file mode 100644
index 66671823d866..000000000000
--- a/pkgs/development/compilers/stanc/default.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ lib
-, fetchFromGitHub
-, ocamlPackages
-}:
-
-ocamlPackages.buildDunePackage rec {
-  pname = "stanc";
-  version = "2.34.0";
-
-  minimalOCamlVersion = "4.12";
-  duneVersion = "3";
-
-  src = fetchFromGitHub {
-    owner = "stan-dev";
-    repo = "stanc3";
-    rev = "v${version}";
-    hash = "sha256-ixZCix3oLZhzs08JbmbNCO0lhAu1Jf+KnpHNKlU/FaA=";
-  };
-
-  # Error: This expression has type [ `Use_Sys_unix ]
-  postPatch = ''
-    substituteInPlace test/integration/run_bin_on_args.ml \
-      --replace "if Sys.file_exists (to_windows path) then to_windows cmd else cmd" "cmd"
-  '';
-
-  nativeBuildInputs = with ocamlPackages; [
-    menhir
-  ];
-  buildInputs = with ocamlPackages; [
-    core_unix
-    menhirLib
-    ppx_deriving
-    fmt
-    yojson
-  ];
-
-  meta = with lib; {
-    homepage = "https://github.com/stan-dev/stanc3";
-    description = "The Stan compiler and utilities";
-    license = licenses.bsd3;
-    maintainers = with maintainers; [ wegank ];
-    platforms = platforms.unix;
-  };
-}
diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix
index 76c2da0a656a..cef1358aed73 100644
--- a/pkgs/development/compilers/swift/compiler/default.nix
+++ b/pkgs/development/compilers/swift/compiler/default.nix
@@ -284,7 +284,6 @@ in stdenv.mkDerivation {
     patch -p1 -d swift -i ${./patches/swift-linux-fix-libc-paths.patch}
     patch -p1 -d swift -i ${./patches/swift-linux-fix-linking.patch}
     patch -p1 -d swift -i ${./patches/swift-darwin-libcxx-flags.patch}
-    patch -p1 -d swift -i ${./patches/swift-darwin-link-cxxabi.patch}
     patch -p1 -d swift -i ${substituteAll {
       src = ./patches/swift-darwin-plistbuddy-workaround.patch;
       inherit swiftArch;
diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-darwin-link-cxxabi.patch b/pkgs/development/compilers/swift/compiler/patches/swift-darwin-link-cxxabi.patch
deleted file mode 100644
index dad9b3285dc1..000000000000
--- a/pkgs/development/compilers/swift/compiler/patches/swift-darwin-link-cxxabi.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-This patches the stdlib backdeploy static lib to have its users link c++abi.
-Without this, later steps that try to link this fail looking for global
-new/delete operators (__Znwm/__ZdlPv).
-
---- a/stdlib/toolchain/Compatibility56/Overrides.cpp
-+++ b/stdlib/toolchain/Compatibility56/Overrides.cpp
-@@ -23,6 +23,7 @@
- using namespace swift;
- 
- __asm__ (".linker_option \"-lc++\"");
-+__asm__ (".linker_option \"-lc++abi\"");
- 
- #define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
-   Override_ ## name name;
diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix
index afb8ce39dcce..c111a8d86bfa 100644
--- a/pkgs/development/compilers/swift/default.nix
+++ b/pkgs/development/compilers/swift/default.nix
@@ -25,9 +25,13 @@ let
     #
     # The following selects the correct Clang version, matching the version
     # used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
-    clang = if pkgs.stdenv.isDarwin
+    clang = let
+      # https://github.com/NixOS/nixpkgs/issues/295322
+      clangNoMarch = swiftLlvmPackages.clang.override { disableMarch = true; };
+    in
+    if pkgs.stdenv.isDarwin
       then
-        swiftLlvmPackages.clang.override rec {
+        clangNoMarch.override rec {
           libc = apple_sdk.Libsystem;
           bintools = pkgs.bintools.override { inherit libc; };
           # Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
@@ -35,17 +39,9 @@ let
           # that can happen when a Swift application dynamically links different versions
           # of libc++ and libc++abi than libraries it links are using.
           inherit (llvmPackages) libcxx;
-          extraPackages = [
-            llvmPackages.libcxxabi
-            # Use the compiler-rt associated with clang, but use the libc++abi from the stdenv
-            # to avoid linking against two different versions (for the same reasons as above).
-            (swiftLlvmPackages.compiler-rt.override {
-              inherit (llvmPackages) libcxxabi;
-            })
-          ];
         }
       else
-        swiftLlvmPackages.clang;
+        clangNoMarch;
 
     # Overrides that create a useful environment for swift packages, allowing
     # packaging with `swiftPackages.callPackage`. These are similar to
diff --git a/pkgs/development/compilers/swift/foundation/default.nix b/pkgs/development/compilers/swift/foundation/default.nix
index b0da48c68a95..eab509c5aaa1 100644
--- a/pkgs/development/compilers/swift/foundation/default.nix
+++ b/pkgs/development/compilers/swift/foundation/default.nix
@@ -63,6 +63,7 @@ in stdenv.mkDerivation {
 
   meta = {
     description = "Core utilities, internationalization, and OS independence for Swift";
+    mainProgram = "plutil";
     homepage = "https://github.com/apple/swift-corelibs-foundation";
     platforms = lib.platforms.linux;
     license = lib.licenses.asl20;
diff --git a/pkgs/development/compilers/swift/sourcekit-lsp/default.nix b/pkgs/development/compilers/swift/sourcekit-lsp/default.nix
index caba3e3441f3..a2dd73fefa13 100644
--- a/pkgs/development/compilers/swift/sourcekit-lsp/default.nix
+++ b/pkgs/development/compilers/swift/sourcekit-lsp/default.nix
@@ -67,6 +67,7 @@ stdenv.mkDerivation {
 
   meta = {
     description = "Language Server Protocol implementation for Swift and C-based languages";
+    mainProgram = "sourcekit-lsp";
     homepage = "https://github.com/apple/sourcekit-lsp";
     platforms = with lib.platforms; linux ++ darwin;
     license = lib.licenses.asl20;
diff --git a/pkgs/development/compilers/swift/swift-docc/default.nix b/pkgs/development/compilers/swift/swift-docc/default.nix
index e79487e7eded..5dec14eb475d 100644
--- a/pkgs/development/compilers/swift/swift-docc/default.nix
+++ b/pkgs/development/compilers/swift/swift-docc/default.nix
@@ -51,6 +51,7 @@ stdenv.mkDerivation {
 
   meta = {
     description = "Documentation compiler for Swift";
+    mainProgram = "docc";
     homepage = "https://github.com/apple/swift-docc";
     platforms = with lib.platforms; linux ++ darwin;
     license = lib.licenses.asl20;
diff --git a/pkgs/development/compilers/typescript/default.nix b/pkgs/development/compilers/typescript/default.nix
index 86eaf06bf5c4..9e91337da753 100644
--- a/pkgs/development/compilers/typescript/default.nix
+++ b/pkgs/development/compilers/typescript/default.nix
@@ -2,20 +2,20 @@
 
 buildNpmPackage rec {
   pname = "typescript";
-  version = "5.4.2";
+  version = "5.4.3";
 
   src = fetchFromGitHub {
     owner = "microsoft";
     repo = "TypeScript";
     rev = "v${version}";
-    hash = "sha256-/iB9TEgXqiIsGSRrcADAv8UCjoOdmcyVFGj8EBccQl0=";
+    hash = "sha256-yB87R6LyuTbSbQOcRi+QOhrnUy+ra76PiCzsEvPx3ds=";
   };
 
   patches = [
     ./disable-dprint-dstBundler.patch
   ];
 
-  npmDepsHash = "sha256-UDyPWbr3FcPRHOtkVTIKXQwN5k02qlhRMbgylkWTrQI=";
+  npmDepsHash = "sha256-XlXDof0yFxEpNCZN+4ZY2BVgpbAkwdAUJcTRxIXi8eQ=";
 
   passthru.tests = {
     version = testers.testVersion {
diff --git a/pkgs/development/compilers/uasm/default.nix b/pkgs/development/compilers/uasm/default.nix
index 9fe0e42cb138..ba3e5b03a584 100644
--- a/pkgs/development/compilers/uasm/default.nix
+++ b/pkgs/development/compilers/uasm/default.nix
@@ -56,6 +56,7 @@ stdenv.mkDerivation rec {
   meta = with lib; {
     homepage = "https://www.terraspace.co.uk/uasm.html";
     description = "A free MASM-compatible assembler based on JWasm";
+    mainProgram = "uasm";
     platforms = platforms.unix;
     maintainers = with maintainers; [ thiagokokada ];
     license = licenses.watcom;
diff --git a/pkgs/development/compilers/urn/default.nix b/pkgs/development/compilers/urn/default.nix
index 66f1bda6d5f9..87e28d9672da 100644
--- a/pkgs/development/compilers/urn/default.nix
+++ b/pkgs/development/compilers/urn/default.nix
@@ -52,6 +52,7 @@ stdenv.mkDerivation {
   meta = with lib; {
     homepage = "https://urn-lang.com";
     description = "Yet another Lisp variant which compiles to Lua";
+    mainProgram = "urn";
     license = licenses.bsd3;
     maintainers = with maintainers; [ CrazedProgrammer ];
     platforms = platforms.all;
diff --git a/pkgs/development/compilers/urweb/default.nix b/pkgs/development/compilers/urweb/default.nix
index b72548e753c3..2621f4bc8050 100644
--- a/pkgs/development/compilers/urweb/default.nix
+++ b/pkgs/development/compilers/urweb/default.nix
@@ -43,6 +43,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "Advanced purely-functional web programming language";
+    mainProgram = "urweb";
     homepage    = "http://www.impredicative.com/ur/";
     license     = lib.licenses.bsd3;
     platforms   = lib.platforms.linux ++ lib.platforms.darwin;
diff --git a/pkgs/development/compilers/xa/dxa.nix b/pkgs/development/compilers/xa/dxa.nix
index 44e3e8fb9671..5eec63c171d2 100644
--- a/pkgs/development/compilers/xa/dxa.nix
+++ b/pkgs/development/compilers/xa/dxa.nix
@@ -37,6 +37,7 @@ stdenv.mkDerivation (finalAttrs: {
   meta = {
     homepage = "https://www.floodgap.com/retrotech/xa/";
     description = "Andre Fachat's open-source 6502 disassembler";
+    mainProgram = "dxa";
     license = lib.licenses.gpl2Plus;
     maintainers = with lib.maintainers; [ AndersonTorres ];
     platforms = with lib.platforms; unix;
diff --git a/pkgs/development/compilers/zasm/default.nix b/pkgs/development/compilers/zasm/default.nix
index cd15b756b36e..bd98622edf3f 100644
--- a/pkgs/development/compilers/zasm/default.nix
+++ b/pkgs/development/compilers/zasm/default.nix
@@ -42,6 +42,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Z80 / 8080 / Z180 assembler (for unix-style OS)";
+    mainProgram = "zasm";
     homepage = "https://k1.spdns.de/Develop/Projects/zasm/Distributions/";
     license = licenses.bsd2;
     maintainers = [ maintainers.turbomack ];
diff --git a/pkgs/development/compilers/zulu/16.nix b/pkgs/development/compilers/zulu/16.nix
deleted file mode 100644
index 941a7e8d64f9..000000000000
--- a/pkgs/development/compilers/zulu/16.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ callPackage
-, enableJavaFX ? false
-, ...
-}@args:
-
-callPackage ./common.nix ({
-  # Details from https://www.azul.com/downloads/?version=java-16-sts&package=jdk
-  # Note that the latest build may differ by platform
-  dists = {
-    x86_64-darwin = {
-      zuluVersion = "16.32.15";
-      jdkVersion = "16.0.2";
-      hash =
-        if enableJavaFX then "sha256-6URaSBNHQWLauO//kCuKXb4Z7AqyshWnoeJEyVRKgaY="
-        else "sha256-NXgBj/KixTknaCYbo3B+rOo11NImH5CDUIU0LhTCtMo=";
-    };
-
-    aarch64-darwin = {
-      zuluVersion = "16.32.15";
-      jdkVersion = "16.0.2";
-      hash =
-        if enableJavaFX then "sha256-QuyhIAxUY3Vv1adGihW+LIsXtpDX2taCmFsMFj9o5vs="
-        else "sha256-3bUfDcLLyahLeURFAgLAVapBZHvqtam8GHbWTA6MQog=";
-    };
-  };
-} // builtins.removeAttrs args [ "callPackage" ])
diff --git a/pkgs/development/compilers/zz/default.nix b/pkgs/development/compilers/zz/default.nix
index 4ec5131bf74c..ea4e33b8a903 100644
--- a/pkgs/development/compilers/zz/default.nix
+++ b/pkgs/development/compilers/zz/default.nix
@@ -44,6 +44,7 @@ rustPlatform.buildRustPackage rec {
 
   meta = with lib; {
     description = "ZetZ a zymbolic verifier and tranzpiler to bare metal C";
+    mainProgram = "zz";
     homepage = "https://github.com/zetzit/zz";
     license = licenses.mit;
     maintainers = [ maintainers.marsam ];