diff --git a/.github/scripts/build-package.sh b/.github/scripts/build-package.sh index 2e49e9e..1c386a7 100755 --- a/.github/scripts/build-package.sh +++ b/.github/scripts/build-package.sh @@ -9,15 +9,16 @@ PACKAGE_REPOSITORY=$1 CLEAN_BUILD=${CLEAN_BUILD:-0} INSTALL_PACKAGE=${INSTALL_PACKAGE:-0} NO_EXTRACT=${NO_EXTRACT:-0} +NO_CHECK=${NO_CHECK:-1} ARGUMENTS="--syncdeps \ --rmdeps \ --noconfirm \ --noprogressbar \ - --nocheck \ --skippgpcheck \ --force \ $([ "$NO_EXTRACT" = 1 ] && echo "--noextract" || echo "") \ + $([ "$NO_CHECK" = 1 ] && echo "--nocheck " || echo "") \ $([ "$CLEAN_BUILD" = 1 ] && echo "--cleanbuild" || echo "") \ $([ "$INSTALL_PACKAGE" = 1 ] && echo "--install" || echo "")" diff --git a/.github/scripts/patch-dejagnu.sh b/.github/scripts/patch-dejagnu.sh new file mode 100755 index 0000000..acf858a --- /dev/null +++ b/.github/scripts/patch-dejagnu.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on +set -o pipefail # fail of any command in pipeline is an error + +DIR="`dirname ${BASH_SOURCE[0]}`/../.." +DIR=`realpath $DIR` + +pushd / + echo "::group::Patch Dejagnu" + patch -p1 -b -i "$DIR/patches/dejagnu/0001-local-exec.patch" + echo "::endgroup::" +popd diff --git a/.github/workflows/build-and-test-mingw-w64-gcc.yml b/.github/workflows/build-and-test-mingw-w64-gcc.yml new file mode 100644 index 0000000..969fd6f --- /dev/null +++ b/.github/workflows/build-and-test-mingw-w64-gcc.yml @@ -0,0 +1,65 @@ +name: Build and test mingw-w64-gcc + +on: + pull_request: + workflow_dispatch: + inputs: + packages_repository: + description: "MSYS2 packages repository to build from" + type: string + default: "Windows-on-ARM-Experiments/MINGW-packages" + packages_branch: + description: "MSYS2 packages branch to build from" + type: string + default: "woarm64" + arch: + description: 'Architecture to build for' + required: false + default: 'x86_64' + tag: + description: 'Tag to use for the artifact' + required: true + gcc_module: + description: 'GCC module to test' + required: false + default: '' + gcc_test_filter: + description: 'GCC test filter' + required: false + default: '' + workflow_call: + inputs: + packages_repository: + type: string + packages_branch: + type: string + arch: + type: string + tag: + type: string + gcc_module: + type: string + gcc_test_filter: + type: string + +env: + ARCH: ${{ inputs.arch || 'x86_64' }} + + TAG: ${{ inputs.tag || 'test' }} + MODULE: ${{ inputs.gcc_module || '' }} + FILTER: ${{ inputs.gcc_test_filter || '' }} + +defaults: + run: + shell: msys2 {0} + +jobs: + build-and-test-mingw-w64-gcc: + name: Build and test mingw-w64-gcc + uses: ./.github/workflows/build-package.yml + with: + package_name: mingw-w64-gcc + arch: ${{ inputs.arch || 'x86_64' }} + check: true + packages_repository: ${{ inputs.packages_repository || 'Windows-on-ARM-Experiments/MINGW-packages' }} + packages_branch: ${{ inputs.packages_branch || 'woarm64' }} diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index 626e7cf..17d9b7a 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -13,6 +13,18 @@ on: description: "Install additional dependencies" type: string default: "" + arch: + description: "Architecture to build for" + type: string + default: "aarch64" + cross: + description: "Enable cross-compilation of the package" + type: boolean + default: false + check: + description: "Enable check step after the package is built" + type: boolean + default: false packages_repository: description: "MSYS2 packages repository to build from" type: string @@ -28,6 +40,7 @@ defaults: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NO_CHECK: ${{ inputs.check && '0' || '1' }} jobs: build: @@ -42,6 +55,14 @@ jobs: - 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: Install dependencies run: | pacman -S --noconfirm \ @@ -49,7 +70,8 @@ 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' }} \ + ccache \ + ${{ contains(inputs.packages_repository, 'MINGW') && format('{0}-{1}-{2}', 'mingw-w64', inputs.arch, 'gcc')|| '' }} \ ${{ inputs.dependencies }} - name: Download artifacts @@ -67,13 +89,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: Patch Dejagnu + if: ${{ inputs.check }} + run: | + `cygpath "${{ github.workspace }}"`/.github/scripts/patch-dejagnu.sh - name: Enable Ccache id: enable-ccache @@ -108,6 +127,13 @@ jobs: retention-days: 1 path: ${{ github.workspace }}/packages/${{ inputs.package_name }}/*.pkg.tar.zst + - name: Upload ${{ inputs.package_name }} test results + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.package_name }}-tests + retention-days: 14 + path: ${{ github.workspace }}/packages/${{ inputs.package_name }}/src/test-results + - name: Upload build folder if: failure() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f288c1b..84b5df7 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/mingw-cross-toolchain.yml b/.github/workflows/mingw-cross-toolchain.yml index 38df232..484ab89 100644 --- a/.github/workflows/mingw-cross-toolchain.yml +++ b/.github/workflows/mingw-cross-toolchain.yml @@ -24,7 +24,7 @@ jobs: with: package_name: mingw-w64-cross-headers packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-binutils: needs: mingw-w64-cross-headers @@ -33,7 +33,7 @@ jobs: package_name: mingw-w64-cross-binutils needs: ${{ toJson(needs) }} packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-gcc-stage1: needs: [mingw-w64-cross-headers, mingw-w64-cross-binutils] @@ -42,7 +42,7 @@ jobs: package_name: mingw-w64-cross-gcc-stage1 needs: ${{ toJson(needs) }} packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-windows-default-manifest: needs: [mingw-w64-cross-binutils, mingw-w64-cross-gcc-stage1] @@ -51,7 +51,7 @@ jobs: package_name: mingw-w64-cross-windows-default-manifest needs: ${{ toJson(needs) }} packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-crt: needs: @@ -66,7 +66,7 @@ jobs: needs: ${{ toJson(needs) }} dependencies: mingw-w64-cross-winpthreads packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-winpthreads: needs: @@ -81,7 +81,7 @@ jobs: package_name: mingw-w64-cross-winpthreads needs: ${{ toJson(needs) }} packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-gcc: needs: @@ -98,7 +98,7 @@ jobs: package_name: mingw-w64-cross-gcc needs: ${{ toJson(needs) }} packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} mingw-w64-cross-zlib: needs: [ @@ -115,4 +115,4 @@ jobs: package_name: mingw-w64-cross-zlib needs: ${{ toJson(needs) }} packages_repository: Windows-on-ARM-Experiments/MSYS2-packages - packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }} + packages_branch: ${{ inputs.msys2_packages_branch || 'woarm64' }} diff --git a/patches/dejagnu/0001-local-exec.patch b/patches/dejagnu/0001-local-exec.patch new file mode 100644 index 0000000..14be0b2 --- /dev/null +++ b/patches/dejagnu/0001-local-exec.patch @@ -0,0 +1,159 @@ +--- a/usr/share/dejagnu/remote.exp ++++ b/usr/share/dejagnu/remote.exp +@@ -164,14 +164,7 @@ proc local_exec { commandline inp outp timeout } { + # ignore SIGHUP. + global errorInfo + if { $inp eq "" && $outp eq "" } { +- set id -1 +- set result [catch "eval spawn -ignore SIGHUP \{${commandline}\}" pid] +- if { $result == 0 } { +- set result2 0 +- } else { +- set pid 0 +- set result2 5 +- } ++ set status [catch "exec ${commandline}" output] + } else { + # Use a command pipeline with open. + if { $inp ne "" } { +@@ -205,78 +198,80 @@ proc local_exec { commandline inp outp timeout } { + } + set pid [pid $id] + set result [catch "spawn -ignore SIGHUP -leaveopen $id" result2] +- } +- # Prepend "-" to each pid, to generate the "process group IDs" needed by +- # kill. +- set pgid "-[join $pid { -}]" +- verbose "pid is $pid $pgid" +- if { $result != 0 || $result2 != 0 } { +- # This shouldn't happen. +- if {[info exists errorInfo]} { +- set foo $errorInfo +- } else { +- set foo "" ++ ++ # Prepend "-" to each pid, to generate the "process group IDs" needed by ++ # kill. ++ set pgid "-[join $pid { -}]" ++ verbose "pid is $pid $pgid" ++ if { $result != 0 || $result2 != 0 } { ++ # This shouldn't happen. ++ if {[info exists errorInfo]} { ++ set foo $errorInfo ++ } else { ++ set foo "" ++ } ++ verbose "spawn -open $id failed, $result $result2, $foo" ++ catch "close $id" ++ return [list -1 "spawn failed"] + } +- verbose "spawn -open $id failed, $result $result2, $foo" +- catch "close $id" +- return [list -1 "spawn failed"] +- } + +- set got_eof 0 +- set output "" ++ set got_eof 0 ++ set output "" + +- # Wait for either $timeout seconds to elapse, or for the program to +- # exit. +- expect { +- -i $spawn_id -timeout $timeout -re ".+" { +- append output $expect_out(buffer) +- exp_continue -continue_timer +- } +- timeout { +- warning "program timed out" +- } +- eof { +- set got_eof 1 ++ # Wait for either $timeout seconds to elapse, or for the program to ++ # exit. ++ expect { ++ -i $spawn_id -timeout $timeout -re ".+" { ++ append output $expect_out(buffer) ++ exp_continue -continue_timer ++ } ++ timeout { ++ warning "program timed out" ++ } ++ eof { ++ set got_eof 1 ++ } + } +- } + +- # If we didn't get EOF, we have to kill the poor defenseless program. +- if { $got_eof } { +- set pid -1 +- } +- set r2 [close_wait_program $spawn_id $pid wres] +- if { $id > 0 } { +- if { $pid > 0 } { +- # If timed-out, don't wait for all the processes associated +- # with the pipeline to terminate as a stuck one would cause +- # us to hang. +- catch {fconfigure $id -blocking false} ++ # If we didn't get EOF, we have to kill the poor defenseless program. ++ if { $got_eof } { ++ set pid -1 + } +- set r2 [catch "close $id" res] +- } else { +- verbose "waitres is $wres" 2 +- if { $r2 == 0 } { +- set r2 [lindex $wres 3] +- if { [llength $wres] > 4 } { +- if { [lindex $wres 4] eq "CHILDKILLED" } { +- set r2 1 +- } ++ set r2 [close_wait_program $spawn_id $pid wres] ++ if { $id > 0 } { ++ if { $pid > 0 } { ++ # If timed-out, don't wait for all the processes associated ++ # with the pipeline to terminate as a stuck one would cause ++ # us to hang. ++ catch {fconfigure $id -blocking false} + } +- if { $r2 != 0 } { +- set res $wres ++ set r2 [catch "close $id" res] ++ } else { ++ verbose "waitres is $wres" 2 ++ if { $r2 == 0 } { ++ set r2 [lindex $wres 3] ++ if { [llength $wres] > 4 } { ++ if { [lindex $wres 4] eq "CHILDKILLED" } { ++ set r2 1 ++ } ++ } ++ if { $r2 != 0 } { ++ set res $wres ++ } else { ++ set res "" ++ } + } else { +- set res "" ++ set res "wait failed" + } ++ } ++ if { $r2 != 0 || $res ne "" || ! $got_eof } { ++ verbose "close result is $res" ++ set status 1 + } else { +- set res "wait failed" ++ set status 0 + } + } +- if { $r2 != 0 || $res ne "" || ! $got_eof } { +- verbose "close result is $res" +- set status 1 +- } else { +- set status 0 +- } ++ + verbose "output is $output status $status" + if { $outp eq "" || $outp eq "|& cat" } { + return [list $status $output]