Skip to content

Commit 0fd94bb

Browse files
committed
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 <[email protected]>
1 parent 77599bb commit 0fd94bb

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/cpp/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ config MINIMAL_LIBCPP
8585
config GLIBCXX_LIBCPP
8686
bool "GNU C++ Standard Library"
8787
depends on !NATIVE_APPLICATION
88-
depends on NEWLIB_LIBC || (PICOLIBC && !PICOLIBC_USE_MODULE)
88+
depends on NEWLIB_LIBC || PICOLIBC
8989
help
9090
Build with GNU C++ Standard Library (libstdc++) provided by the GNU
9191
Compiler Collection (GCC)-based toolchain.

lib/libc/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ config SUPPORT_MINIMAL_LIBC
1515
bool
1616
default y
1717

18+
# Picolibc with C++ support in Zephyr SDK is handled by Zephyr SDK's own Kconfig.
1819
config PICOLIBC_SUPPORTED
1920
bool
2021
depends on ARC || ARM || ARM64 || MIPS || RISCV
2122
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" != "arcmwdt"
23+
depends on !(CPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr")
2224
default y
2325
help
2426
Selected when the target has support for picolibc.
@@ -42,6 +44,7 @@ config PICOLIBC
4244
select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
4345
select LIBC_ERRNO if THREAD_LOCAL_STORAGE
4446
depends on !NATIVE_APPLICATION
47+
depends on PICOLIBC_SUPPORTED
4548
help
4649
Build with picolibc library. The picolibc library is built as
4750
a module if PICOLIBC_MODULE is set, otherwise picolibc is

lib/libc/picolibc/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
if PICOLIBC
55

66
config PICOLIBC_USE_MODULE
7-
bool "Use picolibc module"
7+
bool "Picolibc as module"
88
default y
9-
select PICOLIBC_MODULE
9+
depends on ZEPHYR_PICOLIBC_MODULE
10+
depends on !GLIBCXX_LIBCPP
1011
help
1112
Use picolibc module instead of picolibc included with toolchain
1213

0 commit comments

Comments
 (0)