Skip to content

Rework toolchain building flow #99

Rework toolchain building flow

Rework toolchain building flow #99

Workflow file for this run

name: Build toolchains
on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master
env:
ARTIFACT_STAGING_DIR: artifact
jobs:
build:
strategy:
matrix:
name: [rv32imcb, rv64imac]
os: [ubuntu-latest, ubuntu-24.04-arm]
build_type: [Release, Debug]
include:
- os: ubuntu-latest
host_arch: x86_64
- os: ubuntu-24.04-arm
host_arch: aarch64
- name: rv32imcb
display_name: RV32IMCB toolchains (Ibex)
target: riscv32-unknown-elf
output_dir: /tools/riscv
march: rv32imc_zba_zbb_zbc_zbs
mabi: ilp32
mcmodel: medany
- name: rv64imac
display_name: RV64IMAC toolchains (Muntjac)
target: riscv64-unknown-elf
output_dir: /tools/riscv
march: rv64imac
mabi: lp64
mcmodel: medany
exclude:
- os: ubuntu-24.04-arm
build_type: Debug
- name: rv64imac
build_type: Debug
name: ${{ matrix.build_type }} ${{ matrix.host_arch }} build of ${{ matrix.display_name }}
runs-on: ${{ matrix.os }}
# This is an AlmaLinux 8 based image
container: quay.io/pypa/manylinux_2_28_${{ matrix.host_arch }}
timeout-minutes: 360
steps:
- uses: actions/checkout@v4
- name: Setup environment
run: |
echo ::group::Install dependencies
./prepare-host.sh
echo ::endgroup::
echo Preparing toolchain destination directory...
sudo mkdir -p /tools/riscv
sudo chmod 0777 /tools/riscv
echo ::group::Set the host architecture env var
echo "HOST_ARCH=${{ matrix.host_arch }}" >> "$GITHUB_ENV"
echo ::endgroup::
echo ::group::Set the release tag env var
echo "RELEASE_TAG=$(./release_tag.sh)" >> "$GITHUB_ENV"
echo ::endgroup::
echo Creating artifact staging directory...
mkdir "$ARTIFACT_STAGING_DIR"
echo ::group::Log free disk space
sudo df -h || true
sudo du -h / --max-depth 3 | sort -h || true
echo ::endgroup::
echo "::group::Installed packages"
dnf repoquery -C --installed --qf "%{size} %{name}" | sort -n | numfmt --to=iec --format="%.2f"
echo "::endgroup::"
# Git warns about this repo having dubious ownership - ignore.
git config --global --add safe.directory "$(pwd)"
- name: Build Binutils
run: |
./build-binutils.sh \
"${{ matrix.target }}" \
"${{ matrix.output_dir }}"
- name: Log free disk space
run: df -h
- name: Build Clang toolchain
run: |
./build-clang-with-args.sh \
"lowrisc-toolchain-${{ matrix.name }}" \
"${{ matrix.build_type }}" \
"${{ matrix.target }}" \
"${{ matrix.output_dir }}" \
"${{ matrix.march }}" \
"${{ matrix.mabi}}" \
"${{ matrix.mcmodel }}" \
"${{ matrix.cflags }}"
- name: Package toolchains
run: |
suffix=""
if [ "$RELEASE_TAG" != "" ]; then
suffix+="-${RELEASE_TAG}"
fi
if [ "${{ matrix.build_type }}" == "Debug" ]; then
suffix+="-debug"
fi
./create-prefixed-archive.sh \
"lowrisc-toolchain-${{ matrix.name }}-${HOST_ARCH}${suffix}" \
"${{ matrix.output_dir }}" \
"${ARTIFACT_STAGING_DIR}"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}-${{ matrix.host_arch }}-toolchains
path: ${{ env.ARTIFACT_STAGING_DIR }}
- name: Check tarballs
run: |
set -e
for f in "${ARTIFACT_STAGING_DIR}"/*.tar.xz; do
./check-tarball.sh "$f"
done
- name: Release
if: github.ref_type == 'tag'
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create the release if it doesn't already exist.
gh release create "$RELEASE_TAG" --prerelease || echo "release exists"
# Upload this job's artifacts.
gh release upload "$RELEASE_TAG" --clobber "${ARTIFACT_STAGING_DIR}/*.tar.xz"