From 1025538c8c371b8bcb49f939a036ad5afc6f3284 Mon Sep 17 00:00:00 2001 From: LP-HAW Date: Sun, 16 Jun 2024 19:22:16 +0200 Subject: [PATCH] makefiles: change RISC-V GCC -march to rv32imac_zicsr --- makefiles/arch/riscv.inc.mk | 19 ++++--------------- makefiles/cargo-targets.inc.mk | 4 +++- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/makefiles/arch/riscv.inc.mk b/makefiles/arch/riscv.inc.mk index 675c7737e08f..cd3069723d98 100644 --- a/makefiles/arch/riscv.inc.mk +++ b/makefiles/arch/riscv.inc.mk @@ -45,22 +45,11 @@ ifeq (,$(TARGET_ARCH)) $(error No RISC-V toolchain detected. Make sure a RISC-V toolchain is installed.) endif -ifeq ($(TOOLCHAIN),gnu) - GCC_DEFAULTS_TO_NEW_RISCV_ISA ?= $(shell echo "typedef int dont_be_pedantic;" | $(TARGET_ARCH)-gcc -march=rv32imac -mabi=ilp32 -misa-spec=2.2 -E - > /dev/null 2>&1 && echo 1 || echo 0) -endif - -GCC_DEFAULTS_TO_NEW_RISCV_ISA ?= 0 - -CFLAGS_CPU := -march=rv32imac -mabi=ilp32 +CFLAGS_CPU := -march=rv32imac_zicsr -mabi=ilp32 -# Since RISC-V ISA specifications 20191213 instructions previously included in -# rv32imac have been moved to the ZICSR extension. See -# https://riscv.org/wp-content/uploads/2019/12/riscv-spec-20191213.pdf -# -# Select the oldest ISA spec in which ZICSR was not yet split out into an -# extension -ifeq (1,$(GCC_DEFAULTS_TO_NEW_RISCV_ISA)) - CFLAGS_CPU += -misa-spec=2.2 +# LLVM<17 does not support Zicsr extension in ISA-string +ifeq ($(TOOLCHAIN),llvm) + CFLAGS_CPU := -march=rv32imac -mabi=ilp32 endif # Always use riscv32-none-elf as target triple for clang, as some diff --git a/makefiles/cargo-targets.inc.mk b/makefiles/cargo-targets.inc.mk index de45a0c7c1f6..a4dfd154e71b 100644 --- a/makefiles/cargo-targets.inc.mk +++ b/makefiles/cargo-targets.inc.mk @@ -39,7 +39,9 @@ $(CARGO_COMPILE_COMMANDS): $(BUILDDEPS) -e 's/"riscv64-elf"/"riscv32"/g' \ | $(LAZYSPONGE) $@ - +# LLVM<17 does not support RISC-V Zicsr extension in ISA-string, so it must +# be removed when Rust is used with TOOLCHAIN=gnu +$(CARGO_LIB): CFLAGS := $(subst -march=rv32imac_zicsr,-march=rv32imac,$(CFLAGS)) $(CARGO_LIB): $(RIOTBUILD_CONFIG_HEADER_C) $(BUILDDEPS) $(CARGO_COMPILE_COMMANDS) FORCE @command -v cargo >/dev/null || ($(COLOR_ECHO) \ '$(COLOR_RED)Error: `cargo` command missing to build Rust modules.$(COLOR_RESET) Please install as described on .' ;\