This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 52e99bc66be483358fb36ff2ee8e1727db62fcd7
Author: chao an <[email protected]>
AuthorDate: Tue Jan 16 08:57:01 2024 +0800

    risc-v/toolchain: move zicsr/zifencei extension into Kconfig
    
    Signed-off-by: chao an <[email protected]>
---
 arch/risc-v/Kconfig                   | 14 ++++++++++++++
 arch/risc-v/src/common/Toolchain.defs | 10 +++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/risc-v/Kconfig b/arch/risc-v/Kconfig
index 5956c84252..fea9c6f88f 100644
--- a/arch/risc-v/Kconfig
+++ b/arch/risc-v/Kconfig
@@ -288,6 +288,20 @@ config ARCH_RV_ISA_V
        default n
        depends on ARCH_FPU
 
+config ARCH_RV_ISA_ZICSR_ZIFENCEI
+       bool
+       default y
+       ---help---
+               
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
+               
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=98416dbb0a62579d4a7a4a76bab51b5b52fec2cd
+               GCC-12.1.0 bumped the default ISA spec to the newer 20191213 
version,
+               which moves some instructions from the I extension to the Zicsr 
and
+               Zifencei extensions. This requires explicitly specifying Zicsr 
and
+               Zifencei when GCC >= 12.1.0. To make life easier, and avoid 
forcing
+               toolchains that default to a newer ISA spec to version 2.2. For
+               clang < 17 or GCC < 11.3.0, for which this is not possible or 
need
+               special treatment.
+
 config ARCH_RV_MMIO_BITS
        int
        # special cases
diff --git a/arch/risc-v/src/common/Toolchain.defs 
b/arch/risc-v/src/common/Toolchain.defs
index 391f90b5ad..b3241c2c14 100644
--- a/arch/risc-v/src/common/Toolchain.defs
+++ b/arch/risc-v/src/common/Toolchain.defs
@@ -185,9 +185,13 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG)
     ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)v
   endif
 
-  GCC_VERSION = ${shell $(CROSSDEV)gcc --version | grep gcc | grep -oE 
'[0-9]+\.[0-9]+\.[0-9]+' | tail -n 1 | cut -d"." -f1 }
-  ifeq ($(shell expr $(GCC_VERSION) \>= 12), 1)
-    ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_zicsr_zifencei
+  ifeq ($(CONFIG_ARCH_RV_ISA_ZICSR_ZIFENCEI),y)
+    ifeq ($(GCCVER),)
+      export GCCVER = ${shell $(CROSSDEV)gcc --version | grep gcc | grep -oE 
'[0-9]+\.[0-9]+\.[0-9]+' | tail -n 1 | cut -d"." -f1 }
+    endif
+    ifeq ($(shell expr $(GCCVER) \>= 12), 1)
+      ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_zicsr_zifencei
+    endif
   endif
 
   # Detect abi type

Reply via email to