diff --git a/.github/scripts/build-package.sh b/.github/scripts/build-package.sh index 2e49e9e..54fb003 100755 --- a/.github/scripts/build-package.sh +++ b/.github/scripts/build-package.sh @@ -21,12 +21,19 @@ ARGUMENTS="--syncdeps \ $([ "$CLEAN_BUILD" = 1 ] && echo "--cleanbuild" || echo "") \ $([ "$INSTALL_PACKAGE" = 1 ] && echo "--install" || echo "")" -ccache -svv || true +echo "::group::Ccache statistics before build" + echo "CCACHE_DIR: $CCACHE_DIR" + ccache -svv || true +echo "::endgroup::" -if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then - makepkg-mingw $ARGUMENTS -else - makepkg $ARGUMENTS -fi +echo "::group::Build package" + if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then + makepkg-mingw $ARGUMENTS + else + makepkg $ARGUMENTS + fi +echo "::endgroup::" -ccache -svv || true +echo "::group::Ccache statistics after build" + ccache -svv || true +echo "::endgroup::" diff --git a/.github/scripts/download-artifacts.sh b/.github/scripts/download-artifacts.sh index ee8c01c..89837b7 100755 --- a/.github/scripts/download-artifacts.sh +++ b/.github/scripts/download-artifacts.sh @@ -5,9 +5,11 @@ set -x # echo on set -o pipefail # fail of any command in pipeline is an error RUN_ID=$1 -NEEDS=`echo "$2" | /mingw64/bin/jq 'keys|join(" ")' | sed 's/"//g'` -for NEED in $NEEDS; do - echo "Downloading $NEED artifact." - /mingw64/bin/gh run download $RUN_ID -n $NEED +for ARG in "${@:2}"; do + NEEDS=`echo "$ARG" | /mingw64/bin/jq 'keys|join(" ")' | sed 's/"//g'` + for NEED in $NEEDS; do + echo "Downloading $NEED artifact." + /mingw64/bin/gh run download $RUN_ID -n $NEED + done done diff --git a/.github/scripts/enable-ccache.sh b/.github/scripts/enable-ccache.sh index 8a8f300..d05195c 100755 --- a/.github/scripts/enable-ccache.sh +++ b/.github/scripts/enable-ccache.sh @@ -6,11 +6,14 @@ set -o pipefail # fail of any command in pipeline is an error DIR="`dirname ${BASH_SOURCE[0]}`/../.." DIR=`realpath $DIR` +CCACHE_DIR=$DIR/ccache if [[ -n "$GITHUB_WORKSPACE" ]]; then - echo "CCACHE_DIR=$DIR/ccache" >> "$GITHUB_ENV" + echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV" echo timestamp=$(date -u --iso-8601=seconds) >> "$GITHUB_OUTPUT" fi +mkdir -p $CCACHE_DIR + pushd / echo "::group::/etc/makepkg.conf" patch -p1 -b -i "$DIR/patches/ccache/0001-makepkg.patch" @@ -22,3 +25,15 @@ pushd / cat /etc/makepkg_mingw.conf echo "::endgroup::" popd + +pacman -S --noconfirm ccache + +pushd /usr/lib/ccache/bin + echo "::group::Add aarch64 toolchain to ccache" + export MSYS=winsymlinks + ln -sf /usr/bin/ccache aarch64-w64-mingw32-c++ + ln -sf /usr/bin/ccache aarch64-w64-mingw32-g++ + ln -sf /usr/bin/ccache aarch64-w64-mingw32-gcc + ls -al + echo "::endgroup::" +popd diff --git a/.github/scripts/pacman-workaround.sh b/.github/scripts/pacman-workaround.sh new file mode 100644 index 0000000..96e8d90 --- /dev/null +++ b/.github/scripts/pacman-workaround.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on +set -o pipefail # fail of any command in pipeline is an error + +if [ -z "$GITHUB_WORKSPACE" ]; then + DIR=`pwd` +else + DIR=`cygpath "$GITHUB_WORKSPACE"` +fi + +echo "::group::Pacman hang workaround" + while ! timeout -k 15s 10s pacman -U --noconfirm "$DIR/patches/pacman/pacman-6.1.0-4-x86_64.pkg.tar.zst" + do + echo "Command failed, retrying..." + done +echo "::endgroup::" + +echo "::group::Install patch" + pacman -S --noconfirm patch +echo "::endgroup::" + +pushd / + echo "::group::Pin pacman packages" + patch -p1 -b -i "$DIR/patches/pacman/0001-pin-packages.patch" + echo "::endgroup::" + + echo "::group::/etc/pacman.conf" + cat /etc/pacman.conf + echo "::endgroup::" +popd diff --git a/.github/scripts/setup-mingwarm64.sh b/.github/scripts/setup-mingwarm64.sh new file mode 100644 index 0000000..a994954 --- /dev/null +++ b/.github/scripts/setup-mingwarm64.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on +set -o pipefail # fail of any command in pipeline is an error + +if [ -z "$GITHUB_WORKSPACE" ]; then + DIR=`pwd` +else + DIR=`cygpath "$GITHUB_WORKSPACE"` +fi + +echo "::group::Install patch" + pacman -S --noconfirm patch +echo "::endgroup::" + +pushd / + echo "::group::Patch MSYS2 environment" + patch -p1 -b -i "$DIR/patches/makepkg/0001-mingwarm64.patch" + if [[ "$DEBUG" = "1" ]]; then + patch -p1 -b -i "$DIR/patches/makepkg/0002-enable-debug.patch" + fi + echo "::endgroup::" + + echo "::group::/etc/makepkg_mingw.conf" + cat /etc/makepkg_mingw.conf + echo "::endgroup::" + + echo "::group::/etc/profile" + cat /etc/profile + echo "::endgroup::" + + echo "::group::/usr/share/makepkg/tidy/strip.sh" + cat /usr/share/makepkg/tidy/strip.sh + echo "::endgroup::" +popd diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index 626e7cf..abb10c8 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -6,13 +6,6 @@ on: package_name: description: "Package name to build" type: string - needs: - description: "Parent workflow job dependencies" - type: string - dependencies: - description: "Install additional dependencies" - type: string - default: "" packages_repository: description: "MSYS2 packages repository to build from" type: string @@ -21,6 +14,17 @@ on: description: "MSYS2 packages branch to build from" type: string default: "woarm64" + runner_arch: + description: "Architecture to build on" + type: string + default: "x86_64" + needs: + description: "Parent workflow job dependencies" + type: string + dependencies: + description: "Install additional dependencies" + type: string + default: "" defaults: run: @@ -28,20 +32,79 @@ defaults: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CLEAN_BUILD: 1 jobs: build: name: Build ${{ inputs.package_name }} - runs-on: windows-latest + runs-on: ${{ fromJson(inputs.runner_arch == 'aarch64' && '["Windows", "ARM64", "Blackhex"]' || '["windows-latest"]') }} steps: + - name: Kill hanging processes + if: ${{ inputs.runner_arch == 'aarch64' }} + shell: powershell + run: | + tasklist + taskkill /F /FI 'MODULES eq msys-2.0.dll' + tasklist + Set-Location "${{ github.workspace }}" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path packages + exit 0 + + - name: Fix Git long paths + if: ${{ inputs.runner_arch == 'aarch64' }} + shell: powershell + run: | + git config --global core.longpaths true + + - name: Fix $PATH + if: ${{ inputs.runner_arch == 'aarch64' }} + shell: powershell + run: | + Write-Output "GITHUB_PATH: $env:GITHUB_PATH" + Write-Output "C:\Program Files\Git\usr\bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - uses: msys2/setup-msys2@v2 + timeout-minutes: 10 with: msystem: ${{ contains(inputs.packages_repository, 'MINGW') && 'MINGW64' || 'MSYS' }} + update: ${{ inputs.runner_arch == 'x86_64' }} + cache: ${{ inputs.runner_arch == 'x86_64' }} - name: Checkout repository uses: actions/checkout@v4 + - name: Checkout ${{ inputs.packages_repository }} repository + uses: actions/checkout@v4 + with: + repository: ${{ inputs.packages_repository }} + ref: ${{ inputs.packages_branch }} + sparse-checkout: ${{ inputs.package_name }} + path: ${{ github.workspace }}/packages + + - name: Pacman hang workaround + if: ${{ inputs.runner_arch == 'aarch64' }} + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/pacman-workaround.sh + + - name: First MSYS2 update + if: ${{ inputs.runner_arch == 'aarch64' }} + shell: powershell + run: | + msys2 -c 'pacman -Syuu --noconfirm' + exit 0 + + - name: Second MSYS2 update + if: ${{ inputs.runner_arch == 'aarch64' }} + shell: powershell + run: | + msys2 -c 'pacman -Syuu --noconfirm' + + - name: Setup packages repository + if: ${{ inputs.runner_arch == 'aarch64' }} + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh + - name: Install dependencies run: | pacman -S --noconfirm \ @@ -49,7 +112,7 @@ jobs: mingw-w64-x86_64-github-cli \ mingw-w64-x86_64-jq \ base-devel \ - ${{ contains(inputs.packages_repository, 'MINGW') && 'mingw-w64-cross-gcc mingw-w64-x86_64-ccache' || ' ccache' }} \ + ${{ contains(inputs.packages_repository, 'MINGW') && 'mingw-w64-cross-gcc mingw-w64-cross-windows-default-manifest mingw-w64-x86_64-gcc-libs' || '' }} \ ${{ inputs.dependencies }} - name: Download artifacts @@ -67,13 +130,10 @@ jobs: run: | `cygpath "${{ github.workspace }}"`/.github/scripts/pthread-headers-hack-before.sh - - name: Checkout ${{ inputs.packages_repository }} repository - uses: actions/checkout@v4 - with: - repository: ${{ inputs.packages_repository }} - ref: ${{ inputs.packages_branch }} - sparse-checkout: ${{ inputs.package_name }} - path: ${{ github.workspace }}/packages + - name: Setup MINGWARM64 environment + if: ${{ inputs.runner_arch == 'aarch64' }} + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/setup-mingwarm64.sh - name: Enable Ccache id: enable-ccache @@ -81,7 +141,7 @@ jobs: `cygpath "${{ github.workspace }}"`/.github/scripts/enable-ccache.sh - name: Restore Ccache - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v4 with: path: ${{ github.workspace }}/ccache key: main-ccache-${{ steps.enable-ccache.outputs.timestamp }} @@ -90,13 +150,11 @@ jobs: - name: Build ${{ inputs.package_name }} working-directory: ${{ github.workspace }}/packages/${{ inputs.package_name }} run: | - ccache -svv || true `cygpath "${{ github.workspace }}"`/.github/scripts/build-package.sh ${{ inputs.packages_repository }} - ccache -svv || true - name: Save Ccache if: always() - uses: actions/cache/save@v4 + uses: actions/cache/save@v4 with: path: ${{ github.workspace }}/ccache key: main-ccache-${{ steps.enable-ccache.outputs.timestamp }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f288c1b..c468c92 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,6 +12,11 @@ on: type: string required: false default: "woarm64" + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + required: false + default: "woarm64" jobs: mingw-cross-toolchain: @@ -20,9 +25,18 @@ jobs: with: msys2_packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} + mingw-native-toolchain: + name: MinGW native toolchain + uses: ./.github/workflows/mingw-native-toolchain.yml + with: + mingw_packages_branch: ${{ inputs.mingw_packages_branch || 'woarm64' }} + repository: name: Create MSYS2 repository - needs: mingw-cross-toolchain + needs: [ + mingw-cross-toolchain, + mingw-native-toolchain + ] runs-on: windows-latest defaults: @@ -50,8 +64,10 @@ jobs: - name: Download artifacts run: | - `cygpath "${{ github.workspace }}"`/.github/scripts/download-artifacts.sh ${{ github.run_id }} \ - '${{ needs.mingw-cross-toolchain.outputs.artifacts }}' + `cygpath "${{ github.workspace }}"`/.github/scripts/download-artifacts.sh \ + ${{ github.run_id }} \ + '${{ needs.mingw-cross-toolchain.outputs.artifacts }}' \ + '${{ needs.mingw-native-toolchain.outputs.artifacts }}' - name: Setup MSYS2 packages repository run: | @@ -75,7 +91,7 @@ jobs: path: "." deploy: - if: github.ref == 'refs/heads/main' + #if: github.ref == 'refs/heads/main' name: Deploy MSYS2 repository needs: repository runs-on: ubuntu-latest diff --git a/.github/workflows/mingw-native-toolchain.yml b/.github/workflows/mingw-native-toolchain.yml new file mode 100644 index 0000000..91a133b --- /dev/null +++ b/.github/workflows/mingw-native-toolchain.yml @@ -0,0 +1,242 @@ +name: Build MinGW native toolchain + +on: + workflow_dispatch: + inputs: + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + required: false + default: "woarm64" + workflow_call: + inputs: + mingw_packages_branch: + description: "MINGW-packages branch to build" + type: string + default: "woarm64" + outputs: + artifacts: + value: ${{ toJson(jobs) }} + +jobs: + mingw-w64-libiconv: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-libiconv + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-libtre-git: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-libtre-git + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-libsystre: + needs: [ + mingw-w64-libtre-git + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-libsystre + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-ncurses: + needs: [ + mingw-w64-libtre-git, + mingw-w64-libsystre + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-ncurses + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-gettext: + needs: [ + mingw-w64-libiconv, + mingw-w64-libtre-git, + mingw-w64-libsystre, + mingw-w64-ncurses + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-gettext + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-headers-git: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-headers-git + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-crt-git: + needs: [ + mingw-w64-headers-git + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-crt-git + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-winpthreads-git: + needs: [ + mingw-w64-headers-git, + mingw-w64-crt-git + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-winpthreads-git + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-bzip2: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-bzip2 + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-zlib: + needs: [ + mingw-w64-bzip2 + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-zlib + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-zstd: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-zstd + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-gmp: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-gmp + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-mpfr: + uses: ./.github/workflows/build-package.yml + needs: [ + mingw-w64-gmp + ] + with: + package_name: mingw-w64-mpfr + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-isl: + uses: ./.github/workflows/build-package.yml + needs: [ + mingw-w64-gmp + ] + with: + package_name: mingw-w64-isl + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-binutils: + needs: [ + mingw-w64-libiconv, + mingw-w64-libtre-git, + mingw-w64-libsystre, + mingw-w64-ncurses, + mingw-w64-gettext, + mingw-w64-headers-git, + mingw-w64-winpthreads-git, + mingw-w64-bzip2, + mingw-w64-zlib, + mingw-w64-zstd, + mingw-w64-gmp, + mingw-w64-mpfr, + mingw-w64-isl + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-binutils + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-mpc: + needs: [ + mingw-w64-gmp, + mingw-w64-mpfr + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-mpc + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} + + mingw-w64-windows-default-manifest: + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-windows-default-manifest + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + + mingw-w64-gcc: + needs: [ + mingw-w64-libiconv, + mingw-w64-libtre-git, + mingw-w64-libsystre, + mingw-w64-ncurses, + mingw-w64-gettext, + mingw-w64-headers-git, + mingw-w64-winpthreads-git, + mingw-w64-bzip2, + mingw-w64-zlib, + mingw-w64-zstd, + mingw-w64-gmp, + mingw-w64-mpfr, + mingw-w64-isl, + mingw-w64-binutils, + mingw-w64-mpc, + mingw-w64-crt-git, + mingw-w64-windows-default-manifest + ] + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-gcc + packages_repository: Windows-on-ARM-Experiments/MINGW-packages + packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }} + runner_arch: aarch64 + needs: ${{ toJson(needs) }} diff --git a/build-native.sh b/build-native.sh new file mode 100644 index 0000000..33de4ec --- /dev/null +++ b/build-native.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on + +if [[ "$MSYSTEM" != "MINGW64" ]]; then + echo "This script must be run in the MSYS2 MINGW64 shell" + exit 1 +fi + +ROOT_DIR=`dirname ${BASH_SOURCE[0]}` +ROOT_DIR=`realpath $ROOT_DIR` +CLEAN_BUILD=${CLEAN_BUILD:-0} + +function build_package () { + PACKAGE=$1 + echo "::group::Build $PACKAGE" + pushd ../MINGW-packages/$PACKAGE + rm -rf *.pkg.tar.zst + INSTALL_PACKAGE=1 \ + $ROOT_DIR/.github/scripts/build-package.sh MINGW + popd + echo "::endgroup::" +} + +function remove_package() { + PACKAGE=$1 + pacman -R -d -d $PACKAGE +} + +pacman -S --noconfirm \ + base-devel \ + mingw-w64-cross-gcc \ + mingw-w64-cross-windows-default-manifest \ + mingw-w64-x86_64-gcc-libs + +build_package mingw-w64-libiconv +build_package mingw-w64-libtre-git +build_package mingw-w64-libsystre +build_package mingw-w64-ncurses +build_package mingw-w64-gettext +build_package mingw-w64-bzip2 +build_package mingw-w64-zlib +build_package mingw-w64-zstd +build_package mingw-w64-gmp +build_package mingw-w64-mpfr +build_package mingw-w64-isl +build_package mingw-w64-mpc + +build_package mingw-w64-headers-git +build_package mingw-w64-crt-git +build_package mingw-w64-winpthreads-git +build_package mingw-w64-binutils +build_package mingw-w64-windows-default-manifest +build_package mingw-w64-gcc diff --git a/build.sh b/build.sh index 055c908..f7ef4b2 100644 --- a/build.sh +++ b/build.sh @@ -3,10 +3,15 @@ set -e # exit on error set -x # echo on +if [[ "$MSYSTEM" != "MSYS" ]]; then + echo "This script must be run in the MSYS2 MSYS shell" + exit 1 +fi + CLEAN_BUILD=${CLEAN_BUILD:-0} MAKEPKG_OPTIONS="--syncdeps --rmdeps --noconfirm --noprogressbar --nocheck --force --install" -if [ "$CLEAN_BUILD" = 1 ] ; then +if [[ "$CLEAN_BUILD" = 1 ]] ; then MAKEPKG_OPTIONS="$MAKEPKG_OPTIONS --cleanbuild" fi @@ -18,7 +23,8 @@ pacman -R --noconfirm mingw-w64-cross-gcc-stage1 || true pacman -R --noconfirm mingw-w64-cross-binutils || true pacman -R --noconfirm mingw-w64-cross-headers || true -pacman -S --noconfirm base-devel +pacman -S --noconfirm \ + base-devel echo "::group::Build mingw-w64-cross-headers" pushd ../MSYS2-packages/mingw-w64-cross-headers diff --git a/patches/makepkg/0001-mingwarm64.patch b/patches/makepkg/0001-mingwarm64.patch new file mode 100644 index 0000000..da2aa4a --- /dev/null +++ b/patches/makepkg/0001-mingwarm64.patch @@ -0,0 +1,101 @@ +--- a/etc/makepkg_mingw.conf ++++ b/etc/makepkg_mingw.conf +@@ -34,17 +34,22 @@ + # + + if [[ "$MSYSTEM" == "MINGW64" ]]; then +- CARCH="x86_64" +- 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++" +- CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1" +- CFLAGS="-march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong" ++ CARCH="aarch64" ++ CHOST="aarch64-w64-mingw32" ++ MINGW_CHOST="aarch64-w64-mingw32" ++ MINGW_PREFIX="/mingwarm64" ++ MINGW_PACKAGE_PREFIX="mingw-w64-aarch64" ++ CC="aarch64-w64-mingw32-gcc" ++ CXX="aarch64-w64-mingw32-g++" ++ RC="aarch64-w64-mingw32-windres" ++ WINDRES="aarch64-w64-mingw32-windres" ++ STRIP="aarch64-w64-mingw32-strip" ++ OBJDUMP="aarch64-w64-mingw32-objdump" ++ OBJCOPY="aarch64-w64-mingw32-objcopy" ++ CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1 -I/mingwarm64/include" ++ CFLAGS="-O1 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong" + CXXFLAGS="$CFLAGS" +- LDFLAGS="" ++ LDFLAGS="-L/mingwarm64/lib" + elif [[ "$MSYSTEM" == "MINGW32" ]]; then + CARCH="i686" + CHOST="i686-w64-mingw32" +--- a/etc/msystem ++++ b/etc/msystem +@@ -31,9 +31,9 @@ + export MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX + ;; + MINGW64) +- MSYSTEM_PREFIX='/mingw64' +- MSYSTEM_CARCH='x86_64' +- MSYSTEM_CHOST='x86_64-w64-mingw32' ++ MSYSTEM_PREFIX='/mingwarm64' ++ MSYSTEM_CARCH='aarch64' ++ MSYSTEM_CHOST='aarch64-w64-mingw32' + MINGW_CHOST="${MSYSTEM_CHOST}" + MINGW_PREFIX="${MSYSTEM_PREFIX}" + MINGW_PACKAGE_PREFIX="mingw-w64-${MSYSTEM_CARCH}" +--- 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="/usr/lib/ccache/bin:${MINGW_MOUNT_POINT}/bin:${MINGW_MOUNT_POINT}/${MSYSTEM_CHOST}/bin:/opt/bin:/opt/${MSYSTEM_CHOST}/bin:/mingw64/bin:/mingw64/${MSYSTEM_CHOST}/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" +--- a/usr/share/makepkg/executable/strip.sh ++++ b/usr/share/makepkg/executable/strip.sh +@@ -30,7 +30,7 @@ + + executable_strip() { + if check_option "strip" "y"; then +- if ! type -p strip >/dev/null; then ++ if ! type -p $STRIP >/dev/null; then + error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" + return 1 + fi +--- 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 diff --git a/patches/makepkg/0002-enable-debug.patch b/patches/makepkg/0002-enable-debug.patch new file mode 100644 index 0000000..4ead6a3 --- /dev/null +++ b/patches/makepkg/0002-enable-debug.patch @@ -0,0 +1,20 @@ +--- a/etc/makepkg_mingw.conf ++++ b/etc/makepkg_mingw.conf +@@ -47,7 +47,7 @@ + OBJDUMP="aarch64-w64-mingw32-objdump" + OBJCOPY="aarch64-w64-mingw32-objcopy" + CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1 -I/mingwarm64/include" +- CFLAGS="-O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong" ++ CFLAGS="-g -O0 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong" + CXXFLAGS="$CFLAGS" + LDFLAGS="-L/mingwarm64/lib" + elif [[ "$MSYSTEM" == "MINGW32" ]]; then +@@ -169,7 +169,7 @@ + #-- lto: Add compile flags for building with link time optimization + #-- autodeps: Automatically add depends/provides + # +-OPTIONS=(strip docs !libtool staticlibs emptydirs zipman purge !debug !lto !autodeps) ++OPTIONS=(!strip docs !libtool staticlibs emptydirs zipman purge !debug !lto !autodeps) + + #-- File integrity checks to use. Valid: ck, md5, sha1, sha224, sha256, sha384, sha512, b2 + INTEGRITY_CHECK=(sha256) diff --git a/patches/pacman/0001-pin-packages.patch b/patches/pacman/0001-pin-packages.patch new file mode 100644 index 0000000..9e0d212 --- /dev/null +++ b/patches/pacman/0001-pin-packages.patch @@ -0,0 +1,11 @@ +--- a/etc/pacman.conf ++++ b/etc/pacman.conf +@@ -21,7 +21,7 @@ + Architecture = auto + + # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +-#IgnorePkg = ++IgnorePkg = pacman pacman-mirrors + #IgnoreGroup = + + #NoUpgrade = diff --git a/patches/pacman/0002-add-woarm64-repository.patch b/patches/pacman/0002-add-woarm64-repository.patch new file mode 100644 index 0000000..5931616 --- /dev/null +++ b/patches/pacman/0002-add-woarm64-repository.patch @@ -0,0 +1,13 @@ +--- a/etc/pacman.conf ++++ b/etc/pacman.conf +@@ -70,6 +70,10 @@ + # Server = https://repo.msys2.org/staging/ + # SigLevel = Never + ++[woarm64] ++Server = https://windows-on-arm-experiments.github.io/msys2-woarm64-build/x86_64 ++SigLevel = Optional ++ + [clangarm64] + Include = /etc/pacman.d/mirrorlist.mingw + diff --git a/patches/pacman/pacman-6.1.0-4-x86_64.pkg.tar.zst b/patches/pacman/pacman-6.1.0-4-x86_64.pkg.tar.zst new file mode 100644 index 0000000..2b47255 Binary files /dev/null and b/patches/pacman/pacman-6.1.0-4-x86_64.pkg.tar.zst differ