diff --git a/.github/workflows/binutils-gdb-ci-merge-request.yml b/.github/workflows/binutils-gdb-ci-merge-request.yml new file mode 100644 index 00000000000..f910bafab2a --- /dev/null +++ b/.github/workflows/binutils-gdb-ci-merge-request.yml @@ -0,0 +1,60 @@ +name: Binutils and GDB MR CI +on: pull_request +jobs: + Regression-Tests: + name: Regression Tests + runs-on: ubuntu-latest + steps: + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v2 + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." + - name: Build Binutils and GDB + run: | + cd ${{ github.workspace }} + cd .. + git clone https://github.com/riscvarchive/riscv-dejagnu.git + sudo apt-get update -y + sudo apt-get install -y expect + sudo apt-get install -y libgmp10 + sudo apt-get install -y libgmp-dev + sudo apt-get install -y libmpfr6 + sudo apt-get install -y libmpfr-dev + cd riscv-dejagnu + ./configure + aclocal + automake + sudo make all install + cd ${{ github.workspace }} + source build-corev-binutils-gdb.sh --clean + cd ${{ github.workspace }} + export -p > temp_env + - name: Launch Binutils and GDB Regression Tests + run: | + cd ${{ github.workspace }} + source temp_env + cd ${BUILD_BINUTILS_PREFIX} + make check RUNTESTFLAGS="riscv.exp --target_board=riscv-sim" > ${{ github.workspace }}/regression_report.txt + cd ${{ github.workspace }} + export -p > temp_env + - name: Read Binutils and GDB Regression Report + run: | + cd ${{ github.workspace }} + source temp_env + echo "Reading regression report from $(pwd) folder" + cat regression_report.txt + cd ${{ github.workspace }} + export -p > temp_env + - name: Upload Binutils and GDB Regression Report + uses: actions/upload-artifact@v3 + with: + name: regression_report + path: regression_report.txt + - name: Exit from Binutils and GDB CI + run: + echo "This job's status is ${{ job.status }}." + if grep -q "unexpected failures" ${{ github.workspace }}/regression_report.txt; then exit 1; fi + if grep -q "unexpected passes" ${{ github.workspace }}/regression_report.txt; then exit 1; fi diff --git a/.github/workflows/binutils-gdb-ci-push.yml b/.github/workflows/binutils-gdb-ci-push.yml new file mode 100644 index 00000000000..a0baea046a4 --- /dev/null +++ b/.github/workflows/binutils-gdb-ci-push.yml @@ -0,0 +1,60 @@ +name: Binutils and GDB PUSH CI +on: push +jobs: + Regression-Tests: + name: Regression Tests + runs-on: ubuntu-latest + steps: + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v2 + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." + - name: Build Binutils and GDB + run: | + cd ${{ github.workspace }} + cd .. + git clone https://github.com/riscvarchive/riscv-dejagnu.git + sudo apt-get update -y + sudo apt-get install -y expect + sudo apt-get install -y libgmp10 + sudo apt-get install -y libgmp-dev + sudo apt-get install -y libmpfr6 + sudo apt-get install -y libmpfr-dev + cd riscv-dejagnu + ./configure + aclocal + automake + sudo make all install + cd ${{ github.workspace }} + source build-corev-binutils-gdb.sh --clean + cd ${{ github.workspace }} + export -p > temp_env + - name: Launch Binutils and GDB Regression Tests + run: | + cd ${{ github.workspace }} + source temp_env + cd ${BUILD_BINUTILS_PREFIX} + make check RUNTESTFLAGS="riscv.exp -target_board=riscv-sim" > ${{ github.workspace }}/regression_report.txt + cd ${{ github.workspace }} + export -p > temp_env + - name: Read Binutils and GDB Regression Report + run: | + cd ${{ github.workspace }} + source temp_env + echo "Reading regression report from $(pwd) folder" + cat regression_report.txt + cd ${{ github.workspace }} + export -p > temp_env + - name: Upload Binutils and GDB Regression Report + uses: actions/upload-artifact@v3 + with: + name: regression_report + path: regression_report.txt + - name: Exit from Binutils and GDB CI + run: | + echo "This job's status is ${{ job.status }}." + if grep -q "unexpected failures" ${{ github.workspace }}/regression_report.txt; then exit 1; fi + if grep -q "unexpected passes" ${{ github.workspace }}/regression_report.txt; then exit 1; fi diff --git a/build-corev-binutils-gdb.sh b/build-corev-binutils-gdb.sh new file mode 100644 index 00000000000..762abf02252 --- /dev/null +++ b/build-corev-binutils-gdb.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +# Build script for the CORE-V Binutils and GDB. + +# Copyright (C) 2020 Embecosm Limited +# Contributor Jessica Mills + +# This file is part of the Embecosm GNU toolchain build system for RISC-V. + +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 3 of the License, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. + +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +export ROOT_PREFIX=$(cd ../ && pwd) + +export BINUTILS_GDB_FOLDER=corev-binutils-gdb +export BINUTILS_GDB_PREFIX=${ROOT_PREFIX}/${BINUTILS_PREFIX} + +export BUILD_BINUTILS_FOLDER=build-${BINUTILS_GDB_FOLDER} +export BUILD_BINUTILS_PREFIX=${ROOT_PREFIX}/${BUILD_BINUTILS_FOLDER} + +export INSTALL_FOLDER=toolchain-install +export INSTALL_PREFIX=${ROOT_PREFIX}/${INSTALL_FOLDER} +mkdir -p ${INSTALL_PREFIX} + +PARALLEL_JOBS=$(nproc) +DEFAULTARCH=rv32i +DEFAULTABI=ilp32 + +if [[ $* == *--debug* ]]; then + export BUILD_BINGDB_PREFIX=${ROOT_PREFIX}/${BUILD_BINUTILS_FOLDER}-DEBUG +else + export BUILD_BINGDB_PREFIX=${ROOT_PREFIX}/${BUILD_BINUTILS_FOLDER} +fi + +installs=( + "riscv32-corev-elf-addr2line" + "riscv32-corev-elf-nm" + "riscv32-corev-elf-ar" + "riscv32-corev-elf-objcopy" + "riscv32-corev-elf-objdump" + "riscv32-corev-elf-ranlib" + "riscv32-corev-elf-c++filt" + "riscv32-corev-elf-readelf" + "riscv32-corev-elf-run" + "riscv32-corev-elf-elfedit" + "riscv32-corev-elf-gdb" + "riscv32-corev-elf-size" + "riscv32-corev-elf-gprof" + "riscv32-corev-elf-strings" + "riscv32-corev-elf-ld" + "riscv32-corev-elf-strip" + "riscv32-corev-elf-ld.bfd" + "riscv32-corev-elf-as" + "riscv32-corev-elf-gcc-ar" + "riscv32-corev-elf-gcc-nm" + "riscv32-corev-elf-gcc-ranlib" + "riscv32-corev-elf-gcov" + "riscv32-corev-elf-gcov-dump" + "riscv32-corev-elf-cpp" + "riscv32-corev-elf-gcov-tool" + "riscv32-corev-elf-gcc" + "riscv32-corev-elf-gcc-7.1.1" + "riscv32-corev-elf-c++" + "riscv32-corev-elf-g++" + +) + +if [[ $* == *--help* || $* == *-h* ]]; then + echo "Usage: build-corev-binutils-gdb.sh [--clean] [--debug] [--help | -h]" + echo " Builds and installs the COREV binutils and GDB" + echo " Build directory is the peer directory 'build', install directory is the peer directory 'install'" + echo " Generates installation summary - this is the only action if no options are specified" + echo "The options are:" + echo " --clean Remove build directory" + echo " --debug Include debugging CFLAGS" + echo " --help | -h Print this help message and exit" + exit 0 +fi + + +if [[ $* == *--clean* ]]; then + if [[ -d ${BUILD_BINGDB_PREFIX} ]]; then + echo Cleaning... ${BUILD_BINGDB_PREFIX} + rm -rf ${BUILD_BINGDB_PREFIX} + fi +fi + +# Binutils-gdb +mkdir -p ${BUILD_BINGDB_PREFIX} +cd ${BUILD_BINGDB_PREFIX} +../${BINUTILS_GDB_FOLDER}/configure \ + --target=riscv32-corev-elf \ + --prefix=${INSTALL_PREFIX} \ + --disable-werror + +#CFLAGS as option for debugging +if [[ $* == *--debug* ]]; then + if ! make CFLAGS="-O0 -ggdb3" -j${PARALLEL_JOBS}; then + echo "The build has failed during binutils-gdb!" >/dev/stderr + exit 1 + fi + if ! make CFLAGS="-O0 -ggdb3" install; then + echo "The build has failed during binutils-gdb!" >/dev/stderr + exit 1 + fi +else + if ! make -j${PARALLEL_JOBS}; then + echo "The build has failed during binutils-gdb!" >/dev/stderr + exit 1 + fi + if ! make install; then + echo "The build has failed during binutils-gdb!" >/dev/stderr + exit 1 + fi +fi + +echo ===== Install summary ===== +echo ${INSTALL_PREFIX}/bin/ +for install in "${installs[@]}" +do + [ -f ${INSTALL_PREFIX}/bin/${install} ] && echo "${install} ... exists." || echo "${install} ... does not exist." +done