Backed out 2 changesets (bug 1485016, bug 1512921) as requested by tjr.
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Fri, 21 Dec 2018 05:59:24 +0200
changeset 451643 644731a71be81b31a049deee70170af3ca36efa1
parent 451642 c54772c2aac13902e818ffc007488378fc4c1af3
child 451644 2a2c0b1ebd5c5a8add518189b96456bd3380b134
push id35248
push userebalazs@mozilla.com
push dateFri, 21 Dec 2018 09:37:52 +0000
treeherdermozilla-central@e16b548dc14c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1485016, 1512921
milestone66.0a1
backs out61ae84746b34535c11ebe99081aafe5e07fb7c91
585f7d2135eeaddf35d239c909ef43ffa37fa860
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 1485016, bug 1512921) as requested by tjr. Backed out changeset 61ae84746b34 (bug 1485016) Backed out changeset 585f7d2135ee (bug 1512921)
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
build/moz.configure/toolchain.configure
js/src/old-configure.in
old-configure.in
new file mode 100644
--- /dev/null
+++ b/build/build-clang/aarch64-vastart-checking.patch
@@ -0,0 +1,16 @@
+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,22 +1,26 @@
 {
-    "llvm_revision": "348970",
+    "llvm_revision": "342383",
     "stages": "3",
     "build_libcxx": false,
     "build_type": "Release",
     "assertions": false,
-    "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",
+    "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",
     "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"
     ]
 }
new file mode 100644
--- /dev/null
+++ b/build/build-clang/r342649-hotpatch-8-byte-nops.patch
@@ -0,0 +1,30 @@
+[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 {
-@@ -169,7 +177,9 @@
-
+@@ -161,7 +169,9 @@
+ void InitializePlatformInterceptors() {
    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);
new file mode 100644
--- /dev/null
+++ b/build/build-clang/r343123-pin-asan-dll.patch
@@ -0,0 +1,27 @@
+------------------------------------------------------------------------
+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",
+
+------------------------------------------------------------------------
new file mode 100644
--- /dev/null
+++ b/build/build-clang/r346300-compiler-rt-windows-mmap.patch
@@ -0,0 +1,149 @@
+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/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1596,18 +1596,16 @@ option('--enable-hardening', env='MOZ_SE
 
 @depends('--enable-hardening', '--enable-address-sanitizer',
          '--enable-optimize', c_compiler, target)
 def security_hardening_cflags(hardening_flag, asan, optimize, c_compiler, target):
     compiler_is_gccish = c_compiler.type in ('gcc', 'clang')
 
     flags = []
     js_flags = []
-    ldflags = []
-    js_ldflags = []
 
     # FORTIFY_SOURCE ------------------------------------
     # If hardening is explicitly enabled, or not explicitly disabled
     if hardening_flag.origin == "default" or hardening_flag:
         # Require optimization for FORTIFY_SOURCE. See Bug 1417452
         # Also, undefine it before defining it just in case a distro adds it, see Bug 1418398
         if compiler_is_gccish and optimize and not asan:
             # Don't enable FORTIFY_SOURCE on Android on the top-level, but do enable in js/
@@ -1620,49 +1618,37 @@ def security_hardening_cflags(hardening_
         # fstack-protector ------------------------------------
         # Enable only if hardening is not disabled and ASAN is
         # not on as ASAN will catch the crashes for us
         if compiler_is_gccish and not asan:
             # mingw-clang cross-compile toolchain has bugs with stack protector
             if target.os != 'WINNT' or c_compiler == 'gcc':
                 flags.append("-fstack-protector-strong")
 
-        if c_compiler.type == 'clang-cl':
-            flags.append("-guard:cf")
-            js_flags.append("-guard:cf")
-            # nolongjmp is needed because clang doesn't emit the CFG tables of
-            # setjmp return addresses https://bugs.llvm.org/show_bug.cgi?id=40057
-            ldflags.append("-guard:cf,nolongjmp")
-            js_ldflags.append("-guard:cf,nolongjmp")
-
     # If ASAN _is_ on, undefine FOTIFY_SOURCE just to be safe
     if asan:
         flags.append("-U_FORTIFY_SOURCE")
         js_flags.append("-U_FORTIFY_SOURCE")
 
     # fno-common -----------------------------------------
     # Do not merge variables for ASAN; can detect some subtle bugs
     if asan:
         # clang-cl does not recognize the flag, it must be passed down to clang
         if c_compiler.type == 'clang-cl':
             flags.append("-Xclang")
         flags.append("-fno-common")
 
     return namespace(
         flags=flags,
-        ldflags=ldflags,
         js_flags=js_flags,
-        js_ldflags=js_ldflags,
     )
 
 
 add_old_configure_assignment('MOZ_HARDENING_CFLAGS', security_hardening_cflags.flags)
-add_old_configure_assignment('MOZ_HARDENING_LDFLAGS', security_hardening_cflags.ldflags)
 add_old_configure_assignment('MOZ_HARDENING_CFLAGS_JS', security_hardening_cflags.js_flags)
-add_old_configure_assignment('MOZ_HARDENING_LDFLAGS_JS', security_hardening_cflags.js_ldflags)
 
 # Code Coverage
 # ==============================================================
 
 js_option('--enable-coverage', env='MOZ_CODE_COVERAGE',
           help='Enable code coverage')
 
 
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -514,17 +514,16 @@ esac
 
 dnl ========================================================
 dnl Add optional and non-optional hardening flags from toolchain.configure
 dnl ========================================================
 
 CFLAGS="$CFLAGS $MOZ_HARDENING_CFLAGS_JS"
 CPPFLAGS="$CPPFLAGS $MOZ_HARDENING_CFLAGS_JS"
 CXXFLAGS="$CXXFLAGS $MOZ_HARDENING_CFLAGS_JS"
-LDFLAGS="$LDFLAGS $MOZ_HARDENING_LDFLAGS_JS"
 
 dnl ========================================================
 dnl System overrides of the defaults for target
 dnl ========================================================
 
 case "$target" in
 *-darwin*)
     MOZ_OPTIMIZE_FLAGS="-O3"
@@ -672,19 +671,16 @@ 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
@@ -399,17 +399,16 @@ fi
 
 dnl ========================================================
 dnl Add optional and non-optional hardening flags
 dnl ========================================================
 
 CFLAGS="$CFLAGS $MOZ_HARDENING_CFLAGS"
 CPPFLAGS="$CPPFLAGS $MOZ_HARDENING_CFLAGS"
 CXXFLAGS="$CXXFLAGS $MOZ_HARDENING_CFLAGS"
-LDFLAGS="$LDFLAGS $MOZ_HARDENING_LDFLAGS"
 
 dnl ========================================================
 dnl GNU specific defaults
 dnl ========================================================
 if test "$GNU_CC"; then
     MMX_FLAGS="-mmmx"
     SSE_FLAGS="-msse"
     SSE2_FLAGS="-msse2"
@@ -824,19 +823,16 @@ 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