commit 3797da9b1363edeb6866b85e7685813edeef325c Author: Nicolas Vigier boklm@torproject.org Date: Tue Mar 16 11:04:08 2021 +0100
Bug 40249: Bump mingw-w64 and clang for Firefox 78.9
https://hg.mozilla.org/releases/mozilla-esr78/rev/1b0e1f0d885e https://hg.mozilla.org/releases/mozilla-esr78/rev/d726d74daa39 https://hg.mozilla.org/releases/mozilla-esr78/rev/cc840a008393 --- projects/binutils/config | 5 + projects/clang-source/build | 10 +- projects/clang-source/config | 9 +- projects/clang-source/no-seh.patch | 145 -------------------------- projects/clang/build | 2 + projects/clang/config | 14 +++ projects/mingw-w64-clang/build | 4 + projects/mingw-w64-clang/config | 3 +- projects/mingw-w64-clang/mingw-dwrite_3.patch | 84 +++++++++++++++ projects/mingw-w64/config | 2 +- 10 files changed, 122 insertions(+), 156 deletions(-)
diff --git a/projects/binutils/config b/projects/binutils/config index 2367280..ad341ed 100644 --- a/projects/binutils/config +++ b/projects/binutils/config @@ -7,6 +7,11 @@ var: use_container: 1
targets: + # We use the windows-clang target for the binutils we use for building + # clang during windows builds. See projects/clang/config. + windows-clang: + var: + configure_opt: '--disable-multilib --enable-gold --enable-deterministic-archives --enable-plugins' windows: var: configure_opt: '--target=[% c("arch") %]-w64-mingw32 --disable-multilib --enable-deterministic-archives' diff --git a/projects/clang-source/build b/projects/clang-source/build index d94fcbe..227d614 100644 --- a/projects/clang-source/build +++ b/projects/clang-source/build @@ -10,22 +10,18 @@ tar -xf $rootdir/[% c('input_files_by_name/compiler-rt') %] tar -xf $rootdir/[% c('input_files_by_name/libunwind') %]
mv llvm-[% c("version") %].src llvm +[% IF ! c("var/windows") -%] # LLVM has reproducibility issues when optimizing bitcode, which we need to # patch. See: #32053 for more details. patch -p1 < $rootdir/43909.patch +[% END -%] mv clang-[% c("version") %].src llvm/tools/clang # Having clang-tidy available seems like a good idea mv clang-tools-extra-[% c("version") %].src llvm/tools/clang/tools/extra mv libcxx-[% c("version") %].src llvm/projects/libcxx mv libcxxabi-[% c("version") %].src llvm/projects/libcxxabi mv lld-[% c("version") %].src llvm/tools/lld -[% IF c("var/windows-i686") %] - # mingw-w64 does not support SEH on 32bit systems. Make it possible to - # explicitly disable it. - cd llvm/tools - patch -p1 < $rootdir/no-seh.patch - cd ../../ -[% END %] + mv compiler-rt-[% c("version") %].src llvm/projects/compiler-rt # We need libunwind only for mingw-w64-clang, don't include it as tightly by # putting it into projects/ diff --git a/projects/clang-source/config b/projects/clang-source/config index 8adb18e..a6dce85 100644 --- a/projects/clang-source/config +++ b/projects/clang-source/config @@ -4,6 +4,12 @@ filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz' gpg_keyring: clang.gpg sig_ext: sig
+targets: + windows: + # We use clang 11 for Windows builds: + # https://hg.mozilla.org/releases/mozilla-esr78/rev/cc840a008393 + version: 11.0.1 + input_files: - URL: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-%5B% c("version") %]/llvm-[% c("version") %].src.tar.xz' name: llvm @@ -30,5 +36,4 @@ input_files: name: libunwind file_gpg_id: 1 - filename: 43909.patch - - filename: no-seh.patch - enable: '[% c("var/windows-i686") %]' + enable: '[% ! c("var/windows") %]' diff --git a/projects/clang-source/no-seh.patch b/projects/clang-source/no-seh.patch deleted file mode 100644 index 1a52e40..0000000 --- a/projects/clang-source/no-seh.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 38cbe873d45cf3c881ef4113b48193edfd418f43 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Martin=20Storsj=C3=B6?= martin@martin.st -Date: Mon, 27 Jul 2020 23:44:41 +0300 -Subject: [PATCH] Implement the --no-seh flag - -Previously this flag was just ignored. If set, set the -IMAGE_DLL_CHARACTERISTICS_NO_SEH bit, regardless of the normal safeSEH -machinery. - -In mingw configurations, the safeSEH bit might not be set in e.g. object -files built from handwritten assembly, making it impossible to use the -normal safeseh flag. As mingw setups don't generally use SEH on 32 bit -x86 at all, it should be fine to set that flag bit though - hook up -the existing GNU ld flag for controlling that. - -Differential Revision: https://reviews.llvm.org/D84701 - -diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h -index 4b62cd05f4f..17ea0f8bcab 100644 ---- a/lld/COFF/Config.h -+++ b/lld/COFF/Config.h -@@ -135,6 +135,7 @@ struct Configuration { - bool safeSEH = false; - Symbol *sehTable = nullptr; - Symbol *sehCount = nullptr; -+ bool noSEH = false; - - // Used for /opt:lldlto=N - unsigned ltoo = 2; -diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp -index 15d6fb5121a..b569df07601 100644 ---- a/lld/COFF/Driver.cpp -+++ b/lld/COFF/Driver.cpp -@@ -1574,9 +1574,10 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) { - config->wordsize = config->is64() ? 8 : 4; - - // Handle /safeseh, x86 only, on by default, except for mingw. -- if (config->machine == I386 && -- args.hasFlag(OPT_safeseh, OPT_safeseh_no, !config->mingw)) -- config->safeSEH = true; -+ if (config->machine == I386) { -+ config->safeSEH = args.hasFlag(OPT_safeseh, OPT_safeseh_no, !config->mingw); -+ config->noSEH = args.hasArg(OPT_noseh); -+ } - - // Handle /functionpadmin - for (auto *arg : args.filtered(OPT_functionpadmin, OPT_functionpadmin_opt)) -diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td -index 024b7be8f78..c7e2a5ea57e 100644 ---- a/lld/COFF/Options.td -+++ b/lld/COFF/Options.td -@@ -171,6 +171,7 @@ def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">, - HelpText<"Add symbol as undefined, but allow it to remain undefined">; - def kill_at : F<"kill-at">; - def lldmingw : F<"lldmingw">; -+def noseh : F<"noseh">; - def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">; - def pdb_source_path : P<"pdbsourcepath", - "Base path used to make relative source file path absolute in PDB">; -diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp -index 5736281958f..aead781d38b 100644 ---- a/lld/COFF/Writer.cpp -+++ b/lld/COFF/Writer.cpp -@@ -1352,7 +1352,7 @@ template <typename PEHeaderTy> void Writer::writeHeader() { - pe->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_GUARD_CF; - if (config->integrityCheck) - pe->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY; -- if (setNoSEHCharacteristic) -+ if (setNoSEHCharacteristic || config->noSEH) - pe->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_NO_SEH; - if (config->terminalServerAware) - pe->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE; -diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp -index be1b757e45b..1d292817cfb 100644 ---- a/lld/MinGW/Driver.cpp -+++ b/lld/MinGW/Driver.cpp -@@ -249,6 +249,8 @@ bool mingw::link(ArrayRef<const char *> argsArr, raw_ostream &diag) { - add("-kill-at"); - if (args.hasArg(OPT_appcontainer)) - add("-appcontainer"); -+ if (args.hasArg(OPT_no_seh)) -+ add("-noseh"); - - if (args.getLastArgValue(OPT_m) != "thumb2pe" && - args.getLastArgValue(OPT_m) != "arm64pe" && !args.hasArg(OPT_dynamicbase)) -diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td -index 86400433d04..931cf264837 100644 ---- a/lld/MinGW/Options.td -+++ b/lld/MinGW/Options.td -@@ -45,6 +45,7 @@ def minor_subsystem_version_eq: Joined<["--"], "minor-subsystem-version=">, - Alias<minor_subsystem_version>; - def no_insert_timestamp: F<"no-insert-timestamp">, - HelpText<"Don't include PE header timestamp">; -+def no_seh: F<"no-seh">, HelpText<"Set the 'no SEH' flag in the executable">; - def no_whole_archive: F<"no-whole-archive">, - HelpText<"No longer include all object files for following archives">; - def large_address_aware: Flag<["--"], "large-address-aware">, -@@ -104,7 +105,6 @@ def: Flag<["--"], "full-shutdown">; - def: F<"high-entropy-va">; - def: S<"major-image-version">; - def: S<"minor-image-version">; --def: F<"no-seh">; - def: F<"nxcompat">; - def: F<"pic-executable">; - def: S<"plugin">; -diff --git a/lld/test/COFF/noseh.s b/lld/test/COFF/noseh.s -new file mode 100644 -index 00000000000..44295228622 ---- /dev/null -+++ b/lld/test/COFF/noseh.s -@@ -0,0 +1,19 @@ -+# REQUIRES: x86 -+# RUN: llvm-mc -triple i686-w64-mingw32 %s -filetype=obj -o %t.obj -+# RUN: lld-link -lldmingw %t.obj -out:%t.exe -entry:main -+# RUN: llvm-readobj --file-headers %t.exe | FileCheck %s --check-prefix=DEFAULT -+# RUN: lld-link -lldmingw %t.obj -out:%t.noseh.exe -entry:main -noseh -+# RUN: llvm-readobj --file-headers %t.noseh.exe | FileCheck %s --check-prefix=NOSEH -+ -+# DEFAULT: Characteristics [ -+# DEFAULT-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH -+# DEFAULT: ] -+ -+# NOSEH: Characteristics [ -+# NOSEH: IMAGE_DLL_CHARACTERISTICS_NO_SEH -+# NOSEH: ] -+ -+ .text -+ .globl _main -+_main: -+ ret -diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test -index b8bc2ddea8a..1d53205927b 100644 ---- a/lld/test/MinGW/driver.test -+++ b/lld/test/MinGW/driver.test -@@ -204,3 +204,7 @@ APPCONTAINER: -appcontainer - RUN: ld.lld -### -m i386pep foo.o -delayload user32.dll --delayload shell32.dll | FileCheck -check-prefix DELAYLOAD %s - RUN: ld.lld -### -m i386pep foo.o -delayload=user32.dll --delayload=shell32.dll | FileCheck -check-prefix DELAYLOAD %s - DELAYLOAD: -delayload:user32.dll -delayload:shell32.dll -+ -+RUN: ld.lld -### -m i386pe foo.o -no-seh | FileCheck -check-prefix NOSEH %s -+RUN: ld.lld -### -m i386pe foo.o --no-seh | FileCheck -check-prefix NOSEH %s -+NOSEH: -noseh --- -2.28.0 - diff --git a/projects/clang/build b/projects/clang/build index 33688e5..d4be3de 100644 --- a/projects/clang/build +++ b/projects/clang/build @@ -10,6 +10,8 @@ export PATH="/var/tmp/dist/cmake/bin:$PATH" [% pc('gcc', 'var/setup', { compiler_tarfile => c('input_files_by_name/gcc'), hardened_gcc => 0 }) %] ln -s gcc /var/tmp/dist/gcc/bin/cc +[% END -%] +[% IF c("var/linux") || c("var/windows") -%] tar -C /var/tmp/dist -xf [% c('input_files_by_name/binutils') %] export PATH="/var/tmp/dist/binutils/bin:$PATH" [% END -%] diff --git a/projects/clang/config b/projects/clang/config index 46d308a..623d213 100644 --- a/projects/clang/config +++ b/projects/clang/config @@ -6,6 +6,12 @@ var: container: use_container: 1
+targets: + windows: + # We use clang 11 for Windows builds: + # https://hg.mozilla.org/releases/mozilla-esr78/rev/cc840a008393 + version: 11.0.1 + input_files: - project: container-image - name: '[% c("var/compiler") %]' @@ -14,6 +20,14 @@ input_files: - name: binutils project: binutils enable: '[% c("var/linux") %]' + # We build our own binutils as the one from buster has a regression: + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=953423 + # https://sourceware.org/bugzilla/show_bug.cgi?id=24458 + - name: binutils + project: binutils + enable: '[% c("var/windows") %]' + target_prepend: + - windows-clang - project: cmake name: cmake - project: clang-source diff --git a/projects/mingw-w64-clang/build b/projects/mingw-w64-clang/build index 44a913f..974d2a9 100644 --- a/projects/mingw-w64-clang/build +++ b/projects/mingw-w64-clang/build @@ -60,6 +60,7 @@ default_win32_winnt=0x601
cd $builddir/mingw-w64-clang patch -p1 < $rootdir/mingw-winrt.patch +patch -p1 < $rootdir/mingw-dwrite_3.patch
cd mingw-w64-headers mkdir build && cd build @@ -164,6 +165,9 @@ cmake -DCMAKE_BUILD_TYPE=Release \ make -j[% c("buildconf/num_procs") %] VERBOSE=1
# libcxx +# the build expects ../llvm to exist so we add a symlink +# See https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/merge_req... +ln -s /var/tmp/build/clang-source /var/tmp/build/clang-source/projects/llvm cd $builddir/clang-source/projects/libcxx mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release \ diff --git a/projects/mingw-w64-clang/config b/projects/mingw-w64-clang/config index 1bf5954..080c75b 100644 --- a/projects/mingw-w64-clang/config +++ b/projects/mingw-w64-clang/config @@ -1,7 +1,7 @@ # vim: filetype=yaml sw=2 filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz' git_url: https://git.code.sf.net/p/mingw-w64/mingw-w64 -git_hash: 1b373beec6d07478ffba33726bb3bb21f32e4411 +git_hash: 660e09f3cb20f181b6d6435cb623d65a3922a063 version: '[% c("abbrev") %]'
var: @@ -23,3 +23,4 @@ input_files: - project: llvm-mingw name: llvm-mingw - filename: mingw-winrt.patch + - filename: mingw-dwrite_3.patch diff --git a/projects/mingw-w64-clang/mingw-dwrite_3.patch b/projects/mingw-w64-clang/mingw-dwrite_3.patch new file mode 100644 index 0000000..7c7b8c9 --- /dev/null +++ b/projects/mingw-w64-clang/mingw-dwrite_3.patch @@ -0,0 +1,84 @@ +From 86f4e9cbb5d3099179dc51332970d61d394116f6 Mon Sep 17 00:00:00 2001 +From: Sanketh Menda me@snkth.com +Date: Sat, 17 Oct 2020 15:39:42 -0400 +Subject: [PATCH] dwrite_3.h: rename GetGlyphImageFormats_ to + GetGlyphImageFormats + +Wine's WIDL currently doesn't support overloading functions, so till +that is fixed patch dwrite_3.h to rename GlyphImageFormats_ to +GetGlyphImageFormats. +--- + mingw-w64-headers/include/dwrite_3.h | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/mingw-w64-headers/include/dwrite_3.h b/mingw-w64-headers/include/dwrite_3.h +index 427c39e3b..dd894a8b1 100644 +--- a/mingw-w64-headers/include/dwrite_3.h ++++ b/mingw-w64-headers/include/dwrite_3.h +@@ -8168,7 +8168,7 @@ DEFINE_GUID(IID_IDWriteFontFace4, 0x27f2a904, 0x4eb8, 0x441d, 0x96,0x78, 0x05,0x + MIDL_INTERFACE("27f2a904-4eb8-441d-9678-0563f53e3e2f") + IDWriteFontFace4 : public IDWriteFontFace3 + { +- virtual HRESULT STDMETHODCALLTYPE GetGlyphImageFormats_( ++ virtual HRESULT STDMETHODCALLTYPE GetGlyphImageFormats( + UINT16 glyph, + UINT32 ppem_first, + UINT32 ppem_last, +@@ -8468,7 +8468,7 @@ typedef struct IDWriteFontFace4Vtbl { + WINBOOL *are_local); + + /*** IDWriteFontFace4 methods ***/ +- HRESULT (STDMETHODCALLTYPE *GetGlyphImageFormats_)( ++ HRESULT (STDMETHODCALLTYPE *GetGlyphImageFormats)( + IDWriteFontFace4 *This, + UINT16 glyph, + UINT32 ppem_first, +@@ -8549,7 +8549,7 @@ interface IDWriteFontFace4 { + #define IDWriteFontFace4_AreCharactersLocal(This,characters,count,enqueue_if_not,are_local) (This)->lpVtbl->AreCharactersLocal(This,characters,count,enqueue_if_not,are_local) + #define IDWriteFontFace4_AreGlyphsLocal(This,glyphs,count,enqueue_if_not,are_local) (This)->lpVtbl->AreGlyphsLocal(This,glyphs,count,enqueue_if_not,are_local) + /*** IDWriteFontFace4 methods ***/ +-#define IDWriteFontFace4_GetGlyphImageFormats_(This,glyph,ppem_first,ppem_last,formats) (This)->lpVtbl->GetGlyphImageFormats_(This,glyph,ppem_first,ppem_last,formats) ++#define IDWriteFontFace4_GetGlyphImageFormats(This,glyph,ppem_first,ppem_last,formats) (This)->lpVtbl->GetGlyphImageFormats(This,glyph,ppem_first,ppem_last,formats) + #define IDWriteFontFace4_GetGlyphImageFormats(This) (This)->lpVtbl->GetGlyphImageFormats(This) + #define IDWriteFontFace4_GetGlyphImageData(This,glyph,ppem,format,data,context) (This)->lpVtbl->GetGlyphImageData(This,glyph,ppem,format,data,context) + #define IDWriteFontFace4_ReleaseGlyphImageData(This,context) (This)->lpVtbl->ReleaseGlyphImageData(This,context) +@@ -8692,8 +8692,8 @@ static FORCEINLINE HRESULT IDWriteFontFace4_AreGlyphsLocal(IDWriteFontFace4* Thi + return This->lpVtbl->AreGlyphsLocal(This,glyphs,count,enqueue_if_not,are_local); + } + /*** IDWriteFontFace4 methods ***/ +-static FORCEINLINE HRESULT IDWriteFontFace4_GetGlyphImageFormats_(IDWriteFontFace4* This,UINT16 glyph,UINT32 ppem_first,UINT32 ppem_last,DWRITE_GLYPH_IMAGE_FORMATS *formats) { +- return This->lpVtbl->GetGlyphImageFormats_(This,glyph,ppem_first,ppem_last,formats); ++static FORCEINLINE HRESULT IDWriteFontFace4_GetGlyphImageFormats(IDWriteFontFace4* This,UINT16 glyph,UINT32 ppem_first,UINT32 ppem_last,DWRITE_GLYPH_IMAGE_FORMATS *formats) { ++ return This->lpVtbl->GetGlyphImageFormats(This,glyph,ppem_first,ppem_last,formats); + } + static FORCEINLINE DWRITE_GLYPH_IMAGE_FORMATS IDWriteFontFace4_GetGlyphImageFormats(IDWriteFontFace4* This) { + return This->lpVtbl->GetGlyphImageFormats(This); +@@ -9020,7 +9020,7 @@ typedef struct IDWriteFontFace5Vtbl { + WINBOOL *are_local); + + /*** IDWriteFontFace4 methods ***/ +- HRESULT (STDMETHODCALLTYPE *GetGlyphImageFormats_)( ++ HRESULT (STDMETHODCALLTYPE *GetGlyphImageFormats)( + IDWriteFontFace5 *This, + UINT16 glyph, + UINT32 ppem_first, +@@ -9121,7 +9121,7 @@ interface IDWriteFontFace5 { + #define IDWriteFontFace5_AreCharactersLocal(This,characters,count,enqueue_if_not,are_local) (This)->lpVtbl->AreCharactersLocal(This,characters,count,enqueue_if_not,are_local) + #define IDWriteFontFace5_AreGlyphsLocal(This,glyphs,count,enqueue_if_not,are_local) (This)->lpVtbl->AreGlyphsLocal(This,glyphs,count,enqueue_if_not,are_local) + /*** IDWriteFontFace4 methods ***/ +-#define IDWriteFontFace5_GetGlyphImageFormats_(This,glyph,ppem_first,ppem_last,formats) (This)->lpVtbl->GetGlyphImageFormats_(This,glyph,ppem_first,ppem_last,formats) ++#define IDWriteFontFace5_GetGlyphImageFormats(This,glyph,ppem_first,ppem_last,formats) (This)->lpVtbl->GetGlyphImageFormats(This,glyph,ppem_first,ppem_last,formats) + #define IDWriteFontFace5_GetGlyphImageFormats(This) (This)->lpVtbl->GetGlyphImageFormats(This) + #define IDWriteFontFace5_GetGlyphImageData(This,glyph,ppem,format,data,context) (This)->lpVtbl->GetGlyphImageData(This,glyph,ppem,format,data,context) + #define IDWriteFontFace5_ReleaseGlyphImageData(This,context) (This)->lpVtbl->ReleaseGlyphImageData(This,context) +@@ -9270,8 +9270,8 @@ static FORCEINLINE HRESULT IDWriteFontFace5_AreGlyphsLocal(IDWriteFontFace5* Thi + return This->lpVtbl->AreGlyphsLocal(This,glyphs,count,enqueue_if_not,are_local); + } + /*** IDWriteFontFace4 methods ***/ +-static FORCEINLINE HRESULT IDWriteFontFace5_GetGlyphImageFormats_(IDWriteFontFace5* This,UINT16 glyph,UINT32 ppem_first,UINT32 ppem_last,DWRITE_GLYPH_IMAGE_FORMATS *formats) { +- return This->lpVtbl->GetGlyphImageFormats_(This,glyph,ppem_first,ppem_last,formats); ++static FORCEINLINE HRESULT IDWriteFontFace5_GetGlyphImageFormats(IDWriteFontFace5* This,UINT16 glyph,UINT32 ppem_first,UINT32 ppem_last,DWRITE_GLYPH_IMAGE_FORMATS *formats) { ++ return This->lpVtbl->GetGlyphImageFormats(This,glyph,ppem_first,ppem_last,formats); + } + static FORCEINLINE DWRITE_GLYPH_IMAGE_FORMATS IDWriteFontFace5_GetGlyphImageFormats(IDWriteFontFace5* This) { + return This->lpVtbl->GetGlyphImageFormats(This); diff --git a/projects/mingw-w64/config b/projects/mingw-w64/config index b0ace13..c5dde82 100644 --- a/projects/mingw-w64/config +++ b/projects/mingw-w64/config @@ -1,7 +1,7 @@ # vim: filetype=yaml sw=2 filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz' git_url: https://git.code.sf.net/p/mingw-w64/mingw-w64 -git_hash: 1b373beec6d07478ffba33726bb3bb21f32e4411 +git_hash: 660e09f3cb20f181b6d6435cb623d65a3922a063 version: '[% c("abbrev") %]' var: container: