Browse Source

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 <keithp@keithp.com>
pull/53248/head
Keith Packard 3 years ago committed by Carles Cufí
parent
commit
13dfbaebd1
  1. 2
      lib/cpp/Kconfig
  2. 3
      lib/libc/Kconfig
  3. 5
      lib/libc/picolibc/Kconfig

2
lib/cpp/Kconfig

@ -85,7 +85,7 @@ config MINIMAL_LIBCPP @@ -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.

3
lib/libc/Kconfig

@ -15,10 +15,12 @@ config SUPPORT_MINIMAL_LIBC @@ -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 @@ -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

5
lib/libc/picolibc/Kconfig

@ -4,9 +4,10 @@ @@ -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

Loading…
Cancel
Save