diff --git a/.github/scripts/binutils/build.sh b/.github/scripts/binutils/build.sh index 8a09c20ef5..68d3bbfa11 100755 --- a/.github/scripts/binutils/build.sh +++ b/.github/scripts/binutils/build.sh @@ -9,7 +9,7 @@ cd $BINUTILS_BUILD_PATH if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$BINUTILS_BUILD_PATH/Makefile" ]]; then echo "::group::Configure binutils" - rm -rf $BINUTILS_BUILD_PATH/* + $ROOT_PATH/.github/scripts/binutils/delete-build.sh if [[ "$DEBUG" = 1 ]]; then HOST_OPTIONS="$HOST_OPTIONS \ @@ -67,7 +67,7 @@ if [[ "$RUN_INSTALL" = 1 ]]; then echo "::group::Install binutils" make install if [[ "$DELETE_BUILD" = 1 ]]; then - rm -rf $BINUTILS_BUILD_PATH + $ROOT_PATH/.github/scripts/binutils/delete-build.sh fi echo "::endgroup::" fi diff --git a/.github/scripts/binutils/delete-build.sh b/.github/scripts/binutils/delete-build.sh index 64985625c1..9eaa761ed9 100755 --- a/.github/scripts/binutils/delete-build.sh +++ b/.github/scripts/binutils/delete-build.sh @@ -1,5 +1,11 @@ #!/bin/bash -source `dirname ${BASH_SOURCE[0]}`/config.sh +source `dirname ${BASH_SOURCE[0]}`/../config.sh -rm -rf $BINUTILS_BUILD_PATH +BINUTILS_BUILD_PATH=$BUILD_PATH/binutils + +echo "::group::Delete binutils build" + rm -rf $BINUTILS_BUILD_PATH/* +echo "::endgroup::" + +echo 'Success!' diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh index 11d58e3419..6e1ed0b19e 100755 --- a/.github/scripts/build.sh +++ b/.github/scripts/build.sh @@ -49,13 +49,20 @@ if [[ "$PLATFORM" =~ cygwin ]]; then $ROOT_PATH/.github/scripts/toolchain/build-cygwin.sh 1 fi -$ROOT_PATH/.github/scripts/toolchain/build-gcc.sh - -if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then - $ROOT_PATH/.github/scripts/toolchain/build-mingw.sh +if [[ "$TEST" = 1 ]]; then + DELETE_BUILD=0 \ + $ROOT_PATH/.github/scripts/toolchain/build-gcc.sh +else + $ROOT_PATH/.github/scripts/toolchain/build-gcc.sh fi -if [[ "$PLATFORM" =~ cygwin ]]; then - $ROOT_PATH/.github/scripts/toolchain/build-cygwin.sh 2 + +if [[ "$TEST" = 0 ]]; then + if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then + $ROOT_PATH/.github/scripts/toolchain/build-mingw.sh + fi + if [[ "$PLATFORM" =~ cygwin ]]; then + $ROOT_PATH/.github/scripts/toolchain/build-cygwin.sh 2 + fi fi if [[ "$CCACHE" = 1 ]]; then diff --git a/.github/scripts/config.sh b/.github/scripts/config.sh index d7d8748fa2..7a10351c2a 100644 --- a/.github/scripts/config.sh +++ b/.github/scripts/config.sh @@ -40,8 +40,8 @@ else fi PROCESSOR=$(uname --processor) -BUILD=${BUILD:-$PROCESSOR-pc-linux-gnu} -HOST=${HOST:-$PROCESSOR-pc-linux-gnu} +BUILD=${BUILD:-$PROCESSOR-linux-gnu} +HOST=${HOST:-$PROCESSOR-linux-gnu} TARGET=$ARCH-$PLATFORM TOOLCHAIN_NAME=${TOOLCHAIN_NAME:-$ARCH-$PLATFORM-$CRT} @@ -105,6 +105,7 @@ else fi DEBUG=${DEBUG:-0} # Enable debug build. +TEST=${TEST:-0} # Enable build for testing. CCACHE=${CCACHE:-0} # Enable usage of ccache. RUN_BOOTSTRAP=${RUN_BOOTSTRAP:-0} # Bootstrap dependencies during the build. UPDATE_SOURCES=${UPDATE_SOURCES:-0} # Update source code repositories. diff --git a/.github/scripts/get-cache-keys.sh b/.github/scripts/get-cache-keys.sh index e06c9d302c..306f012126 100755 --- a/.github/scripts/get-cache-keys.sh +++ b/.github/scripts/get-cache-keys.sh @@ -8,8 +8,10 @@ GCC_SHA=$($ROOT_PATH/.github/scripts/get-repository-sha.sh $GCC_REPO $GCC_BRANCH MINGW_SHA=$($ROOT_PATH/.github/scripts/get-repository-sha.sh $MINGW_REPO $MINGW_BRANCH) BINUTILS_SCRIPTS_SHA=$($ROOT_PATH/.github/scripts/get-files-sha.sh $ROOT_PATH $ROOT_PATH/.github/scripts/binutils) TOOLCHAIN_SCRIPTS_SHA=$($ROOT_PATH/.github/scripts/get-files-sha.sh $ROOT_PATH $ROOT_PATH/.github/scripts/toolchain) +TIMESTAMP=$(date -u --iso-8601=seconds) +echo "timestamp=$TIMESTAMP" >> "$GITHUB_OUTPUT" echo "toolchain-cache-key=$TOOLCHAIN_NAME-toolchain-$WORKFLOW_SHA-$BINUTILS_SHA-$GCC_SHA-$MINGW_SHA-$BINUTILS_SCRIPTS_SHA-$TOOLCHAIN_SCRIPTS_SHA" >> "$GITHUB_OUTPUT" echo "runtime-cache-key=$TOOLCHAIN_NAME-runtime-$WORKFLOW_SHA-$BINUTILS_SHA-$GCC_SHA-$MINGW_SHA-$BINUTILS_SCRIPTS_SHA-$TOOLCHAIN_SCRIPTS_SHA" >> "$GITHUB_OUTPUT" -echo "ccache-key=$TARGET-ccache-$(date -u --iso-8601=seconds)" >> "$GITHUB_OUTPUT" +echo "ccache-key=$TARGET-ccache-$TIMESTAMP" >> "$GITHUB_OUTPUT" echo "ccache-restore-keys=$TARGET-ccache-" >> "$GITHUB_OUTPUT" diff --git a/.github/scripts/get-paths.sh b/.github/scripts/get-paths.sh new file mode 100755 index 0000000000..91c2f55db5 --- /dev/null +++ b/.github/scripts/get-paths.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +source `dirname ${BASH_SOURCE[0]}`/config.sh + +echo "root-path-env=$ROOT_PATH" >> $GITHUB_OUTPUT +echo "build-path-env=$BUILD_PATH" >> $GITHUB_OUTPUT +echo "ccache-dir-path-env=$CCACHE_DIR_PATH" >> $GITHUB_OUTPUT +echo "artifact-path-env=$ARTIFACT_PATH" >> $GITHUB_OUTPUT + +if [ -x "$(command -v wslpath)" ]; then + echo "root-path-host=`wslpath -w $ROOT_PATH`" >> $GITHUB_OUTPUT + echo "build-path-host=`wslpath -w $BUILD_PATH`" >> $GITHUB_OUTPUT + echo "ccache-dir-path-host=`wslpath -w $CCACHE_DIR_PATH`" >> $GITHUB_OUTPUT + echo "artifact-path-host=`wslpath -w $ARTIFACT_PATH`" >> $GITHUB_OUTPUT +else + echo "root-path-host=$ROOT_PATH" >> $GITHUB_OUTPUT + echo "build-path-host=$BUILD_PATH" >> $GITHUB_OUTPUT + echo "ccache-dir-path-host=$CCACHE_DIR_PATH" >> $GITHUB_OUTPUT + echo "artifact-path-host=$ARTIFACT_PATH" >> $GITHUB_OUTPUT +fi diff --git a/.github/scripts/toolchain/build-gcc.sh b/.github/scripts/toolchain/build-gcc.sh index aaa6246a0f..a196522129 100755 --- a/.github/scripts/toolchain/build-gcc.sh +++ b/.github/scripts/toolchain/build-gcc.sh @@ -9,7 +9,7 @@ cd $GCC_BUILD_PATH if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then echo "::group::Configure GCC" - rm -rf $GCC_BUILD_PATH/* + $ROOT_PATH/.github/scripts/toolchain/delete-gcc-build.sh if [[ "$DEBUG" = 1 ]]; then HOST_OPTIONS="$HOST_OPTIONS \ @@ -127,7 +127,7 @@ if [[ "$RUN_INSTALL" = 1 ]]; then echo "::group::Install GCC" make install if [[ "$DELETE_BUILD" = 1 ]]; then - rm -rf $GCC_BUILD_PATH + $ROOT_PATH/.github/scripts/toolchain/delete-gcc-build.sh fi echo "::endgroup::" fi diff --git a/.github/scripts/toolchain/compare-gcc-results.sh b/.github/scripts/toolchain/compare-gcc-results.sh index c474e8eaa0..478caa821e 100755 --- a/.github/scripts/toolchain/compare-gcc-results.sh +++ b/.github/scripts/toolchain/compare-gcc-results.sh @@ -2,20 +2,31 @@ source `dirname ${BASH_SOURCE[0]}`/../config.sh -BASELINE_TAG=$1 -TEST_TAG=$2 -BASELINE_PATH=$ARTIFACT_PATH/gcc-tests-$BASELINE_TAG -TEST_PATH=$ARTIFACT_PATH/gcc-tests-$TEST_TAG -RESULTS_PATH=$ARTIFACT_PATH/gcc-tests-results +BASELINE_PATH=$1 +CHANGES_PATH=$2 +RESULTS_PATH=$3 mkdir -p $RESULTS_PATH echo "::group::Compare GCC tests results" - for TEST_FILE in $TEST_PATH/*.sum; do - BASELINE_FIILE=$BASELINE_PATH/`basename $TEST_FILE` - $SOURCE_PATH/gcc/contrib/compare_tests $BASELINE_FIILE $TEST_FILE > \ - $RESULTS_PATH/`basename $TEST_FILE .sum`.diff && true + for CHANGES_FILE in $CHANGES_PATH/*.sum; do + FILE=`basename $CHANGES_FILE` + BASELINE_FILE=$BASELINE_PATH/$FILE + RESULT_FILE=${FILE%.sum}.diff + $SOURCE_PATH/gcc/contrib/compare_tests $BASELINE_FILE $CHANGES_FILE > \ + $RESULTS_PATH/$RESULT_FILE && true done echo "::endgroup::" +echo "::group::Create GCC tests results summary" + rm -rf $RESULTS_PATH/summary.md + SUMMARY_FILE=$RESULTS_PATH/summary.md + for RESULT_FILE in $RESULTS_PATH/*.diff; do + echo "### Test results for \`$(basename $RESULT_FILE)\`" >> $SUMMARY_FILE + echo "" >> $SUMMARY_FILE + echo "\`\`\`" >> $SUMMARY_FILE + cat $RESULT_FILE >> $SUMMARY_FILE + echo "\`\`\`" >> $SUMMARY_FILE + echo "" >> $SUMMARY_FILE + done echo 'Success!' diff --git a/.github/scripts/toolchain/create-gcc-summary.sh b/.github/scripts/toolchain/create-gcc-summary.sh index 257e2e9095..6cfd13547d 100755 --- a/.github/scripts/toolchain/create-gcc-summary.sh +++ b/.github/scripts/toolchain/create-gcc-summary.sh @@ -24,6 +24,7 @@ print_summary() { fi echo "### $TITLE" + echo "" echo "| Metric | Count |" echo "|-----------------------|-----------------------|" echo "| Expected passes | $EXPECTED_PASSES |" diff --git a/.github/scripts/toolchain/delete-gcc-build.sh b/.github/scripts/toolchain/delete-gcc-build.sh new file mode 100755 index 0000000000..d423fe5701 --- /dev/null +++ b/.github/scripts/toolchain/delete-gcc-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source `dirname ${BASH_SOURCE[0]}`/../config.sh + +GCC_BUILD_PATH=$BUILD_PATH/gcc + +echo "::group::Delete GCC build" + rm -rf $GCC_BUILD_PATH/* +echo "::endgroup::" + +echo 'Success!' diff --git a/.github/scripts/toolchain/execute-gcc-tests.sh b/.github/scripts/toolchain/execute-gcc-tests.sh index e87e09dcec..ad361e8dbe 100755 --- a/.github/scripts/toolchain/execute-gcc-tests.sh +++ b/.github/scripts/toolchain/execute-gcc-tests.sh @@ -11,7 +11,6 @@ TARGET_BOARD=${4:-wsl-sim} HOST_BOARD=${5:-} GCC_BUILD_PATH=$BUILD_PATH/gcc -TEST_RESULTS_PATH=$ARTIFACT_PATH/$DIR PATH="$TOOLCHAIN_PATH/bin:$PATH" @@ -38,12 +37,17 @@ echo "::group::Execute GCC tests" CHECK_TEST_FRAMEWORK=1 \ || echo "Error" - mkdir -p $TEST_RESULTS_PATH - rm -rf $TEST_RESULTS_PATH/* + mkdir -p $DIR + rm -rf $DIR/* for FILE in `find $GCC_BUILD_PATH -path '*testsuite*.log' -or -path '*testsuite*.sum'`; do - cp $FILE $TEST_RESULTS_PATH/ + cp $FILE $DIR/ done echo "::endgroup::" +echo "::group::Create GCC tests summary" + $ROOT_PATH/.github/scripts/toolchain/create-gcc-summary.sh $DIR >> $DIR/summary.md + $ROOT_PATH/.github/scripts/toolchain/group-gcc-test-failures.sh $DIR >> $DIR/most-frequent-groups.md +echo "::endgroup::" + echo 'Success!' diff --git a/.github/scripts/toolchain/group-gcc-test-failures.sh b/.github/scripts/toolchain/group-gcc-test-failures.sh index fa53aee709..b1caa08ed7 100755 --- a/.github/scripts/toolchain/group-gcc-test-failures.sh +++ b/.github/scripts/toolchain/group-gcc-test-failures.sh @@ -5,8 +5,7 @@ source `dirname ${BASH_SOURCE[0]}`/../config.sh DIR=$1 python3 $ROOT_PATH/.github/scripts/toolchain/group-gcc-test-failures.py \ - --dir $ARTIFACT_PATH/$DIR >> \ - $ARTIFACT_PATH/$DIR/grouped-test-failures.md + --dir $DIR >> $DIR/grouped-test-failures.md -cat $ARTIFACT_PATH/$DIR/grouped-test-failures.md | +cat $DIR/grouped-test-failures.md | $ROOT_PATH/.github/scripts/toolchain/extract-most-frequent-failures.sh 10 diff --git a/.github/scripts/toolchain/pack-gcc-build.sh b/.github/scripts/toolchain/pack-gcc-build.sh new file mode 100755 index 0000000000..1c29868f96 --- /dev/null +++ b/.github/scripts/toolchain/pack-gcc-build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +source `dirname ${BASH_SOURCE[0]}`/../config.sh + +GCC_BUILD_PATH=$BUILD_PATH/gcc + +echo "::group::Pack GCC build" + mkdir -p $ARTIFACT_PATH + tar czf $ARTIFACT_PATH/gcc-build.tar.gz -C $GCC_BUILD_PATH . +echo "::endgroup::" + +echo 'Success!' diff --git a/.github/workflows/advanced.yml b/.github/workflows/advanced.yml index b6b9dafc46..0167215b9c 100644 --- a/.github/workflows/advanced.yml +++ b/.github/workflows/advanced.yml @@ -4,7 +4,6 @@ on: push: branches: - main - pull_request: workflow_dispatch: inputs: binutils_branch: @@ -133,14 +132,14 @@ jobs: fail-fast: false matrix: arch: [aarch64, x86_64] - platform: [w64-mingw32, pc-linux-gnu, pc-cygwin] + platform: [w64-mingw32, linux-gnu, pc-cygwin] crt: [msvcrt, ucrt, libc] exclude: - platform: w64-mingw32 crt: libc - - platform: pc-linux-gnu + - platform: linux-gnu crt: msvcrt - - platform: pc-linux-gnu + - platform: linux-gnu crt: ucrt - platform: pc-cygwin crt: ucrt @@ -169,7 +168,7 @@ jobs: fetch-depth: 0 - name: Get cache keys - id: cache-keys + id: get-cache-keys run: | .github/scripts/get-cache-keys.sh @@ -179,7 +178,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.ARTIFACT_PATH }}/${{ env.TOOLCHAIN_PACKAGE_NAME }} - key: ${{ steps.cache-keys.outputs.toolchain-cache-key }} + key: ${{ steps.get-cache-keys.outputs.toolchain-cache-key }} enableCrossOsArchive: true - name: Cache runtime @@ -188,7 +187,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.RELATIVE_ARTIFACT_PATH }}/${{ env.RUNTIME_PACKAGE_NAME }} - key: ${{ steps.cache-keys.outputs.runtime-cache-key }} + key: ${{ steps.get-cache-keys.outputs.runtime-cache-key }} enableCrossOsArchive: true - name: Checkout binutils @@ -208,7 +207,7 @@ jobs: path: ${{ env.SOURCE_PATH }}/gcc - name: Checkout MinGW - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'pc-linux-gnu' }} + if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'linux-gnu' }} uses: actions/checkout@v4 with: repository: ${{ env.MINGW_REPO }} @@ -253,8 +252,8 @@ jobs: uses: actions/cache/restore@v4 with: path: ${{ env.CCACHE_DIR_PATH }} - key: ${{ steps.cache-keys.outputs.ccache-key }} - restore-keys: ${{ steps.cache-keys.outputs.ccache-restore-keys }} + key: ${{ steps.get-cache-keys.outputs.ccache-key }} + restore-keys: ${{ steps.get-cache-keys.outputs.ccache-restore-keys }} - name: Build binutils if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' }} @@ -275,12 +274,12 @@ jobs: .github/scripts/binutils/delete-build.sh - name: Install cross headers and libraries - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'pc-linux-gnu' }} + if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'linux-gnu' }} run: | .github/scripts/toolchain/install-cross-headers-libs.sh - name: Build MinGW headers - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'pc-linux-gnu' }} + if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'linux-gnu' }} run: | .github/scripts/toolchain/build-mingw-headers.sh @@ -290,12 +289,12 @@ jobs: .github/scripts/toolchain/install-cygwin-headers.sh - name: Build GCC stage1 - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'pc-linux-gnu' }} + if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'linux-gnu' }} run: | .github/scripts/toolchain/build-gcc-stage1.sh - name: Build MinGW CRT - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'pc-linux-gnu' }} + if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'linux-gnu' }} run: | .github/scripts/toolchain/build-mingw-crt.sh @@ -320,7 +319,7 @@ jobs: .github/scripts/toolchain/build-gcc.sh - name: Build MinGW - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'pc-linux-gnu' }} + if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'linux-gnu' }} run: | .github/scripts/toolchain/build-mingw.sh @@ -334,7 +333,7 @@ jobs: uses: actions/cache/save@v4 with: path: ${{ env.CCACHE_DIR_PATH }} - key: ccache-${{ steps.cache-keys.outputs.ccache-key }} + key: ccache-${{ steps.get-cache-keys.outputs.ccache-key }} - name: Pack toolchain if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && env.PACK_TOOLCHAIN == 'true' }} @@ -375,8 +374,8 @@ jobs: toolchain-artifact-name: ${{ env.PACK_TOOLCHAIN == 'true' && env.TOOLCHAIN_ARTIFACT_NAME || '' }} runtime-package-name: ${{ env.PACK_TOOLCHAIN == 'true' && env.RUNTIME_PACKAGE_NAME || '' }} runtime-artifact-name: ${{ env.PACK_TOOLCHAIN == 'true' && env.RUNTIME_ARTIFACT_NAME || '' }} - toolchain-cache-key: ${{ env.PACK_TOOLCHAIN == 'true' && steps.cache-keys.outputs.toolchain-cache-key || '' }} - runtime-cache-key: ${{ env.PACK_TOOLCHAIN == 'true' && steps.cache-keys.outputs.runtime-cache-key || '' }} + toolchain-cache-key: ${{ env.PACK_TOOLCHAIN == 'true' && steps.get-cache-keys.outputs.toolchain-cache-key || '' }} + runtime-cache-key: ${{ env.PACK_TOOLCHAIN == 'true' && steps.get-cache-keys.outputs.runtime-cache-key || '' }} build-aarch64-tests: needs: [build-toolchain] diff --git a/.github/workflows/build-and-test-toolchain.yml b/.github/workflows/build-and-test-toolchain.yml index 547e306eb8..1dd5c33efb 100644 --- a/.github/workflows/build-and-test-toolchain.yml +++ b/.github/workflows/build-and-test-toolchain.yml @@ -18,7 +18,7 @@ on: arch: description: 'Architecture to build for' required: false - default: 'x86_64' + default: 'aarch64' platform: description: 'Platform to build for' required: false @@ -59,110 +59,258 @@ on: gcc_test_filter: type: string +run-name: Build and test ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-${{ inputs.tag }} toolchain + env: BINUTILS_BRANCH: ${{ inputs.binutils_branch || 'woarm64' }} GCC_BRANCH: ${{ inputs.gcc_branch || 'woarm64' }} MINGW_BRANCH: ${{ inputs.mingw_branch || 'woarm64' }} - ARCH: ${{ inputs.arch || 'x86_64' }} + ARCH: ${{ inputs.arch || 'aarch64' }} PLATFORM: ${{ inputs.platform || 'w64-mingw32' }} + TARGET: ${{ inputs.arch }}-${{ inputs.platform }} CRT: ${{ inputs.crt || 'msvcrt' }} - TAG: ${{ inputs.tag || 'test' }} + VARIANT: ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-${{ inputs.tag }} MODULE: ${{ inputs.gcc_module || '' }} FILTER: ${{ inputs.gcc_test_filter || '' }} + ROOT_PATH: /tmp/work + TOOLCHAIN_ARTIFACT_NAME: toolchain-${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-${{ inputs.tag }} + TOOLCHAIN_PACKAGE_NAME: toolchain-${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-${{ inputs.tag }}.tar.gz + + TEST: 1 CCACHE: 1 + DELETE_BUILD: 1 RUN_BOOTSTRAP: 1 UPDATE_SOURCES: 1 + RESET_SOURCES: 1 + + WSLENV: BINUTILS_BRANCH:GCC_BRANCH:MINGW_BRANCH:ARCH:PLATFORM:CRT:TAG:MODULE:FILTER:ROOT_PATH:TOOLCHAIN_ARTIFACT_NAME:TOOLCHAIN_PACKAGE_NAME:TEST:CCACHE:DELETE_BUILD:RUN_BOOTSTRAP:UPDATE_SOURCES:RESET_SOURCES:GITHUB_OUTPUT/p:GITHUB_STEP_SUMMARY/p + + DEFAULT_WINDOWS_RUNNER: ${{ ((inputs.arch == 'x86_64') && (inputs.platform != 'linux-gnu')) && 1 || 0 }} + DEFAULT_UBUNTU_RUNNER: ${{ (inputs.platform == 'linux-gnu') && 1 || 0 }} + SELF_HOSTED_RUNNER: ${{ ((inputs.arch != 'x86_64') && (inputs.platform != 'linux-gnu')) && 1 || 0 }} + WSL_RUNNER: ${{ (inputs.platform == 'w64-mingw32') && 1 || 0 }} + WSL_DISTRIBUTION: Ubuntu-22.04 + WSL_USER: root jobs: - build-and-test-toolchain: - name: Build and test toolchain - runs-on: windows-latest + build-toolchain: + name: Build ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-${{ inputs.tag }} toolchain + runs-on: ubuntu-22.04 + + outputs: + timestamp: ${{ steps.get-cache-keys.outputs.timestamp }} + + steps: + - name: Debug + run: | + env + + - name: Checkout repository + run: | + git clone --depth=1 ${{ github.server_url }}/${{ github.repository }}.git -b ${{ github.head_ref || github.ref_name || 'main' }} ${{ env.ROOT_PATH }} + + - name: Get cache keys + id: get-cache-keys + run: | + ${{ env.ROOT_PATH }}/.github/scripts/get-cache-keys.sh + + - name: Get paths + id: get-paths + run: | + ${{ env.ROOT_PATH }}/.github/scripts/get-paths.sh + + - name: Restore Ccache + uses: actions/cache/restore@v4 + with: + path: ${{ steps.get-paths.outputs.ccache-dir-path-host }} + key: build-and-test-${{ env.TARGET }}-gcc-ccache-${{ steps.get-cache-keys.outputs.ccache-key }} + restore-keys: build-and-test-${{ env.TARGET }}-gcc-ccache- + + - name: Build toolchain + run: | + ${{ env.ROOT_PATH }}/.github/scripts/build.sh + + - name: Pack GCC build folder + run: | + ${{ env.ROOT_PATH }}/.github/scripts/toolchain/pack-gcc-build.sh + + - name: Delete GCC build folder + run: | + ${{ env.ROOT_PATH }}/.github/scripts/toolchain/delete-gcc-build.sh + + - name: Save GCC build folder + uses: actions/cache/save@v4 + with: + key: gcc-build-${{ env.VARIANT }}-${{ steps.get-cache-keys.outputs.timestamp }} + path: ${{ steps.get-paths.outputs.artifact-path-host }}/gcc-build.tar.gz + enableCrossOsArchive: true + + - name: Pack toolchain + run: | + ${{ env.ROOT_PATH }}/.github/scripts/toolchain/pack.sh + + - name: Save toolchain + uses: actions/cache/save@v4 + with: + key: ${{ env.TOOLCHAIN_ARTIFACT_NAME }}-${{ steps.get-cache-keys.outputs.timestamp }} + path: ${{ steps.get-paths.outputs.artifact-path-host }}/${{ env.TOOLCHAIN_PACKAGE_NAME }} + enableCrossOsArchive: true + + - name: Save Ccache + if: always() + uses: actions/cache/save@v4 + with: + key: build-and-test-${{ env.TARGET }}-gcc-ccache-${{ steps.get-cache-keys.outputs.ccache-key }} + path: ${{ steps.get-paths.outputs.ccache-dir-path-host }} - env: - WSLENV: BINUTILS_BRANCH:GCC_BRANCH:MINGW_BRANCH:ARCH:PLATFORM:CRT:TAG:MODULE:FILTER:CCACHE:RUN_BOOTSTRAP:UPDATE_SOURCES:GITHUB_OUTPUT/p:GITHUB_STEP_SUMMARY/p + test-toolchain: + name: Test ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-${{ inputs.tag }} toolchain + needs: [ + build-toolchain + ] + timeout-minutes: 240 + runs-on: >- + ${{ + (inputs.arch == 'x86_64') + && ((inputs.platform == 'linux-gnu') + && 'ubuntu-22.04' + || 'windows-latest') + || ((inputs.platform == 'linux-gnu') + && 'ubuntu-22.04-arm' + || fromJson('["Windows", "ARM64", "WSL"]')) + }} defaults: run: - shell: wsl-bash {0} + shell: ${{ (env.WSL_RUNNER == 1) && 'wsl-bash {0}' || ((env.DEFAULT_UBUNTU_RUNNER == 1) && 'bash {0}' || 'wsl -d Ubuntu `wslpath -a {0}`') }} steps: - - name: Get cache key - id: get-cache-key + - name: Checkout repository + if: env.WSL_RUNNER == 1 + uses: actions/checkout@v4 + with: + path: ${{ github.workspace }} + + - name: Install zstd + if: env.WSL_RUNNER == 1 shell: powershell run: | - Write-Output "timestamp=$((Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"))" >> "$env:GITHUB_OUTPUT" + .github/scripts/install-zstd.ps1 + + - name: Install WSL (Vampire/setup-wsl) + if: (env.WSL_RUNNER == 1) && (env.DEFAULT_WINDOWS_RUNNER == 1) + uses: Windows-on-ARM-Experiments/setup-wsl@master + with: + distribution: ${{ env.WSL_DISTRIBUTION }} + wsl-shell-user: ${{ env.WSL_USER }} + additional-packages: + git - - name: Setup WSL + - name: Install WSL (Vampire/setup-wsl) + if: (env.WSL_RUNNER == 1) && (env.SELF_HOSTED_RUNNER == 1) uses: Windows-on-ARM-Experiments/setup-wsl@master with: - distribution: Ubuntu-22.04 + distribution: Ubuntu + set-as-default: false + wsl-version: 1 + wsl-shell-user: ${{ env.WSL_USER }} additional-packages: git + - name: Install winget + if: false + uses: Cyberboss/install-winget@v1 + + - name: Install WSL (Ubuntu/WSL/.github/actions/wsl-install) + if: false + uses: Ubuntu/WSL/.github/actions/wsl-install@main + with: + distro: ${{ env.WSL_DISTRIBUTION }} + + - name: Install WSL (wsl --install) + if: false + shell: powershell + run: | + wsl --set-default-version 1 + wsl --install --no-launch --distribution ${{ env.WSL_DISTRIBUTION }} + wsl --list --verbose + + - name: Debug + run: | + env + + - name: Clean up previous build + if: env.SELF_HOSTED_RUNNER == 1 + run: | + rm -rf ${{ env.ROOT_PATH }} + - name: Checkout repository run: | - git clone --depth=1 ${{ github.server_url }}/${{ github.repository }}.git -b ${{ github.head_ref || github.ref_name || 'main' }} ~/work + git clone --depth=1 ${{ github.server_url }}/${{ github.repository }}.git -b ${{ github.head_ref || github.ref_name || 'main' }} ${{ env.ROOT_PATH }} - - name: Get WSL paths - id: get-wsl-paths + - name: Get paths + id: get-paths run: | - source ~/work/.github/scripts/config.sh - mkdir -p $BUILD_PATH - mkdir -p $CCACHE_DIR_PATH - mkdir -p $ARTIFACT_PATH - echo "build-path-win=`wslpath -w $BUILD_PATH`" >> $GITHUB_OUTPUT - echo "ccache-dir-path-win=`wslpath -w $CCACHE_DIR_PATH`" >> $GITHUB_OUTPUT - echo "artifact-path-win=`wslpath -w $ARTIFACT_PATH`" >> $GITHUB_OUTPUT - echo "artifact-path-wsl=$ARTIFACT_PATH" >> $GITHUB_OUTPUT + ${{ env.ROOT_PATH }}/.github/scripts/get-paths.sh - - name: Restore Ccache + - name: Download toolchain uses: actions/cache/restore@v4 with: - path: ${{ steps.get-wsl-paths.outputs.ccache-dir-path-win }} - key: build-and-test-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }} - restore-keys: build-and-test-gcc-ccache- + key: ${{ env.TOOLCHAIN_ARTIFACT_NAME }}-${{ needs.build-toolchain.outputs.timestamp }} + restore-keys: ${{ env.TOOLCHAIN_ARTIFACT_NAME }}-${{ needs.build-toolchain.outputs.timestamp }} + path: ${{ steps.get-paths.outputs.artifact-path-host }}/${{ env.TOOLCHAIN_PACKAGE_NAME }} + enableCrossOsArchive: true + fail-on-cache-miss: true - - name: Build toolchain + - name: Unpack toolchain run: | - ~/work/.github/scripts/build.sh + ${{ env.ROOT_PATH }}/.github/scripts/toolchain/unpack.sh - - name: Save Ccache - if: always() - uses: actions/cache/save@v4 + - name: Download GCC build folder + uses: actions/cache/restore@v4 with: - path: ${{ steps.get-wsl-paths.outputs.ccache-dir-path-win }} - key: build-and-test-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }} + key: gcc-build-${{ env.VARIANT }}-${{ needs.build-toolchain.outputs.timestamp }} + restore-keys: gcc-build-${{ env.VARIANT }}-${{ needs.build-toolchain.outputs.timestamp }} + path: ${{ steps.get-paths.outputs.artifact-path-host }}/gcc-build.tar.gz + enableCrossOsArchive: true + fail-on-cache-miss: true - - name: Execute GCC tests + - name: Unpack GCC build folder run: | - ~/work/.github/scripts/toolchain/execute-gcc-tests.sh "gcc-tests-${{ env.TAG }}" \ - "${{ env.MODULE }}" "${{ env.FILTER }}" + mkdir -p ${{ steps.get-paths.outputs.build-path-env }}/gcc + tar --overwrite -xzf ${{ steps.get-paths.outputs.artifact-path-env }}/gcc-build.tar.gz -C ${{ steps.get-paths.outputs.build-path-env }}/gcc - - name: Create summary + - name: Install dependencies run: | - ~/work/.github/scripts/toolchain/create-gcc-summary.sh " \ - ${{ steps.get-wsl-paths.outputs.artifact-path-wsl }}/gcc-tests-${{ env.TAG }}" >> \ - ${{ steps.get-wsl-paths.outputs.artifact-path-wsl }}/gcc-tests-${{ env.TAG }}/summary.md - cat ${{ steps.get-wsl-paths.outputs.artifact-path-wsl }}/gcc-tests-${{ env.TAG }}/summary.md >> $GITHUB_STEP_SUMMARY + ${{ env.ROOT_PATH }}/.github/scripts/install-dependencies.sh - - name: Group test failures + - name: Download sources run: | - ~/work/.github/scripts/toolchain/group-gcc-test-failures.sh "gcc-tests-${{ env.TAG }}" >> $GITHUB_STEP_SUMMARY + ${{ env.ROOT_PATH }}/.github/scripts/update-sources.sh - - name: Upload build folder - if: failure() - uses: actions/upload-artifact@v4 - with: - name: build - retention-days: 1 - path: ${{ steps.get-wsl-paths.outputs.build-path-win }} + - name: Install libraries + run: | + ${{ env.ROOT_PATH }}/.github/scripts/install-libraries.sh + + - name: Execute GCC tests + run: | + ${{ env.ROOT_PATH }}/.github/scripts/toolchain/execute-gcc-tests.sh \ + "${{ steps.get-paths.outputs.artifact-path-env }}/gcc-tests-${{ env.VARIANT }}" \ + "${{ env.MODULE }}" \ + "${{ env.FILTER }}" + cat "${{ steps.get-paths.outputs.artifact-path-env }}/gcc-tests-${{ env.VARIANT }}/summary.md" >> $GITHUB_STEP_SUMMARY + cat "${{ steps.get-paths.outputs.artifact-path-env }}/gcc-tests-${{ env.VARIANT }}/most-frequent-groups.md" >> $GITHUB_STEP_SUMMARY + + - name: Debug + run: | + ls -al "${{ steps.get-paths.outputs.artifact-path-env }}/gcc-tests-${{ env.VARIANT }}/" - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: gcc-tests-${{ env.TAG }} - path: ${{ steps.get-wsl-paths.outputs.artifact-path-win }}\gcc-tests-${{ env.TAG }} + name: gcc-gests-${{ env.VARIANT }} + path: ${{ steps.get-paths.outputs.artifact-path-host }}/gcc-tests-${{ env.VARIANT }} retention-days: 30 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0ce40a7c1..32d5de763e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,6 @@ on: push: branches: - main - pull_request: workflow_dispatch: inputs: binutils_branch: @@ -39,16 +38,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Get cache key - id: get-cache-key + - name: Get cache keys + id: get-cache-keys run: | - echo "timestamp=$(date -u --iso-8601=seconds)" >> "$GITHUB_OUTPUT" + .github/scripts/get-cache-keys.sh - name: Restore Ccache uses: actions/cache/restore@v4 with: path: ${{ env.CCACHE_DIR_PATH }} - key: main-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }} + key: main-gcc-ccache-${{ steps.get-cache-keys.outputs.ccache-key }} restore-keys: main-gcc-ccache- - name: Run Build @@ -64,7 +63,7 @@ jobs: uses: actions/cache/save@v4 with: path: ${{ env.CCACHE_DIR_PATH }} - key: main-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }} + key: main-gcc-ccache-${{ steps.get-cache-keys.outputs.ccache-key }} - name: Upload build folder if: failure() diff --git a/.github/workflows/test-toolchain.yml b/.github/workflows/test-toolchain.yml index 044265f2a1..afc55b67e6 100644 --- a/.github/workflows/test-toolchain.yml +++ b/.github/workflows/test-toolchain.yml @@ -6,31 +6,31 @@ on: binutils_branch_baseline: description: 'Baseline Binutils branch' required: false - default: 'upstream' + default: 'woarm64' binutils_branch_changes: description: 'Changes Binutils branch' required: false - default: 'upstream' + default: 'woarm64' gcc_branch_baseline: description: 'Baseline GCC branch' required: false - default: 'upstream' + default: 'woarm64' gcc_branch_changes: description: 'Changes GCC branch' required: false - default: 'upstream' + default: 'woarm64' mingw_branch_baseline: description: 'Baseline MinGW branch' required: false - default: 'upstream' + default: 'woarm64' mingw_branch_changes: description: 'Changes MinGW branch' required: false - default: 'upstream' + default: 'woarm64' arch: description: 'Architecture to build for' required: false - default: 'x86_64' + default: 'aarch64' platform: description: 'Platform to build for' required: false @@ -73,7 +73,7 @@ jobs: uses: ./.github/workflows/build-and-test-toolchain.yml with: binutils_branch: ${{ inputs.binutils_branch_baseline }} - gcc_branch: ${{ inputs.gcc_branch_baseline || 'aarch64-patch-stage1-v11-upstream' }} + gcc_branch: ${{ inputs.gcc_branch_baseline }} mingw_branch: ${{ inputs.mingw_branch_baseline }} arch: ${{ inputs.arch }} platform: ${{ inputs.platform }} @@ -85,7 +85,7 @@ jobs: uses: ./.github/workflows/build-and-test-toolchain.yml with: binutils_branch: ${{ inputs.binutils_branch_changes }} - gcc_branch: ${{ inputs.gcc_branch_changes || 'aarch64-patch-stage1-v11' }} + gcc_branch: ${{ inputs.gcc_branch_changes }} mingw_branch: ${{ inputs.mingw_branch_changes }} arch: ${{ inputs.arch }} platform: ${{ inputs.platform }} @@ -114,22 +114,34 @@ jobs: - name: Download baseline artifact uses: actions/download-artifact@v4 with: - name: gcc-tests-baseline + name: gcc-tests-${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-baseline path: ${{ env.ARTIFACT_PATH }}/gcc-tests-baseline - name: Download changes artifact uses: actions/download-artifact@v4 with: - name: gcc-tests-changes + name: gcc-tests-${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-changes path: ${{ env.ARTIFACT_PATH }}/gcc-tests-changes + - name: Debug + run: | + ls -al "${{ env.ARTIFACT_PATH }}/gcc-tests-baseline/" + ls -al "${{ env.ARTIFACT_PATH }}/gcc-tests-changes/" + - name: Compare results run: | - .github/scripts/toolchain/compare-gcc-results.sh baseline changes + .github/scripts/toolchain/compare-gcc-results.sh \ + ${{ env.ARTIFACT_PATH }}/gcc-tests-baseline \ + ${{ env.ARTIFACT_PATH }}/gcc-tests-changes \ + ${{ env.ARTIFACT_PATH }}/gcc-results + + - name: Debug + run: | + ls -al "${{ env.ARTIFACT_PATH }}/gcc-results/" - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: gcc-tests-results - path: ${{ env.ARTIFACT_PATH }}/gcc-tests-results - retention-days: 30 \ No newline at end of file + name: gcc-results-${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }} + path: ${{ env.ARTIFACT_PATH }}/gcc-results + retention-days: 30 diff --git a/.github/workflows/test-toolschains.yml b/.github/workflows/test-toolschains.yml new file mode 100644 index 0000000000..6c33aef903 --- /dev/null +++ b/.github/workflows/test-toolschains.yml @@ -0,0 +1,73 @@ +name: Comparative test of toolchain branches accross multiple targets + +on: + pull_request: + workflow_dispatch: + inputs: + binutils_branch_baseline: + description: 'Baseline Binutils branch' + required: false + default: 'woarm64' + binutils_branch_changes: + description: 'Changes Binutils branch' + required: false + default: 'woarm64' + gcc_branch_baseline: + description: 'Baseline GCC branch' + required: false + default: 'woarm64' + gcc_branch_changes: + description: 'Changes GCC branch' + required: false + default: 'fix-va-list' + mingw_branch_baseline: + description: 'Baseline MinGW branch' + required: false + default: 'woarm64' + mingw_branch_changes: + description: 'Changes MinGW branch' + required: false + default: 'woarm64' + workflow_call: + inputs: + binutils_branch_baseline: + type: string + binutils_branch_changes: + type: string + gcc_branch_baseline: + type: string + gcc_branch_changes: + type: string + mingw_branch_baseline: + type: string + mingw_branch_changes: + type: string + +jobs: + + build-and-test-toolchains: + name: Build and test toolchains + + strategy: + fail-fast: false + matrix: + arch: [aarch64, x86_64] + platform: [w64-mingw32, linux-gnu] + crt: [ucrt, libc] + exclude: + - platform: w64-mingw32 + crt: libc + - platform: linux-gnu + crt: ucrt + + uses: ./.github/workflows/test-toolchain.yml + with: + binutils_branch_baseline: ${{ inputs.binutils_branch_baseline || 'woarm64' }} + binutils_branch_changes: ${{ inputs.binutils_branch_changes || 'woarm64' }} + gcc_branch_baseline: ${{ inputs.gcc_branch_baseline || 'woarm64' }} + gcc_branch_changes: ${{ inputs.gcc_branch_changes || 'fix-va-list' }} + mingw_branch_baseline: ${{ inputs.mingw_branch_baseline || 'woarm64' }} + mingw_branch_changes: ${{ inputs.mingw_branch_changes || 'woarm64' }} + arch: ${{ matrix.arch }} + platform: ${{ matrix.platform }} + crt: ${{ matrix.crt }}