Build rocket-tools for gcc-13

105 views Asked by At

I'm following the instructions in rocket-chip v1.6 to install and run rocket-chip. As mentioned there, I need to install rocket-tools first (it's not mentioned what version of rocket-tools is compatible/tested, so I use the latest tag 2023.05.02 of rocket-tools).

Due to the error I received while makeing rocket-chip, explained here, I needed to build rocket-tools on Ubuntu 23.10 (Mantic) with gcc-13 and g++-13.

I'm trying to run this script that installs all the prerequisites:

set -e

# required packages
sudo apt-get install --yes \
    autoconf \
    automake \
    autotools-dev \
    bc \
    build-essential \
    cmake \
    curl \
    device-tree-compiler \
    flex \
    gawk \
    git \
    gperf \
    libexpat-dev \
    libfl2 \
    libfl-dev \
    libfl-dev \
    libglib2.0-dev \
    libgmp-dev \
    libgoogle-perftools-dev \
    libmpc-dev \
    libmpfr-dev \
    libtool \
    libusb-1.0-0-dev \
    make \
    ninja-build \
    patchutils \
    perl \
    pkg-config \
    python-is-python3 \
    python3-pip \
    python3 \
    tar \
    texinfo \
    wget \
    zlib1g \
    zlib1g-dev

# bison
wget https://launchpad.net/bison/head/3.5.1/+download/bison-3.5.1.tar.gz
tar -xvf bison-3.5.1.tar.gz
cd bison-3.5.1
./configure
make
sudo make install

# rocket-tools
# https://github.com/chipsalliance/rocket-tools/tree/2023.05.02
git clone --single-branch --branch 2023.05.02 https://github.com/freechipsproject/rocket-tools ~/rocket-tools
cd ~/rocket-tools
git submodule update --init --recursive
export RISCV=~/riscv
echo 'export RISCV=~/riscv' >>~/.bashrc
CC=gcc-13 CXX=g++-13 ./build.sh

either with CC=gcc-13 CXX=g++-13 ./build.sh or just ./build.sh, I get the following error:

<logs-trimmed>
.
.
.
Configuring project fsf-binutils-gdb
*** This configuration is not supported in the following subdirectories:
     gdbserver
    (Any other directories should still work fine.)
Building project fsf-binutils-gdb
ar: `u' modifier ignored since `D' is the default (see `U')
configure: WARNING: libdebuginfod is missing or unusable; some features may be unavailable.
libtool: link: warning: `-version-info/-version-number' is ignored for convenience libraries
libtool: link: warning: `-version-info/-version-number' is ignored for convenience libraries
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/binutils/../../binutils/sysinfo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/binutils/../../binutils/defparse.y: warning: 27 shift/reduce conflicts [-Wconflicts-sr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/binutils/../../binutils/rcparse.y: warning: 58 shift/reduce conflicts [-Wconflicts-sr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/binutils/../../binutils/rcparse.y: warning: 10 reduce/reduce conflicts [-Wconflicts-rr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/binutils/../../binutils/mcparse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/ld/../../ld/deffilep.y: warning: 84 shift/reduce conflicts [-Wconflicts-sr]
libtool: link: warning: ignoring multiple `-rpath's for a libtool library
configure: WARNING: decimal float is not supported for this target, ignored
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
configure: WARNING: libipt is missing or unusable; some features may be unavailable.
ar: `u' modifier ignored since `D' is the default (see `U')
configure: WARNING: libdebuginfod is missing or unusable; some features may be unavailable.
configure: WARNING: no enhanced curses library found; disabling TUI
configure: WARNING: libipt is missing or unusable; some features may be unavailable.
configure: WARNING: babeltrace is missing or unusable; GDB is unable to read CTF data.
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/gdb/../../gdb/c-exp.y: warning: 60 shift/reduce conflicts [-Wconflicts-sr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/gdb/../../gdb/c-exp.y: warning: 69 reduce/reduce conflicts [-Wconflicts-rr]
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/gdb/../../gdb/cp-name-parser.y:34.1-12: warning: POSIX Yacc does not support %pure-parser [-Wyacc]
   34 | %pure-parser
      | ^~~~~~~~~~~~
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/gdb/../../gdb/cp-name-parser.y:34.1-12: warning: deprecated directive: ‘%pure-parser’, use ‘%define api.pure’ [-Wdeprecated]
   34 | %pure-parser
      | ^~~~~~~~~~~~
      | %define api.pure
/home/ubuntu/rocket-tools/fsf-binutils-gdb/build/gdb/../../gdb/cp-name-parser.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
In file included from ../../gdb/frame.h:75,
                 from ../../gdb/symtab.h:40,
                 from ../../gdb/language.c:33:
In member function ‘void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’,
    inlined from ‘void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’ at ../../gdb/../gdbsupport/intrusive_list.h:332:24,
    inlined from ‘frame_info_ptr::frame_info_ptr(const frame_info_ptr&)’ at ../../gdb/frame.h:241:26,
    inlined from ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’ at ../../gdb/language.c:530:49:
../../gdb/../gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ‘<anonymous>’ in ‘frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::m_back’ [-Werror=dangling-pointer=]
  415 |     m_back = &elem;
      |     ~~~~~~~^~~~~~~
../../gdb/language.c: In function ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’:
../../gdb/language.c:530:49: note: ‘<anonymous>’ declared here
  530 |       CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
      |                           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
../../gdb/frame.h:359:41: note: ‘frame_info_ptr::frame_list’ declared here
  359 |   static intrusive_list<frame_info_ptr> frame_list;
      |                                         ^~~~~~~~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [Makefile:1916: language.o] Error 1
gmake[1]: *** [Makefile:13212: all-gdb] Error 2
gmake: *** [Makefile:1004: all] Error 2

The only way I can successfully build rocket-tools is if I do this:

sudo apt install --yes gcc-11 g++-11
CC=gcc-11 CXX=g++-11 ./build.sh

However, while being successfully built with 11, rocket-chip doesn't like 11 and spits out an error requiring a newer version.

I'm completely at a loss. Any help that I could make these two work together would be highly appreciated.


UPDATE: I even pulled the latest branch from rocket-tools on Ubuntu 23.10 (Mantic):

git clone https://github.com/chipsalliance/rocket-tools.git ~/rocket-tools
cd ~/rocket-tools
git submodule update --init --recursive
export RISCV=~/riscv
echo 'export RISCV=~/riscv' >>~/.bashrc
./build.sh

I still get a different error:

Configuring project riscv-pk
Building project riscv-pk
../dummy_payload/dummy_entry.S: Assembler messages:
../dummy_payload/dummy_entry.S:23: Warning: unterminated string; newline inserted
../dummy_payload/dummy_entry.S:24: Warning: unterminated string; newline inserted
../dummy_payload/dummy_entry.S:25: Warning: unterminated string; newline inserted
../dummy_payload/dummy_entry.S:26: Warning: unterminated string; newline inserted
../dummy_payload/dummy_entry.S:27: Warning: unterminated string; newline inserted
../dummy_payload/dummy_entry.S:28: Warning: unterminated string; newline inserted
../dummy_payload/dummy_entry.S:29: Warning: unterminated string; newline inserted
/home/ubuntu/riscv/lib/gcc/riscv64-unknown-elf/12.2.0/../../../../riscv64-unknown-elf/bin/ld: warning: dummy_payload has a LOAD segment with RWX permissions
../machine/flush_icache.c: Assembler messages:
../machine/flush_icache.c:4: Error: unrecognized opcode `fence.i', extension `zifencei' required
gmake: *** [Makefile:336: flush_icache.o] Error 1
1

There are 1 answers

0
CiaranLap On

In the build.sh and/or build-rv32ima.sh script you need to update the riscv isa.

From: --with-arch=rv32ima To: --with-arch=rv32ima_zicsr_zifencei

I ran into the same issue and this is what fixed it for me.