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 ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y") || (NATIVE_LIBRARY)
39	depends on !REQUIRES_FULL_LIBCPP || ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y")
40	default y
41	select FULL_LIBC_SUPPORTED
42	help
43	  Selected when the target has support for picolibc.
44
45config SUPPORT_MINIMAL_LIBC
46	bool
47	select MINIMAL_LIBC_SUPPORTED
48	select DEPRECATED
49	help
50	  Legacy symbol that selects MINIMAL_LIBC_SUPPORTED
51
52menu "C Library"
53
54choice LIBC_IMPLEMENTATION
55	prompt "C Library Implementation"
56	default EXTERNAL_LIBC if NATIVE_BUILD
57	default PICOLIBC
58	default NEWLIB_LIBC if REQUIRES_FULL_LIBC
59	default MINIMAL_LIBC
60
61config MINIMAL_LIBC
62	bool "Minimal C library"
63	depends on !NATIVE_APPLICATION
64	depends on !REQUIRES_FULL_LIBC
65	depends on MINIMAL_LIBC_SUPPORTED
66	imply COMPILER_FREESTANDING
67	select COMMON_LIBC_ABORT
68	select COMMON_LIBC_STRNLEN
69	help
70	  Build with minimal C library.
71
72config PICOLIBC
73	bool "Picolibc library"
74	select COMMON_LIBC_ABORT
75	select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
76	select LIBC_ERRNO if THREAD_LOCAL_STORAGE
77	select NEED_LIBC_MEM_PARTITION
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	select NEED_LIBC_MEM_PARTITION
92	help
93	  Build with newlib library. The newlib library is expected to be
94	  part of the SDK in this case.
95
96config ARCMWDT_LIBC
97	bool "ARC MWDT C library"
98	depends on !NATIVE_APPLICATION
99	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "arcmwdt"
100	help
101	  C library provided by ARC MWDT toolchain.
102
103config EXTERNAL_LIBC
104	bool "External C library"
105	help
106	  Build with external/user provided C library.
107
108endchoice # LIBC_IMPLEMENTATION
109
110config HAS_NEWLIB_LIBC_NANO
111	bool
112
113rsource "common/Kconfig"
114rsource "minimal/Kconfig"
115rsource "newlib/Kconfig"
116rsource "picolibc/Kconfig"
117
118config STDOUT_CONSOLE
119	bool "Send stdout to console"
120	depends on CONSOLE_HAS_DRIVER
121	depends on !(NATIVE_APPLICATION || (NATIVE_LIBRARY && EXTERNAL_LIBC))
122	default y
123	help
124	  This option directs standard output (e.g. printf) to the console
125	  device, rather than suppressing it entirely. See also EARLY_CONSOLE
126	  option.
127
128config NEED_LIBC_MEM_PARTITION
129	bool
130	help
131	  Hidden option to signal that a memory partition is needed for
132	  the C library even though it would not have been enabled
133	  otherwise.
134
135endmenu
136