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 REQUIRES_FLOAT_PRINTF
14	bool "Requires floating point support in printf"
15	select CBPRINTF_FP_SUPPORT if MINIMAL_LIBC
16	select NEWLIB_LIBC_FLOAT_PRINTF if NEWLIB_LIBC
17	help
18	  Select a printf implementation that provides a complete
19	  implementation including floating point support.
20
21config FULL_LIBC_SUPPORTED
22	bool
23	help
24	  Selected when the target has at least one C library that offers a
25	  complete implementation and which would be selected when
26	  REQUIRES_FULL_LIBC is set.
27
28config MINIMAL_LIBC_SUPPORTED
29	bool
30	depends on !NATIVE_APPLICATION
31	default y
32	help
33	  Selected when the target has support for the minimal C library
34
35config NEWLIB_LIBC_SUPPORTED
36	bool
37	default y
38	depends on "$(TOOLCHAIN_HAS_NEWLIB)" = "y"
39	depends on !NATIVE_APPLICATION
40	select FULL_LIBC_SUPPORTED
41	help
42	  Selected when the target has support for the newlib C library
43
44# Picolibc with C++ support in Zephyr SDK is handled by Zephyr SDK's own Kconfig.
45config PICOLIBC_SUPPORTED
46	bool
47	depends on !NATIVE_APPLICATION
48	depends on ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y") || (ZEPHYR_PICOLIBC_MODULE && !REQUIRES_FULL_LIBCPP)
49	default y
50	select FULL_LIBC_SUPPORTED
51	help
52	  Selected when the target has support for picolibc.
53
54config NATIVE_LIBC_INCOMPATIBLE
55	bool
56	help
57	  Other Kconfig options can select this, if they are not compatible with the
58	  native/host libC, and should only be compiled with an embedded libC
59
60menu "C Library"
61
62choice LIBC_IMPLEMENTATION
63	prompt "C Library Implementation"
64	default EXTERNAL_LIBC if NATIVE_BUILD && !(NATIVE_LIBRARY && NATIVE_LIBC_INCOMPATIBLE)
65	default PICOLIBC
66	default NEWLIB_LIBC if REQUIRES_FULL_LIBC
67	default MINIMAL_LIBC
68
69config MINIMAL_LIBC
70	bool "Minimal C library"
71	depends on !REQUIRES_FULL_LIBC
72	depends on MINIMAL_LIBC_SUPPORTED
73	imply COMPILER_FREESTANDING
74	select COMMON_LIBC_ABORT
75	select COMMON_LIBC_STRNLEN
76	imply COMMON_LIBC_MALLOC
77	imply COMMON_LIBC_CALLOC
78	imply COMMON_LIBC_REALLOCARRAY
79	help
80	  Build with minimal C library.
81
82config PICOLIBC
83	bool "Picolibc library"
84	select COMMON_LIBC_ABORT
85	imply THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
86	select LIBC_ERRNO if THREAD_LOCAL_STORAGE
87	select NEED_LIBC_MEM_PARTITION
88	select TC_PROVIDES_POSIX_C_LANG_SUPPORT_R
89	imply COMMON_LIBC_MALLOC
90	depends on PICOLIBC_SUPPORTED
91	help
92	  Build with picolibc library. The picolibc library is built as
93	  a module if PICOLIBC_MODULE is set, otherwise picolibc is
94	  expected to be provided by the toolchain.
95
96config NEWLIB_LIBC
97	bool "Newlib C library"
98	select COMMON_LIBC_ABORT
99	depends on NEWLIB_LIBC_SUPPORTED
100	select NEED_LIBC_MEM_PARTITION
101	select TC_PROVIDES_POSIX_C_LANG_SUPPORT_R
102	imply POSIX_DEVICE_IO_ALIAS_CLOSE
103	imply POSIX_DEVICE_IO_ALIAS_OPEN
104	imply POSIX_DEVICE_IO_ALIAS_READ
105	imply POSIX_DEVICE_IO_ALIAS_WRITE
106	imply POSIX_FD_MGMT_ALIAS_LSEEK
107	imply POSIX_FILE_SYSTEM_ALIAS_FSTAT
108	imply POSIX_MULTI_PROCESS_ALIAS_GETPID
109	imply POSIX_SIGNALS_ALIAS_KILL
110	help
111	  Build with newlib library. The newlib library is expected to be
112	  part of the SDK in this case.
113
114config ARCMWDT_LIBC
115	bool "ARC MWDT C library"
116	depends on !NATIVE_APPLICATION
117	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "arcmwdt"
118	help
119	  C library provided by ARC MWDT toolchain.
120
121config EXTERNAL_LIBC
122	bool "External C library"
123	help
124	  Build with external/user provided C library.
125
126endchoice # LIBC_IMPLEMENTATION
127
128config HAS_NEWLIB_LIBC_NANO
129	bool
130
131rsource "common/Kconfig"
132rsource "minimal/Kconfig"
133rsource "newlib/Kconfig"
134rsource "picolibc/Kconfig"
135
136config STDOUT_CONSOLE
137	bool "Send stdout to console"
138	depends on CONSOLE_HAS_DRIVER
139	depends on !(NATIVE_APPLICATION || (NATIVE_LIBRARY && EXTERNAL_LIBC))
140	default y
141	help
142	  This option directs standard output (e.g. printf) to the console
143	  device, rather than suppressing it entirely. See also EARLY_CONSOLE
144	  option.
145
146config NEED_LIBC_MEM_PARTITION
147	bool
148	help
149	  Hidden option to signal that a memory partition is needed for
150	  the C library even though it would not have been enabled
151	  otherwise.
152
153endmenu
154