Skip to content

Commit 7246533

Browse files
cuiziweizwGUIDINGLI
authored andcommitted
Unify the definition of GCCVER and remove duplicate code.
Signed-off-by: cuiziwei <[email protected]>
1 parent d2fc3f2 commit 7246533

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

arch/arm/src/cmake/gcc.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ execute_process(COMMAND ${CMAKE_C_COMPILER} --version
6666
OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
6767
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
6868
"${GCC_VERSION_OUTPUT}")
69-
set(GCCVER ${CMAKE_MATCH_1})
69+
set(GCCVER
70+
${CMAKE_MATCH_1}
71+
PARENT_SCOPE)
7072

7173
if(GCCVER EQUAL 12)
7274
add_compile_options(--param=min-pagesize=0)

arch/arm/src/common/Toolchain.defs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ else
309309
# Wrong warning array subscript [0] is outside array bounds:
310310
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
311311

312-
ifeq ($(GCCVER),)
313-
export GCCVER := $(shell $(CC) --version | grep gcc | sed -E "s/.* ([0-9]+\.[0-9]+).*/\1/" | cut -d'.' -f1)
314-
endif
315-
316312
ifeq ($(GCCVER),12)
317313
ARCHOPTIMIZATION += --param=min-pagesize=0
318314
ifeq ($(CONFIG_ARCH_RAMFUNCS),y)

libs/libxx/libcxx.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ list(APPEND SRCS ${SRCSTMP})
9595
set(FLAGS -Wno-attributes -Wno-deprecated-declarations -Wno-shadow
9696
-Wno-sign-compare)
9797

98-
if(NOT DEFINED GCCVER)
99-
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
100-
OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
101-
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
102-
"${GCC_VERSION_OUTPUT}")
103-
set(GCCVER ${CMAKE_MATCH_1})
104-
endif()
105-
10698
if(GCCVER EQUAL 12)
10799
list(APPEND FLAGS -Wno-maybe-uninitialized -Wno-alloc-size-larger-than)
108100
endif()

libs/libxx/libcxx.defs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ endif
6161
CXXFLAGS += -Wno-shadow -Wno-sign-compare
6262
CXXFLAGS += -Wno-attributes -Wno-deprecated-declarations
6363

64-
ifeq ($(GCCVER),)
65-
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
66-
endif
67-
6864
ifeq ($(shell expr $(GCCVER) \>= 12), 1)
6965
CXXFLAGS += -Wno-maybe-uninitialized -Wno-alloc-size-larger-than
7066
endif

tools/Config.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,11 @@ export DEFINE_PREFIX ?= $(subst X,,${shell $(DEFINE) "$(CC)" X 2> ${EMPTYFILE}})
732732
export INCDIR_PREFIX ?= $(subst "X",,${shell $(INCDIR) "$(CC)" X 2> ${EMPTYFILE}})
733733
export INCSYSDIR_PREFIX ?= $(subst "X",,${shell $(INCDIR) -s "$(CC)" X 2> ${EMPTYFILE}})
734734

735+
# Get the GCC version number
736+
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU), y)
737+
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
738+
endif
739+
735740
# ARCHxxx means the predefined setting(either toolchain, arch, or system specific)
736741
ARCHDEFINES += ${DEFINE_PREFIX}__NuttX__
737742
ifeq ($(CONFIG_NDEBUG),y)

0 commit comments

Comments
 (0)