Skip to content

Update build workflow #549

Update build workflow

Update build workflow #549

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
submodule_cache:
name: Initialize submodule cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout required submodules
run: git submodule update --init --progress -j $(nproc) --depth 1 binutils gcc gdb glibc llvm musl newlib uclibc-ng
- name: Storage size optimization
run: |
git submodule foreach 'git maintenance run'
./.github/dedup-dir.sh ./.git/modules
- name: Setup submodule cache
uses: actions/cache@v4
with:
path: |
binutils
gcc
gdb
glibc
llvm
musl
newlib
uclibc-ng
.git/modules
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
build:
runs-on: ${{ matrix.os }}
needs: [submodule_cache]
strategy:
matrix:
os: [ubuntu-latest]
mode: [newlib, linux, musl, uclibc]
target: [rv32gc-ilp32d, rv64gc-lp64d]
compiler: [gcc, llvm]
exclude:
- mode: musl
compiler: llvm
- mode: uclibc
compiler: llvm
steps:
- name: Remove unneeded frameworks to recover disk space
run: |
echo "-- Before --"
df -h
sudo apt-get purge -y firefox google-chrome-stable temurin-*-jdk ant ant-optional microsoft-edge-stable mono-complete nuget mssql-tools unixodbc-dev mysql-client libmysqlclient-dev php php-pear libpq-dev powershell r-base ruby-full '^dotnet-.*'
sudo apt-get autoremove --purge -y
sudo apt-get clean
sudo rm -rf /usr/local/bin/aliyun
sudo rm -rf /usr/local/bin/aws
sudo rm -rf /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
sudo rm -rf /usr/local/bin/sam
sudo rm -rf /usr/local/aws-sam-cli
sudo rm -rf /usr/local/bin/azcopy
sudo rm -rf /usr/local/bin/azcopy10
sudo rm -rf /opt/az/azcliextensions
sudo rm -rf /usr/local/bin/bazel
sudo rm -rf /usr/local/bin/bicep
sudo rm -rf /opt/hostedtoolcache
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/bin/rebar3
sudo rm -rf /usr/local/share/gecko_driver
sudo rm -rf /usr/local/share/chromedriver-linux64
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /home/linuxbrew
sudo rm -rf /usr/share/apache-maven-*
sudo rm -rf /usr/share/gradle
sudo rm -rf /usr/local/julia*
sudo rm -rf /usr/share/kotlinc
sudo rm -rf /usr/local/bin/minikube
sudo rm -rf /usr/local/share/edge_driver
sudo rm -rf /usr/local/lib/node_modules/*
sudo rm -rf /usr/local/bin/oc
sudo rm -rf /usr/local/bin/oras
sudo rm -rf /usr/share/java/selenium-server-*
sudo rm -rf /usr/share/swift
sudo rm -rf /usr/local/share/vcpkg
sudo rm -rf /usr/local/lib/android
echo "-- After --"
df -h
- uses: actions/checkout@v4
- name: install dependencies
run: sudo ./.github/setup-apt.sh
- name: Load submodule cache
uses: actions/cache/restore@v4
with:
path: |
binutils
gcc
gdb
glibc
llvm
musl
newlib
uclibc-ng
.git/modules
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
- 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]}"
if [ "${{ matrix.compiler }}" == "llvm" ]; then # build toolchain with llvm
$BUILD_TOOLCHAIN --enable-llvm
else
$BUILD_TOOLCHAIN
fi
sudo make -j $(nproc) ${{ matrix.mode }}
- name: make report
if: |
(matrix.mode == 'linux' || matrix.mode == 'newlib')
&& matrix.compiler == 'gcc'
run: |
sudo make report-${{ matrix.mode }} -j $(nproc)
- 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
run: |
./.github/dedup-dir.sh /opt/
XZ_OPT="-e -T0" tar cvJf riscv.tar.xz -C /opt/ riscv/
- name: generate prebuilt toolchain name
id: toolchain-name-generator
run: |
if [[ "${{ matrix.target }}" == *"32"* ]]; then BITS=32; else BITS=64; fi
case "${{ matrix.mode }}" in
"linux")
MODE="glibc";;
"musl")
MODE="musl";;
"uclibc")
MODE="uclibc-ng";;
*)
MODE="elf";;
esac
echo "TOOLCHAIN_NAME=riscv$BITS-$MODE-${{ matrix.os }}-${{ matrix.compiler }}-nightly" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}
path: riscv.tar.xz
test-sim:
runs-on: ${{ matrix.os }}
needs: [submodule_cache]
strategy:
matrix:
os: [ubuntu-latest]
mode: [newlib]
target: [rv64gc-lp64d]
sim: [spike]
steps:
- name: Remove unneeded frameworks to recover disk space
run: |
echo "-- Before --"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
echo "-- After --"
df -h
- uses: actions/checkout@v4
- name: install dependencies
run: sudo ./.github/setup-apt.sh
- name: Load submodule cache
uses: actions/cache/restore@v4
with:
path: |
binutils
gcc
gdb
glibc
llvm
musl
newlib
uclibc-ng
.git/modules
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
- 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
run: make report-${{ matrix.mode }} -j $(nproc)
build-multilib:
if: ${{ false }} # Disable until multilib errors are triaged
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
mode: [newlib, linux]
target: [rv64gc-lp64d]
steps:
- name: Remove unneeded frameworks to recover disk space
run: |
echo "-- Before --"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
echo "-- After --"
df -h
- uses: actions/checkout@v4
- name: install dependencies
run: sudo ./.github/setup-apt.sh
- 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]} --enable-multilib
sudo make -j $(nproc) ${{ matrix.mode }}
- name: make report
run: |
sudo make report-${{ matrix.mode }} -j $(nproc)
- name: tarball build
run: |
./.github/dedup-dir.sh /opt/
XZ_OPT="-e -T0" tar cvJf riscv.tar.xz -C /opt/ riscv/
- name: generate prebuilt toolchain name
id: toolchain-name-generator
run: |
if [[ "${{ matrix.target }}" == *"32"* ]]; then BITS=32; else BITS=64; fi
case "${{ matrix.mode }}" in
"linux")
MODE="glibc";;
"musl")
MODE="musl";;
"uclibc")
MODE="uclibc-ng";;
*)
MODE="elf";;
esac
echo "TOOLCHAIN_NAME=riscv$BITS-$MODE-${{ matrix.os }}-multilib-nightly" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}
path: riscv.tar.xz