From 57ae8a3e6aa8b8b915dc754633bfd8b74103b4c9 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 1 Oct 2021 13:09:46 -0400 Subject: [PATCH] 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" ]]