Skip to content

Commit f875390

Browse files
ycsinnashif
authored andcommitted
lib/libc: picolibc: select its source with Kconfig choice
Implement the selection of the picolibc source in a Kconfig choice as they are mutually exclusive. The following table represents the possible choices, where 'X' means that `PICOLIBC_SUPPORTED=n` and is guarded in the parent level as `PICOLIBC=n`, so we do not need to care. Module Toolchain C++ | Choice 0 0 0 | X 0 0 1 | X 0 1 0 | Toolchain only 0 1 1 | Toolchain only 1 0 0 | Module only 1 0 1 | X 1 1 0 | Toolchain/Module 1 1 1 | Toolchain only The current implementation favors `PICOLIBC_USE_TOOLCHAIN` over `PICOLIBC_USE_MODULE` whenever possible, that preference is maintained in this implementation as well - the TOOLCHAIN source will be the default choice when the toolchain supports it or when the C++ is enabled. Otherwise, fallback to MODULE. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 3875385 commit f875390

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/libc/picolibc/Kconfig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
if PICOLIBC
55

6+
choice PICOLIBC_SOURCE
7+
prompt "Source of Picolibc"
8+
default PICOLIBC_USE_TOOLCHAIN if REQUIRES_FULL_LIBCPP || "$(TOOLCHAIN_HAS_PICOLIBC)" = "y"
9+
default PICOLIBC_USE_MODULE
10+
611
config PICOLIBC_USE_MODULE
7-
bool "Picolibc as module" if "$(TOOLCHAIN_HAS_PICOLIBC)" = "y"
8-
default y if "$(TOOLCHAIN_HAS_PICOLIBC)" != "y"
12+
bool "Picolibc from module"
913
depends on ZEPHYR_PICOLIBC_MODULE
1014
depends on !GLIBCXX_LIBCPP
1115
help
@@ -15,9 +19,14 @@ config PICOLIBC_USE_MODULE
1519

1620
# force TLS when using toolchain with TLS support
1721
config PICOLIBC_USE_TOOLCHAIN
18-
bool
19-
default y if !PICOLIBC_USE_MODULE
22+
bool "Picolibc from toolchain"
23+
depends on "$(TOOLCHAIN_HAS_PICOLIBC)" = "y"
2024
select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
25+
help
26+
Use picolibc included with the toolchain.
27+
This is required when using a full C++ standard library (`REQUIRES_FULL_LIBCPP=y`).
28+
29+
endchoice # PICOLIBC_SOURCE
2130

2231
choice PICOLIBC_IO_LEVEL
2332
prompt "Picolibc printf/scanf level"

0 commit comments

Comments
 (0)