This is an automated email from the ASF dual-hosted git repository.
xiaoxiang 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 541f30878a arch/x86_64:Add CXX configuration for enabling x86_64
support for C++ applications.
541f30878a is described below
commit 541f30878a9f8bf1e3ade80dda598826118814ef
Author: cuiziwei <[email protected]>
AuthorDate: Fri Mar 29 15:22:08 2024 +0800
arch/x86_64:Add CXX configuration for enabling x86_64 support for C++
applications.
Signed-off-by: cuiziwei <[email protected]>
---
arch/x86_64/src/common/Toolchain.defs | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/arch/x86_64/src/common/Toolchain.defs
b/arch/x86_64/src/common/Toolchain.defs
index 3d7a06fdeb..3687c6959c 100644
--- a/arch/x86_64/src/common/Toolchain.defs
+++ b/arch/x86_64/src/common/Toolchain.defs
@@ -64,7 +64,7 @@ endif
ARCHCFLAGS += -fno-common -Wno-attributes
ARCHCXXFLAGS += -fno-common -Wno-attributes -nostdinc++
-ARCHCPUFLAGS = -fno-pic -mcmodel=large -fno-stack-protector -mno-red-zone
-mrdrnd
+ARCHCPUFLAGS = -fno-pic -mcmodel=large -mno-red-zone -mrdrnd
ARCHPICFLAGS = -fPIC
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
@@ -79,6 +79,29 @@ ifeq ($(CONFIG_HOST_MACOS),y)
CROSSDEV = x86_64-elf-
endif
+ifneq ($(CONFIG_CXX_STANDARD),)
+ ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
+endif
+
+ifeq ($(CONFIG_STACK_CANARIES),y)
+ ARCHOPTIMIZATION += -fstack-protector-all
+else
+ ARCHOPTIMIZATION += -fno-stack-protector
+endif
+
+ifneq ($(CONFIG_CXX_EXCEPTION),y)
+ ARCHCXXFLAGS += -fno-exceptions -fcheck-new
+endif
+
+ifneq ($(CONFIG_CXX_RTTI),y)
+ ARCHCXXFLAGS += -fno-rtti
+endif
+
+ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
+ LDFLAGS += --gc-sections
+ ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
+endif
+
ifeq ($(CONFIG_DEBUG_LINK_WHOLE_ARCHIVE),y)
LDFLAGS += --whole-archive
endif
@@ -101,6 +124,7 @@ ifeq ($(CONFIG_LIBCXX),y)
endif
CC = $(CROSSDEV)gcc
+CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -x c
LD = $(CROSSDEV)ld
STRIP = $(CROSSDEV)strip --strip-unneeded
@@ -173,8 +197,8 @@ ifeq ($(CONFIG_ARCH_X86_64_AVX512VBMI),y)
ARCHCPUFLAGS += -mavx512vbmi
endif
-
CFLAGS := $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES)
$(ARCHDEFINES) $(EXTRAFLAGS)
+CXXFLAGS := $(ARCHOPTIMIZATION) $(ARCHCXXFLAGS) $(ARCHXXINCLUDES)
$(ARCHDEFINES) $(EXTRAFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
@@ -182,8 +206,6 @@ ifeq ($(CONFIG_HOST_MACOS),y)
AFLAGS += -Wa,--divide
endif
-LDFLAGS += -nostdlib -static
-
# Loadable module definitions
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden