From 13dfbaebd192a8102c06e173f77a764343b74f2d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 2 Nov 2022 13:11:41 -0700 Subject: [PATCH] libc/picolibc: Clean up Picolibc Kconfig for C++ libstdc++ is supported with Picolibc only when the toolchain version of Picolibc is use -- libstdc++ must be built using a specific Picolibc build and libstdc++ is included with the toolchain. Ideally, we'd allow the use of the Picolibc module whenever we weren't using the GNU libstdc++, including when using the minimal libc++. However, the obvious dependency settings create a loop: config PICOLIBC depends on PICOLIBC_SUPPORTED config PICOLIBC_SUPPORTED depends on !(GLIBCXX_LIBCPP && "$(ZEPHYR_TOOCHAIN_VARIANT" = "zephyr") config GLIBCXX_LIBCPP depends on NEWLIB_LIBC || PICOLIBC To break this loop, we replace GLIBCXX_LIBCPP in the second block with CPP: config PICOLIBC_SUPPORTED depends on !(CPP && "$(ZEPHYR_TOOCHAIN_VARIANT" = "zephyr") This means that picolibc cannot be used with any C++ apps when using the Zephyr SDK, even when not using the GNU libstdc++. However, Zephyr SDK 0.16 will come with an additional Kconfig file that includes: config PICOLIBC_SUPPORTED def_bool y depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr" This will override the Kconfig bits included in Zephyr and allow use of the Picolibc module with C++ code, including using the minimal libc++ bits. Signed-off-by: Keith Packard --- lib/cpp/Kconfig | 2 +- lib/libc/Kconfig | 3 +++ lib/libc/picolibc/Kconfig | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cpp/Kconfig b/lib/cpp/Kconfig index b7bfbf24b1a..131415b87aa 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 697a6ee9943..9e8b618975f 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 492a02a87f0..b52301fff71 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