2

I want to use riscv-gcc to implement an Ibex (RISCV core) example on an Arty-A7 but I haven't been able to build it properly. It's been failing after the 'make' phase. It seems to have something to do with zlib however I'm not so sure since this is the first time I'm building anything from source. I got the source from https://github.com/riscv/riscv-gcc

I've configure it executed make as

../riscv-gcc/configure --enable-multilib
make

it then exits with the following error

checking whether the gcc  -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
make[2]: *** [configure-stage1-zlib] Error 1
make[2]: Leaving directory `/home/alfred/Desktop/Work/riscv_gcc_install'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/alfred/Desktop/Work/riscv_gcc_install'
make: *** [all] Error 2

I've also tried running make (same configuration) with

make all-gcc

but it produces this error instead

checking if gcc  -m32 supports -fno-rtti -fno-exceptions... no
checking for gcc  -m32 option to produce PIC... -fPIC -DPIC
checking if gcc  -m32 PIC flag -fPIC -DPIC works... yes
checking if gcc  -m32 static flag -static works... no
checking if gcc  -m32 supports -c -o file.o... yes
checking if gcc  -m32 supports -c -o file.o... (cached) yes
checking whether the gcc  -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
make: *** [configure-zlib] Error 1

I'm not sure what to do so far besides check prerequisite libraries as suggested by https://gcc.gnu.org/install/prerequisites.html . Can Anyone help me out?

[UPDATE 27/11/19]

I tried to install the complete riscv-gnu-toolchain from < https://github.com/riscv/riscv-gnu-toolchain> to avoid missing dependencies however I still had an error. I did run the suggested apt-get command to install the prerequisites.

I ran the configuration suggested to target riscv32 and proceeded with make as follows

./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d
make linux

I then got this error

make[3]: Entering directory `/home/alfred/Desktop/Work/riscv-gnu-toolchain/build-binutils-linux/binutils'
/bin/bash /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/../ylwrap /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/arparse.y y.tab.c arparse.c y.tab.h `echo arparse.c | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/` y.output arparse.output -- bison -y  -d
m4: unrecognized option '--gnu'
Try `m4 --help' for more information.
make[4]: Entering directory `/home/alfred/Desktop/Work/riscv-gnu-toolchain/build-binutils-linux/binutils'
/bin/bash /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/../ylwrap /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/arparse.y y.tab.c arparse.c y.tab.h `echo arparse.c | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/` y.output arparse.output -- bison -y  -d
m4: unrecognized option '--gnu'
Try `m4 --help' for more information.
make[4]: Leaving directory `/home/alfred/Desktop/Work/riscv-gnu-toolchain/build-binutils-linux/binutils'
/bin/bash /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/../ylwrap /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/sysinfo.y y.tab.c sysinfo.c y.tab.h `echo sysinfo.c | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/` y.output sysinfo.output -- bison -y  -d
/home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/sysinfo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
m4: unrecognized option '--gnu'
Try `m4 --help' for more information.
if [ -r sysinfo.c ]; then \
      gcc -c -I. -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -I/home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/../zlib -g -O2  sysinfo.c ; \
    else \
      gcc -c -I. -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -I/home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/../zlib -g -O2  /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/sysinfo.c ; \
    fi
gcc: error: /home/alfred/Desktop/Work/riscv-gnu-toolchain/riscv-binutils/binutils/sysinfo.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
make[3]: *** [sysinfo.o] Error 4
make[3]: Leaving directory `/home/alfred/Desktop/Work/riscv-gnu-toolchain/build-binutils-linux/binutils'
make[2]: *** [all-binutils] Error 2
make[2]: Leaving directory `/home/alfred/Desktop/Work/riscv-gnu-toolchain/build-binutils-linux'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/alfred/Desktop/Work/riscv-gnu-toolchain/build-binutils-linux'
make: *** [stamps/build-binutils-linux] Error 2

I noticed that m4 did not recognize a certain argument

--gnu

should I be concerned with this?

[UPDATE 16/12/2019]

As recommended, I tried to build the tool-chain in Ubuntu 18.04.03 (originally I was on 14.04) and it seems to have solved the problem quite well! Turns out that the tool-chain is indeed "fragile" when it comes to OS dependencies. Thanks so much for the help!

ajabanto
  • 23
  • 4
  • Hello. Which version of Arty A7 board do you have - -35T or -100T? Which instruction does you use to build gcc? I think you should search not for gcc only variant, but for complete toolchain instruction like https://github.com/riscv/riscv-gnu-toolchain or something from Ibex authors web-site (https://ibex-core.readthedocs.io/en/latest/verification.html#getting-started - GCC setup). The error "Link tests are not allowed" is something connected to incomplete toolchain (ld,binutils,libc) like it was in https://gcc.gnu.org/ml/gcc-help/2012-07/msg00018.html. – osgx Nov 26 '19 at 02:25
  • Hello @osgx , I'm using the --35T version of the Arty-A7. I tried building the riscv-gnu-toolchain instead of just the riscv-gcc however I'm still having trouble. I will update the post. – ajabanto Nov 27 '19 at 04:02

3 Answers3

1

The error "Link tests are not allowed" is something connected to incomplete toolchain (like ld, binutils, libc), similar to report inhttps://gcc.gnu.org/ml/gcc-help/2012-07/msg00018.html.

It is unclear from your question which instruction did you use to build gcc. I think you should search not for gcc only build, but for complete toolchain instruction like https://github.com/riscv/riscv-gnu-toolchain or something from Ibex authors web-site. Ibex documentation in page https://ibex-core.readthedocs.io/en/latest/verification.html#getting-started has some link to "GCC setup", but it is for verification and without complete instruction.

In issue https://github.com/riscv/riscv-gcc/issues/143 there is information that "You can't build gcc without binutils." and "You can't build a useful gcc without a C library.", so try to build complete toolchain, not the gcc only.

In earlier project by lowrisc there was instruction to build toolchain (combined gcc + binutils + newlib): https://www.lowrisc.org/blog/2017/09/building-upstream-risc-v-gccbinutilsnewlib-the-quick-and-dirty-way/ - you may want to modify the instruction with another git (riscv-gcc). Or just try https://github.com/riscv/riscv-gnu-toolchain

osgx
  • 90,338
  • 53
  • 357
  • 513
  • Hello! thanks for the response again, I've just tried to install riscv-gnu-toolchain I willl update the post. This time it exited after doing something related to binutils – ajabanto Nov 27 '19 at 04:04
  • @ajabanto, 35T sounds too small to fit the full project (web page recommends 100T, not sure about real usage and project settings). Seems your m4 is too old - https://lists.gnu.org/archive/html/m4-discuss/2013-01/msg00001.html, try build the toolchain from more recent version of your host linux distribution (GNU m4 1.4.13 is needed). What is your current Linux version (debian ubuntu or something)? I think 16.04 or 18.04 or debian 10 may work. – osgx Nov 28 '19 at 07:35
  • Hello! I see, with regards to the arty a7, we have other boards here I can try but I suppose I'll tackle that issue when I've built the tools needed. Right now I'm currently on ubuntu 14.04 however I won't be able to update to more recent versions since more recent versions of don't work with my workstation due to the chipset I think . I will try to see if I can get a more recent version of m4. Thanks again for the help I will update the post asap after trying out your suggestion – ajabanto Nov 29 '19 at 01:56
  • @ajabanto, you can try virtual machine to run recent linux inside it. – osgx Nov 30 '19 at 02:05
  • I tried running Ubuntu 18.04 on virtual box and true enough I was able to succesfully build the riscv-toolchain without any real errors, thanks alot! I have some other questions, I'll update the post asap for context. – ajabanto Dec 04 '19 at 08:28
0

I have found that the RISC-V toolchain is very fragile with respect to OS dependencies. The toolchain team uses Ubuntu 16, and a lot of errors folks see arise from the changes to the Linux ecosystem since that version.

I got around this issue by creating a Vagrantfile that is configured to use Ubuntu 16, and goes through the official steps, and at least for me, it builds the tools just fine. If you're interested, it's posted inside the stackoverflow question I asked along these lines. If you need to configure the tools differently, it's straightforward to do in the Vagrantfile.

Dylan McNamee
  • 1,696
  • 14
  • 16
0

Try this version for integer riscv. I tried it already and passed.

git clone https://github.com/riscv/riscv-gnu-toolchain  
git checkout 411d134  
git submodule update --init --recursive  
mkdir build  
cd build  
../configure --prefix=/opt/riscv32i --with-arch=rv32i --with-abi=ilp32  
make -j8  

If your riscv has mul/div module, add M standard extension.

../configure --prefix=/opt/riscv32im --with-arch=rv32im --with-abi=ilp32

If your riscv is 64-bit integer core:

../configure --prefix=/opt/riscv64i --with-arch=riscv64i --with-abi=lp64   

select option that you want to build:
"M" Standard Extension for Integer Multiplication and Divison
"A" Standard Extension for Atomic Instructions
"F" Standard Extension for Single-Precision Floating-Point
"D" Standard Extension for Double-Precision Floating-Point
"Q" Standard Extension for Quard-Precision Floating-point
"C" Standard Extension for Compressed Instruction
"G" combination of I, M, A, F and D.

ilp32/ilp32f/ilp32d int-32bits long-32bits pointer-32bits
lp64/lp64f/lp64d int-32bits long-64bits pointer-64bits

The vexrisc full project implement riscv on arty a7 35t, includes toolchain compile and using IntelliJ IDE build riscv project and internal USB jtag debugging may help you.

https://fatalfeel.blogspot.com/2013/12/risc-v-on-arty-a7-35t.html

Maybe you want to try Linux on riscv. It's based on vexrisc

https://github.com/SpinalHDL/SaxonSoc

karel
  • 5,489
  • 46
  • 45
  • 50