0

I'm using a rv32ima bare metal processor, and I need to use riscv32 for it. I've been struggling to find the right combination of packages to compile for it. The closest I've found was:

apt-get install gcc-multilib gcc-riscv64-unknown-elf

And then executing:

riscv64-unknown-elf-gcc -o test.elf test.c -O1 -march=rv32ima -mabi=ilp32 -nostdlib -T flatfile.lds
In file included from test.c:1:
/usr/lib/gcc/riscv64-unknown-elf/9.3.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
    9 | # include_next <stdint.h>
      |                ^~~~~~~~~~

But, it seems to not have the appropriate headers installed.

Side-note: It also doesn't seem to contain an rv32 libc, and I don't really need it but it wouldn't hurt.

Any recommendations? I'm hoping to make this something easy for other people to build/use. Preferably in the Ubuntu/Linux Mint/Debian world.

Charles Lohr
  • 695
  • 1
  • 8
  • 23
  • `multilib` is not somehow carrying the libs for all the possible arches (it's usually only x86 libs for use with old apps on x86_64). In fact, your best choice when dealing with relatively obscure archs is Gentoo (whereupon you set the portage to use the cross-compiler). It's a bit tricky to setup but gives consistent results. As to Debian in particular, I don't think they are interested in riscv32 at all. – oakad Oct 28 '22 at 07:09

1 Answers1

2

You can install it by following the instructions at https://github.com/riscv-collab/riscv-gnu-toolchain To summarize, the process will look something like

git clone https://github.com/riscv/riscv-gnu-toolchain
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build
./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d
make linux

And then add /opt/riscv/bin to your PATH