Reputation: 919
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.
Upvotes: 0
Views: 10404
Reputation: 399
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
Upvotes: 4