The downloads from gnu.org have occasionally failed (probably due
to being under load from AI bots).
eea8f577e02a08d90e7a7c1c60251e7760f6a880 helped a bit by doing the
download from a mirror, but despite that, these downloads still
fail occasionally.

To avoid having to fetch the source tarballs for each build (both
for reducing unnecessary load on the upstream servers, and for
improved reliability), store them in github action caches.

Unless we had a cache hit (a fully matching cache key), download
all the tarballs we're interested in (which then gets stored,
implicitly, the end of the job) upfront. This uses the same cache
key, and downloads the same tarballs, for both the initial "gcc" jobs
(that only need binutils and gcc) and the later "gcc-cross" (which
also need gmp, mpfr and mpc), to allow sharing a single cache
for both of them.

Signed-off-by: Martin Storsjö <[email protected]>
---
 .github/workflows/build.yml | 60 ++++++++++++++++++++++++-------------
 1 file changed, 39 insertions(+), 21 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7ba038d97..aac535497 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -340,11 +340,25 @@ jobs:
       - name: Download dependencies
         run: |
           sudo apt-get update && sudo apt-get install libgmp-dev libmpfr-dev 
libmpc-dev autoconf automake
-      - name: Build binutils
+      - name: Cache tarballs
+        id: cache-gnu
+        uses: actions/cache@v4
+        with:
+          path: /opt/gnu
+          key: binutils-2.42-gcc-14.1.0
+      - name: Download tarballs
+        if: steps.cache-gnu.outputs.cache-hit != 'true'
         run: |
+          mkdir -p /opt/gnu
+          cd /opt/gnu
+          curl -LO https://ftpmirror.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
+          curl -LO https://ftpmirror.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz
+          curl -LO https://ftpmirror.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz
           curl -LO https://ftpmirror.gnu.org/gnu/binutils/binutils-2.42.tar.xz
-          tar -Jxf binutils-*.tar.xz
-          rm binutils-*.tar.xz
+          curl -LO 
https://ftpmirror.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz
+      - name: Build binutils
+        run: |
+          tar -Jxf /opt/gnu/binutils-*.tar.xz
           cd binutils-*
           mkdir build
           cd build
@@ -354,9 +368,7 @@ jobs:
           echo $(pwd)/../../prefix/bin >> $GITHUB_PATH
       - name: Build the base GCC
         run: |
-          curl -LO 
https://ftpmirror.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz
-          tar -Jxf gcc-*.tar.xz
-          rm gcc-*.tar.xz
+          tar -Jxf /opt/gnu/gcc-*.tar.xz
           cd gcc-*
           mkdir build
           cd build
@@ -430,13 +442,27 @@ jobs:
           rm gcc-mingw-*.tar.xz
           sudo mv gcc-mingw* /opt/gcc-mingw
           echo /opt/gcc-mingw/bin >> $GITHUB_PATH
+      - name: Cache tarballs
+        id: cache-gnu
+        uses: actions/cache@v4
+        with:
+          path: /opt/gnu
+          key: binutils-2.42-gcc-14.1.0
+      - name: Download tarballs
+        if: steps.cache-gnu.outputs.cache-hit != 'true'
+        run: |
+          mkdir -p /opt/gnu
+          cd /opt/gnu
+          curl -LO https://ftpmirror.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
+          curl -LO https://ftpmirror.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz
+          curl -LO https://ftpmirror.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz
+          curl -LO https://ftpmirror.gnu.org/gnu/binutils/binutils-2.42.tar.xz
+          curl -LO 
https://ftpmirror.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz
       - name: Build dependencies
         run: |
           PREFIX=$(pwd)/prefix
 
-          curl -LO https://ftpmirror.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
-          tar -Jxf gmp-*.tar.xz
-          rm gmp-*.tar.xz
+          tar -Jxf /opt/gnu/gmp-*.tar.xz
           cd gmp-*
           mkdir build
           cd build
@@ -445,9 +471,7 @@ jobs:
           make install
           cd ../..
 
-          curl -LO https://ftpmirror.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz
-          tar -Jxf mpfr-*.tar.xz
-          rm mpfr-*.tar.xz
+          tar -Jxf /opt/gnu/mpfr-*.tar.xz
           cd mpfr-*
           mkdir build
           cd build
@@ -456,9 +480,7 @@ jobs:
           make install
           cd ../..
 
-          curl -LO https://ftpmirror.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz
-          tar -zxf mpc-*.tar.gz
-          rm mpc-*.tar.gz
+          tar -zxf /opt/gnu/mpc-*.tar.gz
           cd mpc-*
           mkdir build
           cd build
@@ -469,9 +491,7 @@ jobs:
 
       - name: Build binutils
         run: |
-          curl -LO https://ftpmirror.gnu.org/gnu/binutils/binutils-2.42.tar.xz
-          tar -Jxf binutils-*.tar.xz
-          rm binutils-*.tar.xz
+          tar -Jxf /opt/gnu/binutils-*.tar.xz
           cd binutils-*
           mkdir build
           cd build
@@ -481,9 +501,7 @@ jobs:
           echo $(pwd)/../../prefix/bin >> $GITHUB_PATH
       - name: Build GCC
         run: |
-          curl -LO 
https://ftpmirror.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz
-          tar -Jxf gcc-*.tar.xz
-          rm gcc-*.tar.xz
+          tar -Jxf /opt/gnu/gcc-*.tar.xz
           cd gcc-*
           mkdir build
           cd build
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to