From c42c7375d7152d26d6347b47a052d2888d8c6657 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 24 Mar 2020 19:39:17 +0000 Subject: [PATCH 01/12] Revert #18003 "build: remove --large-address-aware linker flag" This reverts commit acd644b83d789a6cdfbeda19732119534d10058e. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index a26ad413a108e..0c363529a59a4 100644 --- a/configure.ac +++ b/configure.ac @@ -770,6 +770,8 @@ if test x$ac_cv_sys_large_files != x && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" fi +AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"]) + AX_GCC_FUNC_ATTRIBUTE([visibility]) AX_GCC_FUNC_ATTRIBUTE([dllexport]) AX_GCC_FUNC_ATTRIBUTE([dllimport]) From f781dd397069c8314bb9fc05961b30050a97c982 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 25 Mar 2020 00:44:52 +0000 Subject: [PATCH 02/12] Partially revert #17740 "build: remove configure checks for win libraries we don't link against" This partially reverts commit 2525c096b002a89d4c561e1474800496ad8ebd7e. --- configure.ac | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 0c363529a59a4..cd020eb9b11d7 100644 --- a/configure.ac +++ b/configure.ac @@ -592,20 +592,20 @@ case $host in *mingw*) TARGET_OS=windows AC_CHECK_LIB([mingwthrd],[main],, AC_MSG_ERROR(libmingwthrd missing)) - AC_CHECK_LIB([kernel32], [GetModuleFileNameA],, AC_MSG_ERROR(libkernel32 missing)) + AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(libkernel32 missing)) AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(libuser32 missing)) AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(libgdi32 missing)) AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(libcomdlg32 missing)) AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(libwinmm missing)) - AC_CHECK_LIB([shell32], [SHGetSpecialFolderPathW],, AC_MSG_ERROR(libshell32 missing)) + AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(libshell32 missing)) AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(libcomctl32 missing)) - AC_CHECK_LIB([ole32], [CoCreateInstance],, AC_MSG_ERROR(libole32 missing)) + AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(libole32 missing)) AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(liboleaut32 missing)) AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(libuuid missing)) - AC_CHECK_LIB([advapi32], [CryptAcquireContextW],, AC_MSG_ERROR(libadvapi32 missing)) - AC_CHECK_LIB([ws2_32], [WSAStartup],, AC_MSG_ERROR(libws2_32 missing)) - AC_CHECK_LIB([shlwapi], [PathRemoveFileSpecW],, AC_MSG_ERROR(libshlwapi missing)) - AC_CHECK_LIB([iphlpapi], [GetAdaptersAddresses],, AC_MSG_ERROR(libiphlpapi missing)) + AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(libadvapi32 missing)) + AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(libws2_32 missing)) + AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(libshlwapi missing)) + AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(libiphlpapi missing)) dnl -static is interpreted by libtool, where it has a different meaning. dnl In libtool-speak, it's -all-static. From fd8c07535648c7d4c277e9b172b8bc9635638195 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 24 Mar 2020 19:43:54 +0000 Subject: [PATCH 03/12] Revert part of #17916 "windows: remove call to SetProcessDEPPolicy" This reverts commit 3d5d7aad269c7afe7e36677d3e76c6579e1b8aba. --- src/init.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 495d96f9384cd..9a3cd50be207c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -925,6 +925,9 @@ bool AppInitBasicSetup(ArgsManager& args) _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #endif #ifdef WIN32 + // Enable Data Execution Prevention (DEP) + SetProcessDEPPolicy(PROCESS_DEP_ENABLE); + // Enable heap terminate-on-corruption HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0); #endif From d519b13ee67622b4905840c89dc2f642f5d7b5f7 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 24 Mar 2020 19:46:02 +0000 Subject: [PATCH 04/12] Revert #17756 "build: remove WINDOWS_BITS from build system" This reverts commit abc147de95fb294a2c0a3105695e708517010322. --- Makefile.am | 2 +- configure.ac | 6 ++++++ share/setup.nsi.in | 14 +++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index c8af4228f35c7..9b3dd729dd24d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,7 @@ BITCOIN_QT_BIN=$(top_builddir)/src/qt/$(BITCOIN_GUI_NAME)$(EXEEXT) BITCOIN_CLI_BIN=$(top_builddir)/src/$(BITCOIN_CLI_NAME)$(EXEEXT) BITCOIN_TX_BIN=$(top_builddir)/src/$(BITCOIN_TX_NAME)$(EXEEXT) BITCOIN_WALLET_BIN=$(top_builddir)/src/$(BITCOIN_WALLET_TOOL_NAME)$(EXEEXT) -BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win64-setup$(EXEEXT) +BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win$(WINDOWS_BITS)-setup$(EXEEXT) empty := space := $(empty) $(empty) diff --git a/configure.ac b/configure.ac index cd020eb9b11d7..93e3ebf03c86a 100644 --- a/configure.ac +++ b/configure.ac @@ -622,6 +622,12 @@ case $host in fi CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" + case $host in + i?86-*) WINDOWS_BITS=32 ;; + x86_64-*) WINDOWS_BITS=64 ;; + *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;; + esac + AC_SUBST(WINDOWS_BITS) dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override diff --git a/share/setup.nsi.in b/share/setup.nsi.in index 5431909bb22d2..c7cd169e4ed52 100644 --- a/share/setup.nsi.in +++ b/share/setup.nsi.in @@ -1,4 +1,4 @@ -Name "@PACKAGE_NAME@ (64-bit)" +Name "@PACKAGE_NAME@ (@WINDOWS_BITS@-bit)" RequestExecutionLevel highest SetCompressor /SOLID lzma @@ -33,7 +33,9 @@ SetDateSave off # Included files !include Sections.nsh !include MUI2.nsh +!if "@WINDOWS_BITS@" == "64" !include x64.nsh +!endif # Variables Var StartMenuGroup @@ -51,7 +53,11 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English # Installer attributes +!if "@WINDOWS_BITS@" == "64" InstallDir $PROGRAMFILES64\Bitcoin +!else +InstallDir $PROGRAMFILES\Bitcoin +!endif CRCCheck on XPStyle on BrandingText " " @@ -92,7 +98,7 @@ Section -post SEC0001 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory $SMPROGRAMS\$StartMenuGroup CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" $INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@ - CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, 64-bit).lnk" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "-testnet" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" 1 + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, @WINDOWS_BITS@-bit).lnk" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "-testnet" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" 1 CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe !insertmacro MUI_STARTMENU_WRITE_END WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" @@ -136,7 +142,7 @@ Section -un.post UNSEC0001 DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" - Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, 64-bit).lnk" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, @WINDOWS_BITS@-bit).lnk" Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk" Delete /REBOOTOK $INSTDIR\uninstall.exe Delete /REBOOTOK $INSTDIR\debug.log @@ -158,6 +164,7 @@ SectionEnd # Installer functions Function .onInit InitPluginsDir +!if "@WINDOWS_BITS@" == "64" ${If} ${RunningX64} ; disable registry redirection (enable access to 64-bit portion of registry) SetRegView 64 @@ -165,6 +172,7 @@ Function .onInit MessageBox MB_OK|MB_ICONSTOP "Cannot install 64-bit version on a 32-bit system." Abort ${EndIf} +!endif FunctionEnd # Uninstaller functions From c8f655622c3042c0d885cc874cf21058f02add3c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 15 Oct 2020 14:14:29 +0000 Subject: [PATCH 05/12] Revert "scripts: no-longer check for 32 bit windows in security-check.py" Minimised to avoid invisible conflicts and unnecessary changes This reverts commit 061acf62a15ad3dbb9f055b7c2569b9832ed623a. --- contrib/devtools/security-check.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py index dc74de91980a4..79d8cf8a6cf7b 100755 --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -194,14 +194,25 @@ def check_ELF_separate_code(executable): def get_PE_dll_characteristics(executable) -> int: '''Get PE DllCharacteristics bits''' + return get_PE_dll_arch_and_characteristics(executable)[1] + +def get_PE_dll_arch_and_characteristics(executable): + ''' + Get PE DllCharacteristics bits. + Returns a tuple (arch,bits) where arch is 'i386:x86-64' or 'i386' + and bits is the DllCharacteristics value. + ''' stdout = run_command([OBJDUMP_CMD, '-x', executable]) + arch = '' bits = 0 for line in stdout.splitlines(): tokens = line.split() + if len(tokens) >= 2 and tokens[0] == 'architecture:': + arch = tokens[1].rstrip(',') if len(tokens)>=2 and tokens[0] == 'DllCharacteristics': bits = int(tokens[1],16) - return bits + return (arch,bits) IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020 IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040 @@ -212,12 +223,18 @@ def check_PE_DYNAMIC_BASE(executable) -> bool: bits = get_PE_dll_characteristics(executable) return (bits & IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE) == IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE +# (64-bit only:) # Must support high-entropy 64-bit address space layout randomization # in addition to DYNAMIC_BASE to have secure ASLR. def check_PE_HIGH_ENTROPY_VA(executable) -> bool: '''PIE: DllCharacteristics bit 0x20 signifies high-entropy ASLR''' - bits = get_PE_dll_characteristics(executable) - return (bits & IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA) == IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA + (arch,bits) = get_PE_dll_arch_and_characteristics(executable) + if arch == 'i386:x86-64': + reqbits = IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA + else: # Unnecessary on 32-bit + assert(arch == 'i386') + reqbits = 0 + return (bits & reqbits) == reqbits def check_PE_RELOC_SECTION(executable) -> bool: '''Check for a reloc section. This is required for functional ASLR.''' From 6b18f76af7305f324559624fb2b58f189a301ee6 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 24 Mar 2020 19:49:25 +0000 Subject: [PATCH 06/12] Partially revert part of #15939 "Remove Windows 32 bit build" This partially reverts commit faf666f8148eeb305a9c4f78459aff2c7268016b. --- .travis.yml | 5 +++++ ci/test/00_setup_env_win32.sh | 17 +++++++++++++++++ contrib/devtools/test-security-check.py | 12 ++++++++++++ contrib/gitian-descriptors/gitian-win.yml | 11 ++++++++--- depends/README.md | 1 + 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 ci/test/00_setup_env_win32.sh diff --git a/.travis.yml b/.travis.yml index 656eed9871a27..c7010b387df86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,11 @@ jobs: script: - set -o errexit; source ./ci/lint/06_script.sh + - stage: test + name: 'Win32 [GOAL: deploy] [unit tests, no gui, no boost::process, no functional tests]' + env: >- + FILE_ENV="./ci/test/00_setup_env_win32.sh" + - stage: test name: '32-bit + dash [GOAL: install] [CentOS 7] [gui]' env: >- diff --git a/ci/test/00_setup_env_win32.sh b/ci/test/00_setup_env_win32.sh new file mode 100644 index 0000000000000..f44a049d426be --- /dev/null +++ b/ci/test/00_setup_env_win32.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2019-2020 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +export LC_ALL=C.UTF-8 + +export CONTAINER_NAME=ci_win32 +export DOCKER_NAME_TAG=ubuntu:18.04 # Check that bionic can cross-compile to win64 (bionic is used in the gitian build as well) +export HOST=i686-w64-mingw32 +export DPKG_ADD_ARCH="i386" +export PACKAGES="python3 nsis g++-mingw-w64-i686 wine-binfmt wine32" +export RUN_FUNCTIONAL_TESTS=false +export RUN_SECURITY_TESTS="true" +export GOAL="deploy" +export BITCOIN_CONFIG="--enable-reduce-exports --disable-gui-tests --without-boost-process" diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py index ec2d886653421..03940958b16bf 100755 --- a/contrib/devtools/test-security-check.py +++ b/contrib/devtools/test-security-check.py @@ -44,6 +44,18 @@ def test_ELF(self): self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE', '-Wl,-z,separate-code']), (0, '')) + def test_32bit_PE(self): + source = 'test1.c' + executable = 'test1.exe' + cc = 'i686-w64-mingw32-gcc' + write_testcode(source) + + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--no-nxcompat','-Wl,--no-dynamicbase']), + (1, executable+': failed DYNAMIC_BASE NX')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--no-dynamicbase']), + (1, executable+': failed DYNAMIC_BASE')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), + (0, '')) def test_PE(self): source = 'test1.c' executable = 'test1.exe' diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index 4d61cded7483e..64a43d92b686e 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -30,7 +30,7 @@ script: | set -e -o pipefail WRAP_DIR=$HOME/wrapped - HOSTS="x86_64-w64-mingw32" + HOSTS="i686-w64-mingw32 x86_64-w64-mingw32" CONFIGFLAGS="--enable-reduce-exports --disable-bench --disable-gui-tests" FAKETIME_HOST_PROGS="ar ranlib nm windres strip objcopy" FAKETIME_PROGS="date makensis zip" @@ -143,8 +143,13 @@ script: | find ${DISTNAME}/bin -type f -executable -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg find ${DISTNAME}/lib -type f -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg cp ../doc/README_windows.txt ${DISTNAME}/readme.txt - find ${DISTNAME} -not -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i//x86_64-w64-mingw32/win64}.zip - find ${DISTNAME} -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i//x86_64-w64-mingw32/win64}-debug.zip + case $i in + i?86-* ) bin_name=win32 ;; + x86_64-*) bin_name=win64 ;; + *) bin_name=$i ;; + esac + find ${DISTNAME} -not -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${bin_name}.zip + find ${DISTNAME} -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${bin_name}-debug.zip cd ../../ rm -rf distsrc-${i} done diff --git a/depends/README.md b/depends/README.md index 5225a6d5c41ef..900c5a384adb6 100644 --- a/depends/README.md +++ b/depends/README.md @@ -24,6 +24,7 @@ Common `host-platform-triplets` for cross compilation are: - `i686-pc-linux-gnu` for Linux 32 bit - `x86_64-pc-linux-gnu` for x86 Linux +- `i686-w64-mingw32` for Win32 - `x86_64-w64-mingw32` for Win64 - `x86_64-apple-darwin16` for macOS - `arm-linux-gnueabihf` for Linux ARM 32 bit From f7af8ec7d02726d2676d6741baeba51bcf354a01 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 12 Jun 2020 06:50:16 +0000 Subject: [PATCH 07/12] gitian: Fix expected win32 binary names This was broken by 5f699b5d417e9cfa920d10d7dac02a35b1ff6eab. --- contrib/gitian-descriptors/gitian-win.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index 64a43d92b686e..af411fabd9d63 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -121,6 +121,11 @@ script: | ORIGPATH="$PATH" # Extract the git archive into a dir for each host and build for i in ${HOSTS}; do + case $i in + i?86-* ) bin_name=win32 ;; + x86_64-*) bin_name=win64 ;; + *) bin_name=$i ;; + esac export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} @@ -133,7 +138,7 @@ script: | make ${MAKEOPTS} make ${MAKEOPTS} -C src check-security make ${MAKEOPTS} -C src check-symbols - make deploy BITCOIN_WIN_INSTALLER="${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe" + make deploy BITCOIN_WIN_INSTALLER="${OUTDIR}/${DISTNAME}-${bin_name}-setup-unsigned.exe" make install DESTDIR=${INSTALLPATH} cd installed mv ${DISTNAME}/bin/*.dll ${DISTNAME}/lib/ @@ -143,11 +148,6 @@ script: | find ${DISTNAME}/bin -type f -executable -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg find ${DISTNAME}/lib -type f -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg cp ../doc/README_windows.txt ${DISTNAME}/readme.txt - case $i in - i?86-* ) bin_name=win32 ;; - x86_64-*) bin_name=win64 ;; - *) bin_name=$i ;; - esac find ${DISTNAME} -not -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${bin_name}.zip find ${DISTNAME} -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${bin_name}-debug.zip cd ../../ @@ -157,5 +157,5 @@ script: | cp -rf contrib/windeploy $BUILD_DIR cd $BUILD_DIR/windeploy mkdir unsigned - cp ${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe unsigned/ + cp ${OUTDIR}/${DISTNAME}-*setup-unsigned.exe unsigned/ find . | sort | tar --mtime="$REFERENCE_DATETIME" --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-win-unsigned.tar.gz From 168f52cc946cb3d17cc1e4ddcc9d0c69ca9d8704 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 17 Nov 2020 15:25:20 +0000 Subject: [PATCH 08/12] CI: Update test-security-check for RELOC_SECTION --- contrib/devtools/test-security-check.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py index 03940958b16bf..5f23687eeb35b 100755 --- a/contrib/devtools/test-security-check.py +++ b/contrib/devtools/test-security-check.py @@ -50,12 +50,15 @@ def test_32bit_PE(self): cc = 'i686-w64-mingw32-gcc' write_testcode(source) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--no-nxcompat','-Wl,--no-dynamicbase']), - (1, executable+': failed DYNAMIC_BASE NX')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--no-dynamicbase']), - (1, executable+': failed DYNAMIC_BASE')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), - (0, '')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--no-nxcompat','-Wl,--no-dynamicbase','-no-pie','-fno-PIE']), + (1, executable+': failed DYNAMIC_BASE NX RELOC_SECTION')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--no-dynamicbase','-no-pie','-fno-PIE']), + (1, executable+': failed DYNAMIC_BASE RELOC_SECTION')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-no-pie','-fno-PIE']), + (1, executable+': failed RELOC_SECTION')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-pie','-fPIE']), + (0, '')) + def test_PE(self): source = 'test1.c' executable = 'test1.exe' From 3984849fbd037fe705594068fef74400657bc531 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 17 Nov 2020 05:36:08 +0000 Subject: [PATCH 09/12] CI: Fix test-security-check make target to work on Win32 --- Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.am b/Makefile.am index 9b3dd729dd24d..29690f5658a25 100644 --- a/Makefile.am +++ b/Makefile.am @@ -355,7 +355,12 @@ if TARGET_DARWIN $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_MACHO endif if TARGET_WINDOWS + ifeq ($(WINDOWS_BITS),32) + $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_32bit_PE + endif + ifeq ($(WINDOWS_BITS),64) $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE + endif endif if TARGET_LINUX $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF From d9c4891f4426960402582c166be4afe21c2fda3d Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 17 Nov 2020 00:41:55 +0000 Subject: [PATCH 10/12] CI: Update Win32 builds to use wrap-wine --- ci/test/00_setup_env_win32.sh | 2 +- ci/test/wrap-wine.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/test/00_setup_env_win32.sh b/ci/test/00_setup_env_win32.sh index f44a049d426be..5b165a08698bd 100644 --- a/ci/test/00_setup_env_win32.sh +++ b/ci/test/00_setup_env_win32.sh @@ -10,7 +10,7 @@ export CONTAINER_NAME=ci_win32 export DOCKER_NAME_TAG=ubuntu:18.04 # Check that bionic can cross-compile to win64 (bionic is used in the gitian build as well) export HOST=i686-w64-mingw32 export DPKG_ADD_ARCH="i386" -export PACKAGES="python3 nsis g++-mingw-w64-i686 wine-binfmt wine32" +export PACKAGES="python3 nsis g++-mingw-w64-i686 wine-binfmt wine32 file" export RUN_FUNCTIONAL_TESTS=false export RUN_SECURITY_TESTS="true" export GOAL="deploy" diff --git a/ci/test/wrap-wine.sh b/ci/test/wrap-wine.sh index 58a8983e6ec6c..d70d5c99b2c9f 100755 --- a/ci/test/wrap-wine.sh +++ b/ci/test/wrap-wine.sh @@ -9,11 +9,16 @@ export LC_ALL=C.UTF-8 for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/univalue/{no_nul,test_json,unitester,object}}.exe; do # shellcheck disable=SC2044 for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename $b_name)"); do - if (file "$b" | grep "Windows"); then + filetype="$(file -b "$b")" + if grep -q "Windows" <<<"${filetype}"; then echo "Wrap $b ..." mv "$b" "${b}_orig" echo '#!/usr/bin/env bash' > "$b" + if grep -q "\b64\b" <<<"${filetype}"; then echo "wine64 \"${b}_orig\" \"\$@\"" >> "$b" + else + echo "wine \"${b}_orig\" \"\$@\"" >> "$b" + fi chmod +x "$b" fi done From 3e30ae0514e791de1e4494ce53140c2ad7b48073 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 17 Nov 2020 00:41:55 +0000 Subject: [PATCH 11/12] CI: Run Win32 ci config also on cirrus --- .cirrus.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index 237560fc2e681..0d03587266d96 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -62,6 +62,14 @@ task: env: FILE_ENV: "./ci/test/00_setup_env_arm.sh" +task: + name: 'Win32 [GOAL: deploy] [unit tests, no gui, no boost::process, no functional tests]' + << : *GLOBAL_TASK_TEMPLATE + container: + image: ubuntu:bionic + env: + FILE_ENV: "./ci/test/00_setup_env_win32.sh" + task: name: 'Win64 [GOAL: deploy] [unit tests, no gui, no boost::process, no functional tests]' << : *GLOBAL_TASK_TEMPLATE From 12bbfb67b309ec8b30814ddabbf8930300f82f0a Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 26 Nov 2020 19:01:19 +0200 Subject: [PATCH 12/12] ci: Exempt Win32 from default --enable-werror Needed to remain compatible with backport commit 681f728a35b800d6f1cc359171b6b40de9ddb9a4 Github-Pull: #20182 Rebased-From: 2f6fe4e4e9e9e35e713c0a20cf891b023592110a --- ci/test/00_setup_env_win32.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/test/00_setup_env_win32.sh b/ci/test/00_setup_env_win32.sh index 5b165a08698bd..436e067130f2a 100644 --- a/ci/test/00_setup_env_win32.sh +++ b/ci/test/00_setup_env_win32.sh @@ -15,3 +15,7 @@ export RUN_FUNCTIONAL_TESTS=false export RUN_SECURITY_TESTS="true" export GOAL="deploy" export BITCOIN_CONFIG="--enable-reduce-exports --disable-gui-tests --without-boost-process" + +# Compiler for MinGW-w64 causes false -Wreturn-type warning. +# See https://sourceforge.net/p/mingw-w64/bugs/306/ +export NO_WERROR=1