Riscv64 gdbserver support for cross compilation?

When doing the cross compilation of the gdb source on a ubuntu host:
./configure --target=riscv64-unknow-linux-gnu --host x86_64-linux-gnu CC=/opt/riscv/bin/riscv64-unknown-linux-gnu-gcc CXX=/opt/riscv/bin/riscv64-unknown-linux-gnu-g++ LD=/opt/riscv/bin/riscv64-unknown-linux-gnu-ld

I am having the following message:
"
*** This configuration is not supported in the following subdirectories:
gdbserver
"
From my understanding this is because the targeted device is not supported by the build, is it something the riscv community is or will be working on?

New comment:

  • Looking at the ${srcdir}/gdbserver/configure.src file only the native programs can have the gdbserver, if $target != $host it will not build, basically gdbserver is not generated if we do crosscompilation…
    Anyone has a work around?

In case it is of interest to someone here are my finding to get gdbserver on the riscv64 SoC Polarfire, I am not saying it is how you should do it but just how I got it to work:

  • You need to get riscv toolchain and build it, in my case I stored the output to /opt/riscv
  • Get the gdb source code
  • In the gdbserver/configure.srv force “gdbserver_host=${target}” so it will build gdbserver elf
  • Then run:
    $ ./configure --target=riscv64-unknow-linux-gnu --host x86_64-linux-gnu CC=/opt/riscv/bin/riscv64-unknown-linux-gnu-gcc CXX=/opt/riscv/bin/riscv64-unknown-linux-gnu-g++ LD=/opt/riscv/bin/riscv64-unknown-linux-gnu-ld AR=/opt/riscv/bin/riscv64-unknown-linux-gnu-ar
  • in gdbserver/Makefile.in add “-static” to CC_LD variable as the linux distrib proviced for SoC polarfire use an old libc not compatible with gdbserver build and it will complain at runtime.
  • You are ready to run make

After better understanding on the build, you should run the following ./configure command:
./configure --build=x86_64-pc-linux-gnu --host=riscv64-unknown-linux-gnu --target=riscv64-unknown-linux-gnu

To get the gdb client to connect remotely to the gdbserver I recommend to use gdb 11.0.50 from the bintutils-gdb distrib. Did not work for me using v10.2