Add GCCVER define to Toolchain.cmake
Since GCCVER will also be used in the toolchain, it needs to be defined in advance. Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
This commit is contained in:
parent
a94c099b7d
commit
9614e1fed5
|
@ -62,17 +62,19 @@ endif()
|
|||
# array subscript [0] is outside array bounds:
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
|
||||
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} --version
|
||||
if(CONFIG_ARCH_TOOLCHAIN_GNU)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} --version
|
||||
OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
||||
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
|
||||
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
|
||||
"${GCC_VERSION_OUTPUT}")
|
||||
set(GCCVER ${CMAKE_MATCH_1})
|
||||
set(GCCVER ${CMAKE_MATCH_1})
|
||||
|
||||
if(GCCVER GREATER_EQUAL 12)
|
||||
if(GCCVER GREATER_EQUAL 12)
|
||||
add_compile_options(--param=min-pagesize=0)
|
||||
if(CONFIG_ARCH_RAMFUNCS)
|
||||
add_link_options(-Wl,--no-warn-rwx-segments)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# override the ARCHIVE command
|
||||
|
|
|
@ -309,12 +309,17 @@ else
|
|||
# Wrong warning array subscript [0] is outside array bounds:
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
|
||||
|
||||
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)
|
||||
ARCHOPTIMIZATION += --param=min-pagesize=0
|
||||
ifeq ($(CONFIG_ARCH_RAMFUNCS),y)
|
||||
LDFLAGS += --no-warn-rwx-segments
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
LDFLAGS += --entry=__start
|
||||
|
||||
|
|
|
@ -181,7 +181,12 @@ ifeq ($(CONFIG_LTO_FULL),y)
|
|||
endif
|
||||
|
||||
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)
|
||||
LDFLAGS += --no-warn-rwx-segments
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add the builtin library
|
||||
|
|
|
@ -190,5 +190,14 @@ if(CONFIG_DEBUG_SYMBOLS)
|
|||
endif()
|
||||
|
||||
if(CONFIG_ARCH_TOOLCHAIN_GNU)
|
||||
if(NOT GCCVER)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} --version
|
||||
OUTPUT_VARIABLE GCC_VERSION_INFO)
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+" GCC_VERSION ${GCC_VERSION_INFO})
|
||||
string(REGEX REPLACE "\\..*" "" GCCVER ${GCC_VERSION})
|
||||
set(GCCVER ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
if(GCCVER GREATER_EQUAL 12)
|
||||
add_link_options(-Wl,--no-warn-rwx-segments)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -413,7 +413,7 @@ config ARCH_RV_MACHINE_ISA_1_13
|
|||
which extend the range of exception codes from 0 ~ 15 to 0 ~ 19.
|
||||
|
||||
config ARCH_RV_ISA_ZICSR_ZIFENCEI
|
||||
bool
|
||||
bool "Enable Zicsr and Zifencei extensions (GCC >= 12.1.0.)"
|
||||
default y
|
||||
---help---
|
||||
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
|
||||
|
|
|
@ -258,9 +258,19 @@ if(CONFIG_RISCV_TOOLCHAIN STREQUAL GNU_RVG)
|
|||
set(ARCHCPUEXTFLAGS ${ARCHCPUEXTFLAGS}v)
|
||||
endif()
|
||||
|
||||
if(NOT GCCVER)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
|
||||
OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
||||
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
|
||||
"${GCC_VERSION_OUTPUT}")
|
||||
set(GCCVER ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARCH_RV_ISA_ZICSR_ZIFENCEI)
|
||||
if(GCCVER GREATER_EQUAL 12 OR CONFIG_ARCH_TOOLCHAIN_CLANG)
|
||||
set(ARCHCPUEXTFLAGS ${ARCHCPUEXTFLAGS}_zicsr_zifencei)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS)
|
||||
set(ARCHCPUEXTFLAGS
|
||||
|
|
|
@ -209,9 +209,18 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG)
|
|||
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)v
|
||||
endif
|
||||
|
||||
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 ($(CONFIG_ARCH_RV_ISA_ZICSR_ZIFENCEI),y)
|
||||
ifeq ($(shell expr "$(GCCVER)" \>= 12), 1)
|
||||
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_zicsr_zifencei
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
|
||||
ARCHCPUEXTFLAGS := $(ARCHCPUEXTFLAGS)_zicsr_zifencei
|
||||
endif
|
||||
endif
|
||||
|
||||
ARCH_RV_EXPERIMENTAL_EXTENSIONS = $(strip $(subst ",,$(CONFIG_ARCH_RV_EXPERIMENTAL_EXTENSIONS)))
|
||||
ifneq ($(ARCH_RV_EXPERIMENTAL_EXTENSIONS),)
|
||||
|
|
|
@ -111,6 +111,12 @@ ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
|
|||
ARCHCXXFLAGS += -nostdinc++
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
|
||||
ifeq ($(GCCVER),)
|
||||
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
|
||||
ARCHCFLAGS += -Wno-psabi
|
||||
ARCHCXXFLAGS += -Wno-psabi
|
||||
|
|
|
@ -115,6 +115,12 @@ ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
|
|||
ARCHCXXFLAGS += -nostdinc++
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
|
||||
ifeq ($(GCCVER),)
|
||||
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
|
||||
ARCHCFLAGS += -Wno-psabi
|
||||
ARCHCXXFLAGS += -Wno-psabi
|
||||
|
|
|
@ -732,11 +732,6 @@ export DEFINE_PREFIX ?= $(subst X,,${shell $(DEFINE) "$(CC)" X 2> ${EMPTYFILE}})
|
|||
export INCDIR_PREFIX ?= $(subst "X",,${shell $(INCDIR) "$(CC)" X 2> ${EMPTYFILE}})
|
||||
export INCSYSDIR_PREFIX ?= $(subst "X",,${shell $(INCDIR) -s "$(CC)" X 2> ${EMPTYFILE}})
|
||||
|
||||
# Get the GCC version number
|
||||
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU), y)
|
||||
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
|
||||
endif
|
||||
|
||||
# ARCHxxx means the predefined setting(either toolchain, arch, or system specific)
|
||||
ARCHDEFINES += ${DEFINE_PREFIX}__NuttX__
|
||||
ifeq ($(CONFIG_NDEBUG),y)
|
||||
|
|
Loading…
Reference in New Issue