From 3ae661729ca14cbc555a7581523850511eef2a6f Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 30 Aug 2024 11:42:23 +0100 Subject: [PATCH] Create x64-mac and x64-win toolchains from prebuilt toolchain with multilib copied in --- .github/workflows/build.yml | 4 +-- build_macos.sh | 22 +++++++++++++ packages/macos/riscv/build-riscv-gcc-other.sh | 31 +++++++++++++++++++ packages/macos/riscv/build-riscv-gcc.sh | 7 +++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 packages/macos/riscv/build-riscv-gcc-other.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5e65a7..68c4ebb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,7 +67,7 @@ jobs: bin/picotool-*-mac.zip bin/pico-sdk-tools-*-mac.zip bin/openocd-*-mac.zip - bin/riscv-toolchain-*-mac.zip + bin/riscv-toolchain-*.zip - name: Add Release Asset uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') @@ -76,7 +76,7 @@ jobs: bin/picotool-*-mac.zip bin/pico-sdk-tools-*-mac.zip bin/openocd-*-mac.zip - bin/riscv-toolchain-*-mac.zip + bin/riscv-toolchain-*.zip build_linux: name: Build Linux diff --git a/build_macos.sh b/build_macos.sh index dc2f83b..70fb944 100755 --- a/build_macos.sh +++ b/build_macos.sh @@ -107,4 +107,26 @@ if [[ "$SKIP_RISCV" != 1 ]]; then pushd "$builddir/riscv-install/" tar -a -cf "$topd/bin/$filename" * popd + + # Package x64-mac riscv toolchain separately as well + version="14" + echo "Risc-V Toolchain version $version" + + filename="riscv-toolchain-${version}-x64-mac.zip" + + echo "Saving Risc-V Toolchain package to $filename" + pushd "$builddir/riscv-install-x64-mac/" + tar -a -cf "$topd/bin/$filename" * + popd + + # Package x64-win riscv toolchain separately as well + version="14" + echo "Risc-V Toolchain version $version" + + filename="riscv-toolchain-${version}-x64-win.zip" + + echo "Saving Risc-V Toolchain package to $filename" + pushd "$builddir/riscv-install-x64-win/" + tar -a -cf "$topd/bin/$filename" * + popd fi diff --git a/packages/macos/riscv/build-riscv-gcc-other.sh b/packages/macos/riscv/build-riscv-gcc-other.sh new file mode 100644 index 0000000..4c47ca9 --- /dev/null +++ b/packages/macos/riscv/build-riscv-gcc-other.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -euo pipefail + +URL=$1 +SUFFIX=$2 + +BASEINSTALLDIR="riscv-install" +INSTALLDIR="$BASEINSTALLDIR-$SUFFIX" +rm -rf $INSTALLDIR +mkdir -p $INSTALLDIR + +BUILDDIR=$(pwd) + +ZIPFILE=$(basename -- "$URL") +FILENAME="${ZIPFILE%.*}" + +wget $URL +unzip $ZIPFILE -d $INSTALLDIR +mv $INSTALLDIR/$FILENAME/* $INSTALLDIR +rm -rf $INSTALLDIR/$FILENAME + +# Remove existing multilibs +rm -rf $INSTALLDIR/lib/gcc/riscv32-unknown-elf/*/rv32* +rm -rf $INSTALLDIR/lib/gcc/riscv32-unknown-elf/*/rv64* +rm -rf $INSTALLDIR/riscv32-unknown-elf/lib/rv32* +rm -rf $INSTALLDIR/riscv32-unknown-elf/lib/rv64* + +# Add new lib +cp -r $BASEINSTALLDIR/lib/gcc/riscv32-unknown-elf/*/rv32* $INSTALLDIR/lib/gcc/riscv32-unknown-elf/*/ +cp -r $BASEINSTALLDIR/riscv32-unknown-elf/lib/rv32* $INSTALLDIR/riscv32-unknown-elf/lib/ diff --git a/packages/macos/riscv/build-riscv-gcc.sh b/packages/macos/riscv/build-riscv-gcc.sh index 922b511..ca4f9a0 100755 --- a/packages/macos/riscv/build-riscv-gcc.sh +++ b/packages/macos/riscv/build-riscv-gcc.sh @@ -16,3 +16,10 @@ cd riscv-gnu-toolchain ./configure --prefix=$BUILDDIR/$INSTALLDIR --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" --with-gcc-src=$BUILDDIR/gcc # 4 threads, as 8 threads runs out of memory make -j4 + +# Make x64 and Windows toolchains, by copying multilib into existing toolchains +cd .. +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +$SCRIPT_DIR/build-riscv-gcc-other.sh "https://buildbot.embecosm.com/job/riscv32-gcc-macos-release/21/artifact/riscv32-embecosm-macos-gcc13.3.0.zip" "x64-mac" +$SCRIPT_DIR/build-riscv-gcc-other.sh "https://buildbot.embecosm.com/job/riscv32-gcc-win64-release/24/artifact/riscv32-embecosm-win64-gcc13.2.0.zip" "x64-win"