From 57ae8a3e6aa8b8b915dc754633bfd8b74103b4c9 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 1 Oct 2021 13:09:46 -0400 Subject: [PATCH 1/8] chore(windows): use Debian Bullseye for Windows cross-compilation bsdtar has moved to libarchive-tools package. Something has changed in the newer gcc or mingw that makes Opus and Sodium fail to build with: undefined reference to `__memcpy_chk' The solution is to use -lssp or -fstack-protector, but while -lssp worked for Opus, it was breaking Sodium's `make install` as it prevented the .def file from being generated during the build time for some reason: /usr/bin/install: cannot stat './libsodium-24.def': No such file or directory while -fstack-protector worked just fine, so -fstack-protector was used for both. This adds a new library dependency on libssp-0.dll. --- .travis/build-windows.sh | 2 +- windows/cross-compile/README.md | 6 +++--- windows/cross-compile/build.sh | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis/build-windows.sh b/.travis/build-windows.sh index f50df36ca..de280d2b5 100755 --- a/.travis/build-windows.sh +++ b/.travis/build-windows.sh @@ -118,7 +118,7 @@ sudo docker run --rm \ -v "$PWD/workspace":/workspace \ -v "$PWD":/qtox \ -e TRAVIS_CI_STAGE="$STAGE" \ - debian:buster-slim \ + debian:bullseye-slim \ /bin/bash /qtox/windows/cross-compile/build.sh "$ARCH" "$BUILD_TYPE" # Purely for debugging diff --git a/windows/cross-compile/README.md b/windows/cross-compile/README.md index 243a3779a..5642ec154 100644 --- a/windows/cross-compile/README.md +++ b/windows/cross-compile/README.md @@ -45,19 +45,19 @@ To start cross-compiling for 32-bit release version of qTox run: sudo docker run --rm \ -v /absolute/path/to/your/workspace:/workspace \ -v /absolute/path/to/your/qtox:/qtox \ - debian:buster-slim \ + debian:bullseye-slim \ /bin/bash /qtox/windows/cross-compile/build.sh i686 release ``` If you want to debug some compilation issue, you might want to instead run: ```sh -# Get shell inside Debian Buster container so that you can poke around if needed +# Get shell inside Debian Bullseye container so that you can poke around if needed sudo docker run -it \ --rm \ -v /absolute/path/to/your/workspace:/workspace \ -v /absolute/path/to/your/qtox:/qtox \ - debian:buster-slim \ + debian:bullseye-slim \ /bin/bash # Run the script bash /qtox/windows/cross-compile/build.sh i686 release diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index 10a8d6d5a..15cc1f690 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -38,9 +38,9 @@ readonly QTOX_SRC_DIR="/qtox" # Make sure we run in an expected environment -if [ ! -f /etc/os-release ] || ! cat /etc/os-release | grep -qi 'buster' +if [ ! -f /etc/os-release ] || ! cat /etc/os-release | grep -qi 'bullseye' then - echo "Error: This script should be run on Debian Buster." + echo "Error: This script should be run on Debian Bullseye." exit 1 fi @@ -130,12 +130,12 @@ apt-get update apt-get install -y --no-install-recommends \ autoconf \ automake \ - bsdtar \ build-essential \ ca-certificates \ cmake \ extra-cmake-modules \ git \ + libarchive-tools \ libtool \ nsis \ pkg-config \ @@ -739,6 +739,7 @@ then rm $OPUS_FILENAME cd opus* + LDFLAGS="-fstack-protector" \ CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \ --prefix="$OPUS_PREFIX_DIR" \ --enable-shared \ @@ -773,6 +774,7 @@ then rm "$SODIUM_FILENAME" cd libsodium* + LDFLAGS="-fstack-protector" \ ./configure --host="$ARCH-w64-mingw32" \ --prefix="$SODIUM_PREFIX_DIR" \ --enable-shared \ @@ -1401,9 +1403,8 @@ mkdir -p "$QTOX_PREFIX_DIR/libsnore-qt5" cp "$SNORE_PREFIX_DIR/lib/plugins/libsnore-qt5/libsnore_backend_windowstoast.dll" "$QTOX_PREFIX_DIR/libsnore-qt5" cp "$SNORE_PREFIX_DIR/bin/SnoreToast.exe" $QTOX_PREFIX_DIR -cp /usr/lib/gcc/$ARCH-w64-mingw32/*-posix/libgcc_s_*.dll $QTOX_PREFIX_DIR -cp /usr/lib/gcc/$ARCH-w64-mingw32/*-posix/libstdc++-6.dll $QTOX_PREFIX_DIR -cp /usr/$ARCH-w64-mingw32/lib/libwinpthread-1.dll $QTOX_PREFIX_DIR +cp /usr/lib/gcc/$ARCH-w64-mingw32/*-posix/{libgcc_s_*.dll,libstdc++*.dll,libssp*.dll} $QTOX_PREFIX_DIR +cp /usr/$ARCH-w64-mingw32/lib/libwinpthread*.dll $QTOX_PREFIX_DIR # Setup wine if [[ "$ARCH" == "i686" ]] From 678b864037bba3f596af313688347d1079db9fa7 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 8 Oct 2021 12:00:06 -0400 Subject: [PATCH 2/8] chore(windows): update OpenSSL to 1.1.1l --- windows/cross-compile/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index 15cc1f690..f986b010d 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -232,9 +232,9 @@ store_apt_cache() # OpenSSL OPENSSL_PREFIX_DIR="$DEP_DIR/libopenssl" -OPENSSL_VERSION=1.1.1k +OPENSSL_VERSION="1.1.1l" # hash from https://www.openssl.org/source/ -OPENSSL_HASH="892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5" +OPENSSL_HASH="0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1" OPENSSL_FILENAME="openssl-$OPENSSL_VERSION.tar.gz" if [ ! -f "$OPENSSL_PREFIX_DIR/done" ] then From 936e9c05cfda642add3819aa3cec079ca3adf68c Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 8 Oct 2021 12:00:54 -0400 Subject: [PATCH 3/8] chore(windows): update Qt to 5.12.11 We are staying on 5.12 instead of 5.15 because 5.12 is supported for longer. There should be one more release in H2 2021. Ideally we would switch to 6.2, but qTox doesn't seem to be Qt6-ready yet. --- windows/cross-compile/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index f986b010d..ced742b08 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -275,10 +275,10 @@ fi QT_PREFIX_DIR="$DEP_DIR/libqt5" QT_MAJOR=5 QT_MINOR=12 -QT_PATCH=10 +QT_PATCH=11 QT_VERSION=$QT_MAJOR.$QT_MINOR.$QT_PATCH -# hash from https://download.qt.io/archive/qt/5.12/5.12.10/single/qt-everywhere-src-5.12.10.tar.xz.mirrorlist -QT_HASH="3e0ee1e57f5cf3eeb038d0b4b22c7eb442285c62639290756b39dc93a1d0e14f" +# hash from https://download.qt.io/archive/qt/5.12/5.12.11/single/qt-everywhere-src-5.12.11.tar.xz.mirrorlist +QT_HASH="0c4cdef158c61827d70d6111423166e2c62b539eaf303f36ad1d0aa8af900b95" QT_FILENAME="qt-everywhere-src-$QT_VERSION.tar.xz" if [ ! -f "$QT_PREFIX_DIR/done" ] then From 1209ba7b9cc968a89c2a185e076c3a15d826ebb3 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 8 Oct 2021 12:01:39 -0400 Subject: [PATCH 4/8] chore(windows): update Exif to 0.6.23 --- windows/cross-compile/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index ced742b08..9be79a638 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -634,15 +634,15 @@ fi # Exif EXIF_PREFIX_DIR="$DEP_DIR/libexif" -EXIF_VERSION=0.6.22 -EXIF_HASH="5048f1c8fc509cc636c2f97f4b40c293338b6041a5652082d5ee2cf54b530c56" +EXIF_VERSION="0.6.23" +EXIF_HASH="a740a99920eb81ae0aa802bb46e683ce6e0cde061c210f5d5bde5b8572380431" EXIF_FILENAME="libexif-$EXIF_VERSION.tar.xz" if [ ! -f "$EXIF_PREFIX_DIR/done" ] then rm -rf "$EXIF_PREFIX_DIR" mkdir -p "$EXIF_PREFIX_DIR" - curl $CURL_OPTIONS -O "https://github.com/libexif/libexif/releases/download/libexif-${EXIF_VERSION//./_}-release/${EXIF_FILENAME}" + curl $CURL_OPTIONS -O "https://github.com/libexif/libexif/releases/download/v${EXIF_VERSION}/libexif-${EXIF_VERSION}.tar.xz" check_sha256 "$EXIF_HASH" "$EXIF_FILENAME" bsdtar --no-same-owner --no-same-permissions -xf $EXIF_FILENAME rm $EXIF_FILENAME From 8e856dfbfd04e07ad41c83af70739945372efe6a Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 8 Oct 2021 12:03:01 -0400 Subject: [PATCH 5/8] chore(windows): update Expat to 2.4.1 --- windows/cross-compile/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index 9be79a638..54cd9f9a1 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -1176,8 +1176,8 @@ set -u # Expat EXPAT_PREFIX_DIR="$DEP_DIR/libexpat" - EXPAT_VERSION="2.3.0" - EXPAT_HASH="caa34f99b6e3bcea8502507eb6549a0a84510b244a748dfb287271b2d47467a9" + EXPAT_VERSION="2.4.1" + EXPAT_HASH="cf032d0dba9b928636548e32b327a2d66b1aab63c4f4a13dd132c2d1d2f2fb6a" EXPAT_FILENAME="expat-$EXPAT_VERSION.tar.xz" if [ ! -f "$EXPAT_PREFIX_DIR/done" ] then From 66c2a0807b4c122c89c0c0ff03b8d05fab8463e7 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 8 Oct 2021 12:03:43 -0400 Subject: [PATCH 6/8] chore(windows): update GDB to 11.1, add GMP GDB 11 gained GMP as a required dependency. --- windows/cross-compile/build.sh | 42 +++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index 54cd9f9a1..5b093189c 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -1205,11 +1205,46 @@ set -u fi + # GMP + + GMP_PREFIX_DIR="$DEP_DIR/libgmp" + GMP_VERSION="6.2.1" + GMP_HASH="fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2" + GMP_FILENAME="gmp-$GMP_VERSION.tar.xz" + if [ ! -f "$GMP_PREFIX_DIR/done" ] + then + rm -rf "$GMP_PREFIX_DIR" + mkdir -p "$GMP_PREFIX_DIR" + + curl $CURL_OPTIONS -O "http://ftp.gnu.org/gnu/gmp/$GMP_FILENAME" + check_sha256 "$GMP_HASH" "$GMP_FILENAME" + bsdtar --no-same-owner --no-same-permissions -xf $GMP_FILENAME + rm $GMP_FILENAME + cd gmp* + + mkdir build + cd build + CFLAGS="-O2 -g0" ../configure --host="$ARCH-w64-mingw32" \ + --prefix="$GMP_PREFIX_DIR" \ + --enable-static \ + --disable-shared + make + make install + cd .. + echo -n $GMP_VERSION > $GMP_PREFIX_DIR/done + + cd .. + rm -rf ./gmp* + else + echo "Using cached build of GMP `cat $GMP_PREFIX_DIR/done`" + fi + + # GDB GDB_PREFIX_DIR="$DEP_DIR/gdb" - GDB_VERSION="10.1" - GDB_HASH="f82f1eceeec14a3afa2de8d9b0d3c91d5a3820e23e0a01bbb70ef9f0276b62c0" + GDB_VERSION="11.1" + GDB_HASH="cccfcc407b20d343fb320d4a9a2110776dd3165118ffd41f4b1b162340333f94" GDB_FILENAME="gdb-$GDB_VERSION.tar.xz" if [ ! -f "$GDB_PREFIX_DIR/done" ] then @@ -1228,7 +1263,8 @@ set -u --prefix="$GDB_PREFIX_DIR" \ --enable-static \ --disable-shared \ - --with-libexpat-prefix="$EXPAT_PREFIX_DIR" + --with-libexpat-prefix="$EXPAT_PREFIX_DIR" \ + --with-libgmp-prefix="$GMP_PREFIX_DIR" make make install cd .. From b11896100c32627c76cb8b9728c5fdc718604602 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Sun, 10 Oct 2021 16:23:30 -0400 Subject: [PATCH 7/8] chore(windows): fix Wine prefix issue --- windows/cross-compile/build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index 5b093189c..b23fd9751 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -1443,6 +1443,10 @@ cp /usr/lib/gcc/$ARCH-w64-mingw32/*-posix/{libgcc_s_*.dll,libstdc++*.dll,libssp* cp /usr/$ARCH-w64-mingw32/lib/libwinpthread*.dll $QTOX_PREFIX_DIR # Setup wine +# Note that SQLCipher and FFmpeg (maybe more?) seem to setup ~/.wine on their +# own, but to the wrong bitness (always 64-bit?), when we want a matching +# bitness here for mingw-ldd, so remove it before proceeding. +rm -rf ~/.wine if [[ "$ARCH" == "i686" ]] then export WINEARCH=win32 @@ -1452,7 +1456,9 @@ then fi winecfg -# qtox.exe dll checks (32-bit on i686, 64-bit on x86_64) +# qtox.exe dll checks +# (system32 contains 32-bit libraries on win32 prefix, but 64-bit on win64 +# prefix) python3 $MINGW_LDD_PREFIX_DIR/bin/mingw-ldd.py $QTOX_PREFIX_DIR/qtox.exe --dll-lookup-dirs $QTOX_PREFIX_DIR ~/.wine/drive_c/windows/system32 > /tmp/$ARCH-qtox-ldd find "$QTOX_PREFIX_DIR" -name '*.dll' > /tmp/$ARCH-qtox-dll-find # dlls loded at run time that don't showup as a link time dependency @@ -1494,7 +1500,9 @@ do done < /tmp/$ARCH-qtox-dll-find -# SnoreToast.exe dll checks (always 32-bit) +# SnoreToast.exe dll checks +# (always 32-bit as SnoreToast.exe is 32-bit itself, so check system32 on win32 +# prefix but syswow64 on win64 prefix) if [[ "$ARCH" == "i686" ]] then SNORETOAST_WINE_DLLS=/root/.wine/drive_c/windows/system32 From b2215454e3e865d68bbbbc432deea10351a2366c Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Sun, 10 Oct 2021 17:15:55 -0400 Subject: [PATCH 8/8] chore(windows): update copyright year --- windows/cross-compile/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/cross-compile/build.sh b/windows/cross-compile/build.sh index b23fd9751..e946f8bf1 100644 --- a/windows/cross-compile/build.sh +++ b/windows/cross-compile/build.sh @@ -2,7 +2,7 @@ # MIT License # -# Copyright (c) 2017-2020 Maxim Biro +# Copyright (c) 2017-2021 Maxim Biro # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal