From 63a716bf0c50a37883a740e1526fde65af083493 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Thu, 29 Aug 2024 19:16:53 +0100 Subject: [PATCH] Attempt Windows toolchain build --- .github/workflows/build.yml | 2 ++ build.ps1 | 21 ++++++++++++++++++++- packages/windows/riscv/build-riscv-gcc.sh | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 packages/windows/riscv/build-riscv-gcc.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5e65a7..b383e1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,7 @@ jobs: bin/picotool-*-x64-win.zip bin/pico-sdk-tools-*-x64-win.zip bin/openocd-*-x64-win.zip + bin/riscv-toolchain-*-x64-win.zip - name: Add Release Asset uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') @@ -35,6 +36,7 @@ jobs: bin/picotool-*-x64-win.zip bin/pico-sdk-tools-*-x64-win.zip bin/openocd-*-x64-win.zip + bin/riscv-toolchain-*-x64-win.zip build_macos: name: Build MacOS diff --git a/build.ps1 b/build.ps1 index 8628259..a976ae1 100644 --- a/build.ps1 +++ b/build.ps1 @@ -235,8 +235,16 @@ if (-not $SkipDownload) { msys 'pacman --noconfirm -Suu' msys "pacman -S --noconfirm --needed autoconf automake git libtool make pactoys pkg-config wget" + # Risc-V requirements + # base-devel minus texinfo + msys "pacman -S --noconfirm --needed base binutils bison diffstat diffutils dos2unix file flex gawk gettext grep make patch sed tar" + msys "pacman -S --noconfirm --needed curl python3 gmp gperf patchutils expat" # pacboy adds MINGW_PACKAGE_PREFIX to package names suffixed with :p - msys "pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p" + msys "pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p libslirp:p mpc:p bc:p zlib:p mpfr:p" +} + +if (-not (Test-Path ".\build\riscv-install\mingw$bitness")) { + msys "cd build && ../packages/windows/riscv/build-riscv-gcc.sh $bitness $mingw_arch" } if (-not (Test-Path ".\build\openocd-install\mingw$bitness")) { @@ -297,3 +305,14 @@ $filename = 'openocd-{0}-{1}.zip' -f Write-Host "Saving OpenOCD package to $filename" exec { tar -a -cf "bin\$filename" -C "build\openocd-install\mingw$bitness\bin" * -C "..\share\openocd" "scripts" } + +# Package Risc-V separately as well + +$version = "14" + +$filename = 'riscv-toolchain-{0}-{1}.zip' -f + $version, + $suffix + +Write-Host "Saving Risc-V toolchain package to $filename" +exec { tar -a -cf "bin\$filename" -C "build\riscv-install" * } diff --git a/packages/windows/riscv/build-riscv-gcc.sh b/packages/windows/riscv/build-riscv-gcc.sh new file mode 100644 index 0000000..ccd1544 --- /dev/null +++ b/packages/windows/riscv/build-riscv-gcc.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -euo pipefail + +BITNESS=$1 +ARCH=$2 + +INSTALLDIR="riscv-install" +rm -rf $INSTALLDIR +mkdir -p $INSTALLDIR + +BUILDDIR=$(pwd) + +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 +make -j$(nproc) gcc +make -j$(nproc) gdb +make -j$(nproc) newlib +make -j$(nproc)