diff --git a/.github/scripts/setup-cross-compilation.sh b/.github/scripts/setup-cross-compilation.sh new file mode 100755 index 0000000..2c1a0eb --- /dev/null +++ b/.github/scripts/setup-cross-compilation.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on +set -o pipefail # fail of any command in pipeline is an error + +pushd / + echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE" + patch -p1 `cygpath "${{ $GITHUB_WORKSPACE }}"`/patches/makepkg/0001-cross-compilation.patch +popd diff --git a/.github/scripts/install-toolchain.sh b/.github/scripts/setup-repository.sh similarity index 84% rename from .github/scripts/install-toolchain.sh rename to .github/scripts/setup-repository.sh index 1dfbaf0..59506aa 100755 --- a/.github/scripts/install-toolchain.sh +++ b/.github/scripts/setup-repository.sh @@ -4,7 +4,7 @@ set -e # exit on error set -x # echo on set -o pipefail # fail of any command in pipeline is an error -pacman -Syu --noconfirm +pacman -Syuu --noconfirm # Add WoArm64 custom repository. REPO='[woarm64] @@ -15,4 +15,3 @@ SigLevel = Optional echo -e "$REPO$(cat /etc/pacman.conf)" > /etc/pacman.conf pacman -Sy --noconfirm -pacman -S mingw-w64-cross-gcc --noconfirm diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index 40968a0..405a3be 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -13,10 +13,18 @@ on: description: "Install additional dependencies" type: string default: "" - msys2_packages_branch: - description: "MSYS2-packages branch to build" + packages_repository: + description: "MSYS2 packages repository to build from" + type: string + default: "Windows-on-ARM-Experiments/MSYS2-packages" + packages_branch: + description: "MSYS2 packages branch to build from" type: string default: "woarm64" + cross_compile: + description: "Use cross-compiler for the package build" + type: boolean + default: false defaults: run: @@ -35,6 +43,13 @@ jobs: msystem: MSYS update: true + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup packages repository + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh + - name: Install dependencies run: | pacman -S --noconfirm \ @@ -42,17 +57,21 @@ jobs: git \ mingw-w64-x86_64-github-cli \ mingw-w64-x86_64-jq \ + ${{ inputs.cross_compile && 'mingw-w64-cross-gcc' || '' }} \ ${{ inputs.dependencies }} - - name: Checkout repository - uses: actions/checkout@v4 + - name: Setup cross-compilation environment + if: ${{ inputs.cross_compile }} + run: | + echo "inputs.cross_compile: ${{ inputs.cross_compile }}" + `cygpath "${{ github.workspace }}"`/.github/scripts/setup-cross-compilation.sh - - name: Checkout MSYS2 packages repository + - name: Checkout ${{ inputs.packages_repository }} repository uses: actions/checkout@v4 with: - repository: Windows-on-ARM-Experiments/MSYS2-packages - ref: ${{ inputs.msys2_packages_branch }} - path: ${{ github.workspace }}/MSYS2-packages + repository: ${{ inputs.packages_repository }} + ref: ${{ inputs.packages_branch }} + path: ${{ github.workspace }}/packages - name: Download artifacts if: ${{ inputs.needs }} @@ -67,7 +86,7 @@ jobs: run: | pacman -U --noconfirm *.pkg.tar.zst - - name: Copy missing headers + - name: Copy missing headers for mingw-w64-cross-crt if: ${{ inputs.package_name == 'mingw-w64-cross-crt' }} run: | cp /opt/x86_64-w64-mingw32/include/pthread_signal.h /opt/aarch64-w64-mingw32/include/ @@ -75,13 +94,19 @@ jobs: cp /opt/x86_64-w64-mingw32/include/pthread_time.h /opt/aarch64-w64-mingw32/include/ - name: Build ${{ inputs.package_name }} - working-directory: ${{ github.workspace }}/MSYS2-packages/${{ inputs.package_name }} + working-directory: ${{ github.workspace }}/packages/${{ inputs.package_name }} run: | - makepkg --syncdeps --rmdeps --cleanbuild --noconfirm --noprogressbar --nocheck --force + if [[ "${{ inputs.packages_repository }}" == *MINGW* ]]; then + command="makepkg-mingw" + else + command="makepkg" + fi + MINGW_ARCH=mingw64 \ + $command --syncdeps --rmdeps --cleanbuild --skippgpcheck --noconfirm --noprogressbar --nocheck --force - name: Upload ${{ inputs.package_name }} uses: actions/upload-artifact@v4 with: name: ${{ inputs.package_name }} retention-days: 1 - path: ${{ github.workspace }}/MSYS2-packages/${{ inputs.package_name }}/*.pkg.tar.zst + path: ${{ github.workspace }}/packages/${{ inputs.package_name }}/*.pkg.tar.zst diff --git a/.github/workflows/check-repository.yml b/.github/workflows/check-repository.yml index b4d032f..0926bb8 100644 --- a/.github/workflows/check-repository.yml +++ b/.github/workflows/check-repository.yml @@ -21,9 +21,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Setup packages repository + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh + - name: Install toolchain run: | - `cygpath "${{ github.workspace }}"`/.github/scripts/install-toolchain.sh + pacman -S mingw-w64-cross-gcc --noconfirm - name: Build hello-world.exe 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..905a7c8 --- /dev/null +++ b/.github/workflows/libjpeg-turbo.yml @@ -0,0 +1,19 @@ +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' }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0794e5e..e9a8783 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: @@ -18,7 +17,8 @@ jobs: uses: ./.github/workflows/build-package.yml with: package_name: mingw-w64-cross-headers - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-binutils: needs: mingw-w64-cross-headers @@ -26,7 +26,8 @@ jobs: with: package_name: mingw-w64-cross-binutils needs: ${{ toJson(needs) }} - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-gcc-stage1: needs: [mingw-w64-cross-headers, mingw-w64-cross-binutils] @@ -34,7 +35,8 @@ jobs: with: package_name: mingw-w64-cross-gcc-stage1 needs: ${{ toJson(needs) }} - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-windows-default-manifest: needs: [mingw-w64-cross-binutils, mingw-w64-cross-gcc-stage1] @@ -42,7 +44,8 @@ jobs: with: package_name: mingw-w64-cross-windows-default-manifest needs: ${{ toJson(needs) }} - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-crt: needs: @@ -56,7 +59,8 @@ jobs: package_name: mingw-w64-cross-crt needs: ${{ toJson(needs) }} dependencies: mingw-w64-cross-winpthreads - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-winpthreads: needs: @@ -70,7 +74,8 @@ jobs: with: package_name: mingw-w64-cross-winpthreads needs: ${{ toJson(needs) }} - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-gcc: needs: @@ -86,7 +91,8 @@ jobs: with: package_name: mingw-w64-cross-gcc needs: ${{ toJson(needs) }} - msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_repository: Windows-on-ARM-Experiments/MSYS2-packages + packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} repository: needs: 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..10f353f --- /dev/null +++ b/.github/workflows/openssl.yml @@ -0,0 +1,20 @@ +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' }} + 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