Bug 1731582 - Move to clang-13 r=firefox-build-system-reviewers,mhentges,decoder
☠☠ backed out by 4912996ac384 ☠ ☠
authorAndi-Bogdan Postelnicu <andi@mozilla.com>
Tue, 19 Oct 2021 14:45:59 +0000
changeset 596358 7de44eaecb1327ab6c2471136151c1b8c5a54b40
parent 596357 30cf1a1380997de94044810ab98c3fc1ad45e50a
child 596359 3da967f1e8fa0120b1fa7d34b08a489924f22300
push id38896
push userabutkovits@mozilla.com
push dateTue, 19 Oct 2021 21:51:00 +0000
treeherdermozilla-central@e9071741b84c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, mhentges, decoder
bugs1731582
milestone95.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1731582 - Move to clang-13 r=firefox-build-system-reviewers,mhentges,decoder Join work with glandium. Differential Revision: https://phabricator.services.mozilla.com/D126208
build/build-clang/clang-12-android.json
build/build-clang/clang-12-linux64.json
build/build-clang/clang-12-macosx64.json
build/build-clang/clang-12-win64-2stage.json
build/build-clang/clang-12-win64.json
build/build-clang/clang-13-android.json
build/build-clang/clang-13-linux64.json
build/build-clang/clang-13-macosx64.json
build/build-clang/clang-13-win64-2stage.json
build/build-clang/clang-13-win64.json
build/build-clang/clang-tidy-ci.patch
build/build-clang/clang-tidy-macosx64.json
build/build-clang/compiler-rt-13-no-codesign.patch
build/build-clang/revert-ga478b0a199f4.patch
build/build-clang/revert-llvmorg-12-init-16421-gb688c5875d08.patch
build/build-clang/revert-llvmorg-13-init-7827-g2a078c307204.patch
build/build-clang/revert-r362047-and-r362065_clang_12.patch
mobile/android/config/mozconfigs/common
mozglue/build/TsanOptions.cpp
taskcluster/ci/fetch/toolchains.yml
taskcluster/ci/instrumented-build/kind.yml
taskcluster/ci/spidermonkey/linux.yml
taskcluster/ci/toolchain/cbindgen.yml
taskcluster/ci/toolchain/cctools-port.yml
taskcluster/ci/toolchain/clang-tidy.yml
taskcluster/ci/toolchain/clang.yml
taskcluster/ci/toolchain/compiler-rt.yml
taskcluster/ci/toolchain/dump-syms.yml
taskcluster/ci/toolchain/fix-stacks.yml
taskcluster/ci/toolchain/gn.yml
taskcluster/ci/toolchain/minidump_stackwalk.yml
taskcluster/ci/toolchain/misc.yml
taskcluster/ci/toolchain/nasm.yml
taskcluster/ci/toolchain/sccache.yml
taskcluster/ci/toolchain/sysroot.yml
taskcluster/ci/webrender/kind.yml
taskcluster/scripts/misc/build-clang-mingw.sh
taskcluster/scripts/misc/build-compiler-rt.sh
taskcluster/scripts/misc/repack-clang-linux-win-cross.sh
--- a/build/build-clang/clang-12-linux64.json
+++ b/build/build-clang/clang-12-linux64.json
@@ -3,17 +3,16 @@
     "pgo" : true,
     "build_libcxx": true,
     "build_wasm": true,
     "build_type": "Release",
     "assertions": false,
     "cc": "/usr/bin/gcc",
     "cxx": "/usr/bin/g++",
     "as": "/usr/bin/gcc",
-    "wasi-compiler-rt": "{MOZ_FETCHES_DIR}/compiler-rt",
     "patches": [
       "static-llvm-symbolizer_clang_12.patch",
       "find_symbolizer_linux_clang_10.patch",
       "android-mangling-error_clang_12.patch",
       "unpoison-thread-stacks_clang_10.patch",
       "downgrade-mangling-error_clang_12.patch",
       "revert-llvmorg-12-init-7827-g2a078c307204.patch",
       "tsan-D101154.patch",
rename from build/build-clang/clang-12-android.json
rename to build/build-clang/clang-13-android.json
--- a/build/build-clang/clang-12-android.json
+++ b/build/build-clang/clang-13-android.json
@@ -44,13 +44,11 @@
           "{MOZ_FETCHES_DIR}/android-ndk/sysroot/usr/include"
         ],
         "api_level": 21
       }
     },
     "patches": [
       "static-llvm-symbolizer_clang_12.patch",
       "find_symbolizer_linux_clang_10.patch",
-      "revert-llvmorg-12-init-7827-g2a078c307204.patch",
-      "revert-llvmorg-12-init-16421-gb688c5875d08.patch",
-      "revert-r362047-and-r362065_clang_12.patch"
+      "revert-ga478b0a199f4.patch"
     ]
 }
copy from build/build-clang/clang-12-linux64.json
copy to build/build-clang/clang-13-linux64.json
--- a/build/build-clang/clang-12-linux64.json
+++ b/build/build-clang/clang-13-linux64.json
@@ -10,14 +10,14 @@
     "as": "/usr/bin/gcc",
     "wasi-compiler-rt": "{MOZ_FETCHES_DIR}/compiler-rt",
     "patches": [
       "static-llvm-symbolizer_clang_12.patch",
       "find_symbolizer_linux_clang_10.patch",
       "android-mangling-error_clang_12.patch",
       "unpoison-thread-stacks_clang_10.patch",
       "downgrade-mangling-error_clang_12.patch",
-      "revert-llvmorg-12-init-7827-g2a078c307204.patch",
-      "tsan-D101154.patch",
+      "revert-llvmorg-13-init-7827-g2a078c307204.patch",
       "loosen-msvc-detection.patch",
-      "fuzzing_ccov_build_clang_12.patch"
+      "fuzzing_ccov_build_clang_12.patch",
+      "revert-ga478b0a199f4.patch"
     ]
 }
rename from build/build-clang/clang-12-macosx64.json
rename to build/build-clang/clang-13-macosx64.json
--- a/build/build-clang/clang-12-macosx64.json
+++ b/build/build-clang/clang-13-macosx64.json
@@ -11,12 +11,12 @@
     "ar": "{MOZ_FETCHES_DIR}/cctools/bin/x86_64-apple-darwin-ar",
     "ranlib": "{MOZ_FETCHES_DIR}/cctools/bin/x86_64-apple-darwin-ranlib",
     "libtool": "{MOZ_FETCHES_DIR}/cctools/bin/x86_64-apple-darwin-libtool",
     "ld": "{MOZ_FETCHES_DIR}/clang/bin/clang",
     "wasi-compiler-rt": "{MOZ_FETCHES_DIR}/compiler-rt",
     "patches": [
       "static-llvm-symbolizer_clang_12.patch",
       "compiler-rt-cross-compile.patch",
-      "revert-llvmorg-12-init-7827-g2a078c307204.patch",
-      "compiler-rt-no-codesign.patch"
+      "revert-llvmorg-13-init-7827-g2a078c307204.patch",
+      "compiler-rt-13-no-codesign.patch"
     ]
 }
rename from build/build-clang/clang-12-win64-2stage.json
rename to build/build-clang/clang-13-win64-2stage.json
rename from build/build-clang/clang-12-win64.json
rename to build/build-clang/clang-13-win64.json
--- a/build/build-clang/clang-12-win64.json
+++ b/build/build-clang/clang-13-win64.json
@@ -8,13 +8,13 @@
     "cc": "cl.exe",
     "cxx": "cl.exe",
     "ml": "ml64.exe",
     "wasi-compiler-rt": "{MOZ_FETCHES_DIR}/compiler-rt",
     "patches": [
       "unpoison-thread-stacks_clang_10.patch",
       "downgrade-mangling-error_clang_12.patch",
       "bug47258-extract-symbols-mbcs.patch",
-      "revert-llvmorg-12-init-7827-g2a078c307204.patch",
-      "loosen-msvc-detection.patch",
-      "Remove-FlushViewOfFile-when-unmaping-gcda-files.patch"
+      "Remove-FlushViewOfFile-when-unmaping-gcda-files.patch",
+      "revert-llvmorg-13-init-7827-g2a078c307204.patch",
+      "loosen-msvc-detection.patch"
     ]
 }
--- a/build/build-clang/clang-tidy-ci.patch
+++ b/build/build-clang/clang-tidy-ci.patch
@@ -1,25 +1,25 @@
 diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
-index d6913dfd3c07..d031a163fdd7 100644
+index 73d66b980a5e..3b18de2176ba 100644
 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
 +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
-@@ -418,6 +418,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
-     if (!Check->isLanguageVersionSupported(Context.getLangOpts()))
-       continue;
+@@ -432,6 +432,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
+
+   for (auto &Check : Checks) {
      Check->registerMatchers(&*Finder);
 +    Check->registerPPCallbacks(Compiler);
      Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
    }
 
 diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
-index 54b725126752..200780e86804 100644
+index 20e9b8e47e6f..aded1f2e196c 100644
 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
 +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
-@@ -130,6 +130,9 @@ public:
+@@ -70,6 +70,9 @@ public:
      return true;
    }
 
 +  /// This has been deprecated in clang 9 - needed by mozilla-must-override
 +  virtual void registerPPCallbacks(CompilerInstance &Compiler) {}
 +
    /// Override this to register ``PPCallbacks`` in the preprocessor.
    ///
--- a/build/build-clang/clang-tidy-macosx64.json
+++ b/build/build-clang/clang-tidy-macosx64.json
@@ -10,11 +10,11 @@
     "as": "{MOZ_FETCHES_DIR}/clang/bin/clang",
     "ar": "{MOZ_FETCHES_DIR}/cctools/bin/x86_64-apple-darwin-ar",
     "ranlib": "{MOZ_FETCHES_DIR}/cctools/bin/x86_64-apple-darwin-ranlib",
     "libtool": "{MOZ_FETCHES_DIR}/cctools/bin/x86_64-apple-darwin-libtool",
     "ld": "{MOZ_FETCHES_DIR}/clang/bin/clang",
     "patches": [
       "clang-tidy-ci.patch",
       "compiler-rt-cross-compile.patch",
-      "compiler-rt-no-codesign.patch"
+      "compiler-rt-13-no-codesign.patch"
     ]
 }
copy from build/build-clang/compiler-rt-no-codesign.patch
copy to build/build-clang/compiler-rt-13-no-codesign.patch
--- a/build/build-clang/compiler-rt-no-codesign.patch
+++ b/build/build-clang/compiler-rt-13-no-codesign.patch
@@ -1,21 +1,19 @@
-Disable codesign for macosx cross-compile toolchain. Codesign only works on OSX.
-
-Index: cmake/Modules/AddCompilerRT.cmake
-===================================================================
+diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+index bc69ec95c419..9f100fdcec2f 100644
 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
 +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
-@@ -321,14 +321,6 @@
+@@ -366,14 +366,6 @@ function(add_compiler_rt_runtime name type)
          set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
          set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
        endif()
 -      if(APPLE)
 -        # Ad-hoc sign the dylibs
 -        add_custom_command(TARGET ${libname}
 -          POST_BUILD  
 -          COMMAND codesign --sign - $<TARGET_FILE:${libname}>
--          WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+-          WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR}
 -        )
 -      endif()
      endif()
  
      set(parent_target_arg)
new file mode 100644
--- /dev/null
+++ b/build/build-clang/revert-ga478b0a199f4.patch
@@ -0,0 +1,123 @@
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
+index c9360fc67165..b9451bde3dd8 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -310,12 +310,6 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+ }
+ 
+-ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
+-  if (getTriple().isAndroid())
+-    return ToolChain::RLT_CompilerRT;
+-  return Generic_ELF::GetDefaultRuntimeLibType();
+-}
+-
+ ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const {
+   if (getTriple().isAndroid())
+     return ToolChain::CST_Libcxx;
+diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
+index 169a37c44072..65897631715a 100644
+--- a/clang/lib/Driver/ToolChains/Linux.h
++++ b/clang/lib/Driver/ToolChains/Linux.h
+@@ -39,7 +39,6 @@ public:
+                          llvm::opt::ArgStringList &CC1Args) const override;
+   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+                            llvm::opt::ArgStringList &CC1Args) const override;
+-  RuntimeLibType GetDefaultRuntimeLibType() const override;
+   CXXStdlibType GetDefaultCXXStdlibType() const override;
+   bool
+   IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const override;
+diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
+index cc505588331b..fc43acd07644 100644
+--- a/clang/test/Driver/linux-ld.c
++++ b/clang/test/Driver/linux-ld.c
+@@ -283,7 +283,7 @@
+ // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+ // RUN:   | FileCheck --check-prefix=CHECK-CLANG-ANDROID-NONE %s
+ // CHECK-CLANG-ANDROID-NONE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+-// CHECK-CLANG-ANDROID-NONE: "-l:libunwind.a" "-ldl" "-lc"
++// CHECK-CLANG-ANDROID-NONE: "-lgcc" "-ldl" "-lc"
+ //
+ // RUN: %clang -shared -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+ // RUN:     --target=aarch64-linux-android -rtlib=platform --unwindlib=platform \
+@@ -291,7 +291,7 @@
+ // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+ // RUN:   | FileCheck --check-prefix=CHECK-CLANG-ANDROID-SHARED %s
+ // CHECK-CLANG-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+-// CHECK-CLANG-ANDROID-SHARED: "-l:libunwind.a" "-ldl" "-lc"
++// CHECK-CLANG-ANDROID-SHARED: "-lgcc" "-ldl" "-lc"
+ //
+ // RUN: %clang -static -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+ // RUN:     --target=aarch64-linux-android -rtlib=platform --unwindlib=platform \
+@@ -299,7 +299,7 @@
+ // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+ // RUN:   | FileCheck --check-prefix=CHECK-CLANG-ANDROID-STATIC %s
+ // CHECK-CLANG-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+-// CHECK-CLANG-ANDROID-STATIC: "--start-group" "{{[^"]*}}{{/|\\\\}}libclang_rt.builtins-aarch64-android.a" "-l:libunwind.a" "-lc" "--end-group"
++// CHECK-CLANG-ANDROID-STATIC: "--start-group" "-lgcc" "-lc" "--end-group"
+ //
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1      \
+ // RUN:     --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
+@@ -1081,12 +1081,10 @@
+ // CHECK-ANDROID: "--enable-new-dtags"
+ // CHECK-ANDROID: "{{.*}}{{/|\\\\}}crtbegin_dynamic.o"
+ // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
+-// CHECK-ANDROID-NOT: "-lgcc_s"
+-// CHECK-ANDROID-NOT: "-lgcc"
+-// CHECK-ANDROID: "-l:libunwind.a"
++// CHECK-ANDROID-NOT: "gcc_s"
++// CHECK-ANDROID: "-lgcc"
+ // CHECK-ANDROID: "-ldl"
+-// CHECK-ANDROID-NOT: "-lgcc_s"
+-// CHECK-ANDROID-NOT: "-lgcc"
++// CHECK-ANDROID-NOT: "gcc_s"
+ // CHECK-ANDROID: "{{.*}}{{/|\\\\}}crtend_android.o"
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+ // RUN:     --target=arm-linux-androideabi -rtlib=platform --unwindlib=platform \
+@@ -1139,12 +1137,10 @@
+ // CHECK-ANDROID-SO-NOT: "-Bsymbolic"
+ // CHECK-ANDROID-SO: "{{.*}}{{/|\\\\}}crtbegin_so.o"
+ // CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib"
+-// CHECK-ANDROID-SO-NOT: "-lgcc_s"
+-// CHECK-ANDROID-SO-NOT: "-lgcc"
+-// CHECK-ANDROID-SO: "-l:libunwind.a"
++// CHECK-ANDROID-SO-NOT: "gcc_s"
++// CHECK-ANDROID-SO: "-lgcc"
+ // CHECK-ANDROID-SO: "-ldl"
+-// CHECK-ANDROID-SO-NOT: "-lgcc_s"
+-// CHECK-ANDROID-SO-NOT: "-lgcc"
++// CHECK-ANDROID-SO-NOT: "gcc_s"
+ // CHECK-ANDROID-SO: "{{.*}}{{/|\\\\}}crtend_so.o"
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+ // RUN:     --target=arm-linux-androideabi -rtlib=platform --unwindlib=platform \
+@@ -1195,12 +1191,10 @@
+ // CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+ // CHECK-ANDROID-STATIC: "{{.*}}{{/|\\\\}}crtbegin_static.o"
+ // CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib"
+-// CHECK-ANDROID-STATIC-NOT: "-lgcc_eh"
+-// CHECK-ANDROID-STATIC-NOT: "-lgcc"
+-// CHECK-ANDROID-STATIC: "-l:libunwind.a"
++// CHECK-ANDROID-STATIC-NOT: "gcc_s"
++// CHECK-ANDROID-STATIC: "-lgcc"
+ // CHECK-ANDROID-STATIC-NOT: "-ldl"
+-// CHECK-ANDROID-STATIC-NOT: "-lgcc_eh"
+-// CHECK-ANDROID-STATIC-NOT: "-lgcc"
++// CHECK-ANDROID-STATIC-NOT: "gcc_s"
+ // CHECK-ANDROID-STATIC: "{{.*}}{{/|\\\\}}crtend_android.o"
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+ // RUN:     --target=arm-linux-androideabi -rtlib=platform --unwindlib=platform \
+@@ -1253,11 +1247,9 @@
+ // CHECK-ANDROID-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+ // CHECK-ANDROID-PIE: "{{.*}}{{/|\\\\}}crtbegin_dynamic.o"
+ // CHECK-ANDROID-PIE: "-L[[SYSROOT]]/usr/lib"
+-// CHECK-ANDROID-PIE-NOT: "-lgcc_s"
+-// CHECK-ANDROID-PIE-NOT: "-lgcc"
+-// CHECK-ANDROID-PIE: "-l:libunwind.a"
+-// CHECK-ANDROID-PIE-NOT: "-lgcc_s"
+-// CHECK-ANDROID-PIE-NOT: "-lgcc"
++// CHECK-ANDROID-PIE-NOT: "gcc_s"
++// CHECK-ANDROID-PIE: "-lgcc"
++// CHECK-ANDROID-PIE-NOT: "gcc_s"
+ // CHECK-ANDROID-PIE: "{{.*}}{{/|\\\\}}crtend_android.o"
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+ // RUN:     --target=arm-linux-androideabi \
deleted file mode 100644
--- a/build/build-clang/revert-llvmorg-12-init-16421-gb688c5875d08.patch
+++ /dev/null
@@ -1,1242 +0,0 @@
-Revert "[CMake] Split the target side of runtimes build"
-
-This reverts commit b688c5875d08c586f7b35b8f9da1493ebbf92b45.
-
-Commit 98c89ccfbd7467f946874c2af170d0f504355dd1 was in the revert path and is
-also reverted by this patch. That commit doesn't affect us, so it's not worth
-the extra patch-juggling to preserve it.
-
-This will make it easier to apply revert-r362047-and-r362065_clang_12.patch.
-
-diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
-index 243d6ceb2202..d2f5d6bf80f0 100644
---- a/llvm/runtimes/CMakeLists.txt
-+++ b/llvm/runtimes/CMakeLists.txt
-@@ -1,13 +1,26 @@
--# TODO: This file assumes the Clang toolchain so it'd be better if it lived in
--# Clang, except there already is clang/runtime directory which contains
--# similar although simpler functionality. We should figure out how to merge
--# the two files.
--
--# TODO: Selecting runtimes should be always performed inside the runtimes
--# build, see runtimes/CMakeLists.txt, except that we currently check whether
--# compiler-rt is being built to determine whether to first build builtins
--# or not so we need that information in this file as well.
--set(LLVM_ALL_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind;openmp")
-+# This file handles building LLVM runtime sub-projects.
-+
-+# Runtimes are different from tools or other drop-in projects because runtimes
-+# should be built with the LLVM toolchain from the build directory. This file is
-+# a first step to formalizing runtime build interfaces.
-+
-+# Setting CMake minimum required version should be at the very top of the file
-+# if this is the entry point.
-+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-+  cmake_minimum_required(VERSION 3.13.4)
-+  project(Runtimes C CXX ASM)
-+endif()
-+
-+# Find all subdirectories containing CMake projects
-+file(GLOB entries *)
-+foreach(entry ${entries})
-+  if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
-+    list(APPEND runtimes ${entry})
-+  endif()
-+endforeach()
-+
-+# Side-by-side subprojects layout.
-+set(LLVM_ALL_RUNTIMES "libcxx;libcxxabi;libunwind;compiler-rt;openmp")
- set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
-   "Semicolon-separated list of runtimes to build (${LLVM_ALL_RUNTIMES}), or \"all\".")
- if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )
-@@ -35,436 +48,612 @@ function(get_compiler_rt_path path)
-   endforeach()
- endfunction()
-
--include(LLVMExternalProjectUtils)
-+# If this file is acting as a top-level CMake invocation, this code path is
-+# triggered by the external project call for the runtimes target below.
-+if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-
--if(NOT LLVM_BUILD_RUNTIMES)
--  set(EXTRA_ARGS EXCLUDE_FROM_ALL)
--endif()
-+  function(runtime_register_component name)
-+    set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
-+  endfunction()
-
--function(check_apple_target triple builtin_or_runtime)
--  set(error "\
--compiler-rt for Darwin builds for all platforms and architectures using a \
--single configuration. Specify only a single darwin triple (e.g. x86_64-apple-darwin) \
--in your targets list (and not a triple for a specific platform such as macos). \
--You can use variables such as COMPILER_RT_ENABLE_IOS and DARWIN_ios_ARCHS to \
--control the specific platforms and architectures to build.")
-+  cmake_minimum_required(VERSION 3.13.4)
-+  project(Runtimes C CXX ASM)
-
--  set(seen_property ${builtin_or_runtime}_darwin_triple_seen)
--  string(REPLACE "-" ";" triple_components ${triple})
--  foreach(component ${triple_components})
--    string(TOLOWER "${component}" component_lower)
--    if(component_lower MATCHES "^darwin")
--      get_property(darwin_triple_seen GLOBAL PROPERTY ${seen_property})
--      if(darwin_triple_seen)
--        message(FATAL_ERROR "${error}")
--      endif()
--      set_property(GLOBAL PROPERTY ${seen_property} YES)
--      if(NOT RUNTIMES_BUILD_ALLOW_DARWIN)
--        message(FATAL_ERROR "\
--${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
--      endif()
--    elseif(component_lower MATCHES "^ios|^macos|^tvos|^watchos")
--      message(FATAL_ERROR "${error}")
--    endif()
--  endforeach()
--endfunction()
-+  find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
-+  find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
-
--function(builtin_default_target compiler_rt_path)
--  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
-+  # Add the root project's CMake modules, and the LLVM build's modules to the
-+  # CMake module path.
-+  list(INSERT CMAKE_MODULE_PATH 0
-+    "${CMAKE_CURRENT_SOURCE_DIR}/../cmake"
-+    "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
-+  )
-
--  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
--  # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
--  if (TARGET_TRIPLE MATCHES "aix")
--    set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
-+  # Some of the runtimes will conditionally use the compiler-rt sanitizers
-+  # to make this work smoothly we ensure that compiler-rt is added first in
-+  # the list of sub-projects. This allows other sub-projects to have checks
-+  # like `if(TARGET asan)` to enable building with asan.
-+  get_compiler_rt_path(compiler_rt_path)
-+  if(compiler_rt_path)
-+    list(REMOVE_ITEM runtimes ${compiler_rt_path})
-+    if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
-+      list(INSERT runtimes 0 ${compiler_rt_path})
-+    endif()
-   endif()
-
--  llvm_ExternalProject_Add(builtins
--                           ${compiler_rt_path}/lib/builtins
--                           DEPENDS ${ARG_DEPENDS}
--                           CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
--                                      -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
--                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
--                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
--                                      -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
--                                      -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
--                                      -DCMAKE_C_COMPILER_WORKS=ON
--                                      -DCMAKE_ASM_COMPILER_WORKS=ON
--                                      ${BUILTINS_CMAKE_ARGS}
--                           PASSTHROUGH_PREFIXES COMPILER_RT
--                           USE_TOOLCHAIN
--                           ${EXTRA_ARGS})
--endfunction()
-+  # Setting these variables will allow the sub-build to put their outputs into
-+  # the library and bin directories of the top-level build.
-+  set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
-+  set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
-
--function(builtin_register_target compiler_rt_path target)
--  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
-+  # This variable makes sure that e.g. llvm-lit is found.
-+  set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
-+  set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
-
--  check_apple_target(${target} builtin)
-+  # This variable is used by individual runtimes to locate LLVM files.
-+  set(LLVM_PATH ${LLVM_BUILD_MAIN_SRC_DIR})
-
--  get_cmake_property(variableNames VARIABLES)
--  foreach(variableName ${variableNames})
--    string(FIND "${variableName}" "BUILTINS_${target}" out)
--    if("${out}" EQUAL 0)
--      string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
--      string(REPLACE ";" "|" new_value "${${variableName}}")
--      list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
--    endif()
--  endforeach()
-+  if(APPLE)
-+    set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
-+  endif()
-
--  llvm_ExternalProject_Add(builtins-${target}
--                           ${compiler_rt_path}/lib/builtins
--                           DEPENDS ${ARG_DEPENDS}
--                           CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
--                                      -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
--                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
--                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
--                                      -DCMAKE_C_COMPILER_TARGET=${target}
--                                      -DCMAKE_ASM_COMPILER_TARGET=${target}
--                                      -DCMAKE_C_COMPILER_WORKS=ON
--                                      -DCMAKE_ASM_COMPILER_WORKS=ON
--                                      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
--                                      ${${target}_extra_args}
--                           USE_TOOLCHAIN
--                           ${EXTRA_ARGS})
--endfunction()
-+  include(CheckLibraryExists)
-+  include(CheckCCompilerFlag)
-
--# If compiler-rt is present we need to build the builtin libraries first. This
--# is required because the other runtimes need the builtin libraries present
--# before the just-built compiler can pass the configuration tests.
--get_compiler_rt_path(compiler_rt_path)
--if(compiler_rt_path)
--  if(NOT LLVM_BUILTIN_TARGETS)
--    builtin_default_target(${compiler_rt_path}
--      DEPENDS clang-resource-headers)
--  else()
--    if("default" IN_LIST LLVM_BUILTIN_TARGETS)
--      builtin_default_target(${compiler_rt_path}
--        DEPENDS clang-resource-headers)
--      list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
--    else()
--      add_custom_target(builtins)
--      add_custom_target(install-builtins)
--      add_custom_target(install-builtins-stripped)
--    endif()
-+  # We don't have libc++ (yet)...
-+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++")
-
--    foreach(target ${LLVM_BUILTIN_TARGETS})
--      builtin_register_target(${compiler_rt_path} ${target}
--        DEPENDS clang-resource-headers)
--
--      add_dependencies(builtins builtins-${target})
--      add_dependencies(install-builtins install-builtins-${target})
--      add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
--    endforeach()
-+  # ...but we need access to libc++ headers for CMake checks to succeed.
-+  if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
-+    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -isystem ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include")
-   endif()
--  set(deps builtins)
--  # We don't need to depend on the builtins if we're building instrumented
--  # because the next stage will use the same compiler used to build this stage.
--  if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
--    add_dependencies(clang-bootstrap-deps builtins)
--  endif()
--endif()
-
--# We create a list the names of all the runtime projects in all uppercase and
--# with dashes turned to underscores. This gives us the CMake variable prefixes
--# for all variables that will apply to runtimes.
--foreach(entry ${runtimes})
--  get_filename_component(projName ${entry} NAME)
--  string(REPLACE "-" "_" canon_name ${projName})
--  string(TOUPPER ${canon_name} canon_name)
--  list(APPEND prefixes ${canon_name})
--  if (${canon_name} STREQUAL "OPENMP")
--    list(APPEND prefixes "LIBOMP" "LIBOMPTARGET")
--  endif()
--  # Many compiler-rt options start with SANITIZER_ rather than COMPILER_RT_,
--  # so when compiler-rt is enabled, consider both.
--  if(canon_name STREQUAL "COMPILER_RT")
--    list(APPEND prefixes SANITIZER)
--  endif()
-+  # Avoid checking whether the compiler is working.
-+  set(LLVM_COMPILER_CHECKED ON)
-+
-+  # Handle common options used by all runtimes.
-+  include(AddLLVM)
-+  include(HandleLLVMOptions)
-+  include(FindPythonInterp)
-
--  string(FIND ${projName} "lib" LIB_IDX)
--  if(LIB_IDX EQUAL 0)
--    string(SUBSTRING ${projName} 3 -1 projName)
-+  # Remove the -nostdlib++ option we've added earlier.
-+  string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
-+
-+  # Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
-+  if(CMAKE_HOST_APPLE AND APPLE)
-+    include(UseLibtool)
-   endif()
--  list(APPEND runtime_names ${projName})
--endforeach()
-
--if(LLVM_RUNTIME_BUILD_ID_LINK_TARGETS)
--  configure_file(
--    ${CMAKE_CURRENT_SOURCE_DIR}/llvm-strip-link.in
--    ${CMAKE_CURRENT_BINARY_DIR}/llvm-strip-link
--    @ONLY
--  )
--endif()
-+  # This can be used to detect whether we're in the runtimes build.
-+  set(RUNTIMES_BUILD ON)
-
--function(runtime_default_target)
--  cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN})
-+  foreach(entry ${runtimes})
-+    get_filename_component(projName ${entry} NAME)
-
--  include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
--  set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
--  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
-+    # TODO: Clean this up as part of an interface standardization
-+    string(REPLACE "-" "_" canon_name ${projName})
-+    string(TOUPPER ${canon_name} canon_name)
-+
-+    # The subdirectories need to treat this as standalone builds. D57992 tried
-+    # to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if
-+    # llvm & clang are configured in the same CMake, and setup dependencies
-+    # against their targets. OpenMP has fixed the issue so we don't set the
-+    # variable.
-+    if (NOT ${canon_name} STREQUAL "OPENMP")
-+      set(${canon_name}_STANDALONE_BUILD ON)
-+    endif()
-
--  foreach(runtime_name ${runtime_names})
--    list(APPEND extra_targets
--      ${runtime_name}
--      install-${runtime_name}
--      install-${runtime_name}-stripped)
--    if(LLVM_INCLUDE_TESTS)
--      list(APPEND test_targets check-${runtime_name})
-+    if(LLVM_RUNTIMES_LIBDIR_SUBDIR)
-+      set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE STRING "" FORCE)
-     endif()
-+
-+    # Setting a variable to let sub-projects detect which other projects
-+    # will be included under here.
-+    set(HAVE_${canon_name} ON)
-   endforeach()
--  foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
--    if(NOT ${component} IN_LIST SUB_COMPONENTS)
--      list(APPEND extra_targets ${component} install-${component} install-${component}-stripped)
--    endif()
-+
-+  # We do this in two loops so that HAVE_* is set for each runtime before the
-+  # other runtimes are added.
-+  foreach(entry ${runtimes})
-+    get_filename_component(projName ${entry} NAME)
-+
-+    # Between each sub-project we want to cache and clear the LIT properties
-+    set_property(GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
-+    set_property(GLOBAL PROPERTY LLVM_LIT_PARAMS)
-+    set_property(GLOBAL PROPERTY LLVM_LIT_DEPENDS)
-+    set_property(GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
-+
-+    add_subdirectory(${entry} ${projName})
-+
-+    get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
-+    get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
-+    get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
-+    get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
-+
-+    list(APPEND RUNTIMES_LIT_TESTSUITES ${LLVM_LIT_TESTSUITES})
-+    list(APPEND RUNTIMES_LIT_PARAMS ${LLVM_LIT_PARAMS})
-+    list(APPEND RUNTIMES_LIT_DEPENDS ${LLVM_LIT_DEPENDS})
-+    list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
-   endforeach()
-
-   if(LLVM_INCLUDE_TESTS)
--    list(APPEND test_targets runtimes-test-depends check-runtimes)
--  endif()
--
--  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
--  # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
--  if (TARGET_TRIPLE MATCHES "aix")
--    set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
-+    # Add a global check rule now that all subdirectories have been traversed
-+    # and we know the total set of lit testsuites.
-+
-+    add_lit_target(check-runtimes
-+      "Running all regression tests"
-+      ${RUNTIMES_LIT_TESTSUITES}
-+      PARAMS ${RUNTIMES_LIT_PARAMS}
-+      DEPENDS ${RUNTIMES_LIT_DEPENDS}
-+      ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
-+      )
-+    add_custom_target(runtimes-test-depends DEPENDS ${RUNTIMES_LIT_DEPENDS})
-   endif()
-
--  llvm_ExternalProject_Add(runtimes
--                           ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
--                           DEPENDS ${ARG_DEPENDS}
--                           # Builtins were built separately above
--                           CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
--                                      -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
--                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
--                                      -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
--                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
--                                      -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
--                                      -DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
--                                      -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
--                                      -DCMAKE_C_COMPILER_WORKS=ON
--                                      -DCMAKE_CXX_COMPILER_WORKS=ON
--                                      -DCMAKE_ASM_COMPILER_WORKS=ON
--                                      ${RUNTIMES_CMAKE_ARGS}
--                           PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
--                                                ${ARG_PREFIXES}
--                           EXTRA_TARGETS ${extra_targets}
--                                         ${test_targets}
--                                         ${SUB_COMPONENTS}
--                                         ${SUB_CHECK_TARGETS}
--                                         ${SUB_INSTALL_TARGETS}
--                           USE_TOOLCHAIN
--                           ${EXTRA_ARGS})
--endfunction()
-+  get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
-+  if(SUB_COMPONENTS)
-+    list(REMOVE_DUPLICATES SUB_COMPONENTS)
-+    foreach(component ${SUB_COMPONENTS})
-+      if(NOT TARGET ${component})
-+        message(SEND_ERROR "Missing target for runtime component ${component}!")
-+        continue()
-+      endif()
-
--# runtime_register_target(target)
--#   Utility function to register external runtime target.
--function(runtime_register_target name target)
--  cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
--  include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
--  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
-+      if(TARGET check-${component})
-+        list(APPEND SUB_CHECK_TARGETS check-${component})
-+      endif()
-
--  check_apple_target(${target} runtime)
-+      if(TARGET install-${component})
-+        list(APPEND SUB_INSTALL_TARGETS install-${component})
-+      endif()
-+      if(TARGET install-${component}-stripped)
-+        list(APPEND SUB_INSTALL_TARGETS install-${component}-stripped)
-+      endif()
-+    endforeach()
-
--  set(${name}_deps ${ARG_DEPENDS})
--  if(NOT name STREQUAL target)
--    list(APPEND ${name}_deps runtimes-${target})
-+    if(LLVM_RUNTIMES_TARGET)
-+      configure_file(
-+        ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
-+        ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
-+    else()
-+      configure_file(
-+        ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
-+        ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
-+    endif()
-   endif()
-
--  foreach(runtime_name ${runtime_names})
--    set(${runtime_name}-${name} ${runtime_name})
--    set(install-${runtime_name}-${name} install-${runtime_name})
--    set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
--    list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
--    if(LLVM_INCLUDE_TESTS)
--      set(check-${runtime_name}-${name} check-${runtime_name} )
--      list(APPEND ${name}_test_targets check-${runtime_name}-${name})
--    endif()
--  endforeach()
-+else() # if this is included from LLVM's CMake
-+  include(LLVMExternalProjectUtils)
-
--  foreach(target_name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS)
--    set(${target_name}-${name} ${target_name})
--    list(APPEND ${name}_extra_targets ${target_name}-${name})
--  endforeach()
-+  if(NOT LLVM_BUILD_RUNTIMES)
-+    set(EXTRA_ARGS EXCLUDE_FROM_ALL)
-+  endif()
-
--  foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
--    set(${component}-${name} ${component})
--    set(install-${component}-${name} install-${component})
--    set(install-${component}-${name}-stripped install-${component}-stripped)
--    list(APPEND ${name}_extra_targets ${component}-${name} install-${component}-${name} install-${component}-${name}-stripped)
--  endforeach()
-+  function(check_apple_target triple builtin_or_runtime)
-+    set(error "\
-+compiler-rt for Darwin builds for all platforms and architectures using a \
-+single configuration. Specify only a single darwin triple (e.g. x86_64-apple-darwin) \
-+in your targets list (and not a triple for a specific platform such as macos). \
-+You can use variables such as COMPILER_RT_ENABLE_IOS and DARWIN_ios_ARCHS to \
-+control the specific platforms and architectures to build.")
-
--  if(LLVM_INCLUDE_TESTS)
--    set(runtimes-test-depends-${name} runtimes-test-depends)
--    set(check-runtimes-${name} check-runtimes)
--    list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
--    foreach(target_name IN LISTS SUB_CHECK_TARGETS)
--      set(${target_name}-${name} ${target_name})
--      list(APPEND ${name}_test_targets ${target_name}-${name})
--      list(APPEND test_targets ${target_name}-${name})
-+    set(seen_property ${builtin_or_runtime}_darwin_triple_seen)
-+    string(REPLACE "-" ";" triple_components ${triple})
-+    foreach(component ${triple_components})
-+      string(TOLOWER "${component}" component_lower)
-+      if(component_lower MATCHES "^darwin")
-+        get_property(darwin_triple_seen GLOBAL PROPERTY ${seen_property})
-+        if(darwin_triple_seen)
-+          message(FATAL_ERROR "${error}")
-+        endif()
-+        set_property(GLOBAL PROPERTY ${seen_property} YES)
-+        if(NOT RUNTIMES_BUILD_ALLOW_DARWIN)
-+          message(FATAL_ERROR "\
-+${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
-+        endif()
-+      elseif(component_lower MATCHES "^ios|^macos|^tvos|^watchos")
-+        message(FATAL_ERROR "${error}")
-+      endif()
-     endforeach()
--    set(test_targets "${test_targets}" PARENT_SCOPE)
--  endif()
-+  endfunction()
-+
-+  function(builtin_default_target compiler_rt_path)
-+    cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
-
--  set(${name}_extra_args ${ARG_CMAKE_ARGS})
--  get_cmake_property(variableNames VARIABLES)
--  foreach(variableName ${variableNames})
--    string(FIND "${variableName}" "RUNTIMES_${target}_" out)
--    if("${out}" EQUAL 0)
--      string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
--      string(REPLACE ";" "|" new_value "${${variableName}}")
--      list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
-+    set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
-+    # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
-+    if (TARGET_TRIPLE MATCHES "aix")
-+      set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
-     endif()
--  endforeach()
--  if(NOT "${name}" STREQUAL "${target}")
-+
-+    llvm_ExternalProject_Add(builtins
-+                             ${compiler_rt_path}/lib/builtins
-+                             DEPENDS ${ARG_DEPENDS}
-+                             CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
-+                                        -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
-+                                        -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
-+                                        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
-+                                        -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
-+                                        -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
-+                                        -DCMAKE_C_COMPILER_WORKS=ON
-+                                        -DCMAKE_ASM_COMPILER_WORKS=ON
-+                                        ${BUILTINS_CMAKE_ARGS}
-+                             PASSTHROUGH_PREFIXES COMPILER_RT
-+                             USE_TOOLCHAIN
-+                             ${EXTRA_ARGS})
-+  endfunction()
-+
-+  function(builtin_register_target compiler_rt_path target)
-+    cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
-+
-+    check_apple_target(${target} builtin)
-+
-+    get_cmake_property(variableNames VARIABLES)
-     foreach(variableName ${variableNames})
--      string(FIND "${variableName}" "RUNTIMES_${name}_" out)
-+      string(FIND "${variableName}" "BUILTINS_${target}" out)
-       if("${out}" EQUAL 0)
--        string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
-+        string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
-         string(REPLACE ";" "|" new_value "${${variableName}}")
--        list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
-+        list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
-       endif()
-     endforeach()
--  endif()
-
--  if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
--    string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
--    list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
-+    llvm_ExternalProject_Add(builtins-${target}
-+                             ${compiler_rt_path}/lib/builtins
-+                             DEPENDS ${ARG_DEPENDS}
-+                             CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
-+                                        -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
-+                                        -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-+                                        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-+                                        -DCMAKE_C_COMPILER_TARGET=${target}
-+                                        -DCMAKE_ASM_COMPILER_TARGET=${target}
-+                                        -DCMAKE_C_COMPILER_WORKS=ON
-+                                        -DCMAKE_ASM_COMPILER_WORKS=ON
-+                                        -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
-+                                        ${${target}_extra_args}
-+                             USE_TOOLCHAIN
-+                             ${EXTRA_ARGS})
-+  endfunction()
-+
-+  # If compiler-rt is present we need to build the builtin libraries first. This
-+  # is required because the other runtimes need the builtin libraries present
-+  # before the just-built compiler can pass the configuration tests.
-+  get_compiler_rt_path(compiler_rt_path)
-+  if(compiler_rt_path)
-+    if(NOT LLVM_BUILTIN_TARGETS)
-+      builtin_default_target(${compiler_rt_path}
-+        DEPENDS clang-resource-headers)
-+    else()
-+      if("default" IN_LIST LLVM_BUILTIN_TARGETS)
-+        builtin_default_target(${compiler_rt_path}
-+          DEPENDS clang-resource-headers)
-+        list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
-+      else()
-+        add_custom_target(builtins)
-+        add_custom_target(install-builtins)
-+        add_custom_target(install-builtins-stripped)
-+      endif()
-+
-+      foreach(target ${LLVM_BUILTIN_TARGETS})
-+        builtin_register_target(${compiler_rt_path} ${target}
-+          DEPENDS clang-resource-headers)
-+
-+        add_dependencies(builtins builtins-${target})
-+        add_dependencies(install-builtins install-builtins-${target})
-+        add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
-+      endforeach()
-+    endif()
-+    set(deps builtins)
-+    # We don't need to depend on the builtins if we're building instrumented
-+    # because the next stage will use the same compiler used to build this stage.
-+    if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
-+      add_dependencies(clang-bootstrap-deps builtins)
-+    endif()
-   endif()
-
--  if(target IN_LIST LLVM_RUNTIME_BUILD_ID_LINK_TARGETS)
--    list(APPEND EXTRA_ARGS STRIP_TOOL ${CMAKE_CURRENT_BINARY_DIR}/llvm-strip-link)
-+  # We create a list the names of all the runtime projects in all uppercase and
-+  # with dashes turned to underscores. This gives us the CMake variable prefixes
-+  # for all variables that will apply to runtimes.
-+  foreach(entry ${runtimes})
-+    get_filename_component(projName ${entry} NAME)
-+    string(REPLACE "-" "_" canon_name ${projName})
-+    string(TOUPPER ${canon_name} canon_name)
-+    list(APPEND prefixes ${canon_name})
-+    if (${canon_name} STREQUAL "OPENMP")
-+      list(APPEND prefixes "LIBOMP" "LIBOMPTARGET")
-+    endif()
-+    # Many compiler-rt options start with SANITIZER_ rather than COMPILER_RT_,
-+    # so when compiler-rt is enabled, consider both.
-+    if(canon_name STREQUAL "COMPILER_RT")
-+      list(APPEND prefixes SANITIZER)
-+    endif()
-+
-+    string(FIND ${projName} "lib" LIB_IDX)
-+    if(LIB_IDX EQUAL 0)
-+      string(SUBSTRING ${projName} 3 -1 projName)
-+    endif()
-+    list(APPEND runtime_names ${projName})
-+  endforeach()
-+
-+  if(LLVM_RUNTIME_BUILD_ID_LINK_TARGETS)
-+    configure_file(
-+      ${CMAKE_CURRENT_SOURCE_DIR}/llvm-strip-link.in
-+      ${CMAKE_CURRENT_BINARY_DIR}/llvm-strip-link
-+      @ONLY
-+    )
-   endif()
-
--  llvm_ExternalProject_Add(runtimes-${name}
--                           ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
--                           DEPENDS ${${name}_deps}
--                           # Builtins were built separately above
--                           CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
--                                      -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
--                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
--                                      -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
--                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
--                                      -DCMAKE_C_COMPILER_TARGET=${target}
--                                      -DCMAKE_CXX_COMPILER_TARGET=${target}
--                                      -DCMAKE_ASM_COMPILER_TARGET=${target}
--                                      -DCMAKE_C_COMPILER_WORKS=ON
--                                      -DCMAKE_CXX_COMPILER_WORKS=ON
--                                      -DCMAKE_ASM_COMPILER_WORKS=ON
--                                      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
--                                      -DLLVM_RUNTIMES_TARGET=${name}
--                                      ${${name}_extra_args}
--                           EXTRA_TARGETS ${${name}_extra_targets}
--                                         ${${name}_test_targets}
--                           USE_TOOLCHAIN
--                           ${EXTRA_ARGS})
--endfunction()
-+  function(runtime_default_target)
-+    cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN})
-
--if(runtimes)
--  # Create a runtimes target that uses this file as its top-level CMake file.
--  # The runtimes target is a configuration of all the runtime libraries
--  # together in a single CMake invocaiton.
--  if(NOT LLVM_RUNTIME_TARGETS)
--    runtime_default_target(
--      DEPENDS ${deps}
--      PREFIXES ${prefixes})
--    set(test_targets check-runtimes)
--  else()
--    if("default" IN_LIST LLVM_RUNTIME_TARGETS)
--      runtime_default_target(
--        DEPENDS ${deps}
--        PREFIXES ${prefixes})
--      list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
--    else()
--      add_custom_target(runtimes)
--      add_custom_target(runtimes-configure)
--      add_custom_target(install-runtimes)
--      add_custom_target(install-runtimes-stripped)
-+    include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
-+    set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
-+    set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
-+
-+    foreach(runtime_name ${runtime_names})
-+      list(APPEND extra_targets
-+        ${runtime_name}
-+        install-${runtime_name}
-+        install-${runtime_name}-stripped)
-       if(LLVM_INCLUDE_TESTS)
--        add_custom_target(check-runtimes)
--        add_custom_target(runtimes-test-depends)
--        set(test_targets "")
-+        list(APPEND test_targets check-${runtime_name})
-       endif()
--      foreach(runtime_name ${runtime_names})
--        add_custom_target(${runtime_name})
--        add_custom_target(install-${runtime_name})
--        add_custom_target(install-${runtime_name}-stripped)
--      endforeach()
--      if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
--        foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
--          add_custom_target(${component})
--          add_custom_target(install-${component})
--          add_custom_target(install-${component}-stripped)
--        endforeach()
-+    endforeach()
-+    foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
-+      if(NOT ${component} IN_LIST SUB_COMPONENTS)
-+        list(APPEND extra_targets ${component} install-${component} install-${component}-stripped)
-       endif()
-+    endforeach()
-+
-+    if(LLVM_INCLUDE_TESTS)
-+      list(APPEND test_targets runtimes-test-depends check-runtimes)
-     endif()
-
--    foreach(name ${LLVM_RUNTIME_TARGETS})
--      runtime_register_target(${name} ${name}
--        DEPENDS ${deps})
-+    set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
-+    # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
-+    if (TARGET_TRIPLE MATCHES "aix")
-+      set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
-+    endif()
-+
-+    llvm_ExternalProject_Add(runtimes
-+                             ${CMAKE_CURRENT_SOURCE_DIR}
-+                             DEPENDS ${ARG_DEPENDS}
-+                             # Builtins were built separately above
-+                             CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-+                                        -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-+                                        -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
-+                                        -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-+                                        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
-+                                        -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
-+                                        -DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
-+                                        -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
-+                                        -DCMAKE_C_COMPILER_WORKS=ON
-+                                        -DCMAKE_CXX_COMPILER_WORKS=ON
-+                                        -DCMAKE_ASM_COMPILER_WORKS=ON
-+                                        ${RUNTIMES_CMAKE_ARGS}
-+                             PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
-+                                                  ${ARG_PREFIXES}
-+                             EXTRA_TARGETS ${extra_targets}
-+                                           ${test_targets}
-+                                           ${SUB_COMPONENTS}
-+                                           ${SUB_CHECK_TARGETS}
-+                                           ${SUB_INSTALL_TARGETS}
-+                             USE_TOOLCHAIN
-+                             ${EXTRA_ARGS})
-+  endfunction()
-+
-+  # runtime_register_target(target)
-+  #   Utility function to register external runtime target.
-+  function(runtime_register_target name target)
-+    cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
-+    include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
-+    set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
-+
-+    check_apple_target(${target} runtime)
-+
-+    set(${name}_deps ${ARG_DEPENDS})
-+    if(NOT name STREQUAL target)
-+      list(APPEND ${name}_deps runtimes-${target})
-+    endif()
-
--      add_dependencies(runtimes runtimes-${name})
--      add_dependencies(runtimes-configure runtimes-${name}-configure)
--      add_dependencies(install-runtimes install-runtimes-${name})
--      add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
-+    foreach(runtime_name ${runtime_names})
-+      set(${runtime_name}-${name} ${runtime_name})
-+      set(install-${runtime_name}-${name} install-${runtime_name})
-+      set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
-+      list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
-       if(LLVM_INCLUDE_TESTS)
--        add_dependencies(check-runtimes check-runtimes-${name})
--        add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
-+        set(check-${runtime_name}-${name} check-${runtime_name} )
-+        list(APPEND ${name}_test_targets check-${runtime_name}-${name})
-       endif()
--      foreach(runtime_name ${runtime_names})
--        add_dependencies(${runtime_name} ${runtime_name}-${name})
--        add_dependencies(install-${runtime_name} install-${runtime_name}-${name})
--        add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}-stripped)
-+    endforeach()
-+
-+    foreach(target_name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS)
-+      set(${target_name}-${name} ${target_name})
-+      list(APPEND ${name}_extra_targets ${target_name}-${name})
-+    endforeach()
-+
-+    foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
-+      set(${component}-${name} ${component})
-+      set(install-${component}-${name} install-${component})
-+      set(install-${component}-${name}-stripped install-${component}-stripped)
-+      list(APPEND ${name}_extra_targets ${component}-${name} install-${component}-${name} install-${component}-${name}-stripped)
-+    endforeach()
-+
-+    if(LLVM_INCLUDE_TESTS)
-+      set(runtimes-test-depends-${name} runtimes-test-depends)
-+      set(check-runtimes-${name} check-runtimes)
-+      list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
-+      foreach(target_name IN LISTS SUB_CHECK_TARGETS)
-+        set(${target_name}-${name} ${target_name})
-+        list(APPEND ${name}_test_targets ${target_name}-${name})
-+        list(APPEND test_targets ${target_name}-${name})
-       endforeach()
-+      set(test_targets "${test_targets}" PARENT_SCOPE)
-+    endif()
-+
-+    set(${name}_extra_args ${ARG_CMAKE_ARGS})
-+    get_cmake_property(variableNames VARIABLES)
-+    foreach(variableName ${variableNames})
-+      string(FIND "${variableName}" "RUNTIMES_${target}_" out)
-+      if("${out}" EQUAL 0)
-+        string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
-+        string(REPLACE ";" "|" new_value "${${variableName}}")
-+        list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
-+      endif()
-     endforeach()
-+    if(NOT "${name}" STREQUAL "${target}")
-+      foreach(variableName ${variableNames})
-+        string(FIND "${variableName}" "RUNTIMES_${name}_" out)
-+        if("${out}" EQUAL 0)
-+          string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
-+          string(REPLACE ";" "|" new_value "${${variableName}}")
-+          list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
-+        endif()
-+      endforeach()
-+    endif()
-+
-+    if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
-+      string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
-+      list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
-+    endif()
-+
-+    if(target IN_LIST LLVM_RUNTIME_BUILD_ID_LINK_TARGETS)
-+      list(APPEND EXTRA_ARGS STRIP_TOOL ${CMAKE_CURRENT_BINARY_DIR}/llvm-strip-link)
-+    endif()
-
--    foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
--      foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
--        runtime_register_target(${name}+${multilib} ${name}
--          DEPENDS runtimes-${name}
--          CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
--                     -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
--        add_dependencies(runtimes runtimes-${name}+${multilib})
--        add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
--        add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
--        add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
-+    llvm_ExternalProject_Add(runtimes-${name}
-+                             ${CMAKE_CURRENT_SOURCE_DIR}
-+                             DEPENDS ${${name}_deps}
-+                             # Builtins were built separately above
-+                             CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-+                                        -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-+                                        -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-+                                        -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-+                                        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-+                                        -DCMAKE_C_COMPILER_TARGET=${target}
-+                                        -DCMAKE_CXX_COMPILER_TARGET=${target}
-+                                        -DCMAKE_ASM_COMPILER_TARGET=${target}
-+                                        -DCMAKE_C_COMPILER_WORKS=ON
-+                                        -DCMAKE_CXX_COMPILER_WORKS=ON
-+                                        -DCMAKE_ASM_COMPILER_WORKS=ON
-+                                        -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
-+                                        -DLLVM_RUNTIMES_TARGET=${name}
-+                                        ${${name}_extra_args}
-+                             EXTRA_TARGETS ${${name}_extra_targets}
-+                                           ${${name}_test_targets}
-+                             USE_TOOLCHAIN
-+                             ${EXTRA_ARGS})
-+  endfunction()
-+
-+  if(runtimes)
-+    # Create a runtimes target that uses this file as its top-level CMake file.
-+    # The runtimes target is a configuration of all the runtime libraries
-+    # together in a single CMake invocaiton.
-+    if(NOT LLVM_RUNTIME_TARGETS)
-+      runtime_default_target(
-+        DEPENDS ${deps}
-+        PREFIXES ${prefixes})
-+      set(test_targets check-runtimes)
-+    else()
-+      if("default" IN_LIST LLVM_RUNTIME_TARGETS)
-+        runtime_default_target(
-+          DEPENDS ${deps}
-+          PREFIXES ${prefixes})
-+        list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
-+      else()
-+        add_custom_target(runtimes)
-+        add_custom_target(runtimes-configure)
-+        add_custom_target(install-runtimes)
-+        add_custom_target(install-runtimes-stripped)
-+        if(LLVM_INCLUDE_TESTS)
-+          add_custom_target(check-runtimes)
-+          add_custom_target(runtimes-test-depends)
-+          set(test_targets "")
-+        endif()
-+        foreach(runtime_name ${runtime_names})
-+          add_custom_target(${runtime_name})
-+          add_custom_target(install-${runtime_name})
-+          add_custom_target(install-${runtime_name}-stripped)
-+        endforeach()
-+        if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
-+          foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
-+            add_custom_target(${component})
-+            add_custom_target(install-${component})
-+            add_custom_target(install-${component}-stripped)
-+          endforeach()
-+        endif()
-+      endif()
-+
-+      foreach(name ${LLVM_RUNTIME_TARGETS})
-+        runtime_register_target(${name} ${name}
-+          DEPENDS ${deps})
-+
-+        add_dependencies(runtimes runtimes-${name})
-+        add_dependencies(runtimes-configure runtimes-${name}-configure)
-+        add_dependencies(install-runtimes install-runtimes-${name})
-+        add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
-+        if(LLVM_INCLUDE_TESTS)
-+          add_dependencies(check-runtimes check-runtimes-${name})
-+          add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
-+        endif()
-         foreach(runtime_name ${runtime_names})
--          add_dependencies(${runtime_name} ${runtime_name}-${name}+${multilib})
--          add_dependencies(install-${runtime_name} install-${runtime_name}-${name}+${multilib})
--          add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}+${multilib}-stripped)
-+          add_dependencies(${runtime_name} ${runtime_name}-${name})
-+          add_dependencies(install-${runtime_name} install-${runtime_name}-${name})
-+          add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}-stripped)
-         endforeach()
-       endforeach()
--    endforeach()
--  endif()
-
--  if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
--    # TODO: This is a hack needed because the libcxx headers are copied into the
--    # build directory during configuration. Without that step the clang in the
--    # build directory cannot find the C++ headers in certain configurations.
--    # I need to build a mechanism for runtime projects to provide CMake code
--    # that executes at LLVM configuration time to handle this case.
--    add_dependencies(clang-bootstrap-deps runtimes-configure)
--    # We need to add the runtimes as a dependency because compiler-rt can be
--    # built as part of runtimes and we need the profile runtime for PGO
--    add_dependencies(clang-bootstrap-deps runtimes)
--  endif()
-+      foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
-+        foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
-+          runtime_register_target(${name}+${multilib} ${name}
-+            DEPENDS runtimes-${name}
-+            CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
-+                       -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
-+          add_dependencies(runtimes runtimes-${name}+${multilib})
-+          add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
-+          add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
-+          add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
-+          foreach(runtime_name ${runtime_names})
-+            add_dependencies(${runtime_name} ${runtime_name}-${name}+${multilib})
-+            add_dependencies(install-${runtime_name} install-${runtime_name}-${name}+${multilib})
-+            add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}+${multilib}-stripped)
-+          endforeach()
-+        endforeach()
-+      endforeach()
-+    endif()
-
--  if(LLVM_INCLUDE_TESTS)
--    set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
--    set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-runtimes)
--
--    set(RUNTIMES_TEST_DEPENDS
--        FileCheck
--        count
--        llvm-nm
--        llvm-objdump
--        llvm-xray
--        not
--        obj2yaml
--        sancov
--        sanstats
--        gtest_main
--        gtest
--      )
--    foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
--      add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
--    endforeach()
-+    if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
-+      # TODO: This is a hack needed because the libcxx headers are copied into the
-+      # build directory during configuration. Without that step the clang in the
-+      # build directory cannot find the C++ headers in certain configurations.
-+      # I need to build a mechanism for runtime projects to provide CMake code
-+      # that executes at LLVM configuration time to handle this case.
-+      add_dependencies(clang-bootstrap-deps runtimes-configure)
-+      # We need to add the runtimes as a dependency because compiler-rt can be
-+      # built as part of runtimes and we need the profile runtime for PGO
-+      add_dependencies(clang-bootstrap-deps runtimes)
-+    endif()
-+
-+    if(LLVM_INCLUDE_TESTS)
-+      set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
-+      set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-runtimes)
-+
-+      set(RUNTIMES_TEST_DEPENDS
-+          FileCheck
-+          count
-+          llvm-nm
-+          llvm-objdump
-+          llvm-xray
-+          not
-+          obj2yaml
-+          sancov
-+          sanstats
-+          gtest_main
-+          gtest
-+        )
-+      foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
-+        add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
-+      endforeach()
-+    endif()
-   endif()
- endif()
-diff --git a/runtimes/Components.cmake.in b/llvm/runtimes/Components.cmake.in
-similarity index 100%
-rename from runtimes/Components.cmake.in
-rename to llvm/runtimes/Components.cmake.in
-diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
-deleted file mode 100644
-index a1017d91f36a..000000000000
---- a/runtimes/CMakeLists.txt
-+++ /dev/null
-@@ -1,203 +0,0 @@
--# This file handles building LLVM runtime sub-projects.
--cmake_minimum_required(VERSION 3.13.4)
--project(Runtimes C CXX ASM)
--
--set(LLVM_ALL_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind;openmp")
--set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
--  "Semicolon-separated list of runtimes to build (${LLVM_ALL_RUNTIMES}), or \"all\".")
--if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )
--  set(LLVM_ENABLE_RUNTIMES ${LLVM_ALL_RUNTIMES})
--endif()
--
--foreach(proj ${LLVM_ENABLE_RUNTIMES})
--  set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
--  if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
--    list(APPEND runtimes ${proj_dir})
--  else()
--    message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${proj_dir}")
--  endif()
--  string(TOUPPER "${proj}" canon_name)
--  STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})
--  set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
--endforeach()
--
--function(runtime_register_component name)
--  set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
--endfunction()
--
--find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
--find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
--
--# Add path for custom and the LLVM build's modules to the CMake module path.
--list(INSERT CMAKE_MODULE_PATH 0
--  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
--  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
--  "${CMAKE_CURRENT_SOURCE_DIR}/../llvm/cmake"
--  "${CMAKE_CURRENT_SOURCE_DIR}/../llvm/cmake/modules"
--)
--
--function(get_compiler_rt_path path)
--  foreach(entry ${runtimes})
--    get_filename_component(projName ${entry} NAME)
--    if("${projName}" MATCHES "compiler-rt")
--      set(${path} ${entry} PARENT_SCOPE)
--      return()
--    endif()
--  endforeach()
--endfunction()
--
--# Some of the runtimes will conditionally use the compiler-rt sanitizers
--# to make this work smoothly we ensure that compiler-rt is added first in
--# the list of sub-projects. This allows other sub-projects to have checks
--# like `if(TARGET asan)` to enable building with asan.
--get_compiler_rt_path(compiler_rt_path)
--if(compiler_rt_path)
--  list(REMOVE_ITEM runtimes ${compiler_rt_path})
--  if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
--    list(INSERT runtimes 0 ${compiler_rt_path})
--  endif()
--endif()
--
--# Setting these variables will allow the sub-build to put their outputs into
--# the library and bin directories of the top-level build.
--set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
--set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
--
--# This variable makes sure that e.g. llvm-lit is found.
--set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
--set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
--
--# This variable is used by individual runtimes to locate LLVM files.
--set(LLVM_PATH ${LLVM_BUILD_MAIN_SRC_DIR})
--
--if(APPLE)
--  set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
--endif()
--
--include(CheckLibraryExists)
--include(CheckCCompilerFlag)
--
--# Disable use of the installed C++ standard library when building runtimes. If
--# MSVC is true, we must be using the clang-cl driver, which doesn't understand
--# these flags.
--if (NOT MSVC)
--  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++")
--
--  if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
--    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -isystem ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include")
--  endif()
--endif()
--
--# Avoid checking whether the compiler is working.
--set(LLVM_COMPILER_CHECKED ON)
--
--# Handle common options used by all runtimes.
--include(AddLLVM)
--include(HandleLLVMOptions)
--include(FindPythonInterp)
--
--# Remove the -nostdlib++ option we've added earlier.
--string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
--
--# Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
--if(CMAKE_HOST_APPLE AND APPLE)
--  include(UseLibtool)
--endif()
--
--# This can be used to detect whether we're in the runtimes build.
--set(RUNTIMES_BUILD ON)
--
--foreach(entry ${runtimes})
--  get_filename_component(projName ${entry} NAME)
--
--  # TODO: Clean this up as part of an interface standardization
--  string(REPLACE "-" "_" canon_name ${projName})
--  string(TOUPPER ${canon_name} canon_name)
--
--  # The subdirectories need to treat this as standalone builds. D57992 tried
--  # to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if
--  # llvm & clang are configured in the same CMake, and setup dependencies
--  # against their targets. OpenMP has fixed the issue so we don't set the
--  # variable.
--  if (NOT ${canon_name} STREQUAL "OPENMP")
--    set(${canon_name}_STANDALONE_BUILD ON)
--  endif()
--
--  if(LLVM_RUNTIMES_LIBDIR_SUBDIR)
--    set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE STRING "" FORCE)
--  endif()
--
--  # Setting a variable to let sub-projects detect which other projects
--  # will be included under here.
--  set(HAVE_${canon_name} ON)
--endforeach()
--
--# We do this in two loops so that HAVE_* is set for each runtime before the
--# other runtimes are added.
--foreach(entry ${runtimes})
--  get_filename_component(projName ${entry} NAME)
--
--  # Between each sub-project we want to cache and clear the LIT properties
--  set_property(GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
--  set_property(GLOBAL PROPERTY LLVM_LIT_PARAMS)
--  set_property(GLOBAL PROPERTY LLVM_LIT_DEPENDS)
--  set_property(GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
--
--  add_subdirectory(${entry} ${projName})
--
--  get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
--  get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
--  get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
--  get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
--
--  list(APPEND RUNTIMES_LIT_TESTSUITES ${LLVM_LIT_TESTSUITES})
--  list(APPEND RUNTIMES_LIT_PARAMS ${LLVM_LIT_PARAMS})
--  list(APPEND RUNTIMES_LIT_DEPENDS ${LLVM_LIT_DEPENDS})
--  list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
--endforeach()
--
--if(LLVM_INCLUDE_TESTS)
--  # Add a global check rule now that all subdirectories have been traversed
--  # and we know the total set of lit testsuites.
--
--  add_lit_target(check-runtimes
--    "Running all regression tests"
--    ${RUNTIMES_LIT_TESTSUITES}
--    PARAMS ${RUNTIMES_LIT_PARAMS}
--    DEPENDS ${RUNTIMES_LIT_DEPENDS}
--    ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
--    )
--  add_custom_target(runtimes-test-depends DEPENDS ${RUNTIMES_LIT_DEPENDS})
--endif()
--
--get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
--if(SUB_COMPONENTS)
--  list(REMOVE_DUPLICATES SUB_COMPONENTS)
--  foreach(component ${SUB_COMPONENTS})
--    if(NOT TARGET ${component})
--      message(SEND_ERROR "Missing target for runtime component ${component}!")
--      continue()
--    endif()
--
--    if(TARGET check-${component})
--      list(APPEND SUB_CHECK_TARGETS check-${component})
--    endif()
--
--    if(TARGET install-${component})
--      list(APPEND SUB_INSTALL_TARGETS install-${component})
--    endif()
--    if(TARGET install-${component}-stripped)
--      list(APPEND SUB_INSTALL_TARGETS install-${component}-stripped)
--    endif()
--  endforeach()
--
--  if(LLVM_RUNTIMES_TARGET)
--    configure_file(
--      ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
--      ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
--  else()
--    configure_file(
--      ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
--      ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
--  endif()
--endif()
copy from build/build-clang/revert-llvmorg-12-init-7827-g2a078c307204-trunk.patch
copy to build/build-clang/revert-llvmorg-13-init-7827-g2a078c307204.patch
deleted file mode 100644
--- a/build/build-clang/revert-r362047-and-r362065_clang_12.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-Bisection found that r362047 (and its followup build fix r362065) cause the
-build to install the android PGO library into the following location:
-stage2/clang/lib/linux/libclang_rt.profile-arm-android.a
-rather than the expected:
-stage2/clang/lib64/clang/$VERSION/lib/linux/libclang_rt.profile-arm-android.a
-
-For lack of any progress in debugging this, revert those two patches.
-
-diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
-index d2f5d6bf80f0..424f4da01f77 100644
---- a/llvm/runtimes/CMakeLists.txt
-+++ b/llvm/runtimes/CMakeLists.txt
-@@ -59,7 +59,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-   cmake_minimum_required(VERSION 3.13.4)
-   project(Runtimes C CXX ASM)
- 
--  find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
-   find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
- 
-   # Add the root project's CMake modules, and the LLVM build's modules to the
-@@ -67,6 +66,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-   list(INSERT CMAKE_MODULE_PATH 0
-     "${CMAKE_CURRENT_SOURCE_DIR}/../cmake"
-     "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
-+    "${LLVM_LIBRARY_DIR}/cmake/llvm"
-   )
- 
-   # Some of the runtimes will conditionally use the compiler-rt sanitizers
-@@ -81,6 +81,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-     endif()
-   endif()
- 
-+  # LLVMConfig.cmake contains a bunch of CMake variables from the LLVM build.
-+  # This file is installed as part of LLVM distributions, so this can be used
-+  # either from a build directory or an installed LLVM.
-+  include(LLVMConfig)
-+
-   # Setting these variables will allow the sub-build to put their outputs into
-   # the library and bin directories of the top-level build.
-   set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
-@@ -90,9 +95,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-   set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
-   set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
- 
--  # This variable is used by individual runtimes to locate LLVM files.
--  set(LLVM_PATH ${LLVM_BUILD_MAIN_SRC_DIR})
--
-   if(APPLE)
-     set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
-   endif()
-@@ -421,6 +423,8 @@ ${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
-                              # Builtins were built separately above
-                              CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-                                         -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-+                                        -DLLVM_BINARY_DIR=${LLVM_BINARY_DIR}
-+                                        -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
-                                         -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
-                                         -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-                                         -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
-@@ -527,6 +531,8 @@ ${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
-                              # Builtins were built separately above
-                              CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-                                         -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-+                                        -DLLVM_BINARY_DIR=${LLVM_BINARY_DIR}
-+                                        -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
-                                         -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-                                         -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-                                         -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
--- a/mobile/android/config/mozconfigs/common
+++ b/mobile/android/config/mozconfigs/common
@@ -35,9 +35,14 @@ if [ -n "$TASKCLUSTER_PGO_PROFILE_USE" -
     # see bug 1539933.
     # ac_add_options --with-pgo-jarlog=${MOZ_FETCHES_DIR}/en-US.log
     ac_add_options --with-pgo-profile-path=${MOZ_FETCHES_DIR}/merged.profdata
 fi
 
 # Package js shell.
 export MOZ_PACKAGE_JSSHELL=1
 
+if [ -d "$MOZ_FETCHES_DIR/binutils/bin" ]; then
+    mk_add_options "export PATH=$MOZ_FETCHES_DIR/binutils/bin:$PATH"
+    export LDFLAGS="$LDFLAGS -B $MOZ_FETCHES_DIR/binutils/bin"
+fi
+
 JS_BINARY="$topsrcdir/mobile/android/config/js_wrapper.sh"
--- a/mozglue/build/TsanOptions.cpp
+++ b/mozglue/build/TsanOptions.cpp
@@ -297,14 +297,15 @@ extern "C" const char* __tsan_default_su
          "race:scale_blit\n"
 
          "race:mozilla::gl::MesaMemoryLeakWorkaround\n"
 
          // Bug 1733908
          "race:js::wasm::Code::bestTier\n"
          "race:js::wasm::Code::commitTier2\n"
          "race:js::wasm::Code::setTier2\n"
+         "race:js::wasm::Code::setAndBorrowTier2\n"
 
       // End of suppressions.
       ;  // Please keep this semicolon.
 }
 // clang-format on
 #endif  // _MSC_VER
--- a/taskcluster/ci/fetch/toolchains.yml
+++ b/taskcluster/ci/fetch/toolchains.yml
@@ -375,16 +375,23 @@ clang-10:
 
 clang-12:
     description: clang 12.0.1 source code
     fetch:
         type: git
         repo: https://github.com/llvm/llvm-project
         revision: fed41342a82f5a3a9201819a82bf7a48313e296b
 
+clang-13:
+    description: clang 13.0.0 source code
+    fetch:
+        type: git
+        repo: https://github.com/llvm/llvm-project
+        revision: d7b669b3a30345cfcdb2fde2af6f48aa4b94845d
+
 clang-trunk:
     description: clang main branch source code
     attributes:
         cached_task: false
     fetch:
         type: git
         repo: https://github.com/llvm/llvm-project
         branch: main
--- a/taskcluster/ci/instrumented-build/kind.yml
+++ b/taskcluster/ci/instrumented-build/kind.yml
@@ -164,16 +164,18 @@ jobs:
                 - builds/releng_base_android_64_builds.py
             custom-build-variant-cfg: x86-profile-generate
             tooltool-downloads: internal
         fetches:
             toolchain:
                 - android-gradle-dependencies
                 - android-ndk-linux
                 - android-sdk-linux
+                # Workaround issues in binutils from the ndk with the compiler-rt from clang-13
+                - linux64-binutils
                 - linux64-clang-android-cross
                 - linux64-rust-android
                 - linux64-rust-size
                 - linux64-cbindgen
                 - linux64-dump_syms
                 - linux64-nasm
                 - linux64-node
                 - sysroot-x86_64-linux-gnu
--- a/taskcluster/ci/spidermonkey/linux.yml
+++ b/taskcluster/ci/spidermonkey/linux.yml
@@ -425,17 +425,19 @@ sm-fuzzing-linux64/opt:
         symbol: SM(f)
     worker:
         env:
             MOZ_JS_UPLOAD_BINARIES_DEFAULT: "1"
     run:
         spidermonkey-variant: fuzzing
     fetches:
         toolchain:
-            - linux64-clang
+            # Keep this with clang-12 until we move to rust 1.56 that uses the same
+            # LLVM-13 backend as clang-13
+            - linux64-clang-12
             - linux64-rust
             - linux64-cbindgen
             - linux64-dump_syms
             - linux64-breakpad-injector
             - linux64-minidump-stackwalk
             - linux64-llvm-symbolizer
             - sysroot-x86_64-linux-gnu
 
--- a/taskcluster/ci/toolchain/cbindgen.yml
+++ b/taskcluster/ci/toolchain/cbindgen.yml
@@ -23,41 +23,41 @@ linux64-cbindgen:
     treeherder:
         symbol: TL(cbindgen)
     worker:
         max-run-time: 1800
     run:
         arguments: ['x86_64-unknown-linux-gnu']
     fetches:
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-rust-1.47
             - sysroot-x86_64-linux-gnu
 
 macosx64-cbindgen:
     treeherder:
         symbol: TM(cbindgen)
     run:
         arguments: ['x86_64-apple-darwin']
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - linux64-rust-macos-1.47
             - macosx64-sdk-11.0
 
 macosx64-aarch64-cbindgen:
     treeherder:
         symbol: TM(cbindgen-arm64)
     run:
         arguments: ['aarch64-apple-darwin']
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - linux64-rust-macos-1.49
             - macosx64-sdk-11.0
 
 win64-cbindgen:
     treeherder:
         symbol: TW64(cbindgen)
     worker-type: b-win2012
     worker:
--- a/taskcluster/ci/toolchain/cctools-port.yml
+++ b/taskcluster/ci/toolchain/cctools-port.yml
@@ -8,20 +8,20 @@ job-defaults:
     worker:
         max-run-time: 1800
     fetches:
         fetch:
             - cctools-port
             - libtapi
             - ldid
 
-linux64-cctools-port-clang-12:
+linux64-cctools-port-clang-13:
     treeherder:
-        symbol: TL(cctools-clang-12)
+        symbol: TL(cctools-clang-13)
     run:
         script: build-cctools-port.sh
         toolchain-alias: linux64-cctools-port
         toolchain-artifact: public/build/cctools.tar.zst
     fetches:
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-binutils
             - linux64-toolchain-sysroot
--- a/taskcluster/ci/toolchain/clang-tidy.yml
+++ b/taskcluster/ci/toolchain/clang-tidy.yml
@@ -18,34 +18,34 @@ job-defaults:
             - 'build/clang-plugin/**/*.h'
             - 'build/clang-plugin/*.inc'
             - 'build/clang-plugin/*.py'
             - 'build/clang-plugin/moz.build'
             - 'build/clang-plugin/Makefile.in'
             - 'build/build-clang/build-clang.py'
     fetches:
         fetch:
-            - clang-12
+            - clang-13
 
 linux64-clang-tidy:
     index:
         job-name: linux64-clang-tidy
     treeherder:
         symbol: TL(clang-tidy)
     run:
         script: build-clang.sh
         arguments:
             - 'build/build-clang/clang-tidy-linux64.json'
         resources:
             - 'build/build-clang/clang-tidy-linux64.json'
     run-on-projects:
         - trunk
     fetches:
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-toolchain-sysroot
 
 macosx64-clang-tidy:
     index:
         job-name: macosx64-clang-tidy
     treeherder:
         symbol: TM(clang-tidy)
     worker-type: b-linux-large
@@ -54,18 +54,18 @@ macosx64-clang-tidy:
         arguments:
             - 'build/build-clang/clang-tidy-macosx64.json'
         resources:
             - 'build/build-clang/clang-tidy-macosx64.json'
     run-on-projects:
         - trunk
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12-macosx-cross
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13-macosx-cross
             - macosx64-sdk-11.0
 
 macosx64-arch64-clang-tidy:
     index:
         job-name: macosx64-aarch64-clang-tidy
     treeherder:
         symbol: TM(clang-tidy-aarch64)
     worker-type: b-linux-large
@@ -77,18 +77,18 @@ macosx64-arch64-clang-tidy:
         arguments:
             - 'build/build-clang/clang-tidy-macosx64.json'
         resources:
             - 'build/build-clang/clang-tidy-macosx64.json'
     run-on-projects:
         - trunk
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12-macosx-cross
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13-macosx-cross
             - macosx64-sdk-11.0
 
 win64-clang-tidy:
     description: "Clang-tidy toolchain build"
     index:
         job-name: win64-clang-tidy
     treeherder:
         symbol: TW64(clang-tidy)
@@ -131,10 +131,10 @@ linux64-clang-tidy-external:
             - 'build/build-clang/clang-tidy-external-linux64.json'
         resources:
             - 'build/build-clang/clang-tidy-external-linux64.json'
     run-on-projects: []
     fetches:
         fetch:
             - civet-source
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-toolchain-sysroot
--- a/taskcluster/ci/toolchain/clang.yml
+++ b/taskcluster/ci/toolchain/clang.yml
@@ -41,58 +41,58 @@ linux64-clang-7:
             - 'build/build-clang/clang-7-linux64.json'
         toolchain-artifact: public/build/clang.tar.zst
     fetches:
         fetch:
             - clang-7
         toolchain:
             - linux64-toolchain-sysroot
 
-linux64-clang-12-mingw-x86:
-    description: "MinGW-Clang 12 x86 toolchain build"
+linux64-clang-13-mingw-x86:
+    description: "MinGW-Clang 13 x86 toolchain build"
     treeherder:
         symbol: TMW(clang-x86)
     worker-type: b-linux
     run:
         script: build-clang-mingw.sh
         arguments:
             - 'x86'
         toolchain-alias: linux64-clang-mingw-x86
         toolchain-artifact: public/build/clangmingw.tar.zst
     fetches:
         fetch:
-            - clang-12
+            - clang-13
             - mingw-w64
             - libunwind
             - llvm-mingw
             - gcc-9.3.0
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
 
-linux64-clang-12-mingw-x64:
-    description: "MinGW-Clang 12 x64 toolchain build"
+linux64-clang-13-mingw-x64:
+    description: "MinGW-Clang 13 x64 toolchain build"
     treeherder:
         symbol: TMW(clang-x64)
         tier: 1
     worker-type: b-linux
     run:
         script: build-clang-mingw.sh
         arguments:
             - 'x64'
         toolchain-alias: linux64-clang-mingw-x64
         toolchain-artifact: public/build/clangmingw.tar.zst
     fetches:
         fetch:
-            - clang-12
+            - clang-13
             - mingw-w64
             - libunwind
             - llvm-mingw
             - gcc-9.3.0
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
 
 linux64-clang-10:
     description: "Clang 10 toolchain build"
     treeherder:
         symbol: TL(clang10)
     run:
         using: toolchain-script
         script: build-clang.sh
@@ -139,230 +139,251 @@ linux64-clang-12:
     run-on-projects: [trunk]
     run:
         using: toolchain-script
         script: build-clang.sh
         arguments:
             - 'build/build-clang/clang-12-linux64.json'
         resources:
             - 'build/build-clang/clang-12-linux64.json'
-        toolchain-alias: linux64-clang
         toolchain-artifact: public/build/clang.tar.zst
     fetches:
         fetch:
             - clang-12
         toolchain:
             - linux64-toolchain-sysroot
-            - wasm32-wasi-compiler-rt-12
 
-linux64-clang-12-android-cross:
-    description: "Clang 12 toolchain build"
+linux64-clang-13:
+    description: "Clang 13 toolchain build"
+    attributes:
+        local-toolchain: true
     treeherder:
-        symbol: TL(clang12-android)
+        symbol: TL(clang13)
+    run-on-projects: [trunk]
+    run:
+        using: toolchain-script
+        script: build-clang.sh
+        arguments:
+            - 'build/build-clang/clang-13-linux64.json'
+        resources:
+            - 'build/build-clang/clang-13-linux64.json'
+        toolchain-alias: linux64-clang
+        toolchain-artifact: public/build/clang.tar.zst
+    fetches:
+        fetch:
+            - clang-13
+        toolchain:
+            - linux64-toolchain-sysroot
+            - wasm32-wasi-compiler-rt-13
+
+linux64-clang-13-android-cross:
+    description: "Clang 13 toolchain build"
+    treeherder:
+        symbol: TL(clang13-android)
     run:
         using: toolchain-script
         script: repack-clang-linux-cross.sh
         arguments:
             - aarch64
             - arm
             - x86
             - x64
         toolchain-alias: linux64-clang-android-cross
         toolchain-artifact: public/build/clang.tar.zst
     dependencies:
-        android-aarch64-compiler-rt-12: toolchain-android-aarch64-compiler-rt-12
-        android-arm-compiler-rt-12: toolchain-android-arm-compiler-rt-12
-        android-x86-compiler-rt-12: toolchain-android-x86-compiler-rt-12
-        android-x64-compiler-rt-12: toolchain-android-x64-compiler-rt-12
+        android-aarch64-compiler-rt-13: toolchain-android-aarch64-compiler-rt-13
+        android-arm-compiler-rt-13: toolchain-android-arm-compiler-rt-13
+        android-x86-compiler-rt-13: toolchain-android-x86-compiler-rt-13
+        android-x64-compiler-rt-13: toolchain-android-x64-compiler-rt-13
     fetches:
         toolchain:
-            - linux64-clang-12
-        android-aarch64-compiler-rt-12:
+            - linux64-clang-13
+        android-aarch64-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
               dest: aarch64
-        android-arm-compiler-rt-12:
+        android-arm-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
               dest: arm
-        android-x86-compiler-rt-12:
+        android-x86-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
               dest: x86
-        android-x64-compiler-rt-12:
+        android-x64-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
               dest: x64
 
-linux64-clang-12-aarch64-cross:
-    description: "Clang 12 toolchain build with aarch64 runtime"
+linux64-clang-13-aarch64-cross:
+    description: "Clang 13 toolchain build with aarch64 runtime"
     treeherder:
-        symbol: TL(clang12-aarch64)
+        symbol: TL(clang13-aarch64)
     worker-type: b-linux
     worker:
         max-run-time: 600
     run:
         script: repack-clang-linux-cross.sh
         toolchain-alias: linux64-clang-aarch64-cross
         toolchain-artifact: public/build/clang.tar.zst
     dependencies:
-        linux64-aarch64-compiler-rt-12: toolchain-linux64-aarch64-compiler-rt-12
+        linux64-aarch64-compiler-rt-13: toolchain-linux64-aarch64-compiler-rt-13
     fetches:
         toolchain:
-            - linux64-clang-12
-        linux64-aarch64-compiler-rt-12:
+            - linux64-clang-13
+        linux64-aarch64-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
 
-linux64-clang-12-macosx-cross:
-    description: "Clang 12 toolchain repack with MacOS Compiler RT libs"
+linux64-clang-13-macosx-cross:
+    description: "Clang 13 toolchain repack with MacOS Compiler RT libs"
     treeherder:
-        symbol: TL(clang12-macosx-cross)
+        symbol: TL(clang13-macosx-cross)
     worker-type: b-linux
     worker:
         max-run-time: 600
     run:
         script: repack-clang-linux-macosx-cross.sh
         toolchain-alias: linux64-clang-macosx-cross
         toolchain-artifact: public/build/clang.tar.zst
     dependencies:
-        macosx64-aarch64-compiler-rt-12: toolchain-macosx64-aarch64-compiler-rt-12
-        macosx64-x64-compiler-rt-12: toolchain-macosx64-x64-compiler-rt-12
+        macosx64-aarch64-compiler-rt-13: toolchain-macosx64-aarch64-compiler-rt-13
+        macosx64-x64-compiler-rt-13: toolchain-macosx64-x64-compiler-rt-13
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
-        macosx64-aarch64-compiler-rt-12:
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
+        macosx64-aarch64-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
               dest: aarch64
-        macosx64-x64-compiler-rt-12:
+        macosx64-x64-compiler-rt-13:
             - artifact: compiler-rt.tar.zst
               dest: x86_64
 
-linux64-clang-12-win-cross:
-    description: "Clang 12 toolchain repack with Windows Compiler RT libs"
+linux64-clang-13-win-cross:
+    description: "Clang 13 toolchain repack with Windows Compiler RT libs"
     treeherder:
-        symbol: TL(clang12-win-cross)
+        symbol: TL(clang13-win-cross)
     worker-type: b-linux
     worker:
         max-run-time: 600
     run:
         script: repack-clang-linux-win-cross.sh
         toolchain-alias: linux64-clang-win-cross
         toolchain-artifact: public/build/clang.tar.zst
     dependencies:
-        win64-clang-12-2stage: toolchain-win64-clang-12-2stage
+        win64-clang-13-2stage: toolchain-win64-clang-13-2stage
     fetches:
         toolchain:
-            - linux64-clang-12
-        win64-clang-12-2stage:
+            - linux64-clang-13
+        win64-clang-13-2stage:
             # Put this into a new directory so it doesn't conflict with the linux toolchain
             - artifact: clang.tar.zst
               dest: clang-cl
               extract: false
 
-macosx64-clang-12:
-    description: "Clang 12 toolchain build"
+macosx64-clang-13:
+    description: "Clang 13 toolchain build"
     attributes:
         local-toolchain: true
     treeherder:
-        symbol: TM(clang-12)
+        symbol: TM(clang-13)
     worker-type: b-linux-large
     worker:
         max-run-time: 3600
     run-on-projects:
         - trunk
     run:
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-12-macosx64.json'
+            - 'build/build-clang/clang-13-macosx64.json'
         resources:
-            - 'build/build-clang/clang-12-macosx64.json'
+            - 'build/build-clang/clang-13-macosx64.json'
         toolchain-alias: macosx64-clang
         toolchain-artifact: public/build/clang.tar.zst
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12-macosx-cross
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13-macosx-cross
             - macosx64-sdk-11.0
-            - wasm32-wasi-compiler-rt-12
+            - wasm32-wasi-compiler-rt-13
 
-macosx64-aarch64-clang-12:
-    description: "Clang 12 toolchain build"
+macosx64-aarch64-clang-13:
+    description: "Clang 13 toolchain build"
     attributes:
         local-toolchain: true
     treeherder:
-        symbol: TM(clang-12-aarch64)
+        symbol: TM(clang-13-aarch64)
     worker-type: b-linux-large
     worker:
         env:
             OSX_ARCH: arm64
         max-run-time: 3600
     run-on-projects:
         - trunk
     run:
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-12-macosx64.json'
+            - 'build/build-clang/clang-13-macosx64.json'
         resources:
-            - 'build/build-clang/clang-12-macosx64.json'
+            - 'build/build-clang/clang-13-macosx64.json'
         toolchain-alias: macosx64-aarch64-clang
         toolchain-artifact: public/build/clang.tar.zst
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12-macosx-cross
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13-macosx-cross
             - macosx64-sdk-11.0
-            - wasm32-wasi-compiler-rt-12
+            - wasm32-wasi-compiler-rt-13
 
-win64-clang-12:
-    description: "Clang-cl 12 toolchain build"
+win64-clang-13:
+    description: "Clang-cl 13 toolchain build"
     attributes:
         local-toolchain: true
     treeherder:
-        symbol: TW64(clang-12)
+        symbol: TW64(clang-13)
     worker-type: b-win2012
     worker:
         env:
             TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/vs2017-15.9.manifest"
         max-run-time: 9000
     run-on-projects:
         - trunk
     run:
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-12-win64.json'
+            - 'build/build-clang/clang-13-win64.json'
         resources:
-            - 'build/build-clang/clang-12-win64.json'
+            - 'build/build-clang/clang-13-win64.json'
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         toolchain-alias: win64-clang
         toolchain-artifact: public/build/clang.tar.zst
         tooltool-downloads: internal
     fetches:
         fetch:
-            - clang-12
+            - clang-13
             - cmake
             - ninja
         toolchain:
-            - wasm32-wasi-compiler-rt-12
+            - wasm32-wasi-compiler-rt-13
 
-win64-clang-12-2stage:
-    description: "Clang-cl 12 toolchain 2-stage quick build"
+win64-clang-13-2stage:
+    description: "Clang-cl 13 toolchain 2-stage quick build"
     treeherder:
-        symbol: TW64(clang-12-2stage)
+        symbol: TW64(clang-13-2stage)
     worker-type: b-win2012
     worker:
         env:
             TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/vs2017-15.9.manifest"
     run:
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-12-win64-2stage.json'
+            - 'build/build-clang/clang-13-win64-2stage.json'
         resources:
-            - 'build/build-clang/clang-12-win64-2stage.json'
+            - 'build/build-clang/clang-13-win64-2stage.json'
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         toolchain-alias: win64-clang-2stage
         toolchain-artifact: public/build/clang.tar.zst
         tooltool-downloads: internal
     fetches:
         fetch:
-            - clang-12
+            - clang-13
             - cmake
             - ninja
--- a/taskcluster/ci/toolchain/compiler-rt.yml
+++ b/taskcluster/ci/toolchain/compiler-rt.yml
@@ -6,143 +6,143 @@ job-defaults:
     worker-type: b-linux
     worker:
         max-run-time: 1800
     run:
         using: toolchain-script
         script: build-compiler-rt.sh
         toolchain-artifact: public/build/compiler-rt.tar.zst
 
-android-aarch64-compiler-rt-12:
-    description: "android aarch64 Compiler-rt for Clang 12 toolchain build"
+android-aarch64-compiler-rt-13:
+    description: "android aarch64 Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TA(aarch64-crt-12)
+        symbol: TA(aarch64-crt-13)
     run:
         arguments:
             - aarch64-linux-android
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
         resources:
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-android-ndk-linux-repack
 
-android-arm-compiler-rt-12:
-    description: "android arm Compiler-rt for Clang 12 toolchain build"
+android-arm-compiler-rt-13:
+    description: "android arm Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TA(arm-crt-12)
+        symbol: TA(arm-crt-13)
     run:
         arguments:
             - armv7-linux-android
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
         resources:
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-android-ndk-linux-repack
 
-android-x86-compiler-rt-12:
-    description: "android x86 Compiler-rt for Clang 12 toolchain build"
+android-x86-compiler-rt-13:
+    description: "android x86 Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TA(x86-crt-12)
+        symbol: TA(x86-crt-13)
     run:
         arguments:
             - i686-linux-android
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
         resources:
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-android-ndk-linux-repack
 
-android-x64-compiler-rt-12:
-    description: "android x64 Compiler-rt for Clang 12 toolchain build"
+android-x64-compiler-rt-13:
+    description: "android x64 Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TA(x64-crt-12)
+        symbol: TA(x64-crt-13)
     run:
         arguments:
             - x86_64-linux-android
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
         resources:
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-android-ndk-linux-repack
 
-linux64-aarch64-compiler-rt-12:
-    description: "Linux aarch64 Compiler-rt for Clang 12 toolchain build"
+linux64-aarch64-compiler-rt-13:
+    description: "Linux aarch64 Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TL(aarch64-crt-12)
+        symbol: TL(aarch64-crt-13)
     run:
         arguments:
             - aarch64-unknown-linux-gnu
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
         resources:
             - 'build/build-clang/find_symbolizer_linux_clang_10.patch'
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
             - linux64-binutils
-            - linux64-clang-12
+            - linux64-clang-13
             - sysroot-aarch64-linux-gnu
 
-macosx64-x64-compiler-rt-12:
-    description: "macOS x64 Compiler-rt for Clang 12 toolchain build"
+macosx64-x64-compiler-rt-13:
+    description: "macOS x64 Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TM(x64-crt-12)
+        symbol: TM(x64-crt-13)
     run:
         arguments:
             - x86_64-apple-darwin
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - macosx64-sdk-11.0
 
-macosx64-aarch64-compiler-rt-12:
-    description: "macOS aarch64 Compiler-rt for Clang 12 toolchain build"
+macosx64-aarch64-compiler-rt-13:
+    description: "macOS aarch64 Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TM(aarch64-crt-12)
+        symbol: TM(aarch64-crt-13)
     run:
         arguments:
             - aarch64-apple-darwin
     fetches:
         fetch:
-            - clang-12
+            - clang-13
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - macosx64-sdk-11.0
 
-wasm32-wasi-compiler-rt-12:
-    description: "wasm32-wasi Compiler-rt for Clang 12 toolchain build"
+wasm32-wasi-compiler-rt-13:
+    description: "wasm32-wasi Compiler-rt for Clang 13 toolchain build"
     treeherder:
-        symbol: TL(wasi-crt-12)
+        symbol: TL(wasi-crt-13)
     worker-type: b-linux-xlarge
     run:
         script: build-compiler-rt-wasi.sh
         toolchain-alias: wasm32-wasi-compiler-rt
     fetches:
         fetch:
-            - clang-12
+            - clang-13
             - wasi-sdk
 
 wasm32-wasi-compiler-rt-10:
     description: "wasm32-wasi Compiler-rt for Clang 10 toolchain build"
     treeherder:
         symbol: TL(wasi-crt-10)
     worker-type: b-linux-xlarge
     run:
--- a/taskcluster/ci/toolchain/dump-syms.yml
+++ b/taskcluster/ci/toolchain/dump-syms.yml
@@ -19,46 +19,46 @@ linux64-dump_syms:
     treeherder:
         symbol: TL(dump_syms)
     worker-type: b-linux
     run:
         toolchain-artifact: public/build/dump_syms.tar.zst
     fetches:
         toolchain:
             - linux64-binutils
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-rust-1.55
             - sysroot-x86_64-linux-gnu
 
 macosx64-dump_syms:
     treeherder:
         symbol: TM(dump_syms)
     worker-type: b-linux
     run:
         arguments: ['x86_64-apple-darwin']
         toolchain-artifact: public/build/dump_syms.tar.zst
     fetches:
         toolchain:
             - linux64-rust-macos-1.55
-            - linux64-clang-12
-            - linux64-cctools-port-clang-12
+            - linux64-clang-13
+            - linux64-cctools-port-clang-13
             - macosx64-sdk-11.0
 
 macosx64-aarch64-dump_syms:
     treeherder:
         symbol: TM(dump_syms-arm64)
     worker-type: b-linux
     run:
         arguments: ['aarch64-apple-darwin']
         toolchain-artifact: public/build/dump_syms.tar.zst
     fetches:
         toolchain:
             - linux64-rust-macos-1.55
-            - linux64-clang-12
-            - linux64-cctools-port-clang-12
+            - linux64-clang-13
+            - linux64-cctools-port-clang-13
             - macosx64-sdk-11.0
 
 win64-dump_syms:
     treeherder:
         symbol: TW64(dump_syms)
     worker-type: b-win2012
     worker:
         env:
--- a/taskcluster/ci/toolchain/fix-stacks.yml
+++ b/taskcluster/ci/toolchain/fix-stacks.yml
@@ -21,43 +21,43 @@ linux64-fix-stacks:
     treeherder:
         symbol: TL(fix-stacks)
     run:
         arguments: ['x86_64-unknown-linux-gnu']
         toolchain-artifact: public/build/fix-stacks.tar.zst
     fetches:
         toolchain:
             - linux64-binutils
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-rust-1.47
             - sysroot-x86_64-linux-gnu
 
 macosx64-fix-stacks:
     treeherder:
         symbol: TM(fix-stacks)
     run:
         arguments: ['x86_64-apple-darwin']
         toolchain-artifact: public/build/fix-stacks.tar.zst
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - linux64-rust-macos-1.47
             - macosx64-sdk-11.0
 
 macosx64-aarch64-fix-stacks:
     treeherder:
         symbol: TM(fix-stacks-arm64)
     run:
         arguments: ['aarch64-apple-darwin']
         toolchain-artifact: public/build/fix-stacks.tar.zst
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - linux64-rust-macos-1.49
             - macosx64-sdk-11.0
 
 win32-fix-stacks:
     treeherder:
         symbol: TW32(fix-stacks)
     worker:
         env:
@@ -65,11 +65,11 @@ win32-fix-stacks:
     run:
         arguments: ['i686-pc-windows-msvc']
         toolchain-artifact: public/build/fix-stacks.tar.zst
         resources:
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         tooltool-downloads: internal
     fetches:
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-liblowercase
             - linux64-rust-windows-1.47
--- a/taskcluster/ci/toolchain/gn.yml
+++ b/taskcluster/ci/toolchain/gn.yml
@@ -25,18 +25,18 @@ linux64-gn:
 
 macosx64-gn:
     treeherder:
         symbol: TM(gn)
     run:
         script: build-gn-macosx.sh
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - macosx64-sdk-11.0
 
 win32-gn:
     treeherder:
         symbol: TW64(gn)
     worker-type: b-win2012
     worker:
         max-run-time: 3600
--- a/taskcluster/ci/toolchain/minidump_stackwalk.yml
+++ b/taskcluster/ci/toolchain/minidump_stackwalk.yml
@@ -23,42 +23,42 @@ job-defaults:
     run-on-projects:
         - trunk
 
 linux64-minidump-stackwalk:
     treeherder:
         symbol: TL(stackwalk)
     fetches:
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-binutils
             - linux64-rust-1.53
             - linux64-toolchain-sysroot
 
 macosx64-minidump-stackwalk:
     treeherder:
         symbol: TM(stackwalk)
     run:
         arguments: ['macosx64']
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - linux64-rust-macos-1.53
             - macosx64-sdk-11.0
 
 macosx64-aarch64-minidump-stackwalk:
     treeherder:
         symbol: TM(stackwalk-arm64)
     run:
         arguments: ['macosx64-aarch64']
     fetches:
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13
             - linux64-rust-macos-1.53
             - macosx64-sdk-11.0
 
 win32-minidump-stackwalk:
     treeherder:
         symbol: TW32(stackwalk)
     run:
         arguments: ['mingw32']
@@ -71,11 +71,11 @@ linux64-breakpad-injector:
     description: "breakpad injector toolchain build"
     run:
         script: build-breakpad-injector.sh
         toolchain-artifact: public/build/injector.tar.zst
     treeherder:
         symbol: TL(injector)
     fetches:
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-binutils
             - linux64-toolchain-sysroot
--- a/taskcluster/ci/toolchain/misc.yml
+++ b/taskcluster/ci/toolchain/misc.yml
@@ -47,30 +47,30 @@ linux64-hfsplus:
         script: build-hfsplus-linux.sh
         resources:
             - 'build/unix/build-hfsplus/build-hfsplus.sh'
         toolchain-artifact: public/build/hfsplus-tools.tar.zst
     fetches:
         fetch:
             - hfsplus-tools
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
 
 linux64-libdmg:
     description: "libdmg-hfsplus toolchain build"
     treeherder:
         symbol: TL(libdmg-hfs+)
     run:
         script: build-libdmg-hfsplus.sh
         toolchain-artifact: public/build/dmg.tar.zst
     fetches:
         fetch:
             - libdmg-hfsplus
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-toolchain-sysroot
 
 linux64-mar-tools:
     description: "mar-tools toolchain build"
     treeherder:
         symbol: TL(mar-tools)
     fetches:
         toolchain:
@@ -288,10 +288,10 @@ nsis:
     run:
         script: build-nsis.sh
         toolchain-artifact: public/build/nsis.tar.zst
     fetches:
         fetch:
             - nsis-3.07
             - nsis-3.07-win
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - sysroot-x86_64-linux-gnu
--- a/taskcluster/ci/toolchain/nasm.yml
+++ b/taskcluster/ci/toolchain/nasm.yml
@@ -33,58 +33,58 @@ macosx64-nasm:
         symbol: TM(nasm)
     run:
         script: build-nasm.sh
         arguments: ['macosx64']
     fetches:
         fetch:
             - nasm-2.15.05
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12-macosx-cross
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13-macosx-cross
             - macosx64-sdk-11.0
 
 macosx64-aarch64-nasm:
     description: "nasm macosx64 build"
     attributes:
         local-toolchain: true
     treeherder:
         symbol: TM(nasm-aarch64)
     run:
         script: build-nasm.sh
         arguments: ['macosx64-aarch64']
     fetches:
         fetch:
             - nasm-2.14.02
         toolchain:
-            - linux64-cctools-port-clang-12
-            - linux64-clang-12-macosx-cross
+            - linux64-cctools-port-clang-13
+            - linux64-clang-13-macosx-cross
             - macosx64-sdk-11.0
 
 linux64-nasm:
     description: "nasm linux64 build"
     attributes:
         local-toolchain: true
     treeherder:
         symbol: TL(nasm)
     run:
         script: build-nasm.sh
         arguments: ['linux64']
     fetches:
         fetch:
             - nasm-2.15.05
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - sysroot-x86_64-linux-gnu
 
 linux64-nasm-2.14.02:
     description: "nasm linux64 minimum supported version build"
     treeherder:
         symbol: TL(nasm-2.14.02)
     run:
         script: build-nasm.sh
         arguments: ['linux64']
     fetches:
         fetch:
             - nasm-2.14.02
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
             - sysroot-x86_64-linux-gnu
--- a/taskcluster/ci/toolchain/sccache.yml
+++ b/taskcluster/ci/toolchain/sccache.yml
@@ -22,50 +22,50 @@ linux64-sccache:
     worker-type: b-linux
     worker:
         max-run-time: 1800
     run:
         toolchain-artifact: public/build/sccache.tar.zst
     fetches:
         toolchain:
             - linux64-rust-1.47
-            - linux64-clang-12
+            - linux64-clang-13
             - linux64-binutils
             - sysroot-x86_64-linux-gnu
 
 macosx64-sccache:
     treeherder:
         symbol: TM(sccache)
     worker-type: b-linux
     worker:
         max-run-time: 1800
     run:
         arguments: ['x86_64-apple-darwin']
         toolchain-artifact: public/build/sccache.tar.zst
     fetches:
         toolchain:
             - linux64-rust-macos-1.47
-            - linux64-clang-12
-            - linux64-cctools-port-clang-12
+            - linux64-clang-13
+            - linux64-cctools-port-clang-13
             - macosx64-sdk-11.0
 
 macosx64-aarch64-sccache:
     treeherder:
         symbol: TM(sccache-aarch64)
     worker-type: b-linux
     worker:
         max-run-time: 1800
     run:
         arguments: ['aarch64-apple-darwin']
         toolchain-artifact: public/build/sccache.tar.zst
     fetches:
         toolchain:
             - linux64-rust-macos-1.49
-            - linux64-clang-12
-            - linux64-cctools-port-clang-12
+            - linux64-clang-13
+            - linux64-cctools-port-clang-13
             - macosx64-sdk-11.0
 
 win64-sccache:
     treeherder:
         symbol: TW64(sccache)
     worker-type: b-win2012
     worker:
         max-run-time: 3600
--- a/taskcluster/ci/toolchain/sysroot.yml
+++ b/taskcluster/ci/toolchain/sysroot.yml
@@ -70,20 +70,20 @@ sysroot-wasm32-wasi:
     run-on-projects: [trunk]
     treeherder:
         symbol: TL(sysroot-wasi)
     run:
         script: build-sysroot-wasi.sh
         toolchain-artifact: public/build/sysroot-wasm32-wasi.tar.zst
     fetches:
         fetch:
-            - clang-12
+            - clang-13
             - wasi-sdk
         toolchain:
-            - linux64-clang-12
+            - linux64-clang-13
 
 sysroot-aarch64-linux-gnu:
     description: "Sysroot for linux64 aarch64 builds"
     attributes:
         local-toolchain: true
     run-on-projects: [trunk]
     treeherder:
         symbol: TL(sysroot-aarch64)
--- a/taskcluster/ci/webrender/kind.yml
+++ b/taskcluster/ci/webrender/kind.yml
@@ -102,25 +102,25 @@ jobs:
             artifacts:
                 - type: file
                   name: public/build/wrench-macos.tar.bz2
                   path: /builds/worker/artifacts/wrench-macos.tar.bz2
                 - type: file
                   name: public/build/wrench-macos-headless.tar.bz2
                   path: /builds/worker/artifacts/wrench-macos-headless.tar.bz2
         dependencies:
-            macosx64-clang-12: toolchain-macosx64-clang-12
+            macosx64-clang-13: toolchain-macosx64-clang-13
         fetches:
             toolchain:
                 - linux64-rust-macos
                 - linux64-cctools-port
-                - linux64-clang-12-macosx-cross
+                - linux64-clang-13-macosx-cross
                 - macosx64-sdk-10.12
                 - wrench-deps
-            macosx64-clang-12:
+            macosx64-clang-13:
                 - artifact: clang.tar.zst
                   dest: clang-mac
         run:
             using: run-task
             command: '$HOME/checkouts/gecko/taskcluster/scripts/misc/wrench-macos-build.sh'
         treeherder:
             platform: osx-cross/opt
             symbol: WR(B)
--- a/taskcluster/scripts/misc/build-clang-mingw.sh
+++ b/taskcluster/scripts/misc/build-clang-mingw.sh
@@ -144,74 +144,17 @@ EOF
 
 build_libcxx() {
   # Below, we specify -g -gcodeview to build static libraries with debug information.
   # Because we're not distributing these builds, this is fine. If one were to distribute
   # the builds, perhaps one would want to make those flags conditional or investigation
   # other options.
   DEBUG_FLAGS="-g -gcodeview"
 
-  mkdir libunwind
-  pushd libunwind
-  cmake \
-      -DCMAKE_BUILD_TYPE=Release \
-      -DCMAKE_INSTALL_PREFIX=$CROSS_PREFIX_DIR \
-      -DCMAKE_C_COMPILER=$CC \
-      -DCMAKE_CXX_COMPILER=$CXX \
-      -DCMAKE_CROSSCOMPILING=TRUE \
-      -DCMAKE_SYSROOT=$CROSS_PREFIX_DIR \
-      -DCMAKE_SYSTEM_NAME=Windows \
-      -DCMAKE_C_COMPILER_WORKS=TRUE \
-      -DCMAKE_CXX_COMPILER_WORKS=TRUE \
-      -DLLVM_COMPILER_CHECKED=TRUE \
-      -DCMAKE_AR=$INSTALL_DIR/bin/llvm-ar \
-      -DCMAKE_RANLIB=$INSTALL_DIR/bin/llvm-ranlib \
-      -DLLVM_NO_OLD_LIBSTDCXX=TRUE \
-      -DCXX_SUPPORTS_CXX11=TRUE \
-      -DCXX_SUPPORTS_CXX_STD=TRUE \
-      -DLIBUNWIND_USE_COMPILER_RT=TRUE \
-      -DLIBUNWIND_ENABLE_THREADS=TRUE \
-      -DLIBUNWIND_ENABLE_SHARED=FALSE \
-      -DLIBUNWIND_ENABLE_CROSS_UNWINDING=FALSE \
-      -DCMAKE_CXX_FLAGS="${DEBUG_FLAGS} -Wno-dll-attribute-on-redeclaration -nostdinc++ -I$TOOLCHAIN_DIR/libcxx/include -DPSAPI_VERSION=2" \
-      -DCMAKE_C_FLAGS="-Wno-dll-attribute-on-redeclaration" \
-      $MOZ_FETCHES_DIR/libunwind
-  make $make_flags
-  make $make_flags install
-  popd
-
-  mkdir libcxxabi
-  pushd libcxxabi
-  cmake \
-      -DCMAKE_BUILD_TYPE=Release \
-      -DCMAKE_INSTALL_PREFIX=$CROSS_PREFIX_DIR \
-      -DCMAKE_C_COMPILER=$CC \
-      -DCMAKE_CXX_COMPILER=$CXX \
-      -DCMAKE_CROSSCOMPILING=TRUE \
-      -DCMAKE_SYSTEM_NAME=Windows \
-      -DCMAKE_C_COMPILER_WORKS=TRUE \
-      -DCMAKE_CXX_COMPILER_WORKS=TRUE \
-      -DCMAKE_SYSROOT=$CROSS_PREFIX_DIR \
-      -DLLVM_COMPILER_CHECKED=TRUE \
-      -DCMAKE_AR=$INSTALL_DIR/bin/llvm-ar \
-      -DCMAKE_RANLIB=$INSTALL_DIR/bin/llvm-ranlib \
-      -DLIBCXXABI_USE_COMPILER_RT=ON \
-      -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
-      -DLIBCXXABI_ENABLE_THREADS=ON \
-      -DLIBCXXABI_TARGET_TRIPLE=$machine-w64-mingw32 \
-      -DLIBCXXABI_ENABLE_SHARED=OFF \
-      -DLIBCXXABI_LIBCXX_INCLUDES=$TOOLCHAIN_DIR/libcxx/include \
-      -DLLVM_NO_OLD_LIBSTDCXX=TRUE \
-      -DCXX_SUPPORTS_CXX11=TRUE \
-      -DCXX_SUPPORTS_CXX_STD=TRUE \
-      -DCMAKE_CXX_FLAGS="${DEBUG_FLAGS} -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_HAS_THREAD_API_WIN32" \
-      $TOOLCHAIN_DIR/libcxxabi
-  make $make_flags VERBOSE=1
-  popd
-
+  # First configure libcxx
   mkdir libcxx
   pushd libcxx
   cmake \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_INSTALL_PREFIX=$CROSS_PREFIX_DIR \
       -DCMAKE_C_COMPILER=$CC \
       -DCMAKE_CXX_COMPILER=$CXX \
       -DCMAKE_CROSSCOMPILING=TRUE \
@@ -233,16 +176,77 @@ build_libcxx() {
       -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
       -DLIBCXX_ENABLE_FILESYSTEM=OFF \
       -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
       -DLIBCXX_CXX_ABI=libcxxabi \
       -DLIBCXX_CXX_ABI_INCLUDE_PATHS=$TOOLCHAIN_DIR/libcxxabi/include \
       -DLIBCXX_CXX_ABI_LIBRARY_PATH=../libcxxabi/lib \
       -DCMAKE_CXX_FLAGS="${DEBUG_FLAGS} -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \
       $TOOLCHAIN_DIR/libcxx
+  popd
+
+  mkdir libunwind
+  pushd libunwind
+  cmake \
+      -DCMAKE_BUILD_TYPE=Release \
+      -DCMAKE_INSTALL_PREFIX=$CROSS_PREFIX_DIR \
+      -DCMAKE_C_COMPILER=$CC \
+      -DCMAKE_CXX_COMPILER=$CXX \
+      -DCMAKE_CROSSCOMPILING=TRUE \
+      -DCMAKE_SYSROOT=$CROSS_PREFIX_DIR \
+      -DCMAKE_SYSTEM_NAME=Windows \
+      -DCMAKE_C_COMPILER_WORKS=TRUE \
+      -DCMAKE_CXX_COMPILER_WORKS=TRUE \
+      -DLLVM_COMPILER_CHECKED=TRUE \
+      -DCMAKE_AR=$INSTALL_DIR/bin/llvm-ar \
+      -DCMAKE_RANLIB=$INSTALL_DIR/bin/llvm-ranlib \
+      -DLLVM_NO_OLD_LIBSTDCXX=TRUE \
+      -DCXX_SUPPORTS_CXX11=TRUE \
+      -DCXX_SUPPORTS_CXX_STD=TRUE \
+      -DLIBUNWIND_USE_COMPILER_RT=TRUE \
+      -DLIBUNWIND_ENABLE_THREADS=TRUE \
+      -DLIBUNWIND_ENABLE_SHARED=FALSE \
+      -DLIBUNWIND_ENABLE_CROSS_UNWINDING=FALSE \
+      -DCMAKE_CXX_FLAGS="${DEBUG_FLAGS} -Wno-dll-attribute-on-redeclaration -nostdinc++ -I$TOOLCHAIN_DIR/build/libcxx/include/c++/v1 -DPSAPI_VERSION=2" \
+      -DCMAKE_C_FLAGS="-Wno-dll-attribute-on-redeclaration" \
+      $MOZ_FETCHES_DIR/libunwind
+  make $make_flags
+  make $make_flags install
+  popd
+
+  mkdir libcxxabi
+  pushd libcxxabi
+  cmake \
+      -DCMAKE_BUILD_TYPE=Release \
+      -DCMAKE_INSTALL_PREFIX=$CROSS_PREFIX_DIR \
+      -DCMAKE_C_COMPILER=$CC \
+      -DCMAKE_CXX_COMPILER=$CXX \
+      -DCMAKE_CROSSCOMPILING=TRUE \
+      -DCMAKE_SYSTEM_NAME=Windows \
+      -DCMAKE_C_COMPILER_WORKS=TRUE \
+      -DCMAKE_CXX_COMPILER_WORKS=TRUE \
+      -DCMAKE_SYSROOT=$CROSS_PREFIX_DIR \
+      -DLLVM_COMPILER_CHECKED=TRUE \
+      -DCMAKE_AR=$INSTALL_DIR/bin/llvm-ar \
+      -DCMAKE_RANLIB=$INSTALL_DIR/bin/llvm-ranlib \
+      -DLIBCXXABI_USE_COMPILER_RT=ON \
+      -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
+      -DLIBCXXABI_ENABLE_THREADS=ON \
+      -DLIBCXXABI_TARGET_TRIPLE=$machine-w64-mingw32 \
+      -DLIBCXXABI_ENABLE_SHARED=OFF \
+      -DLIBCXXABI_LIBCXX_INCLUDES=$TOOLCHAIN_DIR/libcxx/include/ \
+      -DLLVM_NO_OLD_LIBSTDCXX=TRUE \
+      -DCXX_SUPPORTS_CXX11=TRUE \
+      -DCXX_SUPPORTS_CXX_STD=TRUE \
+      -DCMAKE_CXX_FLAGS="${DEBUG_FLAGS} -I$TOOLCHAIN_DIR/build/libcxx/include/c++/v1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_HAS_THREAD_API_WIN32" \
+      $TOOLCHAIN_DIR/libcxxabi
+  make $make_flags VERBOSE=1
+  popd
+
+  pushd libcxx
   make $make_flags VERBOSE=1
   make $make_flags install
 
   # libc++.a depends on libunwind.a. Whild linker will automatically link
   # to libc++.a in C++ mode, it won't pick libunwind.a, requiring caller
   # to explicitly pass -lunwind. Wo work around that, we merge libunwind.a
   # into libc++.a.
   merge_libs $CROSS_PREFIX_DIR/lib/libc++.a $CROSS_PREFIX_DIR/lib/libunwind.a
--- a/taskcluster/scripts/misc/build-compiler-rt.sh
+++ b/taskcluster/scripts/misc/build-compiler-rt.sh
@@ -90,16 +90,17 @@ case "$target" in
     -DCMAKE_ASM_FLAGS='$cflags'
     -DCMAKE_CXX_FLAGS='-fPIC -Qunused-arguments $cflags'
     -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=lld $exe_linker_flags'
     -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld
     -DANDROID=1
     -DANDROID_NATIVE_API_LEVEL=$api_level
     -DSANITIZER_ALLOW_CXXABI=OFF
     -DCOMPILER_RT_BUILD_LIBFUZZER=OFF
+    -DCOMPILER_RT_BUILD_ORC=OFF
   "
   ;;
 aarch64-unknown-linux-gnu)
   libdir=lib/linux
   EXTRA_CMAKE_FLAGS="
     -DCMAKE_SYSROOT=$MOZ_FETCHES_DIR/sysroot-aarch64-linux-gnu
     -DCMAKE_LINKER=$MOZ_FETCHES_DIR/clang/bin/ld.lld
   "
--- a/taskcluster/scripts/misc/repack-clang-linux-win-cross.sh
+++ b/taskcluster/scripts/misc/repack-clang-linux-win-cross.sh
@@ -4,15 +4,16 @@ set -x -e -v
 # This script is to repack a linux clang with Windows clang-cl.exe and compiler runtime.
 
 cd $MOZ_FETCHES_DIR
 
 # We already have the Linux clang extracted in $MOZ_FETCHES_DIR/clang by fetch-content
 # We have a non-extracted clang-cl/clang.tar.zst for Windows clang-cl that we need to extract
 # files from.
 
-$GECKO_PATH/taskcluster/scripts/misc/zstdpy -d clang-cl/clang.tar.zst | tar -x --wildcards clang/lib/clang/*/lib/windows clang/bin/clang-cl.exe clang/bin/llvm-symbolizer.exe
+$GECKO_PATH/taskcluster/scripts/misc/zstdpy -d clang-cl/clang.tar.zst | tar -x --wildcards clang/lib/clang/*/lib/windows clang/bin/clang.exe clang/bin/llvm-symbolizer.exe
+mv clang/bin/clang.exe clang/bin/clang-cl.exe
 chmod +x clang/bin/clang-cl.exe
 tar caf clang.tar.zst clang
 
 # Put a tarball in the artifacts dir
 mkdir -p $UPLOAD_DIR
 cp clang.tar.zst $UPLOAD_DIR