Skip to content
Merged
Show file tree
Hide file tree
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
54 changes: 18 additions & 36 deletions .github/workflows/toolchain_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,17 @@ jobs:
- os: ubuntu-24.04-arm
host_arch: aarch64
- name: rv32imcb
display_name: Toolchains targeting Ibex with bit-manipulation extensions
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: GCC and Clang/LLVM toolchains targeting RV64IMAC (Muntjac)
display_name: RV64IMAC toolchains (Muntjac)
target: riscv64-unknown-elf
output_dir: /tools/riscv
march: rv64imac
mabi: lp64
mcmodel: medany
# - name: multilib-baremetal
# display_name: RV64 GCC (Multilib Baremetal)
# target: riscv64-unknown-elf
# output_dir: /opt/riscv-baremetal-toolchain
# - name: multilib-linux
# display_name: RV64 GCC (Multilib Linux)
# target: riscv64-unknown-linux-gnu
# output_dir: /opt/riscv-linux-toolchain

name: ${{ matrix.host_arch }} build of ${{ matrix.display_name }}
runs-on: ${{ matrix.os }}
Expand All @@ -62,10 +52,6 @@ jobs:
./prepare-host.sh
echo ::endgroup::

echo ::group::Install crosstool-ng
./install-crosstool-ng.sh
echo ::endgroup::

echo Preparing toolchain destination directory...
sudo mkdir -p /tools/riscv
sudo chmod 0777 /tools/riscv
Expand All @@ -81,27 +67,27 @@ jobs:
echo Creating artifact staging directory...
mkdir "$ARTIFACT_STAGING_DIR"

- name: Build GCC toolchain
# Git warns about this repo having dubious ownership - ignore.
git config --global --add safe.directory "$(pwd)"

- name: Build Binutils
run: |
./build-gcc-with-args.sh \
"lowrisc-toolchain-gcc-${{ matrix.name }}" \
"${{ matrix.target }}" \
"${{ matrix.output_dir }}" \
"${{ matrix.march }}" \
"${{ matrix.mabi}}" \
"${{ matrix.mcmodel }}" \
"${{ matrix.cflags }}"
./build-binutils.sh "${{ matrix.target }}"

- name: Build Clang toolchain
run: |
./build-clang-with-args.sh \
"lowrisc-toolchain-${{ matrix.name }}" \
"${{ matrix.target }}" \
"${{ matrix.output_dir }}" \
"${{ matrix.march }}" \
"${{ matrix.mabi}}" \
"${{ matrix.mcmodel }}" \
"${{ matrix.cflags }}"
--name "lowrisc-toolchain-${{ matrix.name }}" \
--target "${{ matrix.target }}" \
--march "${{ matrix.march }}" \
--mabi "${{ matrix.mabi}}" \
--mcmodel "${{ matrix.mcmodel }}"

- name: Package toolchains
run: |
./create-prefixed-archive.sh \
"lowrisc-toolchain-${{ matrix.name }}-${HOST_ARCH}-${RELEASE_TAG}" \
"${ARTIFACT_STAGING_DIR}"

- uses: actions/upload-artifact@v4
with:
Expand All @@ -120,12 +106,8 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
# Git warns about this repo having dubious ownership - ignore.
git config --global --add safe.directory /__w/lowrisc-toolchains/lowrisc-toolchains

# 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}/lowrisc-toolchain-${{ matrix.name }}-${HOST_ARCH}-${RELEASE_TAG}.tar.xz" \
"${ARTIFACT_STAGING_DIR}/lowrisc-toolchain-gcc-${{ matrix.name }}-${HOST_ARCH}-${RELEASE_TAG}.tar.xz"
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,28 @@ Head over to the
[GitHub releases for this repository](https://github.com/lowRISC/lowrisc-toolchains/releases)
for pre-built toolchains.

* A GCC RV32IMC without hardfloat support, targeting [Ibex](https://github.com/lowRISC/ibex/)
* A GCC RV64IMAC, targeting [Muntjac](https://github.com/lowRISC/muntjac)
* A GCC elf multilib toolchain
* A GCC linux multilib toolchain
* Clang RV32IMCB without hardfloat support, targeting [Ibex](https://github.com/lowRISC/ibex/)
* Clang RV64IMAC, targeting [Muntjac](https://github.com/lowRISC/muntjac)

How to do a release
-------------------

1. Modify any of the following variables to configure the build:
- `CROSSTOOL_NG_VERSION` in `install-crosstool-ng.sh`

2. Modify any of the `*.config` files to update the crosstool-ng configurations
for a particular toolchain.

3. Push the changes or do a pull request, and wait for the CI workflow to
1. Push the changes or do a pull request, and wait for the CI workflow to
complete.

The build can be tested by downloading the GitHub artifacts.
1. Go to the [lowrisc-toolchains Actions page](https://github.com/lowRISC/lowrisc-toolchains/actions).
2. Select a workflow run from the list.
4. Download the desired artifact from the bottom of the page and test it.

4. Tag a release
2. Tag a release

```bash
VERSION=$(date +%Y%m%d)-1
git tag -a -m "Release version $VERSION" $VERSION
```

5. Push the tag
3. Push the tag

```bash
git push origin $VERSION
Expand Down
72 changes: 72 additions & 0 deletions build-binutils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

## build-binutils.sh
#
# Builds:
# - GNU Binutils, GDB
#
# Then:
# - Creates a tar file of the whole install directory

set -e -o pipefail

repo_dir="$(git rev-parse --show-toplevel)"
build_dir="${repo_dir}/build"
patch_dir="${repo_dir}/patches"
dist_dir="${build_dir}/dist"

source "${repo_dir}/sw-versions.sh"

if [ "$#" -ne 1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "USAGE: $0 <target>" >&2
echo >&2
echo "EXAMPLE:" >&2
echo " $0 riscv32" >&2
exit 1
fi

target="$1"

# Double check the arch part of the target tuple.
target_arch="${target/%-*}"
if [ "$target_arch" != "riscv32" ] && [ "$target_arch" != "riscv64" ]; then
echo "Error: unsupported target '${target}'" >&2
echo >&2
echo "Supported arches are: riscv32, riscv64" >&2
exit 1
fi

set -x

mkdir -p "$build_dir"
cd "$build_dir"

if [ ! -d binutils ]; then
git clone "$BINUTILS_URL" binutils \
--branch "$BINUTILS_BRANCH" \
--depth 1
fi

cd binutils
git reset --hard
git checkout "$BINUTILS_COMMIT"
git apply "${patch_dir}/binutils/"*

mkdir -p build
cd build

mkdir -p "$dist_dir"

# NOTE: We don't want to require `libexpat` to be dynamically linked.
# It turns out to be quite hard to statically link *only* `libexpat`.
../configure \
--target "$target" \
--program-prefix="$target-" \
--prefix "$dist_dir" \
--with-expat=no

make -j "$(nproc)"
make install
Loading