Skip to content

Commit

Permalink
Unify the definition of GCCVER and remove duplicate code.
Browse files Browse the repository at this point in the history
Signed-off-by: cuiziwei <[email protected]>
  • Loading branch information
cuiziweizw committed Oct 12, 2024
1 parent 994e157 commit b48a7cc
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 22 deletions.
6 changes: 0 additions & 6 deletions arch/arm/src/cmake/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ 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
OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
string(REGEX MATCH "\\+\\+.* ([0-9]+)\\.[0-9]+" GCC_VERSION_REGEX
"${GCC_VERSION_OUTPUT}")
set(GCCVER ${CMAKE_MATCH_1})

if(GCCVER EQUAL 12)
add_compile_options(--param=min-pagesize=0)
if(CONFIG_ARCH_RAMFUNCS)
Expand Down
4 changes: 0 additions & 4 deletions arch/arm/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,6 @@ else
# Wrong warning array subscript [0] is outside array bounds:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523

ifeq ($(GCCVER),)
export GCCVER := $(shell $(CC) --version | grep gcc | sed -E "s/.* ([0-9]+\.[0-9]+).*/\1/" | cut -d'.' -f1)
endif

ifeq ($(GCCVER),12)
ARCHOPTIMIZATION += --param=min-pagesize=0
ifeq ($(CONFIG_ARCH_RAMFUNCS),y)
Expand Down
6 changes: 6 additions & 0 deletions cmake/nuttx_toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,9 @@ if(NOT NUTTX_FIND_TOOLCHAIN_LIB_DEFINED)
nuttx_add_extra_library(${extra_lib_path})
endfunction()
endif()

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})
8 changes: 0 additions & 8 deletions libs/libxx/libcxx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ list(APPEND SRCS ${SRCSTMP})
set(FLAGS -Wno-attributes -Wno-deprecated-declarations -Wno-shadow
-Wno-sign-compare)

if(NOT DEFINED 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(GCCVER EQUAL 12)
list(APPEND FLAGS -Wno-maybe-uninitialized -Wno-alloc-size-larger-than)
endif()
Expand Down
4 changes: 0 additions & 4 deletions libs/libxx/libcxx.defs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ endif
CXXFLAGS += -Wno-shadow -Wno-sign-compare
CXXFLAGS += -Wno-attributes -Wno-deprecated-declarations

ifeq ($(GCCVER),)
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
endif

ifeq ($(shell expr $(GCCVER) \>= 12), 1)
CXXFLAGS += -Wno-maybe-uninitialized -Wno-alloc-size-larger-than
endif
Expand Down
3 changes: 3 additions & 0 deletions tools/Config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@ 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
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)

# ARCHxxx means the predefined setting(either toolchain, arch, or system specific)
ARCHDEFINES += ${DEFINE_PREFIX}__NuttX__
ifeq ($(CONFIG_NDEBUG),y)
Expand Down

0 comments on commit b48a7cc

Please sign in to comment.