Bug 1512921 - Bump clang to trunk 348970 for Windows builds. r=dmajor
authorTom Ritter <tom@mozilla.com>
Tue, 27 Nov 2018 14:44:34 -0600
changeset 508360 585f7d2135eeaddf35d239c909ef43ffa37fa860
parent 508359 afab7f523f072f350733bc3e5ce96a0e76663cf1
child 508361 1f1ae5bf237747dc7c648a476e176bc850b15bce
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor
bugs1512921, 348970
milestone66.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 1512921 - Bump clang to trunk 348970 for Windows builds. r=dmajor This removes several patches that have been upstreamed.
build/build-clang/aarch64-vastart-checking.patch
build/build-clang/clang-win64.json
build/build-clang/r342649-hotpatch-8-byte-nops.patch
build/build-clang/r342652-unpoison-thread-stacks.patch
build/build-clang/r343123-pin-asan-dll.patch
build/build-clang/r346300-compiler-rt-windows-mmap.patch
js/src/old-configure.in
old-configure.in
deleted file mode 100644
--- a/build/build-clang/aarch64-vastart-checking.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-AArch64 Windows uses a five-argument __va_start, just like ARM.
-
-https://bugs.llvm.org/show_bug.cgi?id=39090
-
-diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
-index 22483f8..53d9cb2 100644
---- a/clang/lib/Sema/SemaChecking.cpp
-+++ b/clang/lib/Sema/SemaChecking.cpp
-@@ -917,6 +917,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
-     switch (Context.getTargetInfo().getTriple().getArch()) {
-     case llvm::Triple::arm:
-     case llvm::Triple::thumb:
-+    case llvm::Triple::aarch64:
-       if (SemaBuiltinVAStartARMMicrosoft(TheCall))
-         return ExprError();
-       break;
--- a/build/build-clang/clang-win64.json
+++ b/build/build-clang/clang-win64.json
@@ -1,26 +1,22 @@
 {
-    "llvm_revision": "342383",
+    "llvm_revision": "348970",
     "stages": "3",
     "build_libcxx": false,
     "build_type": "Release",
     "assertions": false,
-    "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_700/final",
-    "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_700/final",
-    "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_700/final",
-    "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_700/final",
-    "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_700/final",
+    "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/trunk",
+    "clang_repo": "https://llvm.org/svn/llvm-project/cfe/trunk",
+    "lld_repo": "https://llvm.org/svn/llvm-project/lld/trunk",
+    "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/trunk",
+    "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/trunk",
     "python_path": "c:/mozilla-build/python/python.exe",
     "cc": "cl.exe",
     "cxx": "cl.exe",
     "ml": "ml64.exe",
     "patches": [
       "workaround-issue38586.patch",
-      "r342649-hotpatch-8-byte-nops.patch",
       "r342652-unpoison-thread-stacks.patch",
-      "r343123-pin-asan-dll.patch",
-      "aarch64-vastart-checking.patch",
       "downgrade-mangling-error.patch",
-      "r346300-compiler-rt-windows-mmap.patch",
       "loosen-msvc-detection.patch"
     ]
 }
deleted file mode 100644
--- a/build/build-clang/r342649-hotpatch-8-byte-nops.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-[winasan] Reduce hotpatch prefix check to 8 bytes
-
-Same idea as r310419: The 8 byte nop is a suffix of the 9 byte nop, and we need at most 6 bytes.
-
-Differential Revision: https://reviews.llvm.org/D51788
-
---- a/compiler-rt/lib/interception/interception_win.cc	(revision 342648)
-+++ b/compiler-rt/lib/interception/interception_win.cc	(revision 342649)
-@@ -223,8 +223,8 @@
-   return true;
- }
- 
--static const u8 kHintNop9Bytes[] = {
--  0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
-+static const u8 kHintNop8Bytes[] = {
-+  0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
- };
- 
- template<class T>
-@@ -239,8 +239,8 @@
- static bool FunctionHasPadding(uptr address, uptr size) {
-   if (IsMemoryPadding(address - size, size))
-     return true;
--  if (size <= sizeof(kHintNop9Bytes) &&
--      FunctionHasPrefix(address, kHintNop9Bytes))
-+  if (size <= sizeof(kHintNop8Bytes) &&
-+      FunctionHasPrefix(address, kHintNop8Bytes))
-     return true;
-   return false;
- }
--- a/build/build-clang/r342652-unpoison-thread-stacks.patch
+++ b/build/build-clang/r342652-unpoison-thread-stacks.patch
@@ -16,18 +16,18 @@ Differential Revision: https://reviews.l
 +  uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit;
 +  __asan_unpoison_memory_region(tib->StackLimit, stackSize);
 +  return REAL(NtTerminateThread(rcx));
 +}
 +
  // }}}
  
  namespace __asan {
-@@ -161,7 +169,9 @@
- void InitializePlatformInterceptors() {
+@@ -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);
deleted file mode 100644
--- a/build/build-clang/r343123-pin-asan-dll.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-------------------------------------------------------------------------
-r343123 | dmajor | 2018-09-26 12:28:39 -0400 (Wed, 26 Sep 2018) | 5 lines
-
-[winasan] Pin the ASan DLL to prevent unloading
-
-Differential Revision: https://reviews.llvm.org/D52505
-
-===================================================================
---- a/compiler-rt/lib/asan/asan_win.cc	(revision 343122)
-+++ b/compiler-rt/lib/asan/asan_win.cc	(revision 343123)
-@@ -167,6 +167,14 @@
- namespace __asan {
- 
- void InitializePlatformInterceptors() {
-+  // The interceptors were not designed to be removable, so we have to keep this
-+  // module alive for the life of the process.
-+  HMODULE pinned;
-+  CHECK(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
-+                           GET_MODULE_HANDLE_EX_FLAG_PIN,
-+                           (LPCWSTR)&InitializePlatformInterceptors,
-+                           &pinned));
-+
-   ASAN_INTERCEPT_FUNC(CreateThread);
-   ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);
-   CHECK(::__interception::OverrideFunction("NtTerminateThread",
-
-------------------------------------------------------------------------
deleted file mode 100644
--- a/build/build-clang/r346300-compiler-rt-windows-mmap.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-From 0b881f23c6f2a637ab97d71e964cc3743fef98b8 Mon Sep 17 00:00:00 2001
-From: Marco Castelluccio <mcastelluccio@mozilla.com>
-Date: Wed, 7 Nov 2018 09:38:26 +0000
-Subject: [PATCH] [GCOV] Close file mapping handle on Windows, so flushed gcda
- files can be removed while the process is in execution
-
-git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@346300 91177308-0d34-0410-b5e6-96231b3b80d8
----
- lib/profile/GCDAProfiling.c                   | 49 +++++++++++++++++++
- lib/profile/WindowsMMap.c                     |  8 ---
- lib/profile/WindowsMMap.h                     |  8 +++
- .../instrprof-gcov-__gcov_flush-multiple.c    | 16 ++++++
- ...nstrprof-gcov-__gcov_flush-multiple.c.gcov | 21 ++++++++
- .../instrprof-gcov-__gcov_flush-multiple.test | 10 ++++
- 6 files changed, 104 insertions(+), 8 deletions(-)
- create mode 100644 test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c
- create mode 100644 test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov
- create mode 100644 test/profile/instrprof-gcov-__gcov_flush-multiple.test
-
-diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
-index cbca36551..0665a680c 100644
---- a/compiler-rt/lib/profile/GCDAProfiling.c
-+++ b/compiler-rt/lib/profile/GCDAProfiling.c
-@@ -29,6 +29,8 @@
- #include <string.h>
- 
- #if defined(_WIN32)
-+#define WIN32_LEAN_AND_MEAN
-+#include <windows.h>
- #include "WindowsMMap.h"
- #else
- #include <sys/mman.h>
-@@ -86,6 +88,9 @@ static uint64_t cur_buffer_size = 0;
- static uint64_t cur_pos = 0;
- static uint64_t file_size = 0;
- static int new_file = 0;
-+#if defined(_WIN32)
-+static HANDLE mmap_handle = NULL;
-+#endif
- static int fd = -1;
- 
- typedef void (*fn_ptr)();
-@@ -255,6 +260,28 @@ static int map_file() {
-   if (file_size == 0)
-     return -1;
- 
-+#if defined(_WIN32)
-+  HANDLE mmap_fd;
-+  if (fd == -1)
-+    mmap_fd = INVALID_HANDLE_VALUE;
-+  else
-+    mmap_fd = (HANDLE)_get_osfhandle(fd);
-+
-+  mmap_handle = CreateFileMapping(mmap_fd, NULL, PAGE_READWRITE, DWORD_HI(file_size), DWORD_LO(file_size), NULL);
-+  if (mmap_handle == NULL) {
-+    fprintf(stderr, "profiling: %s: cannot create file mapping: %d\n", filename,
-+            GetLastError());
-+    return -1;
-+  }
-+
-+  write_buffer = MapViewOfFile(mmap_handle, FILE_MAP_WRITE, 0, 0, file_size);
-+  if (write_buffer == NULL) {
-+    fprintf(stderr, "profiling: %s: cannot map: %d\n", filename,
-+            GetLastError());
-+    CloseHandle(mmap_handle);
-+    return -1;
-+  }
-+#else
-   write_buffer = mmap(0, file_size, PROT_READ | PROT_WRITE,
-                       MAP_FILE | MAP_SHARED, fd, 0);
-   if (write_buffer == (void *)-1) {
-@@ -263,10 +290,30 @@ static int map_file() {
-             strerror(errnum));
-     return -1;
-   }
-+#endif
-+
-   return 0;
- }
- 
- static void unmap_file() {
-+#if defined(_WIN32)
-+  if (!FlushViewOfFile(write_buffer, file_size)) {
-+    fprintf(stderr, "profiling: %s: cannot flush mapped view: %d\n", filename,
-+            GetLastError());
-+  }
-+
-+  if (!UnmapViewOfFile(write_buffer)) {
-+    fprintf(stderr, "profiling: %s: cannot unmap mapped view: %d\n", filename,
-+            GetLastError());
-+  }
-+
-+  if (!CloseHandle(mmap_handle)) {
-+    fprintf(stderr, "profiling: %s: cannot close file mapping handle: %d\n", filename,
-+            GetLastError());
-+  }
-+
-+  mmap_handle = NULL;
-+#else
-   if (msync(write_buffer, file_size, MS_SYNC) == -1) {
-     int errnum = errno;
-     fprintf(stderr, "profiling: %s: cannot msync: %s\n", filename,
-@@ -277,6 +324,8 @@ static void unmap_file() {
-    * is written and we don't care.
-    */
-   (void)munmap(write_buffer, file_size);
-+#endif
-+
-   write_buffer = NULL;
-   file_size = 0;
- }
-diff --git a/compiler-rt/lib/profile/WindowsMMap.c b/compiler-rt/lib/profile/WindowsMMap.c
-index dc87a888a..41cc67f41 100644
---- a/compiler-rt/lib/profile/WindowsMMap.c
-+++ b/compiler-rt/lib/profile/WindowsMMap.c
-@@ -24,14 +24,6 @@
- 
- #include "InstrProfiling.h"
- 
--#ifdef __USE_FILE_OFFSET64
--# define DWORD_HI(x) (x >> 32)
--# define DWORD_LO(x) ((x) & 0xffffffff)
--#else
--# define DWORD_HI(x) (0)
--# define DWORD_LO(x) (x)
--#endif
--
- COMPILER_RT_VISIBILITY
- void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
- {
-diff --git a/compiler-rt/lib/profile/WindowsMMap.h b/compiler-rt/lib/profile/WindowsMMap.h
-index ac2c911c8..51a130b31 100644
---- a/compiler-rt/lib/profile/WindowsMMap.h
-+++ b/compiler-rt/lib/profile/WindowsMMap.h
-@@ -45,6 +45,14 @@
- #define   LOCK_NB   4    /* don't block when locking */
- #define   LOCK_UN   8    /* unlock */
- 
-+#ifdef __USE_FILE_OFFSET64
-+# define DWORD_HI(x) (x >> 32)
-+# define DWORD_LO(x) ((x) & 0xffffffff)
-+#else
-+# define DWORD_HI(x) (0)
-+# define DWORD_LO(x) (x)
-+#endif
-+
- void *mmap(void *start, size_t length, int prot, int flags, int fd,
-            off_t offset);
- 
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -671,16 +671,19 @@ case "$target" in
           changequote([,])
         fi
         dnl VS2013+ supports -Gw for better linker optimizations.
         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
         dnl Disabled on ASan because it causes false-positive ODR violations.
         if test -z "$MOZ_ASAN"; then
             CFLAGS="$CFLAGS -Gw"
             CXXFLAGS="$CXXFLAGS -Gw"
+        else
+            # String tail merging doesn't play nice with ASan's ODR checker.
+            LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
         fi
         # khuey says we can safely ignore MSVC warning C4251
         # MSVC warning C4244 (implicit type conversion may lose data) warns
         # and requires workarounds for perfectly valid code.  Also, GCC/clang
         # don't warn about it by default. So for consistency/sanity, we turn
         # it off on MSVC, too.
         # MSVC warning C4267 warns for narrowing type conversions from size_t
         # to 32-bit integer types on 64-bit platforms.  Since this is virtually
--- a/old-configure.in
+++ b/old-configure.in
@@ -823,16 +823,19 @@ case "$target" in
             SSSE3_FLAGS="-mssse3"
         fi
         dnl VS2013+ supports -Gw for better linker optimizations.
         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
         dnl Disabled on ASan because it causes false-positive ODR violations.
         if test -z "$MOZ_ASAN"; then
             CFLAGS="$CFLAGS -Gw"
             CXXFLAGS="$CXXFLAGS -Gw"
+        else
+            # String tail merging doesn't play nice with ASan's ODR checker.
+            LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
         fi
         # khuey says we can safely ignore MSVC warning C4251
         # MSVC warning C4244 (implicit type conversion may lose data) warns
         # and requires workarounds for perfectly valid code.  Also, GCC/clang
         # don't warn about it by default. So for consistency/sanity, we turn
         # it off on MSVC, too.
         # MSVC warning C4267 warns for narrowing type conversions from size_t
         # to 32-bit integer types on 64-bit platforms.  Since this is virtually