This is an automated email from the ASF dual-hosted git repository.
ligd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 7246533aeb Unify the definition of GCCVER and remove duplicate code.
7246533aeb is described below
commit 7246533aebaca182fee88ef0e1c4da231f775123
Author: cuiziwei <[email protected]>
AuthorDate: Sat Oct 12 15:30:06 2024 +0800
Unify the definition of GCCVER and remove duplicate code.
Signed-off-by: cuiziwei <[email protected]>
---
arch/arm/src/cmake/gcc.cmake | 4 +++-
arch/arm/src/common/Toolchain.defs | 4 ----
libs/libxx/libcxx.cmake | 8 --------
libs/libxx/libcxx.defs | 4 ----
tools/Config.mk | 5 +++++
5 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/arch/arm/src/cmake/gcc.cmake b/arch/arm/src/cmake/gcc.cmake
index 1a44143144..bd0796f8af 100644
--- a/arch/arm/src/cmake/gcc.cmake
+++ b/arch/arm/src/cmake/gcc.cmake
@@ -66,7 +66,9 @@ 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})
+set(GCCVER
+ ${CMAKE_MATCH_1}
+ PARENT_SCOPE)
if(GCCVER EQUAL 12)
add_compile_options(--param=min-pagesize=0)
diff --git a/arch/arm/src/common/Toolchain.defs
b/arch/arm/src/common/Toolchain.defs
index 22a35be0ec..7c3e01082c 100644
--- a/arch/arm/src/common/Toolchain.defs
+++ b/arch/arm/src/common/Toolchain.defs
@@ -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)
diff --git a/libs/libxx/libcxx.cmake b/libs/libxx/libcxx.cmake
index 73f436ccd1..7eaa673958 100644
--- a/libs/libxx/libcxx.cmake
+++ b/libs/libxx/libcxx.cmake
@@ -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()
diff --git a/libs/libxx/libcxx.defs b/libs/libxx/libcxx.defs
index 0740f19393..c0e6a2af21 100644
--- a/libs/libxx/libcxx.defs
+++ b/libs/libxx/libcxx.defs
@@ -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
diff --git a/tools/Config.mk b/tools/Config.mk
index 2637786f0e..244f853066 100644
--- a/tools/Config.mk
+++ b/tools/Config.mk
@@ -732,6 +732,11 @@ 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)