From cb82c202e88ab5f0697e2c8be91748528348c364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Barto=C5=88?= Date: Fri, 24 May 2024 09:05:52 +0200 Subject: [PATCH] Build libjpeg-turbo, OpenSSL, OpenBLAS, and FFmpeg packages using MSYS2 MinGW toolchain --- .github/scripts/setup-cross-compilation.sh | 12 ++++ .github/workflows/build-package.yml | 5 ++ .github/workflows/ffmpeg.yml | 20 ++++++ .github/workflows/libjpeg-turbo.yml | 20 ++++++ .github/workflows/main.yml | 1 - .github/workflows/openblas.yml | 20 ++++++ .github/workflows/openssl.yml | 21 ++++++ patches/makepkg/0001-cross-compilation.patch | 67 ++++++++++++++++++++ 8 files changed, 165 insertions(+), 1 deletion(-) create mode 100755 .github/scripts/setup-cross-compilation.sh create mode 100644 .github/workflows/ffmpeg.yml create mode 100644 .github/workflows/libjpeg-turbo.yml create mode 100644 .github/workflows/openblas.yml create mode 100644 .github/workflows/openssl.yml create mode 100644 patches/makepkg/0001-cross-compilation.patch diff --git a/.github/scripts/setup-cross-compilation.sh b/.github/scripts/setup-cross-compilation.sh new file mode 100755 index 0000000..134c82c --- /dev/null +++ b/.github/scripts/setup-cross-compilation.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on +set -o pipefail # fail of any command in pipeline is an error + +pushd / + patch -p1 -i `cygpath "$GITHUB_WORKSPACE"`/patches/makepkg/0001-cross-compilation.patch + cat /etc/makepkg_mingw.conf + cat /etc/profile + cat /usr/share/makepkg/tidy/strip.sh +popd diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index 7c18728..59e6af3 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -74,6 +74,11 @@ jobs: sparse-checkout: ${{ inputs.package_name }} path: ${{ github.workspace }}/packages + - name: Setup cross-compilation environment + if: ${{ contains(inputs.packages_repository, 'MINGW') }} + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/setup-cross-compilation.sh + - name: Enable Ccache id: enable-ccache run: | diff --git a/.github/workflows/ffmpeg.yml b/.github/workflows/ffmpeg.yml new file mode 100644 index 0000000..8799d38 --- /dev/null +++ b/.github/workflows/ffmpeg.yml @@ -0,0 +1,20 @@ +name: Build MinGW FFmpeg using MSYS2 toolchain + +on: + pull_request: + workflow_dispatch: + inputs: + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + required: false + default: "woarm64" + +jobs: + mingw-w64-ffmpeg: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-ffmpeg + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + cross_compile: true diff --git a/.github/workflows/libjpeg-turbo.yml b/.github/workflows/libjpeg-turbo.yml new file mode 100644 index 0000000..a4b9a64 --- /dev/null +++ b/.github/workflows/libjpeg-turbo.yml @@ -0,0 +1,20 @@ +name: Build MinGW libjpeg-turbo using MSYS2 toolchain + +on: + pull_request: + workflow_dispatch: + inputs: + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + required: false + default: "woarm64" + +jobs: + mingw-w64-libjpeg-turbo: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-libjpeg-turbo + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + cross_compile: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3295b1..88d1a81 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,6 @@ on: push: branches: - main - pull_request: workflow_dispatch: inputs: msys2_packages_branch: diff --git a/.github/workflows/openblas.yml b/.github/workflows/openblas.yml new file mode 100644 index 0000000..c78aad6 --- /dev/null +++ b/.github/workflows/openblas.yml @@ -0,0 +1,20 @@ +name: Build MinGW OpenBLAS using MSYS2 toolchain + +on: + pull_request: + workflow_dispatch: + inputs: + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + required: false + default: "woarm64" + +jobs: + mingw-w64-openblas: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-openblas + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + cross_compile: true diff --git a/.github/workflows/openssl.yml b/.github/workflows/openssl.yml new file mode 100644 index 0000000..d8da911 --- /dev/null +++ b/.github/workflows/openssl.yml @@ -0,0 +1,21 @@ +name: Build MinGW OpenSSL using MSYS2 toolchain + +on: + pull_request: + workflow_dispatch: + inputs: + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + required: false + default: "woarm64" + +jobs: + mingw-w64-openssl: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-openssl + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + dependencies: mingw-w64-cross-zlib + cross_compile: true diff --git a/patches/makepkg/0001-cross-compilation.patch b/patches/makepkg/0001-cross-compilation.patch new file mode 100644 index 0000000..f90833a --- /dev/null +++ b/patches/makepkg/0001-cross-compilation.patch @@ -0,0 +1,67 @@ +diff --git a/etc/makepkg_mingw.conf b/etc/makepkg_mingw.conf +--- a/etc/makepkg_mingw.conf ++++ b/etc/makepkg_mingw.conf +@@ -34,15 +34,17 @@ + # + + if [[ "$MSYSTEM" == "MINGW64" ]]; then +- CARCH="x86_64" ++ CARCH="aarch64" + CHOST="x86_64-w64-mingw32" + MINGW_CHOST="x86_64-w64-mingw32" + MINGW_PREFIX="/mingw64" + MINGW_PACKAGE_PREFIX="mingw-w64-x86_64" +- CC="gcc" +- CXX="g++" ++ CC="aarch64-w64-mingw32-gcc" ++ CXX="aarch64-w64-mingw32-g++" ++ STRIP="aarch64-w64-mingw32-strip" ++ OBJDUMP="aarch64-w64-mingw32-objdump" + CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1" +- CFLAGS="-march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong" ++ CFLAGS="-O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong" + CXXFLAGS="$CFLAGS" + LDFLAGS="" + elif [[ "$MSYSTEM" == "MINGW32" ]]; then +diff --git a/etc/profile b/etc/profile +--- a/etc/profile ++++ b/etc/profile +@@ -49,7 +49,7 @@ + case "${MSYSTEM}" in + MINGW*|CLANG*|UCRT*) + MINGW_MOUNT_POINT="${MINGW_PREFIX}" +- PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}" ++ PATH="/opt/bin:${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}" + PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig" + PKG_CONFIG_SYSTEM_INCLUDE_PATH="${MINGW_MOUNT_POINT}/include" + PKG_CONFIG_SYSTEM_LIBRARY_PATH="${MINGW_MOUNT_POINT}/lib" +diff --git a/usr/share/makepkg/tidy/strip.sh b/usr/share/makepkg/tidy/strip.sh +--- a/usr/share/makepkg/tidy/strip.sh ++++ b/usr/share/makepkg/tidy/strip.sh +@@ -85,7 +85,7 @@ + strip_file(){ + local binary=$1; shift + local tempfile=$(mktemp "$binary.XXXXXX") +- if strip "$@" "$binary" -o "$tempfile"; then ++ if $STRIP "$@" "$binary" -o "$tempfile"; then + cat "$tempfile" > "$binary" + fi + rm -f "$tempfile" +@@ -95,7 +95,7 @@ + local binary=$1; + + local tempfile=$(mktemp "$binary.XXXXXX") +- if strip -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$binary" -o "$tempfile"; then ++ if $STRIP -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$binary" -o "$tempfile"; then + cat "$tempfile" > "$binary" + fi + rm -f "$tempfile" +@@ -176,7 +176,7 @@ + case "${binary##*/}" in + *.dll|*.exe|*.sfx|*.so|*.so.[0-9]*|*.oct|*.cmxs) ;; + # make sure this isn't some oddly named DLL +- *) if LANG=en_US.UTF-8 LC_ALL=C objdump -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0' ++ *) if LANG=en_US.UTF-8 LC_ALL=C $OBJDUMP -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0' + then + mv "${binary}" "${binary}.exe" + binary+=.exe