zephyr/lib/libc/Kconfig
Keith Packard 13dfbaebd1 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>
2023-01-20 09:03:25 +01:00

99 lines
2.5 KiB
Plaintext

# C library
# Copyright (c) 2016 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
menu "C Library"
config REQUIRES_FULL_LIBC
bool
help
Helper symbol to indicate some feature requires a C library implementation
with more functionality than what MINIMAL_LIBC provides
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.
choice LIBC_IMPLEMENTATION
prompt "C Library Implementation"
default EXTERNAL_LIBC if NATIVE_APPLICATION
default NEWLIB_LIBC if REQUIRES_FULL_LIBC
default MINIMAL_LIBC
config MINIMAL_LIBC
bool "Minimal C library"
depends on !NATIVE_APPLICATION
depends on !REQUIRES_FULL_LIBC
depends on SUPPORT_MINIMAL_LIBC
help
Build with minimal C library.
config PICOLIBC
bool "Picolibc library"
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
expected to be provided by the toolchain.
config NEWLIB_LIBC
bool "Newlib C library"
depends on !NATIVE_APPLICATION
help
Build with newlib library. The newlib library is expected to be
part of the SDK in this case.
config ARCMWDT_LIBC
bool "ARC MWDT C library"
depends on !NATIVE_APPLICATION
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "arcmwdt"
help
C library provided by ARC MWDT toolchain.
config EXTERNAL_LIBC
bool "External C library"
help
Build with external/user provided C library.
endchoice # LIBC_IMPLEMENTATION
config HAS_NEWLIB_LIBC_NANO
bool
rsource "minimal/Kconfig"
rsource "newlib/Kconfig"
rsource "picolibc/Kconfig"
config STDOUT_CONSOLE
bool "Send stdout to console"
depends on CONSOLE_HAS_DRIVER
depends on !NATIVE_APPLICATION
default y
help
This option directs standard output (e.g. printf) to the console
device, rather than suppressing it entirely. See also EARLY_CONSOLE
option.
config NEED_LIBC_MEM_PARTITION
bool
help
Hidden option to signal that a memory partition is needed for
the C library even though it would not have been enabled
otherwise.
endmenu