Using new toolchain (12.2) csr opcode errors.
Opened this issue · 5 comments
The _zicsr and _zifecei options for -march are no longer assumed if you specify i as an option to -march=
For test cases that have any csr opcodes in them 9DUT or Sail) it will fail the compile with a message:
Error: unrecognized opcode csrr a0,mhartid', extension zicsr' required
Currently the python scripts for generating makefile for both the DUT and Sail use as passed in parameter {0}
-march={0} which for testing C extension translates to -march=rv64ic
Changing the python to a fixed value of : -march=rv64imafdc_zicsr_zifencei instead of the {0} fixes this issue and allows the test cases to compile w/o errors.
I do not know if this is the long term fix for this as some cross-compilers may not support the full extension set, based on how they were built.
Each test file has the RVTEST_ISA
function that defines the ISA string which is picked up by the RISCOF and passed to -march
flag.
And each test has an appropriate ISA string depending on the Instruction OPCODES that the test executes. For example for the C extension tests, the RVTEST_ISA is defined as RV64IC (which translates to -march=rv64ic
), except for c.ebreak test. As c.ebreak
raises an exception, it executes CSR opcodes. Hence, zicsr
is included in the ISA string for this test (link).
So, the test carefully includes only those minimum extensions/features to the ISA string that are required by the test. Since the C extension tests do not execute (or are not required to execute) CSR opcodes (except c.ebreak), so ISA string only includes ic
and does not include zicsr
. If there is a bug in the implementation (or the C extension is disabled in the implementation), it may cause a trap and tries to execute CSR opcodes, then the toolchain will throw the compilation error because zicsr
is not included (and not required to be included by that test)