Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated compiler target architecture #86

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Updated compiler target architecture #86

merged 1 commit into from
Aug 1, 2023

Conversation

Aidan-McNay
Copy link
Contributor

@Aidan-McNay Aidan-McNay commented Jul 20, 2023

Modified the compiler architecture flag from -march=rv32i to -march=rv32i_zicsr to work with modern GCC. This should resolve #37 and #87

@Aidan-McNay Aidan-McNay changed the title Updated compiler architecture Updated compiler target architecture Jul 20, 2023
Copy link
Contributor

@RTimothyEdwards RTimothyEdwards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @jeffdi , please merge this pull request.

@jeffdi jeffdi merged commit bf6d5a5 into efabless:main Aug 1, 2023
@Aidan-McNay Aidan-McNay deleted the ISA-Fix branch August 3, 2023 22:21
@RTimothyEdwards
Copy link
Contributor

@Aidan-McNay : Jeff reports that this is now a problem with the older versions of gcc; apparently while the behavior of including the "zicsr" package was default, there was no specific architecture name associated with it, so that "-march=rv32i_zicsr" just throws an error. @jeffdi : Is this still an issue, or are we dealing with it by insisting on a specific version of gcc?

One solution would be to get the gcc version when running the Makefile recipe and set the architecture version accordingly (although I don't know at what version of gcc-riscv this change was made). I believe the Makefile is set up so that the value can be passed as an environment variable, so that's a workaround in either case (old Makefile/new gcc or new Makefile/old gcc). But handling it automatically in the Makefile is the better solution.

@Aidan-McNay
Copy link
Contributor Author

@RTimothyEdwards Ok - apologies for the issues. I can take a look into it and get back soon🙂

@RTimothyEdwards
Copy link
Contributor

Actually, looking at the code base, the Makefile compiler options are not set as variables but hard-coded. So adding something like RISCV_TYPE ?= rv32i_zicsr would be a minimal effort to provide a workaround in the case of an incompatible gcc version.

The RISCV_TYPE was used in the caravel verification testbenches to accommodate the difference in architecture between the original PicoRV32 and the Vex-RISC and should have been carried over into the caravel_board Makefiles to begin with.

@RTimothyEdwards
Copy link
Contributor

@Aidan-McNay : No need to apologize. I was just hoping you might be willing to work on a more generally-applicable solution (so that I don't have to!). If you can, then great, and you have my thanks.

@jeffdi
Copy link
Contributor

jeffdi commented Aug 4, 2023 via email

@RTimothyEdwards
Copy link
Contributor

@jeffdi : You have changed it to ARCH=rv132 which is not a compiler target. It should be rv32i (or rv32i_zicsr).

@Aidan-McNay
Copy link
Contributor Author

Looked into a bit - it looks as though in older versions, Zicsr was included in the "I" extension. With gcc >= 11.1.0, it was split off and needed to be specified explicitly.

https://github.com/riscv-collab/riscv-gcc/blob/5964b5cd72721186ea2195a7be8d40cfe6554023/gcc/common/config/riscv/riscv-common.c#L409

https://lore.kernel.org/lkml/[email protected]/t/

Definitely happy to work on it - I like the idea of having a master Makefile that sets variables appropriate for the environment

@jeffdi
Copy link
Contributor

jeffdi commented Aug 4, 2023 via email

@jeffdi
Copy link
Contributor

jeffdi commented Aug 4, 2023 via email

@jeffdi
Copy link
Contributor

jeffdi commented Aug 4, 2023 via email

@Aidan-McNay
Copy link
Contributor Author

@jeffdi Just created a PR for this :) (also, not sure about your specific setup, but I'm on an M1 Mac, and I was able to get riscv64-unknown-elf-gcc v.12.2.0 from Homebrew)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

risc-v toolchain requirement should be documented
3 participants