YosysHQ / picorv32

PicoRV32 - A Size-Optimized RISC-V CPU
ISC License
3.06k stars 749 forks source link

Toolchain: would it make sens to move to gcc-riscv64-unknown-elf and friends only? #214

Open Riesi opened 2 years ago

Riesi commented 2 years ago

Hello, I wanted to try building this project and I didnt really want to install the toolchain via the supplied Makefile, because not using the package manager seems pretty ugly to me. So I searched for the needed packages and couldnt find them. Only the *-riscv64-unknown-elf versions seem to be available on Ubuntu or AUR. After finding the following reference: https://aur.archlinux.org/packages/riscv64-unknown-elf-gcc#comment-635901 I tried to build with *-riscv64-unknown-elf directly and after fixing up the Makefile to use that binary the make test seem to pass.

Would it make sense to move the Makefile to *-riscv64-unknown-elf, since it seems to be the recommended instead of *-riscv32-unknown-elf.

Riesi commented 2 years ago

Am I missing something? Why this repo is building different compilers per each architecture instead of simply using -march

jeras commented 2 years ago

I would too like to be able to test PicoRV32 (make test_verilator) with a prebuilt compiler, my choice would be a nightly from https://github.com/riscv-collab/riscv-gnu-toolchain

I first modified the Makefile to accept a system variable specyfiing the compiler, but I could not get past library issues (either floating point or more general for riscv64-elf-ubuntu-20.04-nightly-2022.08.19-nightly).

$ git diff Makefile 
diff --git a/Makefile b/Makefile
index d7027e3..dcd1b04 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ TEST_OBJS = $(addsuffix .o,$(basename $(wildcard tests/*.S)))
 FIRMWARE_OBJS = firmware/start.o firmware/irq.o firmware/print.o firmware/hello.o firmware/sieve.o firmware/multest.o firmware/stats.o
 GCC_WARNS  = -Werror -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings
 GCC_WARNS += -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -pedantic # -Wconversion
-TOOLCHAIN_PREFIX = $(RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX)i/bin/riscv32-unknown-elf-
+TOOLCHAIN_PREFIX ?= $(RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX)i/bin/riscv32-unknown-elf-
 COMPRESSED_ISA = C

 # Add things like "export http_proxy=... https_proxy=..." here