From 90b4b511f2f94f9cd2a7a15f83aaba1ec8d2ece8 Mon Sep 17 00:00:00 2001 From: David Major Date: Thu, 24 Jan 2019 15:03:52 +0000 Subject: [PATCH] Bug 1521129 - Bump clang-cl to 8.0.0 rc1 r=glandium Differential Revision: https://phabricator.services.mozilla.com/D17009 --HG-- rename : build/build-clang/r342652-unpoison-thread-stacks.patch => build/build-clang/unpoison-thread-stacks.patch extra : moz-landing-system : lando --- .../aarch64-vastart-checking.patch | 16 -- build/build-clang/clang-win64.json | 21 +-- .../r342649-hotpatch-8-byte-nops.patch | 30 ---- build/build-clang/r343123-pin-asan-dll.patch | 27 ---- .../r346300-compiler-rt-windows-mmap.patch | 149 ------------------ ...cks.patch => unpoison-thread-stacks.patch} | 4 +- build/moz.configure/toolchain.configure | 2 + 7 files changed, 12 insertions(+), 237 deletions(-) delete mode 100644 build/build-clang/aarch64-vastart-checking.patch delete mode 100644 build/build-clang/r342649-hotpatch-8-byte-nops.patch delete mode 100644 build/build-clang/r343123-pin-asan-dll.patch delete mode 100644 build/build-clang/r346300-compiler-rt-windows-mmap.patch rename build/build-clang/{r342652-unpoison-thread-stacks.patch => unpoison-thread-stacks.patch} (95%) diff --git a/build/build-clang/aarch64-vastart-checking.patch b/build/build-clang/aarch64-vastart-checking.patch deleted file mode 100644 index d7586dad4b7f..000000000000 --- 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; diff --git a/build/build-clang/clang-win64.json b/build/build-clang/clang-win64.json index b7a34ab30f07..1144d457c46f 100644 --- a/build/build-clang/clang-win64.json +++ b/build/build-clang/clang-win64.json @@ -1,27 +1,22 @@ { - "llvm_revision": "349247", + "llvm_revision": "352000", "stages": "3", "build_libcxx": false, "build_type": "Release", "assertions": false, - "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_701/final", - "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_701/final", - "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_701/final", - "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_701/final", - "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_701/final", + "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_800/rc1", + "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_800/rc1", + "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_800/rc1", + "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_800/rc1", + "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_800/rc1", "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", + "unpoison-thread-stacks.patch", "downgrade-mangling-error.patch", - "r346300-compiler-rt-windows-mmap.patch", - "loosen-msvc-detection.patch", - "r350774.patch" + "loosen-msvc-detection.patch" ] } diff --git a/build/build-clang/r342649-hotpatch-8-byte-nops.patch b/build/build-clang/r342649-hotpatch-8-byte-nops.patch deleted file mode 100644 index baa154dde96b..000000000000 --- 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 -@@ -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; - } diff --git a/build/build-clang/r343123-pin-asan-dll.patch b/build/build-clang/r343123-pin-asan-dll.patch deleted file mode 100644 index 27ba517e43f3..000000000000 --- 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", - ------------------------------------------------------------------------- diff --git a/build/build-clang/r346300-compiler-rt-windows-mmap.patch b/build/build-clang/r346300-compiler-rt-windows-mmap.patch deleted file mode 100644 index 1558a407876c..000000000000 --- 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 -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 - - #if defined(_WIN32) -+#define WIN32_LEAN_AND_MEAN -+#include - #include "WindowsMMap.h" - #else - #include -@@ -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); - diff --git a/build/build-clang/r342652-unpoison-thread-stacks.patch b/build/build-clang/unpoison-thread-stacks.patch similarity index 95% rename from build/build-clang/r342652-unpoison-thread-stacks.patch rename to build/build-clang/unpoison-thread-stacks.patch index caa6c3ad6425..375732b91d2f 100644 --- a/build/build-clang/r342652-unpoison-thread-stacks.patch +++ b/build/build-clang/unpoison-thread-stacks.patch @@ -21,8 +21,8 @@ Differential Revision: https://reviews.llvm.org/D52091 // }}} namespace __asan { -@@ -161,7 +169,9 @@ - void InitializePlatformInterceptors() { +@@ -169,7 +177,9 @@ + ASAN_INTERCEPT_FUNC(CreateThread); ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter); - diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 57a47836f342..f69bb6c03a18 100755 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -1605,6 +1605,8 @@ def lto(value, pgo, c_compiler): cflags.append("-flto") else: cflags.append("-flto=thin") + # Workaround for https://bugs.llvm.org/show_bug.cgi?id=40414 + cflags.append("-fsplit-lto-unit") # With clang-cl, -flto can only be used with -c or -fuse-ld=lld. # AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld. cflags.append("-fuse-ld=lld");