Use C++ standard lib from toolchain

Signed-off-by: trns1997 <trns1997@gmail.com>
This commit is contained in:
trns1997 2024-02-26 18:46:20 +08:00 committed by Xiang Xiao
parent 113ab704c7
commit 54e9e582d5
22 changed files with 155 additions and 28 deletions

View file

@ -481,15 +481,17 @@ if(WIN32)
else()
add_compile_options(
# system wide warnings
-Wall
$<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>
-Wshadow
-Wundef
-Wall $<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes> -Wshadow -Wundef
# system wide options
$<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>
$<$<COMPILE_LANGUAGE:ASM>:-D__ASSEMBLY__>)
endif()
if(NOT CONFIG_LIBCXXTOOLCHAIN)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>)
else()
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_STDLIB_H_>)
endif()
if(NOT CONFIG_CXX_EXCEPTION)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fcheck-new>)

View file

@ -184,7 +184,12 @@ if(CONFIG_DEBUG_SYMBOLS)
endif()
set(ARCHCFLAGS "-Wstrict-prototypes")
set(ARCHCXXFLAGS "-nostdinc++")
if(NOT CONFIG_LIBCXXTOOLCHAIN)
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
else()
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
endif()
if(NOT CONFIG_CXX_EXCEPTION)
string(APPEND ARCHCXXFLAGS " -fno-exceptions -fcheck-new")

View file

@ -289,12 +289,18 @@ endif
# Architecture flags
ARCHCFLAGS += -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -nostdinc++ -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wno-attributes -Wno-unknown-pragmas
# When all C++ code is built using GCC 7.1 or a higher version,
# we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
# Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -Wno-psabi
ARCHCXXFLAGS += -Wno-psabi
@ -386,6 +392,10 @@ ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
ifeq ($(CONFIG_LIBCXXTOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libstdc++.a))
endif
# Zig toolchain
include $(TOPDIR)/tools/Zig.defs

View file

@ -96,7 +96,7 @@ ifeq ($(CONFIG_ARCH_FPU),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Werror -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
@ -105,6 +105,12 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
# we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
# Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -Wno-psabi
ARCHCXXFLAGS += -Wno-psabi

View file

@ -123,8 +123,14 @@ set(ARCHCFLAGS
"-Wstrict-prototypes -fno-common -Wall -Wshadow -Werror -Wundef -Wno-attributes -Wno-unknown-pragmas"
)
set(ARCHCXXFLAGS
"-nostdinc++ -fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas"
)
"-fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas")
if(NOT CONFIG_LIBCXXTOOLCHAIN)
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
else()
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
endif()
if(NOT ${CONFIG_ARCH_TOOLCHAIN_CLANG})
string(APPEND ARCHCFLAGS " -Wno-psabi")
string(APPEND ARCHCXXFLAGS " -Wno-psabi")

View file

@ -99,11 +99,17 @@ else
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -46,11 +46,17 @@ else
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -65,11 +65,17 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ARCHCPUFLAGS = -mrtl-version-$(RTL_VERSION) -Wa,-rtl$(RTL_VERSION)
ARCHCPUFLAGS += -Wa,-p -mmsg-full-path -TARG:arch=cevaxc5 -Wa,-vdiv4 -Wno-unused

View file

@ -65,11 +65,17 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ARCHCPUFLAGS = -mrtl-version-$(RTL_VERSION) -Wa,-rtl$(RTL_VERSION)
ARCHCPUFLAGS += -Wa,-p

View file

@ -260,11 +260,17 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -72,11 +72,17 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -44,7 +44,7 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
@ -65,6 +65,12 @@ OBJDUMP = $(CROSSDEV)objdump
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name))
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifeq ($(CONFIG_LIBM_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif

View file

@ -55,11 +55,17 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -113,8 +113,13 @@ set(ARCHCFLAGS
"-Wstrict-prototypes -fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas"
)
set(ARCHCXXFLAGS
"-nostdinc++ -fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas"
)
"-fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas")
if(NOT CONFIG_LIBCXXTOOLCHAIN)
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
else()
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
endif()
if(NOT ${CONFIG_ARCH_TOOLCHAIN_CLANG})
string(APPEND ARCHCFLAGS " -Wno-psabi")

View file

@ -78,7 +78,7 @@ ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
@ -87,6 +87,12 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
# we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
# Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -Wno-psabi
ARCHCXXFLAGS += -Wno-psabi

View file

@ -99,7 +99,12 @@ if(CONFIG_CXX_STANDARD)
endif()
set(ARCHCFLAGS "-Wstrict-prototypes")
set(ARCHCXXFLAGS "-nostdinc++")
if(NOT CONFIG_LIBCXXTOOLCHAIN)
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
else()
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
endif()
if(NOT CONFIG_CXX_EXCEPTION)
string(APPEND ARCHCXXFLAGS " -fno-exceptions -fcheck-new")

View file

@ -77,11 +77,17 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -89,8 +89,13 @@ set(ARCHCFLAGS
"-Wstrict-prototypes -fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas"
)
set(ARCHCXXFLAGS
"-nostdinc++ -fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas"
)
"-fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas")
if(NOT CONFIG_LIBCXXTOOLCHAIN)
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
else()
set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
endif()
if(CONFIG_CXX_EXCEPTION)
string(APPEND ARCHCXXFLAGS " -fno-exceptions -fcheck-new")

View file

@ -102,7 +102,7 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
@ -111,6 +111,12 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
# we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
# Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -Wno-psabi
ARCHCXXFLAGS += -Wno-psabi

View file

@ -106,7 +106,7 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
@ -115,6 +115,12 @@ ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
# we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
# Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -Wno-psabi
ARCHCXXFLAGS += -Wno-psabi

View file

@ -102,7 +102,7 @@ endif
# Add -fno-common because macOS "ld -r" doesn't seem to pick objects
# for common symbols.
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCXXFLAGS += -fno-common
# Add -fvisibility=hidden
# Because we don't want export nuttx's symbols to share libraries
@ -116,6 +116,12 @@ ARCHCXXFLAGS += -ffunction-sections -fdata-sections
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas
ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
ARCHCXXFLAGS += -nostdinc++
else
ARCHCXXFLAGS += -D_STDLIB_H_
endif
ifneq ($(CONFIG_CXX_STANDARD),)
ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD)
endif

View file

@ -26,6 +26,11 @@ choice
prompt "C++ Library"
default LIBCXXMINI
config LIBCXXTOOLCHAIN
bool "Toolchain C++ support"
---help---
Use Standard C++ library from toolchain.
config LIBCXXMINI
bool "Basic C++ support"
---help---