buildroot/arch
Romain Naour d479264b34 arch/Config.in.riscv: enable Zicsr and Zifencei standalone extensions with gcc >= 12
Since gcc 12, the default RISC-V ISA spec version was bump to 20191213 [1].

This bump introduces a major compatibility issue: support for the csr read/write
(csrr*/csrw*) instructions and fence.i instruction has been separated
from the "I" extension, becoming two standalone extensions: Zicsr and
Zifencei. gcc now has specific -march suffixes to enable those
extensions (_zicsr and _zifencei). If they are not used and code that
uses these instructions is built, one would get errors such as
unrecognized opcode "csrr" (or "fence.i").

For example, without Zifencei we can't build the opensbi
bootloader[2]:

opensbi-1.0/lib/sbi/sbi_tlb.c: Assembler messages:
opensbi-1.0/lib/sbi/sbi_tlb.c:190: Error: unrecognized opcode `fence.i', extension `zifencei' required

As a workaround, the opensbi build system has been patched [3] to use
-march=rv64imafdc_zicsr_zifencei when needed.  This workaround doesn't
work in Buildroot due to the local patch
0001-Makefile-Don-t-specify-mabi-or-march.patch which removes -march
from CFLAGS.

In the context of Buildroot, we have decided for now to assume that
all RISC-V cores that are Linux capable will implement the Zicsr and
Zifencei extensions: it is in fact the case today ase these extensions
were part of the I extension, that all cores support. OpenSBI and
Linux are making the same assumption (see [5]).

Therefore, when gcc >= 12, the -march value gets appended with
_zicsr_zifencei.

[1] https://gcc.gnu.org/gcc-12/changes.html
[2] https://github.com/riscv-software-src/opensbi/blob/v0.9/lib/sbi/sbi_tlb.c#L173
[3] 5d53b55aa7
[4] https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/aE1ZeHHCYf4
[5] http://lists.busybox.net/pipermail/buildroot/2022-July/646698.html

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Mark Corbin <mark@dibsco.co.uk>
[Thomas: add comment in .mk file, rework commit log]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2022-07-23 17:31:27 +02:00
..
arch.mk arch: drop BR2_GCC_TARGET_CPU_REVISION option 2018-10-01 14:52:32 +02:00
arch.mk.arc arch/arc: explicitly set "max-page-size" for GNU LD 2019-12-25 22:09:52 +01:00
arch.mk.csky arch/csky: add support for the ck860 core 2019-05-31 22:59:57 +02:00
arch.mk.riscv arch/Config.in.riscv: enable Zicsr and Zifencei standalone extensions with gcc >= 12 2022-07-23 17:31:27 +02:00
arch.mk.xtensa arc/xtensa: store the Xtensa overlay in the per-package DL_DIR 2018-04-02 15:59:30 +02:00
Config.in package/elf2flt: Remove Config.in.host 2022-07-23 16:38:54 +02:00
Config.in.arc core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.arm arch/Config.in: armeb no-MMU is not supported 2022-06-08 11:46:49 +02:00
Config.in.csky core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.m68k core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.microblaze core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.mips core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.nios2 core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.or1k core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.powerpc arch/Config.in.powerpc: disable some variants on ppc64le 2022-06-06 15:15:00 +02:00
Config.in.riscv core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.s390x core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.sh arch/Config.in.sh: move BR2_ARCH_HAS_MMU_MANDATORY one level up 2022-04-24 10:45:17 +02:00
Config.in.sparc core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00
Config.in.x86 arch/Config.in.x86: fix bonnell typo 2022-05-15 20:10:35 +02:00
Config.in.xtensa core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH 2022-02-08 21:20:23 +01:00