Skip to content

Add Submodule Caching to Toolchain Generation #1607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 69 additions & 10 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,53 @@ on:
pull_request:
branches:
- master

env:
cache-path: |
.git/modules
jobs:
cache:
name: Update Submodule Cache
runs-on: ubuntu-24.04
outputs:
key: submodules-${{ steps.submodule-hash.outputs.HASH }}
steps:
- uses: actions/checkout@v4

- name: Generate Submodule Hash
id: submodule-hash
run: echo "HASH=$(git submodule | sha1sum | head -c 40)" >> $GITHUB_OUTPUT

- name: Check if Cache Exists for Exact Submodule Configuration
id: cache-check
uses: actions/cache/restore@v4
with:
path: ${{ env.cache-path }}
key: submodules-${{ steps.submodule-hash.outputs.HASH }}
lookup-only: true

- name: If Cache Misses, Update Cache
uses: actions/cache@v4
if: steps.cache-check.outputs.cache-hit != 'true'
with:
path: ${{ env.cache-path }}
key: submodules-${{ steps.submodule-hash.outputs.HASH }}
restore-keys: |
submodules-

- name: Clone Submodules
if: steps.cache-check.outputs.cache-hit != 'true'
run: |
git submodule update --init --progress uclibc-ng
git submodule update --init --progress --depth 1 --jobs $(nproc)



build:
name: Build Toolchain Variants
runs-on: ${{ matrix.os }}
needs: [cache]
env:
cache-key: ${{ needs.cache.outputs.key }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
Expand All @@ -34,10 +77,16 @@ jobs:

- uses: actions/checkout@v4

- name: install dependencies
- name: Restore Submodule Cache
uses: actions/cache/restore@v4
with:
path: ${{ env.cache-path }}
key: ${{ env.cache-key }}

- name: Install Dependencies
run: sudo ./.github/setup-apt.sh

- name: build toolchain
- name: Build Toolchain
run: |
TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n"))
BUILD_TOOLCHAIN="./configure --prefix=/opt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]}"
Expand All @@ -48,24 +97,24 @@ jobs:
fi
sudo make -j $(nproc) ${{ matrix.mode }}

- name: make report
- name: Generate Report
if: |
matrix.os == 'ubuntu-24.04'
&& (matrix.mode == 'linux' || matrix.mode == 'newlib')
&& matrix.compiler == 'gcc'
run: |
sudo make report-${{ matrix.mode }} -j $(nproc)

- name: recover space
- name: Recover Space
run: |
sudo du -hs / 2> /dev/null || true
sudo rm -rf binutils dejagnu gcc gdb glibc llvm musl newlib pk qemu spike uclibc-ng || true
sudo du -hs / 2> /dev/null || true

- name: tarball build
- name: Tar Toolchain
run: tar czvf riscv.tar.gz -C /opt/ riscv/

- name: generate prebuilt toolchain name
- name: Generate Prebuilt Toolchain Name
id: toolchain-name-generator
run: |
if [[ "${{ matrix.target }}" == *"32"* ]]; then BITS=32; else BITS=64; fi
Expand All @@ -87,7 +136,11 @@ jobs:
path: riscv.tar.gz

test-sim:
name: Test Simulation
runs-on: ${{ matrix.os }}
needs: [cache]
env:
cache-key: ${{ needs.cache.outputs.key }}
strategy:
matrix:
os: [ubuntu-24.04]
Expand All @@ -106,16 +159,22 @@ jobs:

- uses: actions/checkout@v4

- name: install dependencies
- name: Restore Submodule Cache
uses: actions/cache/restore@v4
with:
path: ${{ env.cache-path }}
key: ${{ env.cache-key }}

- name: Install Dependencies
run: sudo ./.github/setup-apt.sh

- name: build toolchain
- name: Build Toolchain
run: |
TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n"))
./configure --prefix=/opt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} --with-sim=${{ matrix.sim }}
make -j $(nproc) ${{ matrix.mode }}

- name: make report
- name: Generate Report
run: make report-${{ matrix.mode }} -j $(nproc)

build-multilib:
Expand Down