[tbb-commits] [tor-browser-build/master] Bug 23228: add support for building mingw-w64 for Windows 64

gk at torproject.org gk at torproject.org
Mon Nov 6 09:47:27 UTC 2017


commit b82d82d9cf9cb751e088085fb1093026b20a0e4d
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Sat Aug 12 22:50:58 2017 +0200

    Bug 23228: add support for building mingw-w64 for Windows 64
    
    Add torbrowser-windows-x86_64 support to rbm.conf.
    
    Update mingw-w64 to use the x86_64-w64-mingw32 target (instead of
    i686-w64-mingw32) for torbrowser-windows-x86_64 builds.
---
 projects/binutils/64bit-fixups.patch    | 55 +++++++++++++++++++++++++++++++++
 projects/binutils/build                 |  7 +++--
 projects/binutils/config                |  6 ++--
 projects/mingw-w64/build                | 32 +++++++++++++------
 projects/mingw-w64/config               | 15 ++++++---
 projects/mingw-w64/i686-w64-mingw32-g++ |  4 ---
 projects/mingw-w64/i686-w64-mingw32-gcc |  4 ---
 projects/mingw-w64/i686-w64-mingw32-ld  |  4 ---
 rbm.conf                                | 33 ++++++++++++++------
 9 files changed, 122 insertions(+), 38 deletions(-)

diff --git a/projects/binutils/64bit-fixups.patch b/projects/binutils/64bit-fixups.patch
new file mode 100644
index 0000000..33c0297
--- /dev/null
+++ b/projects/binutils/64bit-fixups.patch
@@ -0,0 +1,55 @@
+From f3ba95e14437f10de8b8f296930ff2a8495d18c6 Mon Sep 17 00:00:00 2001
+From: Georg Koppen <gk at torproject.org>
+Date: Tue, 12 Sep 2017 07:21:16 +0000
+Subject: [PATCH] 64bit fixups
+
+
+diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
+index b566903b14..27006bdf79 100644
+--- a/ld/emultempl/pep.em
++++ b/ld/emultempl/pep.em
+@@ -730,7 +730,7 @@ gld${EMULATION_NAME}_handle_option (int optc)
+       pep_dll_exclude_all_symbols = 1;
+       break;
+     case OPTION_ENABLE_RELOC_SECTION:
+-      pe_dll_enable_reloc_section = 1;
++      pep_dll_enable_reloc_section = 1;
+       break;
+     case OPTION_EXCLUDE_LIBS:
+       pep_dll_add_excludes (optarg, EXCLUDELIBS);
+@@ -1623,7 +1623,7 @@ gld_${EMULATION_NAME}_finish (void)
+ 
+ #ifdef DLL_SUPPORT
+   if (link_info.shared
+-      || (!link_info.relocatable && pe_dll_enable_reloc_section)
++      || (!link_info.relocatable && pep_dll_enable_reloc_section)
+       || (!link_info.relocatable && pep_def_file->num_exports != 0))
+     {
+       pep_dll_fill_sections (link_info.output_bfd, &link_info);
+diff --git a/ld/pep-dll.c b/ld/pep-dll.c
+index 0e5e8b1523..b5f99b90e0 100644
+--- a/ld/pep-dll.c
++++ b/ld/pep-dll.c
+@@ -31,6 +31,7 @@
+ #define pe_dll_export_everything    pep_dll_export_everything
+ #define pe_dll_exclude_all_symbols  pep_dll_exclude_all_symbols
+ #define pe_dll_do_default_excludes  pep_dll_do_default_excludes
++#define pe_dll_enable_reloc_section pep_dll_enable_reloc_section
+ #define pe_dll_kill_ats             pep_dll_kill_ats
+ #define pe_dll_stdcall_aliases      pep_dll_stdcall_aliases
+ #define pe_dll_warn_dup_exports     pep_dll_warn_dup_exports
+diff --git a/ld/pep-dll.h b/ld/pep-dll.h
+index 1e7e3d65d4..c31e69cc8e 100644
+--- a/ld/pep-dll.h
++++ b/ld/pep-dll.h
+@@ -31,6 +31,7 @@ extern def_file * pep_def_file;
+ extern int pep_dll_export_everything;
+ extern int pep_dll_exclude_all_symbols;
+ extern int pep_dll_do_default_excludes;
++extern int pep_dll_enable_reloc_section;
+ extern int pep_dll_kill_ats;
+ extern int pep_dll_stdcall_aliases;
+ extern int pep_dll_warn_dup_exports;
+-- 
+2.14.1
+
diff --git a/projects/binutils/build b/projects/binutils/build
index a7d83d9..6d8e0b2 100644
--- a/projects/binutils/build
+++ b/projects/binutils/build
@@ -21,10 +21,13 @@ cd [% project %]-[% c("version") %]
 [% IF c('var/windows') -%]
   # XXX: This is needed due to bug 10102.
   sed 's/= extern_rt_rel_d;/= extern_rt_rel_d;\n  memset (extern_rt_rel_d, 0, PE_IDATA5_SIZE);/' -i ld/pe-dll.c
-  # Needed for the hardening...
-  patch -p1 < ../enable-reloc-section-ld.patch
   # Zeroing timestamps in PE headers reliably, see bug 12753.
   patch -p1 < ../peXXigen.patch
+  # Needed for the hardening...
+  patch -p1 < ../enable-reloc-section-ld.patch
+[% END -%]
+[% IF c('var/windows-x86_64') -%]
+  patch -p1 < ../64bit-fixups.patch
 [% END -%]
 [% IF c("var/linux") -%]
   # We need to work around a gold linker bug in 2.24 to get selfrando working,
diff --git a/projects/binutils/config b/projects/binutils/config
index f272c76..25417c0 100644
--- a/projects/binutils/config
+++ b/projects/binutils/config
@@ -7,9 +7,9 @@ var:
     use_container: 1
 
 targets:
-  windows-i686:
+  windows:
     var:
-      configure_opt: '--target=i686-w64-mingw32 --disable-multilib --enable-deterministic-archives'
+      configure_opt: '--target=[% c("arch") %]-w64-mingw32 --disable-multilib --enable-deterministic-archives'
 
 input_files:
   - URL: https://ftp.gnu.org/gnu/binutils/binutils-[% c("version") %].tar.bz2
@@ -19,6 +19,8 @@ input_files:
   - project: container-image
   - filename: enable-reloc-section-ld.patch
     enable: '[% c("var/windows") %]'
+  - filename: 64bit-fixups.patch
+    enable: '[% c("var/windows-x86_64") %]'
   - filename: peXXigen.patch
     enable: '[% c("var/windows") %]'
   - filename: binutils-224-gold.patch
diff --git a/projects/mingw-w64/build b/projects/mingw-w64/build
index 0fc4517..8d3e567 100644
--- a/projects/mingw-w64/build
+++ b/projects/mingw-w64/build
@@ -14,7 +14,7 @@ tar xf $rootdir/[% project %]-[% c("version") %].tar.gz
 mkdir -p builddir/mingw-w64/mingw-w64-headers32
 cd builddir/mingw-w64/mingw-w64-headers32
 /var/tmp/build/[% project %]-[% c("version") %]/mingw-w64-headers/configure \
-                --prefix=$distdir/i686-w64-mingw32 --host=i686-w64-mingw32 \
+                --prefix=$distdir/[% c("arch") %]-w64-mingw32 --host=[% c("arch") %]-w64-mingw32 \
                 --enable-sdk=all --enable-secure-api --enable-idl
 make install
 
@@ -23,28 +23,28 @@ mkdir gcc
 cd gcc
 tar xjf $rootdir/gcc-[% c("var/gcc_version") %].tar.bz2
 # We don't want to link against msvcrt.dll due to bug 9084.
-i686-w64-mingw32-g++ -dumpspecs > $distdir/msvcr100.spec
+[% c("arch") %]-w64-mingw32-g++ -dumpspecs > $distdir/msvcr100.spec
 sed 's/msvcrt/msvcr100/' -i $distdir/msvcr100.spec
 # Linking libgcc against msvcrt is hard-coded...
 sed 's/msvcrt/msvcr100/' -i gcc-[% c("var/gcc_version") %]/gcc/config/i386/t-mingw-w32
 # LDFLAGS_FOR_TARGET does not work for some reason. Thus, we take
 # CFLAGS_FOR_TARGET.
 export CFLAGS_FOR_TARGET="-specs=$distdir/msvcr100.spec -Wl,--nxcompat -Wl,--dynamicbase"
-gcc-[% c("var/gcc_version") %]/configure --prefix=$distdir --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++
+gcc-[% c("var/gcc_version") %]/configure --prefix=$distdir --target=[% c("arch") %]-w64-mingw32 --disable-multilib --enable-languages=c,c++
 make -j[% c("buildconf/num_procs") %] all-gcc
 make install-gcc
 
 mkdir -p /var/tmp/build/builddir/mingw-w64/mingw-w64-crt32
 cd /var/tmp/build/builddir/mingw-w64/mingw-w64-crt32
 /var/tmp/build/[% project %]-[% c("version") %]/mingw-w64-crt/configure \
-                 --host=i686-w64-mingw32 --prefix=$distdir/i686-w64-mingw32
+                 --host=[% c("arch") %]-w64-mingw32 --prefix=$distdir/[% c("arch") %]-w64-mingw32
 make -j[% c("buildconf/num_procs") %]
 make install
 
 mkdir -p /var/tmp/build/builddir/mingw-w64/widl32
 cd /var/tmp/build/builddir/mingw-w64/widl32
 /var/tmp/build/[% project %]-[% c("version") %]/mingw-w64-tools/widl/configure \
-                 --prefix=$distdir --target=i686-w64-mingw32
+                 --prefix=$distdir --target=[% c("arch") %]-w64-mingw32
 make -j[% c("buildconf/num_procs") %]
 make install
 
@@ -52,12 +52,26 @@ cd /var/tmp/build/gcc
 make -j[% c("buildconf/num_procs") %]
 make install
 mkdir -p $distdir/gcclibs
-cp i686-w64-mingw32/libssp/.libs/libssp-0.dll $distdir/gcclibs
-cp i686-w64-mingw32/libgcc/shlib/libgcc_s_sjlj-1.dll $distdir/gcclibs
+cp [% c("arch") %]-w64-mingw32/libssp/.libs/libssp-0.dll $distdir/gcclibs
+cp [% c("arch") %]-w64-mingw32/libgcc/shlib/[% c("var/libgcc_dll") %] $distdir/gcclibs
 
 mkdir -p $distdir/helpers
-mv $rootdir/i686-w64-mingw32-g++ $rootdir/i686-w64-mingw32-gcc \
-    $rootdir/i686-w64-mingw32-ld $distdir/helpers/
+
+cat > $distdir/helpers/[% c("arch") %]-w64-mingw32-g++ << 'EOF'
+#!/bin/sh
+/var/tmp/dist/mingw-w64/bin/[% c("arch") %]-w64-mingw32-g++ -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -fstack-protector --param ssp-buffer-size=4 -fno-strict-overflow "$@"
+EOF
+
+cat > $distdir/helpers/[% c("arch") %]-w64-mingw32-gcc << 'EOF'
+#!/bin/sh
+/var/tmp/dist/mingw-w64/bin/[% c("arch") %]-w64-mingw32-gcc -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -fstack-protector --param ssp-buffer-size=4 -fno-strict-overflow "$@"
+EOF
+
+cat > $distdir/helpers/[% c("arch") %]-w64-mingw32-ld << 'EOF'
+#!/bin/sh
+/var/tmp/dist/mingw-w64/bin/[% c("arch") %]-w64-mingw32-ld --dynamicbase --nxcompat --enable-reloc-section -lssp -L$gcclibs "$@"
+EOF
+
 chmod +x $distdir/helpers/*
 
 cd /var/tmp/dist
diff --git a/projects/mingw-w64/config b/projects/mingw-w64/config
index ac1caa9..bb66167 100644
--- a/projects/mingw-w64/config
+++ b/projects/mingw-w64/config
@@ -11,19 +11,26 @@ var:
     - automake
     - build-essential
     - libmpc-dev
-    - g++-mingw-w64-i686
   setup: |
     [% c("var/setarch") -%]
     mkdir -p /var/tmp/dist
     tar -C /var/tmp/dist -xf [% c("compiler_tarfile") %]
     export PATH="/var/tmp/dist/mingw-w64/helpers:/var/tmp/dist/mingw-w64/bin:$PATH"
     export gcclibs=/var/tmp/dist/mingw-w64/gcclibs
+targets:
+  windows-i686:
+    var:
+      libgcc_dll: libgcc_s_sjlj-1.dll
+      arch_deps:
+        - g++-mingw-w64-i686
+  windows-x86_64:
+    var:
+      libgcc_dll: libgcc_s_seh-1.dll
+      arch_deps:
+        - g++-mingw-w64-x86-64
 input_files:
   - project: container-image
   - URL: 'https://ftp.gnu.org/gnu/gcc/gcc-[% c("var/gcc_version") %]/gcc-[% c("var/gcc_version") %].tar.bz2'
     sha256sum: 608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a
   - name: binutils
     project: binutils
-  - filename: i686-w64-mingw32-g++
-  - filename: i686-w64-mingw32-gcc
-  - filename: i686-w64-mingw32-ld
diff --git a/projects/mingw-w64/i686-w64-mingw32-g++ b/projects/mingw-w64/i686-w64-mingw32-g++
deleted file mode 100755
index c5421a2..0000000
--- a/projects/mingw-w64/i686-w64-mingw32-g++
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# Hardened mingw gcc wrapper
-
-/var/tmp/dist/mingw-w64/bin/i686-w64-mingw32-g++ -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -fstack-protector --param ssp-buffer-size=4 -fno-strict-overflow "$@"
diff --git a/projects/mingw-w64/i686-w64-mingw32-gcc b/projects/mingw-w64/i686-w64-mingw32-gcc
deleted file mode 100755
index 741ef8a..0000000
--- a/projects/mingw-w64/i686-w64-mingw32-gcc
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# Hardened mingw gcc wrapper
-
-/var/tmp/dist/mingw-w64/bin/i686-w64-mingw32-gcc -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -fstack-protector --param ssp-buffer-size=4 -fno-strict-overflow "$@"
diff --git a/projects/mingw-w64/i686-w64-mingw32-ld b/projects/mingw-w64/i686-w64-mingw32-ld
deleted file mode 100755
index bcf5e5b..0000000
--- a/projects/mingw-w64/i686-w64-mingw32-ld
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# Hardened mingw gcc wrapper
-
-/var/tmp/dist/mingw-w64/bin/i686-w64-mingw32-ld --dynamicbase --nxcompat --enable-reloc-section -lssp -L$gcclibs "$@"
diff --git a/rbm.conf b/rbm.conf
index ab2a080..6e800f2 100644
--- a/rbm.conf
+++ b/rbm.conf
@@ -171,15 +171,36 @@ targets:
 
   torbrowser-windows-i686:
     - windows-i686
+    - windows
+  torbrowser-windows-x86_64:
+    - windows-x86_64
+    - windows
+  windows-x86_64:
+    arch: x86_64
+    var:
+      windows-x86_64: 1
+      osname: windows-x86_64
+      container:
+        arch: amd64
   windows-i686:
     arch: i686
     var:
-      windows: 1
+      windows-i686: 1
       osname: windows-i686
       container:
-        suite: precise
         arch: i386
-      configure_opt: '--host=i686-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]"'
+      setarch: |
+        if test -z "$RBM_SETARCH"
+        then
+           export RBM_SETARCH=1
+           exec setarch i686 ./build
+        fi
+  windows:
+    var:
+      windows: 1
+      container:
+        suite: precise
+      configure_opt: '--host=[% c("arch") %]-w64-mingw32 CFLAGS="[% c("var/CFLAGS") %]" LDFLAGS="[% c("var/LDFLAGS") %]"'
       CFLAGS: '[% c("var/flag_mwindows") %] -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fno-strict-overflow -Wno-missing-field-initializers -Wformat -Wformat-security'
       LDFLAGS: '[% c("var/flag_mwindows") %] -Wl,--dynamicbase -Wl,--nxcompat -Wl,--enable-reloc-section -lssp -L$gcclibs'
       flag_mwindows: '-mwindows'
@@ -193,12 +214,6 @@ targets:
         - zip
         - unzip
       faketime_path: /usr/lib/faketime/libfaketime.so.1
-      setarch: |
-        if test -z "$RBM_SETARCH"
-        then
-           export RBM_SETARCH=1
-           exec setarch i686 ./build
-        fi
       fteproxy: 1
       install_wine_ppa: |
         # Install a Wine new enough to have a fix for



More information about the tbb-commits mailing list