Open dipsankarb opened 2 years ago
Try adding the architecture flag march
and mabi
to GCC to override the ones set in nano spec.
For example:
riscv64-unknown-elf-gcc -fno-common -fno-builtin-printf -specs=htif_nano.specs -march=rv32imafc -mabi=ilp32f -c hello.c
riscv64-unknown-elf-gcc -static -specs=htif_nano.specs -march=rv32imafc -mabi=ilp32f hello.o -o hello.riscv
And yes, you are correct that the default toolchain Chipyard builds does not have rv32 libraries, and you would need to build the toolchain with --enable-multilib
flag. Here's an example
./configure --prefix=/path/to/your/RISCV --with-multilib-generator="rv32i-ilp32--;rv32im-ilp32--;rv32ima-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv64i-lp64--;rv64im-lp64--;rv64ima-lp64--;rv64imac-lp64--;rv64imaf-lp64f--;rv64imafd-lp64d--;rv64imafdc-lp64d--"
I am trying to compile a 32bit binary (similar to the ones in $RISCV/generators/riscv-sodor/riscv-bmarks) for running with the SODOR cores. However, if I compile one with riscv64-unknown-elf-gcc, I suppose it will produce a 64bit binary. I want to build it as per the instructions given in this page (https://chipyard.readthedocs.io/en/latest/Software/Baremetal.html). I have tried doing this using riscv64-unknown-elf-gcc which generates elf64. However, the simulation inside verilator using a Sodor1Stage is taking forever to run and generating out file GBs in size. I am pretty sure, I have to generate a elf32 file. Please share some pointers on how to get it done.
I know I have to build it with --enable-multilib, but how do I pass that during build-tollchains? Thank you.