1# C library
2
3# Copyright (c) 2016 Intel Corporation
4# SPDX-License-Identifier: Apache-2.0
5
6config REQUIRES_FULL_LIBC
7	prompt "Require complete C library"
8	bool
9	help
10	  Select a C library implementation that provides a complete C library
11	  implementation, rather than the subset provided by MINIMAL_LIBC.
12
13config FULL_LIBC_SUPPORTED
14	bool
15	help
16	  Selected when the target has at least one C library that offers a
17	  complete implementation and which would be selected when
18	  REQUIRES_FULL_LIBC is set.
19
20config MINIMAL_LIBC_SUPPORTED
21	bool
22	default y
23	help
24	  Selected when the target has support for the minimal C library
25
26config NEWLIB_LIBC_SUPPORTED
27	bool
28	default y
29	depends on "$(TOOLCHAIN_HAS_NEWLIB)" = "y"
30	select FULL_LIBC_SUPPORTED
31	help
32	  Selected when the target has support for the newlib C library
33
34# Picolibc with C++ support in Zephyr SDK is handled by Zephyr SDK's own Kconfig.
35config PICOLIBC_SUPPORTED
36	bool
37	depends on !NATIVE_APPLICATION
38	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr"
39	depends on !(CPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr")
40	# picolibc text is outside .pinned.text on this board. #54148
41	default y
42	select FULL_LIBC_SUPPORTED
43	help
44	  Selected when the target has support for picolibc.
45
46config SUPPORT_MINIMAL_LIBC
47	bool
48	select MINIMAL_LIBC_SUPPORTED
49	select DEPRECATED
50	help
51	  Legacy symbol that selects MINIMAL_LIBC_SUPPORTED
52
53menu "C Library"
54
55choice LIBC_IMPLEMENTATION
56	prompt "C Library Implementation"
57	default EXTERNAL_LIBC if NATIVE_APPLICATION
58	default NEWLIB_LIBC if REQUIRES_FULL_LIBC
59	default PICOLIBC if REQUIRES_FULL_LIBC
60	default MINIMAL_LIBC
61
62config MINIMAL_LIBC
63	bool "Minimal C library"
64	depends on !NATIVE_APPLICATION
65	depends on !REQUIRES_FULL_LIBC
66	depends on MINIMAL_LIBC_SUPPORTED
67	imply COMPILER_FREESTANDING
68	select COMMON_LIBC_ABORT
69	select COMMON_LIBC_STRNLEN
70	help
71	  Build with minimal C library.
72
73config PICOLIBC
74	bool "Picolibc library"
75	select COMMON_LIBC_ABORT
76	select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
77	select LIBC_ERRNO if THREAD_LOCAL_STORAGE
78	imply COMMON_LIBC_MALLOC
79	depends on !NATIVE_APPLICATION
80	depends on PICOLIBC_SUPPORTED
81	help
82	  Build with picolibc library. The picolibc library is built as
83	  a module if PICOLIBC_MODULE is set, otherwise picolibc is
84	  expected to be provided by the toolchain.
85
86config NEWLIB_LIBC
87	bool "Newlib C library"
88	select COMMON_LIBC_ABORT
89	depends on !NATIVE_APPLICATION
90	depends on NEWLIB_LIBC_SUPPORTED
91	help
92	  Build with newlib library. The newlib library is expected to be
93	  part of the SDK in this case.
94
95config ARCMWDT_LIBC
96	bool "ARC MWDT C library"
97	depends on !NATIVE_APPLICATION
98	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "arcmwdt"
99	help
100	  C library provided by ARC MWDT toolchain.
101
102config EXTERNAL_LIBC
103	bool "External C library"
104	help
105	  Build with external/user provided C library.
106
107endchoice # LIBC_IMPLEMENTATION
108
109config HAS_NEWLIB_LIBC_NANO
110	bool
111
112rsource "common/Kconfig"
113rsource "minimal/Kconfig"
114rsource "newlib/Kconfig"
115rsource "picolibc/Kconfig"
116
117config STDOUT_CONSOLE
118	bool "Send stdout to console"
119	depends on CONSOLE_HAS_DRIVER
120	depends on !NATIVE_APPLICATION
121	default y
122	help
123	  This option directs standard output (e.g. printf) to the console
124	  device, rather than suppressing it entirely. See also EARLY_CONSOLE
125	  option.
126
127config NEED_LIBC_MEM_PARTITION
128	bool
129	help
130	  Hidden option to signal that a memory partition is needed for
131	  the C library even though it would not have been enabled
132	  otherwise.
133
134endmenu
135