diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 2dbb1e3e08eae..cfa594d4314de 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -104,6 +104,7 @@ set_compiler_property(PROPERTY warning_error_coding_guideline set_compiler_property(PROPERTY cstd -std=) if (NOT CONFIG_NEWLIB_LIBC AND + NOT (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_USE_MODULE) AND NOT COMPILER STREQUAL "xcc" AND NOT CONFIG_HAS_ESPRESSIF_HAL AND NOT CONFIG_NATIVE_APPLICATION) diff --git a/lib/cpp/Kconfig b/lib/cpp/Kconfig index b7bfbf24b1a99..131415b87aad2 100644 --- a/lib/cpp/Kconfig +++ b/lib/cpp/Kconfig @@ -85,7 +85,7 @@ config MINIMAL_LIBCPP config GLIBCXX_LIBCPP bool "GNU C++ Standard Library" depends on !NATIVE_APPLICATION - depends on NEWLIB_LIBC || (PICOLIBC && !PICOLIBC_USE_MODULE) + depends on NEWLIB_LIBC || PICOLIBC help Build with GNU C++ Standard Library (libstdc++) provided by the GNU Compiler Collection (GCC)-based toolchain. diff --git a/lib/libc/Kconfig b/lib/libc/Kconfig index 697a6ee99439d..9e8b618975f40 100644 --- a/lib/libc/Kconfig +++ b/lib/libc/Kconfig @@ -15,10 +15,12 @@ config SUPPORT_MINIMAL_LIBC bool default y +# Picolibc with C++ support in Zephyr SDK is handled by Zephyr SDK's own Kconfig. config PICOLIBC_SUPPORTED bool depends on ARC || ARM || ARM64 || MIPS || RISCV depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" != "arcmwdt" + depends on !(CPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr") default y help Selected when the target has support for picolibc. @@ -42,6 +44,7 @@ config PICOLIBC select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE select LIBC_ERRNO if THREAD_LOCAL_STORAGE depends on !NATIVE_APPLICATION + depends on PICOLIBC_SUPPORTED help Build with picolibc library. The picolibc library is built as a module if PICOLIBC_MODULE is set, otherwise picolibc is diff --git a/lib/libc/picolibc/Kconfig b/lib/libc/picolibc/Kconfig index 492a02a87f03c..b52301fff716a 100644 --- a/lib/libc/picolibc/Kconfig +++ b/lib/libc/picolibc/Kconfig @@ -4,9 +4,10 @@ if PICOLIBC config PICOLIBC_USE_MODULE - bool "Use picolibc module" + bool "Picolibc as module" default y - select PICOLIBC_MODULE + depends on ZEPHYR_PICOLIBC_MODULE + depends on !GLIBCXX_LIBCPP help Use picolibc module instead of picolibc included with toolchain diff --git a/samples/cpp/cpp_synchronization/sample.yaml b/samples/cpp/cpp_synchronization/sample.yaml index e3e9669a1ad09..2b9311e2067c3 100644 --- a/samples/cpp/cpp_synchronization/sample.yaml +++ b/samples/cpp/cpp_synchronization/sample.yaml @@ -13,3 +13,18 @@ tests: - "Create semaphore (.*)" - "main: Hello World!" - "coop_thread_entry: Hello World!" + sample.cpp.synchronization.picolibc: + filter: CONFIG_PICOLIBC_SUPPORTED + extra_configs: + - CONFIG_PICOLIBC=y + tags: cpp + toolchain_exclude: issm xcc + integration_platforms: + - qemu_x86 + harness: console + harness_config: + type: multi_line + regex: + - "Create semaphore (.*)" + - "main: Hello World!" + - "coop_thread_entry: Hello World!" diff --git a/tests/lib/cpp/libcxx/testcase.yaml b/tests/lib/cpp/libcxx/testcase.yaml index 3a1371345b506..a57941b182792 100644 --- a/tests/lib/cpp/libcxx/testcase.yaml +++ b/tests/lib/cpp/libcxx/testcase.yaml @@ -23,6 +23,17 @@ tests: - CONFIG_GLIBCXX_LIBCPP=y integration_platforms: - mps2_an385 + cpp.libcxx.glibcxx.picolibc: + filter: TOOLCHAIN_HAS_PICOLIBC == 1 + toolchain_exclude: xcc + tags: cpp + timeout: 60 + extra_configs: + - CONFIG_PICOLIBC=y + - CONFIG_GLIBCXX_LIBCPP=y + - CONFIG_CPP_EXCEPTIONS=y + integration_platforms: + - mps2_an385 cpp.libcxx.arcmwdtlib: toolchain_allow: arcmwdt min_flash: 54