diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index bb81af0b0e..4f2dedb4fa 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -234,6 +234,10 @@ endif ARCHCFLAGS += -Wstrict-prototypes ARCHCXXFLAGS += -nostdinc++ +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/arm64/src/Toolchain.defs b/arch/arm64/src/Toolchain.defs index 1733644997..3da85b5258 100644 --- a/arch/arm64/src/Toolchain.defs +++ b/arch/arm64/src/Toolchain.defs @@ -80,6 +80,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Werror ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/avr/src/avr/Toolchain.defs b/arch/avr/src/avr/Toolchain.defs index d0013c9de0..09a80e24fe 100644 --- a/arch/avr/src/avr/Toolchain.defs +++ b/arch/avr/src/avr/Toolchain.defs @@ -104,6 +104,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/avr/src/avr32/Toolchain.defs b/arch/avr/src/avr32/Toolchain.defs index 20a7306519..928074f65e 100644 --- a/arch/avr/src/avr32/Toolchain.defs +++ b/arch/avr/src/avr32/Toolchain.defs @@ -51,6 +51,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/mips/src/mips32/Toolchain.defs b/arch/mips/src/mips32/Toolchain.defs index 7357020599..c63c9067bb 100644 --- a/arch/mips/src/mips32/Toolchain.defs +++ b/arch/mips/src/mips32/Toolchain.defs @@ -265,6 +265,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/misoc/src/lm32/Toolchain.defs b/arch/misoc/src/lm32/Toolchain.defs index c4f12a5f65..9269a4fd95 100644 --- a/arch/misoc/src/lm32/Toolchain.defs +++ b/arch/misoc/src/lm32/Toolchain.defs @@ -77,6 +77,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/or1k/src/mor1kx/Toolchain.defs b/arch/or1k/src/mor1kx/Toolchain.defs index d6fd133559..ccf1293250 100644 --- a/arch/or1k/src/mor1kx/Toolchain.defs +++ b/arch/or1k/src/mor1kx/Toolchain.defs @@ -60,6 +60,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 8e6b9edac6..de253c1b64 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -73,6 +73,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/sparc/src/sparc_v8/Toolchain.defs b/arch/sparc/src/sparc_v8/Toolchain.defs index 623692ee6a..6e34981bae 100644 --- a/arch/sparc/src/sparc_v8/Toolchain.defs +++ b/arch/sparc/src/sparc_v8/Toolchain.defs @@ -82,6 +82,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index 7cc1c55c89..3a58e527b7 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -85,6 +85,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index 9f92ef3e7f..fe46f33442 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -85,6 +85,10 @@ ARCHCXXFLAGS += -fno-common -nostdinc++ ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifneq ($(CONFIG_CXX_EXCEPTION),y) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index e501b6f340..a13ec5d738 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -106,6 +106,10 @@ ARCHCXXFLAGS += -ffunction-sections -fdata-sections ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHCXXFLAGS += -Wall -Wshadow -Wundef +ifneq ($(CONFIG_CXX_STANDARD),) + ARCHCXXFLAGS += -std=$(CONFIG_CXX_STANDARD) +endif + ifeq ($(CONFIG_CXX_EXCEPTION),) ARCHCXXFLAGS += -fno-exceptions -fcheck-new endif diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig index 865554465c..410ac201ca 100644 --- a/libs/libxx/Kconfig +++ b/libs/libxx/Kconfig @@ -85,6 +85,12 @@ endchoice endif +config CXX_STANDARD + string "Language standard" + default "c++17" + ---help--- + Possible values: c++98, c++11, c++14, c++17 and c++20 + config CXX_EXCEPTION bool "Enable Exception Support" diff --git a/libs/libxx/libcxx.defs b/libs/libxx/libcxx.defs index f08576cb22..16e9a1cd61 100644 --- a/libs/libxx/libcxx.defs +++ b/libs/libxx/libcxx.defs @@ -50,7 +50,6 @@ ifeq ($(wildcard libcxx/.git),) $(call DELDIR, libcxx) endif -CXXFLAGS += -std=c++17 CXXFLAGS += ${DEFINE_PREFIX}_LIBCPP_BUILDING_LIBRARY ifeq ($(CONFIG_LIBSUPCXX), y)