Backed out 2 changesets (bug 1573211) as requested by dmajor on irc. CLOSED TREE
authorBrindusan Cristian <cbrindusan@mozilla.com>
Thu, 26 Sep 2019 20:12:51 +0300
changeset 495162 a3d9784a3b3326edc67c95699227b5fa684183d9
parent 495161 13d8012af41b777b5461397598ba7f3d6b8c0d71
child 495163 4af5b90d68a35f2f264bdb3e636cfb7c588ff091
push id96480
push usercbrindusan@mozilla.com
push dateThu, 26 Sep 2019 17:15:31 +0000
treeherderautoland@a3d9784a3b33 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1573211
milestone71.0a1
backs out587463567434d7422816503be6cb13e9cc42d005
de0fe40466cb3a451ba0680179cd6373d4d94baf
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
Backed out 2 changesets (bug 1573211) as requested by dmajor on irc. CLOSED TREE Backed out changeset 587463567434 (bug 1573211) Backed out changeset de0fe40466cb (bug 1573211)
build/build-clang/clang-8-android.json
build/build-clang/clang-8-linux64-aarch64-cross.json
build/build-clang/clang-8-linux64.json
build/build-clang/clang-8-macosx64.json
build/build-clang/clang-android.json
build/build-clang/clang-linux64-aarch64-cross.json
build/build-clang/clang-linux64.json
build/build-clang/clang-macosx64.json
build/build-clang/clang-tidy-8.patch
build/build-clang/clang-tidy-linux64.json
build/build-clang/clang-tidy-macosx64.json
build/build-clang/clang-tidy-win64.json
build/build-clang/clang-win64.json
build/build-clang/compiler-rt-no-codesign.patch
build/build-clang/downgrade-mangling-error.patch
build/build-clang/r357725-asan-vs2019.patch
build/build-clang/r372020-r372182-profiler-linkage.patch
build/build-clang/rename_gcov_flush.patch
build/build-clang/revert-r355311.patch
build/build-clang/revert-r359260-due-to-bug41817.patch
build/build-clang/revert-r362047-and-r362065.patch
build/build-clang/unpoison-thread-stacks.patch
build/build-clang/workaround-issue38586.patch
taskcluster/ci/build/linux.yml
taskcluster/ci/fetch/toolchains.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/dist-toolchains.yml
taskcluster/ci/toolchain/gn.yml
taskcluster/ci/toolchain/minidump_stackwalk.yml
taskcluster/ci/toolchain/misc.yml
taskcluster/ci/toolchain/sccache.yml
taskcluster/scripts/misc/build-clang-8-linux-macosx-cross.sh
taskcluster/scripts/misc/build-clang-linux-macosx-cross.sh
tools/clang-tidy/config.yaml
tools/clang-tidy/test/bugprone-string-constructor.json
rename from build/build-clang/clang-android.json
rename to build/build-clang/clang-8-android.json
--- a/build/build-clang/clang-android.json
+++ b/build/build-clang/clang-8-android.json
@@ -44,12 +44,11 @@
           "{MOZ_FETCHES_DIR}/android-ndk/sysroot/usr/include"
         ],
         "api_level": 21
       }
     },
     "patches": [
       "static-llvm-symbolizer.patch",
       "find_symbolizer_linux.patch",
-      "rename_gcov_flush.patch",
-      "revert-r362047-and-r362065.patch"
+      "rename_gcov_flush.patch"
     ]
 }
rename from build/build-clang/clang-linux64-aarch64-cross.json
rename to build/build-clang/clang-8-linux64-aarch64-cross.json
rename from build/build-clang/clang-linux64.json
rename to build/build-clang/clang-8-linux64.json
rename from build/build-clang/clang-macosx64.json
rename to build/build-clang/clang-8-macosx64.json
new file mode 100644
--- /dev/null
+++ b/build/build-clang/clang-tidy-8.patch
@@ -0,0 +1,10 @@
+--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py	2019-03-27 15:12:48.000000000 +0200
++++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py	2019-03-27 15:12:39.000000000 +0200
+@@ -169,6 +169,7 @@
+     with lock:
+       sys.stdout.write(' '.join(invocation) + '\n' + output.decode('utf-8') + '\n')
+       if len(err) > 0:
++        sys.stdout.flush()
+         sys.stderr.write(err.decode('utf-8') + '\n')
+     queue.task_done()
+ 
--- a/build/build-clang/clang-tidy-linux64.json
+++ b/build/build-clang/clang-tidy-linux64.json
@@ -5,10 +5,11 @@
     "assertions": false,
     "build_clang_tidy": true,
     "python_path": "/usr/bin/python2.7",
     "gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
     "cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
     "cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
     "as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
     "patches": [
+      "clang-tidy-8.patch"
     ]
 }
--- a/build/build-clang/clang-tidy-macosx64.json
+++ b/build/build-clang/clang-tidy-macosx64.json
@@ -10,11 +10,12 @@
     "cc": "{MOZ_FETCHES_DIR}/clang/bin/clang",
     "cxx": "{MOZ_FETCHES_DIR}/clang/bin/clang++",
     "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-8.patch",
       "compiler-rt-no-codesign.patch"
     ]
 }
--- a/build/build-clang/clang-tidy-win64.json
+++ b/build/build-clang/clang-tidy-win64.json
@@ -4,10 +4,11 @@
     "build_type": "Release",
     "assertions": false,
     "build_clang_tidy": true,
     "python_path": "c:/mozilla-build/python/python.exe",
     "cc": "cl.exe",
     "cxx": "cl.exe",
     "ml": "ml64.exe",
     "patches": [
+      "clang-tidy-8.patch"
     ]
 }
--- a/build/build-clang/clang-win64.json
+++ b/build/build-clang/clang-win64.json
@@ -3,15 +3,16 @@
     "build_libcxx": false,
     "build_type": "Release",
     "assertions": false,
     "python_path": "c:/mozilla-build/python/python.exe",
     "cc": "cl.exe",
     "cxx": "cl.exe",
     "ml": "ml64.exe",
     "patches": [
+      "workaround-issue38586.patch",
       "unpoison-thread-stacks.patch",
       "downgrade-mangling-error.patch",
-      "r372020-r372182-profiler-linkage.patch",
-      "revert-r359260-due-to-bug41817.patch",
-      "loosen-msvc-detection.patch"
+      "r357725-asan-vs2019.patch",
+      "loosen-msvc-detection.patch",
+      "revert-r355311.patch"
     ]
 }
--- a/build/build-clang/compiler-rt-no-codesign.patch
+++ b/build/build-clang/compiler-rt-no-codesign.patch
@@ -1,21 +1,21 @@
 Disable codesign for macosx cross-compile toolchain. Codesign only works on OSX.
 
 Index: cmake/Modules/AddCompilerRT.cmake
 ===================================================================
---- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
-+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
-@@ -321,14 +321,6 @@
+--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake	(revision 342374)
++++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake	(working copy)
+@@ -290,14 +290,6 @@
          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}
 -        )
 -      endif()
      endif()
- 
-     set(parent_target_arg)
+     install(TARGETS ${libname}
+       ARCHIVE DESTINATION ${install_dir_${libname}}
--- a/build/build-clang/downgrade-mangling-error.patch
+++ b/build/build-clang/downgrade-mangling-error.patch
@@ -3,21 +3,21 @@ This codepath is exercised by MozsearchI
 indexer) when indexing on Windows. We can do without having the
 unimplemented bits for now as long the compiler doesn't fail the
 build. See also https://bugs.llvm.org/show_bug.cgi?id=39294
 
 diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
 index b483187394..fb01348ebb 100644
 --- a/clang/lib/AST/ItaniumMangle.cpp
 +++ b/clang/lib/AST/ItaniumMangle.cpp
-@@ -3623,20 +3623,21 @@ recurse:
+@@ -3557,20 +3557,21 @@ recurse:
+   case Expr::AsTypeExprClass:
+   case Expr::PseudoObjectExprClass:
    case Expr::AtomicExprClass:
-   case Expr::SourceLocExprClass:
    case Expr::FixedPointLiteralClass:
-   case Expr::BuiltinBitCastExprClass:
    {
      if (!NullOut) {
        // As bad as this diagnostic is, it's better than crashing.
        DiagnosticsEngine &Diags = Context.getDiags();
 -      unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
 +      unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Remark,
                                         "cannot yet mangle expression type %0");
        Diags.Report(E->getExprLoc(), DiagID)
new file mode 100644
--- /dev/null
+++ b/build/build-clang/r357725-asan-vs2019.patch
@@ -0,0 +1,32 @@
+Merge LLVM r357725 to allow ASan builds to run on machines with the VS2019 CRT.
+
+---
+
+[winasan] Fix strrchr interception with vs2019 CRT
+
+strrchr in vs2019 CRT begins with unrecognized instructions.
+
+VCRUNTIME140!strrchr:
+4533c9 xor r9d, r9d
+4c8bc1 mov r8, rcx
+
+Patch by Christopher Reid!
+
+Differential Revision: https://reviews.llvm.org/D60217
+
+===================================================================
+--- a/compiler-rt/lib/interception/interception_win.cc	(revision 365039)
++++ b/compiler-rt/lib/interception/interception_win.cc	(working copy)
+@@ -513,10 +513,12 @@
+     case 0xc0854d:    // 4d 85 c0 : test r8, r8
+     case 0xc2b60f:    // 0f b6 c2 : movzx eax, dl
+     case 0xc03345:    // 45 33 c0 : xor r8d, r8d
++    case 0xc93345:    // 45 33 c9 : xor r9d, r9d
+     case 0xdb3345:    // 45 33 DB : xor r11d, r11d
+     case 0xd98b4c:    // 4c 8b d9 : mov r11, rcx
+     case 0xd28b4c:    // 4c 8b d2 : mov r10, rdx
+     case 0xc98b4c:    // 4C 8B C9 : mov r9, rcx
++    case 0xc18b4c:    // 4C 8B C1 : mov r8, rcx
+     case 0xd2b60f:    // 0f b6 d2 : movzx edx, dl
+     case 0xca2b48:    // 48 2b ca : sub rcx, rdx
+     case 0x10b70f:    // 0f b7 10 : movzx edx, WORD PTR [rax]
deleted file mode 100644
--- a/build/build-clang/r372020-r372182-profiler-linkage.patch
+++ /dev/null
@@ -1,130 +0,0 @@
---- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
-+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
-@@ -731,9 +731,8 @@
-     PD = It->second;
-   }
- 
--  // Match the linkage and visibility of the name global, except on COFF, where
--  // the linkage must be local and consequentially the visibility must be
--  // default.
-+  // Match the linkage and visibility of the name global. COFF supports using
-+  // comdats with internal symbols, so do that if we can.
-   Function *Fn = Inc->getParent()->getParent();
-   GlobalValue::LinkageTypes Linkage = NamePtr->getLinkage();
-   GlobalValue::VisibilityTypes Visibility = NamePtr->getVisibility();
-@@ -749,19 +748,25 @@
-   // new comdat group for the counters and profiling data. If we use the comdat
-   // of the parent function, that will result in relocations against discarded
-   // sections.
--  Comdat *Cmdt = nullptr;
--  GlobalValue::LinkageTypes CounterLinkage = Linkage;
--  if (needsComdatForCounter(*Fn, *M)) {
--    StringRef CmdtPrefix = getInstrProfComdatPrefix();
-+  bool NeedComdat = needsComdatForCounter(*Fn, *M);
-+  Comdat *Cmdt = nullptr; // Comdat group.
-+  if (NeedComdat) {
-     if (TT.isOSBinFormatCOFF()) {
--      // For COFF, the comdat group name must be the name of a symbol in the
--      // group. Use the counter variable name, and upgrade its linkage to
--      // something externally visible, like linkonce_odr.
--      CmdtPrefix = getInstrProfCountersVarPrefix();
--      CounterLinkage = GlobalValue::LinkOnceODRLinkage;
-+      // For COFF, put the counters, data, and values each into their own
-+      // comdats. We can't use a group because the Visual C++ linker will
-+      // report duplicate symbol errors if there are multiple external symbols
-+      // with the same name marked IMAGE_COMDAT_SELECT_ASSOCIATIVE.
-+      Linkage = GlobalValue::LinkOnceODRLinkage;
-+      Visibility = GlobalValue::HiddenVisibility;
-+    } else {
-+      // Otherwise, create one comdat group for everything.
-+      Cmdt = M->getOrInsertComdat(getVarName(Inc, getInstrProfComdatPrefix()));
-     }
--    Cmdt = M->getOrInsertComdat(getVarName(Inc, CmdtPrefix));
-   }
-+  auto MaybeSetComdat = [=](GlobalVariable *GV) {
-+    if (NeedComdat)
-+      GV->setComdat(Cmdt ? Cmdt : M->getOrInsertComdat(GV->getName()));
-+  };
- 
-   uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
-   LLVMContext &Ctx = M->getContext();
-@@ -776,8 +781,8 @@
-   CounterPtr->setSection(
-       getInstrProfSectionName(IPSK_cnts, TT.getObjectFormat()));
-   CounterPtr->setAlignment(8);
--  CounterPtr->setComdat(Cmdt);
--  CounterPtr->setLinkage(CounterLinkage);
-+  MaybeSetComdat(CounterPtr);
-+  CounterPtr->setLinkage(Linkage);
- 
-   auto *Int8PtrTy = Type::getInt8PtrTy(Ctx);
-   // Allocate statically the array of pointers to value profile nodes for
-@@ -798,7 +803,7 @@
-       ValuesVar->setSection(
-           getInstrProfSectionName(IPSK_vals, TT.getObjectFormat()));
-       ValuesVar->setAlignment(8);
--      ValuesVar->setComdat(Cmdt);
-+      MaybeSetComdat(ValuesVar);
-       ValuesPtrExpr =
-           ConstantExpr::getBitCast(ValuesVar, Type::getInt8PtrTy(Ctx));
-     }
-@@ -831,7 +836,8 @@
-   Data->setVisibility(Visibility);
-   Data->setSection(getInstrProfSectionName(IPSK_data, TT.getObjectFormat()));
-   Data->setAlignment(INSTR_PROF_DATA_ALIGNMENT);
--  Data->setComdat(Cmdt);
-+  MaybeSetComdat(Data);
-+  Data->setLinkage(Linkage);
- 
-   PD.RegionCounters = CounterPtr;
-   PD.DataVar = Data;
---- a/llvm/test/Instrumentation/InstrProfiling/PR23499.ll
-+++ b/llvm/test/Instrumentation/InstrProfiling/PR23499.ll
-@@ -20,8 +20,8 @@
- 
- 
- ; COFF-NOT: __profn__Z3barIvEvv
--; COFF: @__profc__Z3barIvEvv = linkonce_odr dso_local global [1 x i64] zeroinitializer, section "{{.*}}prfc$M", comdat, align 8
--; COFF: @__profd__Z3barIvEvv = internal global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}prfd{{.*}}", comdat($__profc__Z3barIvEvv), align 8
-+; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}prfc$M", comdat, align 8
-+; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}prfd{{.*}}", comdat, align 8
- 
- 
- declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1
---- a/llvm/test/Instrumentation/InstrProfiling/comdat.ll
-+++ b/llvm/test/Instrumentation/InstrProfiling/comdat.ll
-@@ -17,8 +17,8 @@
- 
- ; ELF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat($__profv_foo_inline), align 8
- ; ELF: @__profd_foo_inline = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat($__profv_foo_inline), align 8
--; COFF: @__profc_foo_inline = linkonce_odr dso_local global{{.*}}, section ".lprfc$M", comdat, align 8
--; COFF: @__profd_foo_inline = internal global{{.*}}, section ".lprfd$M", comdat($__profc_foo_inline), align 8
-+; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 8
-+; COFF: @__profd_foo_inline = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 8
- define weak_odr void @foo_inline() comdat {
-   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
-   ret void
-@@ -30,8 +30,8 @@
- 
- ; ELF: @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat($__profv_foo_extern)
- ; ELF: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat($__profv_foo_extern)
--; COFF: @__profc_foo_extern = linkonce_odr dso_local global{{.*}}, section ".lprfc$M", comdat, align 8
--; COFF: @__profd_foo_extern = internal global{{.*}}, section ".lprfd$M", comdat($__profc_foo_extern), align 8
-+; COFF: @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 8
-+; COFF: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 8
- define available_externally void @foo_extern() {
-   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
-   ret void
---- a/llvm/test/Instrumentation/InstrProfiling/linkage.ll
-+++ b/llvm/test/Instrumentation/InstrProfiling/linkage.ll
-@@ -57,8 +57,8 @@
- ; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat($__profv_foo_extern), align 8
- ; MACHO: @__profc_foo_extern = linkonce_odr hidden global
- ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
--; COFF: @__profc_foo_extern = linkonce_odr dso_local global {{.*}}section ".lprfc$M", comdat, align 8
--; COFF: @__profd_foo_extern = internal global {{.*}}section ".lprfd$M", comdat($__profc_foo_extern), align 8
-+; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc$M", comdat, align 8
-+; COFF: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfd$M", comdat, align 8
- define available_externally void @foo_extern() {
-   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
-   ret void
--- a/build/build-clang/rename_gcov_flush.patch
+++ b/build/build-clang/rename_gcov_flush.patch
@@ -1,40 +1,40 @@
 Index: compiler-rt/lib/profile/GCDAProfiling.c
 ===================================================================
 diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
---- a/compiler-rt/lib/profile/GCDAProfiling.c
-+++ b/compiler-rt/lib/profile/GCDAProfiling.c
-@@ -619,7 +619,7 @@
+--- a/compiler-rt/lib/profile/GCDAProfiling.c	(revisione 336380)
++++ b/compiler-rt/lib/profile/GCDAProfiling.c	(copia locale)
+@@ -555,7 +555,7 @@
    fn_list_insert(&flush_fn_list, fn);
  }
  
 -void __gcov_flush() {
 +void __custom_llvm_gcov_flush() {
    struct fn_node* curr = flush_fn_list.head;
  
    while (curr) {
 diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
 index 9af64ed332c..bcebe303ff4 100644
 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
 +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
-@@ -647,7 +647,7 @@
+@@ -648,7 +648,7 @@ void GCOVProfiler::AddFlushBeforeForkAndExec() {
    for (auto I : ForkAndExecs) {
      IRBuilder<> Builder(I);
      FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
--    FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
-+    FunctionCallee GCOVFlush = M->getOrInsertFunction("__custom_llvm_gcov_flush", FTy);
+-    Constant *GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
++    Constant *GCOVFlush = M->getOrInsertFunction("__custom_llvm_gcov_flush", FTy);
      Builder.CreateCall(GCOVFlush);
      I->getParent()->splitBasicBlock(I);
    }
 diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
 index e113f9a679..b3a07b18c0 100644
 --- a/clang/lib/Driver/ToolChains/Darwin.cpp
 +++ b/clang/lib/Driver/ToolChains/Darwin.cpp
-@@ -1122,7 +1122,7 @@
+@@ -1058,7 +1058,7 @@ void Darwin::addProfileRTLibs(const ArgList &Args,
    // runtime's functionality.
    if (hasExportSymbolDirective(Args)) {
      if (needsGCovInstrumentation(Args)) {
 -      addExportedSymbol(CmdArgs, "___gcov_flush");
 +      addExportedSymbol(CmdArgs, "___custom_llvm_gcov_flush");
        addExportedSymbol(CmdArgs, "_flush_fn_list");
        addExportedSymbol(CmdArgs, "_writeout_fn_list");
      } else {
new file mode 100644
--- /dev/null
+++ b/build/build-clang/revert-r355311.patch
@@ -0,0 +1,117 @@
+We need to revert LLVM's r355311 because it breaks exception handling in
+Windows/AArch64 builds
+
+diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+index ac5bdae9f1f..09e0706e284 100644
+--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
++++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+@@ -605,28 +605,19 @@ void AArch64AsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
+ 
+ void AArch64AsmPrinter::EmitJumpTableInfo() {
+   const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
+   if (!MJTI) return;
+ 
+   const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
+   if (JT.empty()) return;
+ 
+-  const Function &F = MF->getFunction();
+   const TargetLoweringObjectFile &TLOF = getObjFileLowering();
+-  bool JTInDiffSection =
+-      !STI->isTargetCOFF() ||
+-      !TLOF.shouldPutJumpTableInFunctionSection(
+-          MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
+-          F);
+-  if (JTInDiffSection) {
+-      // Drop it in the readonly section.
+-      MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(F, TM);
+-      OutStreamer->SwitchSection(ReadOnlySec);
+-  }
++  MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(MF->getFunction(), TM);
++  OutStreamer->SwitchSection(ReadOnlySec);
+ 
+   auto AFI = MF->getInfo<AArch64FunctionInfo>();
+   for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
+     const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
+ 
+     // If this jump table was deleted, ignore it.
+     if (JTBBs.empty()) continue;
+ 
+diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+index d657fd414f3..d32f5a0ab29 100644
+--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
++++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+@@ -204,18 +204,18 @@ static std::string computeDataLayout(const Triple &TT,
+     return "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128";
+   if (LittleEndian)
+     return "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
+   return "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
+ }
+ 
+ static Reloc::Model getEffectiveRelocModel(const Triple &TT,
+                                            Optional<Reloc::Model> RM) {
+-  // AArch64 Darwin and Windows are always PIC.
+-  if (TT.isOSDarwin() || TT.isOSWindows())
++  // AArch64 Darwin is always PIC.
++  if (TT.isOSDarwin())
+     return Reloc::PIC_;
+   // On ELF platforms the default static relocation model has a smart enough
+   // linker to cope with referencing external symbols defined in a shared
+   // library. Hence DynamicNoPIC doesn't need to be promoted to PIC.
+   if (!RM.hasValue() || *RM == Reloc::DynamicNoPIC)
+     return Reloc::Static;
+   return *RM;
+ }
+diff --git a/llvm/test/CodeGen/AArch64/win64-jumptable.ll b/llvm/test/CodeGen/AArch64/win64-jumptable.ll
+deleted file mode 100644
+index 8148a593c91..00000000000
+--- a/llvm/test/CodeGen/AArch64/win64-jumptable.ll
++++ /dev/null
+@@ -1,48 +0,0 @@
+-; RUN: llc -o - %s -mtriple=aarch64-windows -aarch64-enable-compress-jump-tables=0 | FileCheck %s
+-
+-define void @f(i32 %x) {
+-entry:
+-  switch i32 %x, label %sw.epilog [
+-    i32 0, label %sw.bb
+-    i32 1, label %sw.bb1
+-    i32 2, label %sw.bb2
+-    i32 3, label %sw.bb3
+-  ]
+-
+-sw.bb:                                            ; preds = %entry
+-  tail call void @g(i32 0) #2
+-  br label %sw.epilog
+-
+-sw.bb1:                                           ; preds = %entry
+-  tail call void @g(i32 1) #2
+-  br label %sw.epilog
+-
+-sw.bb2:                                           ; preds = %entry
+-  tail call void @g(i32 2) #2
+-  br label %sw.epilog
+-
+-sw.bb3:                                           ; preds = %entry
+-  tail call void @g(i32 3) #2
+-  br label %sw.epilog
+-
+-sw.epilog:                                        ; preds = %entry, %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb
+-  tail call void @g(i32 10) #2
+-  ret void
+-}
+-
+-declare void @g(i32)
+-
+-; CHECK:		.text
+-; CHECK:		f:
+-; CHECK:		.seh_proc f
+-; CHECK:		b	g
+-; CHECK-NEXT:	.p2align	2
+-; CHECK-NEXT:	.LJTI0_0:
+-; CHECK:		.word	.LBB0_2-.LJTI0_0
+-; CHECK:		.word	.LBB0_3-.LJTI0_0
+-; CHECK:		.word	.LBB0_4-.LJTI0_0
+-; CHECK:		.word	.LBB0_5-.LJTI0_0
+-; CHECK:		.section	.xdata,"dr"
+-; CHECK:		.seh_handlerdata
+-; CHECK:		.text
+-; CHECK:		.seh_endproc
deleted file mode 100644
--- a/build/build-clang/revert-r359260-due-to-bug41817.patch
+++ /dev/null
@@ -1,341 +0,0 @@
-https://llvm.org/pr41817 "The linkage changes in r359260 break MIDL code"
-
-MIDL produces non-standards-compliant C code for some of our .idl files. MSVC
-and older versions of clang-cl used to accept it, but r359260 inadvertently
-caused such code to break. Until a fix is available upstream, let's revert
-r359260 in the meantime.
-
-Index: lib/AST/Decl.cpp
-===================================================================
---- a/clang/lib/AST/Decl.cpp
-+++ b/clang/lib/AST/Decl.cpp
-@@ -610,18 +610,6 @@
-   return LinkageInfo::external();
- }
- 
--static StorageClass getStorageClass(const Decl *D) {
--  if (auto *TD = dyn_cast<TemplateDecl>(D))
--    D = TD->getTemplatedDecl();
--  if (D) {
--    if (auto *VD = dyn_cast<VarDecl>(D))
--      return VD->getStorageClass();
--    if (auto *FD = dyn_cast<FunctionDecl>(D))
--      return FD->getStorageClass();
--  }
--  return SC_None;
--}
--
- LinkageInfo
- LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
-                                             LVComputationKind computation,
-@@ -633,28 +621,24 @@
-   // C++ [basic.link]p3:
-   //   A name having namespace scope (3.3.6) has internal linkage if it
-   //   is the name of
-+  //     - an object, reference, function or function template that is
-+  //       explicitly declared static; or,
-+  // (This bullet corresponds to C99 6.2.2p3.)
-+  if (const auto *Var = dyn_cast<VarDecl>(D)) {
-+    // Explicitly declared static.
-+    if (Var->getStorageClass() == SC_Static)
-+      return getInternalLinkageFor(Var);
- 
--  if (getStorageClass(D->getCanonicalDecl()) == SC_Static) {
--    // - a variable, variable template, function, or function template
--    //   that is explicitly declared static; or
--    // (This bullet corresponds to C99 6.2.2p3.)
--    return getInternalLinkageFor(D);
--  }
--
--  if (const auto *Var = dyn_cast<VarDecl>(D)) {
--    // - a non-template variable of non-volatile const-qualified type, unless
--    //   - it is explicitly declared extern, or
--    //   - it is inline or exported, or
--    //   - it was previously declared and the prior declaration did not have
--    //     internal linkage
--    // (There is no equivalent in C99.)
-+    // - a non-inline, non-volatile object or reference that is explicitly
-+    //   declared const or constexpr and neither explicitly declared extern
-+    //   nor previously declared to have external linkage; or (there is no
-+    //   equivalent in C99)
-+    // The C++ modules TS adds "non-exported" to this list.
-     if (Context.getLangOpts().CPlusPlus &&
-         Var->getType().isConstQualified() &&
-         !Var->getType().isVolatileQualified() &&
-         !Var->isInline() &&
--        !isExportedFromModuleInterfaceUnit(Var) &&
--        !isa<VarTemplateSpecializationDecl>(Var) &&
--        !Var->getDescribedVarTemplate()) {
-+        !isExportedFromModuleInterfaceUnit(Var)) {
-       const VarDecl *PrevVar = Var->getPreviousDecl();
-       if (PrevVar)
-         return getLVForDecl(PrevVar, computation);
-@@ -674,6 +658,14 @@
-       if (PrevVar->getStorageClass() == SC_Static)
-         return getInternalLinkageFor(Var);
-     }
-+  } else if (const FunctionDecl *Function = D->getAsFunction()) {
-+    // C++ [temp]p4:
-+    //   A non-member function template can have internal linkage; any
-+    //   other template name shall have external linkage.
-+
-+    // Explicitly declared static.
-+    if (Function->getCanonicalDecl()->getStorageClass() == SC_Static)
-+      return getInternalLinkageFor(Function);
-   } else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
-     //   - a data member of an anonymous union.
-     const VarDecl *VD = IFD->getVarDecl();
-@@ -682,8 +674,6 @@
-   }
-   assert(!isa<FieldDecl>(D) && "Didn't expect a FieldDecl!");
- 
--  // FIXME: This gives internal linkage to names that should have no linkage
--  // (those not covered by [basic.link]p6).
-   if (D->isInAnonymousNamespace()) {
-     const auto *Var = dyn_cast<VarDecl>(D);
-     const auto *Func = dyn_cast<FunctionDecl>(D);
-@@ -743,20 +733,10 @@
- 
-   // C++ [basic.link]p4:
- 
--  //   A name having namespace scope that has not been given internal linkage
--  //   above and that is the name of
--  //   [...bullets...]
--  //   has its linkage determined as follows:
--  //     - if the enclosing namespace has internal linkage, the name has
--  //       internal linkage; [handled above]
--  //     - otherwise, if the declaration of the name is attached to a named
--  //       module and is not exported, the name has module linkage;
--  //     - otherwise, the name has external linkage.
--  // LV is currently set up to handle the last two bullets.
-+  //   A name having namespace scope has external linkage if it is the
-+  //   name of
-   //
--  //   The bullets are:
--
--  //     - a variable; or
-+  //     - an object or reference, unless it has internal linkage; or
-   if (const auto *Var = dyn_cast<VarDecl>(D)) {
-     // GCC applies the following optimization to variables and static
-     // data members, but not to functions:
-@@ -802,7 +782,7 @@
-       mergeTemplateLV(LV, spec, computation);
-     }
- 
--  //     - a function; or
-+  //     - a function, unless it has internal linkage; or
-   } else if (const auto *Function = dyn_cast<FunctionDecl>(D)) {
-     // In theory, we can modify the function's LV by the LV of its
-     // type unless it has C linkage (see comment above about variables
-@@ -856,8 +836,7 @@
-       mergeTemplateLV(LV, spec, computation);
-     }
- 
--  // FIXME: This is not part of the C++ standard any more.
--  //     - an enumerator belonging to an enumeration with external linkage; or
-+  //     - an enumerator belonging to an enumeration with external linkage;
-   } else if (isa<EnumConstantDecl>(D)) {
-     LinkageInfo EnumLV = getLVForDecl(cast<NamedDecl>(D->getDeclContext()),
-                                       computation);
-@@ -865,7 +844,8 @@
-       return LinkageInfo::none();
-     LV.merge(EnumLV);
- 
--  //     - a template
-+  //     - a template, unless it is a function template that has
-+  //       internal linkage (Clause 14);
-   } else if (const auto *temp = dyn_cast<TemplateDecl>(D)) {
-     bool considerVisibility = !hasExplicitVisibilityAlready(computation);
-     LinkageInfo tempLV =
-@@ -872,9 +852,8 @@
-       getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
-     LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
- 
--  //     An unnamed namespace or a namespace declared directly or indirectly
--  //     within an unnamed namespace has internal linkage. All other namespaces
--  //     have external linkage.
-+  //     - a namespace (7.3), unless it is declared within an unnamed
-+  //       namespace.
-   //
-   // We handled names in anonymous namespaces above.
-   } else if (isa<NamespaceDecl>(D)) {
-Index: test/CXX/drs/dr23xx.cpp
-===================================================================
---- a/clang/test/CXX/drs/dr23xx.cpp
-+++ b/clang/test/CXX/drs/dr23xx.cpp
-@@ -60,20 +60,3 @@
- void wrong_value() { auto [x, y] = Bad2(); } // expected-error {{decomposes into 42 elements}}
- } // namespace dr2386
- #endif
--
--namespace dr2387 { // dr2387: 9
--#if __cplusplus >= 201402L
--  template<int> int a = 0;
--  extern template int a<0>; // ok
--
--  template<int> static int b = 0;
--  extern template int b<0>; // expected-error {{internal linkage}}
--
--  template<int> const int c = 0;
--  extern template const int c<0>; // ok, has external linkage despite 'const'
--
--  template<typename T> T d = 0;
--  extern template int d<int>;
--  extern template const int d<const int>;
--#endif
--}
-Index: test/CXX/module/module.interface/p3.cpp
-===================================================================
---- a/clang/test/CXX/module/module.interface/p3.cpp
-+++ b/clang/test/CXX/module/module.interface/p3.cpp
-@@ -48,7 +48,7 @@
- namespace { // expected-note {{here}}
-   export int d; // expected-error {{export declaration appears within anonymous namespace}}
- }
--export template<typename> static int e; // expected-error {{declaration of 'e' with internal linkage cannot be exported}}
-+export template<typename> static int e; // FIXME
- export template<typename> static int f(); // expected-error {{declaration of 'f' with internal linkage cannot be exported}}
- export const int k = 5;
- export static union { int n; }; // expected-error {{declaration of 'n' with internal linkage cannot be exported}}
-Index: test/CXX/module/module.interface/p5.cpp
-===================================================================
---- a/clang/test/CXX/module/module.interface/p5.cpp
-+++ b/clang/test/CXX/module/module.interface/p5.cpp
-@@ -14,7 +14,7 @@
- namespace NS {}
- 
- template<typename> int ta;
--template<typename> static int sta; // expected-note {{target}}
-+template<typename> static int sta;
- template<typename> void tb();
- template<typename> static void stb(); // expected-note {{target}}
- template<typename> struct tc {};
-@@ -44,7 +44,7 @@
-   }
- }
- 
--export { // expected-note 19{{here}}
-+export { // expected-note 18{{here}}
-   using ::a;
-   using ::sa; // expected-error {{using declaration referring to 'sa' with internal linkage}}
-   using ::b;
-@@ -56,7 +56,7 @@
-   using ::sg1; // expected-error {{using declaration referring to 'sg1' with internal linkage}}
- 
-   using ::ta;
--  using ::sta; // expected-error {{using declaration referring to 'sta' with internal linkage}}
-+  using ::sta; // FIXME {{using declaration referring to 'sta' with internal linkage}}
-   using ::tb;
-   using ::stb; // expected-error {{using declaration referring to 'stb' with internal linkage}}
-   using ::tc;
-Index: test/CodeGenCXX/cxx1y-variable-template-linkage.cpp
-===================================================================
---- a/clang/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp
-+++ b/clang/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp
-@@ -6,61 +6,21 @@
- // should be 'internal global' and not 'linkonce_odr global'.
- 
- template <typename T> int x = 42;
--// CHECK-DAG: @_Z1xIiE = linkonce_odr global
-+
- // CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global
- 
--// 'static' affects the linkage of the global
--template <typename T> static int y = 42;
--// CHECK-DAG: @_ZL1yIiE = internal global
--// CHECK-DAG: @_ZL1yIZL3foovE3FooE = internal global
--
--// 'const' does not
--template <typename T> const int z = 42;
--// CHECK-DAG: @_Z1zIiE = linkonce_odr constant
--// CHECK-DAG: @_Z1zIZL3foovE3FooE = internal constant
--
--template <typename T> T t = 42;
--// CHECK-DAG: @_Z1tIiE = linkonce_odr global
--// CHECK-DAG: @_Z1tIKiE = linkonce_odr constant
--
--int mode;
--
- // CHECK-DAG: define internal dereferenceable(4) i32* @_ZL3foov(
--static const int &foo() {
-+static int &foo() {
-    struct Foo { };
--
--   switch (mode) {
--   case 0:
--     // CHECK-DAG: @_Z1xIiE
--     return x<int>;
--   case 1:
--     // CHECK-DAG: @_Z1xIZL3foovE3FooE
--     return x<Foo>;
--   case 2:
--     // CHECK-DAG: @_ZL1yIiE
--     return y<int>;
--   case 3:
--     // CHECK-DAG: @_ZL1yIZL3foovE3FooE
--     return y<Foo>;
--   case 4:
--     // CHECK-DAG: @_Z1zIiE
--     return z<int>;
--   case 5:
--     // CHECK-DAG: @_Z1zIZL3foovE3FooE
--     return z<Foo>;
--   case 6:
--     // CHECK-DAG: @_Z1tIiE
--     return t<int>;
--   case 7:
--     // CHECK-DAG: @_Z1tIKiE
--     return t<const int>;
--   }
-+   
-+   // CHECK-DAG: ret i32* @_Z1xIZL3foovE3FooE
-+   return x<Foo>;
- }
- 
- 
- #if !__has_feature(cxx_exceptions) // File A
- // CHECKA-DAG: define dereferenceable(4) i32* @_Z3barv(
--const int &bar() {
-+int &bar() { 
- 	// CHECKA-DAG: call dereferenceable(4) i32* @_ZL3foov()
- 	return foo();
- }
-@@ -68,7 +28,7 @@
- #else // File B
- 
- // CHECKB-DAG: declare dereferenceable(4) i32* @_Z3barv(
--const int &bar();
-+int &bar();
- 
- int main() {
- 	// CHECKB-DAG: call dereferenceable(4) i32* @_Z3barv()
-Index: test/SemaCXX/warn-unused-filescoped.cpp
-===================================================================
---- a/clang/test/SemaCXX/warn-unused-filescoped.cpp
-+++ b/clang/test/SemaCXX/warn-unused-filescoped.cpp
-@@ -207,9 +207,8 @@
- 
- namespace test10 {
- #if __cplusplus >= 201103L
--// FIXME: Warn on template definitions with no instantiations?
- template<class T>
--constexpr T pi = T(3.14);
-+constexpr T pi = T(3.14); // expected-warning {{unused}}
- #endif
- }
- 
-Index: test/SemaCXX/warn-unused-variables.cpp
-===================================================================
---- a/clang/test/SemaCXX/warn-unused-variables.cpp
-+++ b/clang/test/SemaCXX/warn-unused-variables.cpp
-@@ -135,9 +135,7 @@
-   template<typename T> int m = 0;
-   template<typename T> int m<T*> = 0;
- 
--  // This has external linkage, so could be referenced by a declaration in a
--  // different translation unit.
--  template<> const int m<void> = 0; // no warning
-+  template<> const int m<void> = 0; // expected-warning {{unused variable}}
- }
- 
- namespace ctor_with_cleanups {
deleted file mode 100644
--- a/build/build-clang/revert-r362047-and-r362065.patch
+++ /dev/null
@@ -1,65 +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.
-
---- a/llvm/runtimes/CMakeLists.txt
-+++ b/llvm/runtimes/CMakeLists.txt
-@@ -59,13 +59,12 @@
-   cmake_minimum_required(VERSION 3.4.3)
-   project(Runtimes C CXX ASM)
- 
--  find_package(LLVM 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
-   # CMake module path.
-   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
-@@ -80,6 +79,11 @@
-     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})
-@@ -89,9 +93,6 @@
-   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()
-@@ -380,6 +381,8 @@
-                              # 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=ON
-@@ -470,6 +473,8 @@
-                              # 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/build/build-clang/unpoison-thread-stacks.patch
+++ b/build/build-clang/unpoison-thread-stacks.patch
@@ -1,62 +1,34 @@
 [winasan] Unpoison the stack in NtTerminateThread
 
-In long-running builds we've seen some ASan complaints during thread creation
-that we suspect are due to leftover poisoning from previous threads whose stacks
-occupied that memory. This patch adds a hook that unpoisons the stack just
-before the NtTerminateThread syscall.
+In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a hook that unpoisons the stack just before the NtTerminateThread syscall.
 
 Differential Revision: https://reviews.llvm.org/D52091
 
-** Update for clang 9 ** : After some backouts, this patch eventually landed
-upstream in a different form, as the TLS handler `asan_thread_exit`, but that
-variant causes failures in our test suite, so revert the TLS handler in favor of
-the interceptor approach from the first patch.
-
---- a/compiler-rt/lib/asan/asan_win.cc
-+++ b/compiler-rt/lib/asan/asan_win.cc
+--- a/compiler-rt/lib/asan/asan_win.cc	(revision 342651)
++++ b/compiler-rt/lib/asan/asan_win.cc	(revision 342652)
 @@ -154,6 +154,14 @@
-                             thr_flags, tid);
+                             asan_thread_start, t, thr_flags, tid);
  }
  
 +INTERCEPTOR_WINAPI(void, NtTerminateThread, void *rcx) {
 +  // Unpoison the terminating thread's stack because the memory may be re-used.
 +  NT_TIB *tib = (NT_TIB *)NtCurrentTeb();
 +  uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit;
 +  __asan_unpoison_memory_region(tib->StackLimit, stackSize);
 +  return REAL(NtTerminateThread(rcx));
 +}
 +
  // }}}
  
  namespace __asan {
-@@ -168,7 +176,9 @@
+@@ -169,7 +177,9 @@
  
    ASAN_INTERCEPT_FUNC(CreateThread);
    ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);
 -
 +  CHECK(::__interception::OverrideFunction("NtTerminateThread",
 +                                           (uptr)WRAP(NtTerminateThread),
 +                                           (uptr *)&REAL(NtTerminateThread)));
  #ifdef _WIN64
    ASAN_INTERCEPT_FUNC(__C_specific_handler);
  #else
-@@ -380,19 +390,6 @@
-     void *, unsigned long, void *) = asan_thread_init;
- #endif
- 
--static void NTAPI asan_thread_exit(void *module, DWORD reason, void *reserved) {
--  if (reason == DLL_THREAD_DETACH) {
--    // Unpoison the thread's stack because the memory may be re-used.
--    NT_TIB *tib = (NT_TIB *)NtCurrentTeb();
--    uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit;
--    __asan_unpoison_memory_region(tib->StackLimit, stackSize);
--  }
--}
--
--#pragma section(".CRT$XLY", long, read)  // NOLINT
--__declspec(allocate(".CRT$XLY")) void(NTAPI *__asan_tls_exit)(
--    void *, unsigned long, void *) = asan_thread_exit;
--
- WIN_FORCE_LINK(__asan_dso_reg_hook)
- 
- // }}}
new file mode 100644
--- /dev/null
+++ b/build/build-clang/workaround-issue38586.patch
@@ -0,0 +1,31 @@
+diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
+index 86ca2b3ef..f6ddd24eb 100644
+--- a/compiler-rt/CMakeLists.txt
++++ b/compiler-rt/CMakeLists.txt
+@@ -284,6 +284,26 @@ if(MSVC)
+   # warning from the MS linker complaining that it can't find the 'vc140.pdb'
+   # file used by our object library compilations.
+   list(APPEND SANITIZER_COMMON_CFLAGS /Z7)
++
++# Copied from llvm/cmake/modules/LLVMProcessSources.cmake
++function(llvm_replace_compiler_option var old new)
++  # Replaces a compiler option or switch `old' in `var' by `new'.
++  # If `old' is not in `var', appends `new' to `var'.
++  # Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
++  # If the option already is on the variable, don't add it:
++  if( "${${var}}" MATCHES "(^| )${new}($| )" )
++    set(n "")
++  else()
++    set(n "${new}")
++  endif()
++  if( "${${var}}" MATCHES "(^| )${old}($| )" )
++    string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
++  else()
++    set( ${var} "${${var}} ${n}" )
++  endif()
++  set( ${var} "${${var}}" PARENT_SCOPE )
++endfunction(llvm_replace_compiler_option)
++
+   llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/Z[i7I]" "/Z7")
+   llvm_replace_compiler_option(CMAKE_CXX_FLAGS_DEBUG "/Z[i7I]" "/Z7")
+   llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Z[i7I]" "/Z7")
--- a/taskcluster/ci/build/linux.yml
+++ b/taskcluster/ci/build/linux.yml
@@ -1053,17 +1053,17 @@ linux64-ccov/debug:
         script: "mozharness/scripts/fx_desktop_build.py"
         secrets: true
         custom-build-variant-cfg: code-coverage-debug
         mozconfig-variant: code-coverage-debug
         tooltool-downloads: public
         need-xvfb: true
     fetches:
         toolchain:
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-rust-nightly
             - linux64-gcc
             - linux64-grcov
             - linux64-cbindgen
             - linux64-sccache
             - linux64-nasm
             - linux64-node
 
@@ -1091,17 +1091,17 @@ linux64-ccov/opt:
         script: "mozharness/scripts/fx_desktop_build.py"
         secrets: true
         custom-build-variant-cfg: code-coverage-opt
         mozconfig-variant: code-coverage-opt
         tooltool-downloads: public
         need-xvfb: true
     fetches:
         toolchain:
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-rust-nightly
             - linux64-gcc
             - linux64-cbindgen
             - linux64-sccache
             - linux64-nasm
             - linux64-node
 
 linux64-add-on-devel/opt:
--- a/taskcluster/ci/fetch/toolchains.yml
+++ b/taskcluster/ci/fetch/toolchains.yml
@@ -395,23 +395,16 @@ clang-7:
 
 clang-8:
     description: clang 8.0.1 source code
     fetch:
         type: git
         repo: https://github.com/llvm/llvm-project
         revision: 19a71f6bdf2dddb10764939e7f0ec2b98dba76c9
 
-clang-9:
-    description: clang 9.0.0 source code
-    fetch:
-        type: git
-        repo: https://github.com/llvm/llvm-project
-        revision: 0399d5a9682b3cef71c653373e38890c63c4c365
-
 ninja:
     description: ninja 1.9.0
     fetch:
         type: static-url
         url: https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip
         sha256: 2d70010633ddaacc3af4ffbd21e22fae90d158674a09e132e06424ba3ab036e9
         size: 254497
         artifact-name: ninja.tar.zst
--- a/taskcluster/ci/toolchain/cbindgen.yml
+++ b/taskcluster/ci/toolchain/cbindgen.yml
@@ -39,17 +39,17 @@ macosx64-cbindgen:
     run:
         arguments: ['x86_64-apple-darwin']
         resources:
             - taskcluster/scripts/misc/tooltool-download.sh
         tooltool-downloads: internal
     fetches:
         toolchain:
             - linux64-cctools-port
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-llvm-dsymutil
             - linux64-rust-macos-1.32
 
 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
@@ -15,10 +15,10 @@ job-defaults:
 linux64-cctools-port:
     treeherder:
         symbol: TL(cctools)
     run:
         script: build-cctools-port.sh
         toolchain-artifact: public/build/cctools.tar.xz
     fetches:
         toolchain:
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-binutils
--- a/taskcluster/ci/toolchain/clang-tidy.yml
+++ b/taskcluster/ci/toolchain/clang-tidy.yml
@@ -19,32 +19,31 @@ job-defaults:
             - 'build/clang-plugin/moz.build'
             - 'build/clang-plugin/Makefile.in'
             - 'build/build-clang/build-clang.py'
     run-on-projects:
         - trunk
         - try
     fetches:
         fetch:
-            - clang-9
+            - clang-8
 
 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'
     fetches:
         toolchain:
-            - linux64-binutils
             - linux64-gcc-6
 
 macosx64-clang-tidy:
     index:
         job-name: macosx64-clang-tidy
     treeherder:
         symbol: TM(clang-tidy)
     worker-type: b-linux-large
@@ -57,19 +56,18 @@ macosx64-clang-tidy:
         tooltool-downloads: internal
         arguments:
             - 'build/build-clang/clang-tidy-macosx64.json'
         resources:
             - 'build/build-clang/clang-tidy-macosx64.json'
             - 'taskcluster/scripts/misc/tooltool-download.sh'
     fetches:
         toolchain:
-            - linux64-binutils
             - linux64-cctools-port
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-gcc-6
             - linux64-node
 
 win64-clang-tidy:
     description: "Clang-tidy toolchain build"
     index:
         job-name: win64-clang-tidy
     treeherder:
--- a/taskcluster/ci/toolchain/clang.yml
+++ b/taskcluster/ci/toolchain/clang.yml
@@ -41,34 +41,33 @@ linux64-clang-7:
             - 'build/build-clang/clang-7-linux64.json'
         toolchain-artifact: public/build/clang.tar.xz
     fetches:
         fetch:
             - clang-7
         toolchain:
             - linux64-gcc-6
 
-linux64-clang-9:
-    description: "Clang 9 toolchain build"
+linux64-clang-8:
+    description: "Clang 8 toolchain build"
     treeherder:
-        symbol: TL(clang9)
+        symbol: TL(clang8)
     run:
         using: toolchain-script
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-linux64.json'
+            - 'build/build-clang/clang-8-linux64.json'
         resources:
-            - 'build/build-clang/clang-linux64.json'
+            - 'build/build-clang/clang-8-linux64.json'
         toolchain-alias: linux64-clang
         toolchain-artifact: public/build/clang.tar.xz
     fetches:
         fetch:
-            - clang-9
+            - clang-8
         toolchain:
-            - linux64-binutils
             - linux64-gcc-6
 
 linux64-clang-8-mingw-x86:
     description: "MinGW-Clang Trunk x86 toolchain build"
     treeherder:
         symbol: TMW(clang-x86)
     run:
         script: build-clang-8-mingw.sh
@@ -106,87 +105,85 @@ linux64-clang-8-mingw-x64:
         fetch:
             - clang-8
             - mingw-w64
             - libunwind
             - llvm-mingw
         toolchain:
             - linux64-gcc-6
 
-linux64-clang-9-android-cross:
-    description: "Clang 9 toolchain build"
+linux64-clang-8-android-cross:
+    description: "Clang 8 toolchain build"
     treeherder:
-        symbol: TL(clang9-android)
+        symbol: TL(clang8-android)
     run:
         using: toolchain-script
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-android.json'
+            - 'build/build-clang/clang-8-android.json'
         resources:
-            - 'build/build-clang/clang-android.json'
+            - 'build/build-clang/clang-8-android.json'
         toolchain-alias: linux64-clang-android-cross
         toolchain-artifact: public/build/clang.tar.xz
     fetches:
         fetch:
-            - clang-9
+            - clang-8
         toolchain:
-            - linux64-binutils
             - linux64-gcc-6
             - linux64-android-ndk-linux-repack
 
-linux64-clang-9-aarch64-cross:
-    description: "Clang 9 toolchain build with aarch64 runtime"
+linux64-clang-8-aarch64-cross:
+    description: "Clang 8 toolchain build with aarch64 runtime"
     treeherder:
-        symbol: TL(clang9-aarch64)
+        symbol: TL(clang8-aarch64)
     worker-type: b-linux
     worker:
         max-run-time: 3600
         docker-image: {in-tree: toolchain-arm64-build}
     run:
         using: toolchain-script
         script: build-clang.sh
         arguments:
-            - 'build/build-clang/clang-linux64-aarch64-cross.json'
+            - 'build/build-clang/clang-8-linux64-aarch64-cross.json'
         resources:
-            - 'build/build-clang/clang-linux64-aarch64-cross.json'
+            - 'build/build-clang/clang-8-linux64-aarch64-cross.json'
         toolchain-alias: linux64-clang-aarch64-cross
         toolchain-artifact: public/build/clang.tar.xz
     fetches:
         fetch:
-            - clang-9
+            - clang-8
         toolchain:
             - linux64-binutils
             - linux64-gcc-6
 
-linux64-clang-9-macosx-cross:
-    description: "Clang 9 toolchain build with MacOS Compiler RT libs"
+linux64-clang-8-macosx-cross:
+    description: "Clang 8 toolchain build with MacOS Compiler RT libs"
     treeherder:
-        symbol: TL(clang9-macosx-cross)
+        symbol: TL(clang8-macosx-cross)
     worker-type: b-linux
     worker:
         max-run-time: 3600
         env:
             TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/macosx64/cross-clang.manifest"
     run:
-        script: build-clang-linux-macosx-cross.sh
+        script: build-clang-8-linux-macosx-cross.sh
         arguments:
-            - 'build/build-clang/clang-macosx64.json'
+            - 'build/build-clang/clang-8-macosx64.json'
         resources:
-            - 'build/build-clang/clang-macosx64.json'
+            - 'build/build-clang/clang-8-macosx64.json'
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         toolchain-alias: linux64-clang-macosx-cross
         toolchain-artifact: public/build/clang.tar.xz
         tooltool-downloads: internal
     fetches:
         fetch:
-            - clang-9
+            - clang-8
         toolchain:
-            - linux64-binutils
             - linux64-cctools-port
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-gcc-6
 
 macosx64-clang:
     description: "Clang toolchain build"
     treeherder:
         symbol: TM(clang)
     worker-type: b-linux-large
     worker:
@@ -195,28 +192,27 @@ macosx64-clang:
             TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/macosx64/cross-clang.manifest"
     run-on-projects:
         - trunk
         - try
     run:
         script: build-clang.sh
         tooltool-downloads: internal
         arguments:
-            - 'build/build-clang/clang-macosx64.json'
+            - 'build/build-clang/clang-8-macosx64.json'
         resources:
-            - 'build/build-clang/clang-macosx64.json'
+            - 'build/build-clang/clang-8-macosx64.json'
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         toolchain-artifact: public/build/clang.tar.xz
     fetches:
         fetch:
-            - clang-9
+            - clang-8
         toolchain:
-            - linux64-binutils
             - linux64-cctools-port
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-gcc-6
             - linux64-node
 
 win64-clang-cl:
     description: "Clang-cl toolchain build"
     treeherder:
         symbol: TW64(clang-cl)
     worker-type: b-win2012
@@ -228,11 +224,11 @@ win64-clang-cl:
         arguments:
             - 'build/build-clang/clang-win64.json'
         resources:
             - 'build/build-clang/clang-win64.json'
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         toolchain-artifact: public/build/clang.tar.bz2
     fetches:
         fetch:
-            - clang-9
+            - clang-8
             - cmake
             - ninja
--- a/taskcluster/ci/toolchain/dist-toolchains.yml
+++ b/taskcluster/ci/toolchain/dist-toolchains.yml
@@ -17,17 +17,17 @@ clang-dist-toolchain:
         symbol: TL(clang-dist)
     worker:
         max-run-time: 1800
     run:
         arguments: ['clang']
         toolchain-artifact: public/build/clang-dist-toolchain.tar.xz
     fetches:
         toolchain:
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-sccache
 
 rustc-dist-toolchain:
     treeherder:
         symbol: TL(rustc-dist)
     worker:
         max-run-time: 1800
     run:
--- a/taskcluster/ci/toolchain/gn.yml
+++ b/taskcluster/ci/toolchain/gn.yml
@@ -36,17 +36,17 @@ macosx64-gn:
     run:
         script: build-gn-macosx.sh
         resources:
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         tooltool-downloads: internal
     fetches:
         toolchain:
             - linux64-cctools-port
-            - linux64-clang-9
+            - linux64-clang-8
 
 win32-gn:
     treeherder:
         symbol: TW64(gn)
     worker-type: b-win2012
     worker:
         max-run-time: 3600
         env:
--- a/taskcluster/ci/toolchain/minidump_stackwalk.yml
+++ b/taskcluster/ci/toolchain/minidump_stackwalk.yml
@@ -26,17 +26,17 @@ job-defaults:
         - trunk
         - try
 
 linux64-minidump-stackwalk:
     treeherder:
         symbol: TL(stackwalk)
     fetches:
         toolchain:
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-binutils
             - linux64-rust-1.31
 
 macosx64-minidump-stackwalk:
     treeherder:
         symbol: TM(stackwalk)
     worker:
         env:
@@ -44,17 +44,17 @@ macosx64-minidump-stackwalk:
     run:
         arguments: ['macosx64']
         resources:
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         tooltool-downloads: internal
     fetches:
         toolchain:
             - linux64-cctools-port
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-rust-macos-1.31
 
 win32-minidump-stackwalk:
     treeherder:
         symbol: TW32(stackwalk)
     worker:
         docker-image: {in-tree: mingw32-build}
     run:
--- a/taskcluster/ci/toolchain/misc.yml
+++ b/taskcluster/ci/toolchain/misc.yml
@@ -60,17 +60,17 @@ linux64-hfsplus:
         script: build-hfsplus-linux.sh
         resources:
             - 'build/unix/build-hfsplus/build-hfsplus.sh'
         toolchain-artifact: public/build/hfsplus-tools.tar.xz
     fetches:
         fetch:
             - hfsplus-tools
         toolchain:
-            - linux64-clang-9
+            - linux64-clang-8
 
 linux64-libdmg:
     description: "libdmg-hfsplus toolchain build"
     treeherder:
         symbol: TL(libdmg-hfs+)
     run:
         script: build-libdmg-hfsplus.sh
         toolchain-artifact: public/build/dmg.tar.xz
--- a/taskcluster/ci/toolchain/sccache.yml
+++ b/taskcluster/ci/toolchain/sccache.yml
@@ -43,17 +43,17 @@ macosx64-sccache:
         arguments: ['x86_64-apple-darwin']
         resources:
             - 'taskcluster/scripts/misc/tooltool-download.sh'
         tooltool-downloads: internal
         toolchain-artifact: public/build/sccache.tar.xz
     fetches:
         toolchain:
             - linux64-rust-macos-1.34
-            - linux64-clang-9
+            - linux64-clang-8
             - linux64-cctools-port
             - linux64-llvm-dsymutil
             - linux64-binutils
 
 win64-sccache:
     treeherder:
         symbol: TW64(sccache)
     worker-type: b-win2012
rename from taskcluster/scripts/misc/build-clang-linux-macosx-cross.sh
rename to taskcluster/scripts/misc/build-clang-8-linux-macosx-cross.sh
--- a/tools/clang-tidy/config.yaml
+++ b/tools/clang-tidy/config.yaml
@@ -13,17 +13,17 @@ target: obj-x86_64-pc-linux-gnu
 # 5. Commit this file + the .cpp test case + the json result
 platforms:
   - linux64
   - macosx64
   - win32
   - win64
 # Minimum clang-tidy version that is required for all the following checkers
 # to work properly.
-package_version: "9.0.0"
+package_version: "8.0.1"
 clang_checkers:
   - name: -*
     publish: !!bool no
   - name: bugprone-argument-comment
     reliability: high
   - name: bugprone-assert-side-effect
     reliability: high
   - name: bugprone-bool-pointer-implicit-conversion
--- a/tools/clang-tidy/test/bugprone-string-constructor.json
+++ b/tools/clang-tidy/test/bugprone-string-constructor.json
@@ -1,1 +1,1 @@
-[["warning", "string constructor parameters are probably swapped; expecting string(count, character)", "bugprone-string-constructor"], ["warning", "length is bigger than string literal size", "bugprone-string-constructor"], ["warning", "constructor creating an empty string", "bugprone-string-constructor"], {"reliability": "high"}]
\ No newline at end of file
+[["warning", "string constructor parameters are probably swapped; expecting string(count, character)", "bugprone-string-constructor"], ["warning", "length is bigger then string literal size", "bugprone-string-constructor"], ["warning", "constructor creating an empty string", "bugprone-string-constructor"], {"reliability": "high"}]
\ No newline at end of file