diff --git a/arch/risc-v/src/cmake/Toolchain.cmake b/arch/risc-v/src/cmake/Toolchain.cmake index f3288cfb5988d..d44d2845b96be 100644 --- a/arch/risc-v/src/cmake/Toolchain.cmake +++ b/arch/risc-v/src/cmake/Toolchain.cmake @@ -265,6 +265,12 @@ if(CONFIG_RISCV_TOOLCHAIN STREQUAL GNU_RVG) string(REGEX MATCH "([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX "${GCC_VERSION_OUTPUT}") set(GCCVER ${CMAKE_MATCH_1}) + + if(GCCVER GREATER_EQUAL 12) + if(CONFIG_ARCH_RAMFUNCS OR NOT CONFIG_BOOT_RUNFROMFLASH) + add_link_options(-Wl,--no-warn-rwx-segments) + endif() + endif() endif() if(CONFIG_ARCH_RV_ISA_ZICSR_ZIFENCEI) diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index b0e5729bed69e..803a6278cc105 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -386,6 +386,13 @@ ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y) ifeq ($(GCCVER),) export GCCVER := $(shell $(CC) --version | grep gcc | sed -E "s/.* ([0-9]+\.[0-9]+).*/\1/" | cut -d'.' -f1) endif + ifeq ($(shell expr "$(GCCVER)" \>= 12), 1) + ifeq ($(CONFIG_ARCH_RAMFUNCS),y) + LDFLAGS += --no-warn-rwx-segments + else ifeq ($(CONFIG_BOOT_RUNFROMFLASH),) + LDFLAGS += --no-warn-rwx-segments + endif + endif endif endif