From 90364e837c12d67de51bab178381e417acebda71 Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Sun, 18 Aug 2019 02:13:32 +0200 Subject: [PATCH] cpp: Added option to disable Zephyrs cpp implementation Added a Kconfig option to disable Zephyrs cpp implementation for operator new, delete, pure virtual functions and vtables. Signed-off-by: Jan Van Winkel --- subsys/cpp/CMakeLists.txt | 11 ++++++++--- subsys/cpp/Kconfig | 10 ++++++++++ tests/application_development/libcxx/testcase.yaml | 11 +++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/subsys/cpp/CMakeLists.txt b/subsys/cpp/CMakeLists.txt index eda0b6a6138739..73f4261ae19516 100644 --- a/subsys/cpp/CMakeLists.txt +++ b/subsys/cpp/CMakeLists.txt @@ -1,10 +1,15 @@ # SPDX-License-Identifier: Apache-2.0 -zephyr_sources_ifdef(CONFIG_CPLUSPLUS - cpp_virtual.c - cpp_vtable.cpp +zephyr_sources( cpp_init_array.c cpp_ctors.c cpp_dtors.c +) + +if (NOT CONFIG_LIB_CPLUSPLUS OR CONFIG_ZEPHYR_CPLUSPLUS) +zephyr_sources( + cpp_virtual.c + cpp_vtable.cpp cpp_new.cpp ) +endif() diff --git a/subsys/cpp/Kconfig b/subsys/cpp/Kconfig index 887bb3d1bd0c97..66fdb0f7c86768 100644 --- a/subsys/cpp/Kconfig +++ b/subsys/cpp/Kconfig @@ -65,4 +65,14 @@ config RTTI help This option enables support of C++ RTTI. +if LIB_CPLUSPLUS + +config ZEPHYR_CPLUSPLUS + bool "Use Zephyr C++ Implementation" + help + Use Zephyr implementation for operator new, delete, pure virtual + functions and vtables. + +endif #LIB_CPLUSPLUS + endif # CPLUSPLUS diff --git a/tests/application_development/libcxx/testcase.yaml b/tests/application_development/libcxx/testcase.yaml index fecb371ed5db20..cf2bb7477c9223 100644 --- a/tests/application_development/libcxx/testcase.yaml +++ b/tests/application_development/libcxx/testcase.yaml @@ -2,11 +2,18 @@ tests: misc.app_dev.libcxx: arch_exclude: posix platform_exclude: qemu_x86_coverage + min_flash: 54 tags: cpp + misc.app_dev.libcxx.zephyr_cpp: + arch_exclude: posix + platform_exclude: qemu_x86_coverage + tags: cpp + extra_configs: + - CONFIG_ZEPHYR_CPLUSPLUS=y misc.app_dev.libcxx.exceptions: arch_exclude: posix - platform_exclude: qemu_x86_coverage 96b_meerkat96 - colibri_imx7d_m4 warp7_m4 pico_pi_m4 qemu_x86_64 + platform_exclude: qemu_x86_coverage + min_flash: 54 tags: cpp extra_configs: - CONFIG_EXCEPTIONS=y