1# Copyright © 2021 Amazon.com, Inc. or its affiliates. 2# SPDX-License-Identifier: Apache-2.0 3 4if PICOLIBC 5 6choice 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 11config PICOLIBC_USE_MODULE 12 bool "Picolibc from module" 13 depends on ZEPHYR_PICOLIBC_MODULE 14 depends on !GLIBCXX_LIBCPP 15 help 16 Use picolibc module instead of picolibc included with toolchain. 17 This is enabled by default for toolchains other than the Zephyr 18 SDK. 19 20# force TLS when using toolchain with TLS support 21config PICOLIBC_USE_TOOLCHAIN 22 bool "Picolibc from toolchain" 23 depends on "$(TOOLCHAIN_HAS_PICOLIBC)" = "y" 24 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 29endchoice # PICOLIBC_SOURCE 30 31choice PICOLIBC_IO_LEVEL 32 prompt "Picolibc printf/scanf level" 33 default PICOLIBC_IO_MINIMAL if CBPRINTF_NANO 34 default PICOLIBC_IO_LONG_LONG if CBPRINTF_FULL_INTEGRAL 35 default PICOLIBC_IO_INTEGER 36 help 37 Selects the level of printf and scanf support 38 39config PICOLIBC_IO_FLOAT 40 bool "full support for integer/floating point values in printf/scanf" 41 help 42 Include full floating point and integer support in printf/scanf 43 functions. 44 45config PICOLIBC_IO_LONG_LONG 46 bool "full support for integer values, including long long, in printf/scanf" 47 depends on !REQUIRES_FLOAT_PRINTF && (!CBPRINTF_FP_SUPPORT || CBPRINTF_NANO) 48 help 49 Includes full integer with long long, but no floating 50 point in printf/scanf. 51 52config PICOLIBC_IO_INTEGER 53 bool "full support for integer values, other than long long, in printf/scanf" 54 depends on !REQUIRES_FLOAT_PRINTF && ((!CBPRINTF_FP_SUPPORT && !CBPRINTF_FULL_INTEGRAL) || CBPRINTF_NANO) 55 help 56 Include full integer other than long long, but no floating point 57 in printf/scanf. 58 59config PICOLIBC_IO_MINIMAL 60 bool "limited support for integer values in printf/scanf" 61 depends on !REQUIRES_FLOAT_PRINTF && CBPRINTF_NANO 62 help 63 Include limited integer and no floating point support in 64 printf/scanf. 65 66endchoice 67 68if PICOLIBC_USE_MODULE 69 70choice PICOLIBC_OPTIMIZATIONS 71 prompt "Optimization level" 72 default PICOLIBC_SIZE_OPTIMIZATIONS if SIZE_OPTIMIZATIONS 73 default PICOLIBC_SPEED_OPTIMIZATIONS if SPEED_OPTIMIZATIONS 74 default PICOLIBC_DEBUG_OPTIMIZATIONS if DEBUG_OPTIMIZATIONS 75 default PICOLIBC_NO_OPTIMIZATIONS if NO_OPTIMIZATIONS 76 help 77 Note that these flags shall only control the compiler 78 optimization level for picolibc, not the level for the 79 rest of Zephyr 80 81config PICOLIBC_SIZE_OPTIMIZATIONS 82 bool "Optimize for size" 83 help 84 Compiler optimizations will be set to -Os independently of other 85 options. 86 87config PICOLIBC_SPEED_OPTIMIZATIONS 88 bool "Optimize for speed" 89 help 90 Compiler optimizations will be set to -O2 independently of other 91 options. 92 93config PICOLIBC_DEBUG_OPTIMIZATIONS 94 bool "Optimize debugging experience" 95 help 96 Compiler optimizations will be set to -Og independently of other 97 options. 98 99config PICOLIBC_NO_OPTIMIZATIONS 100 bool "Optimize nothing" 101 help 102 Compiler optimizations will be set to -O0 independently of other 103 options. 104 105endchoice 106 107config PICOLIBC_FAST_STRCMP 108 bool "always use fast strcmp paths" 109 default y 110 help 111 This provides a faster strcmp version even when libc is 112 built in space-optimized mode 113 114config PICOLIBC_ASSERT_VERBOSE 115 bool "assert provides verbose information" 116 help 117 The usual picolibc assert helper, __assert_func, takes file, line, 118 function and expression information to make the presented message 119 more helpful. These all require storage in the image. Unselecting 120 this option eliminates all of that information, making the results 121 less helpful but also making them consume less memory. 122 123config PICOLIBC_IO_C99_FORMATS 124 bool "support C99 format additions in printf/scanf" 125 default y 126 help 127 Includes C99 printf and scanf support for j, z, t size 128 modifiers. C99 support is always included in the floating-point 129 variant 130 131config PICOLIBC_IO_POS_ARGS 132 bool "Support POSIX positional args (e.g. %$1d) in printf/scanf" 133 default y 134 depends on !PICOLIBC_IO_MINIMAL 135 help 136 Includes support for positional args (e.g. $1) in integer-only 137 printf and scanf. Positional args are always supported in the 138 floating-point variant. 139 140config PICOLIBC_IO_FLOAT_EXACT 141 bool "support for exact float/string conversion" 142 default y 143 help 144 Uses Ryu algorithm for exact binary/decimal float conversions. 145 This ensures that printf values with enough digits can be 146 fed to scanf and generate exactly the same binary value. 147 148config PICOLIBC_IO_SMALL_ULTOA 149 bool "avoid soft division in printf" 150 default y 151 help 152 Replaces division and modulus by 10 with shifts and adds when 153 doing binary to decimal conversion in printf for 64-bit 154 values on 32-bit targets. 155 156config PICOLIBC_IO_MINIMAL_LONG_LONG 157 bool "Include long long support in minimal printf" 158 depends on PICOLIBC_IO_MINIMAL 159 default y if CBPRINTF_FULL_INTEGRAL 160 help 161 Include long long support in the minimal picolibc printf code 162 163config PICOLIBC_LOCALE_INFO 164 bool "support locales in libc functions" 165 help 166 Includes code for basic locale support 167 168config PICOLIBC_LOCALE_EXTENDED_INFO 169 bool "support extended locales in libc functions" 170 help 171 Includes code for extended locale support 172 173config PICOLIBC_MULTIBYTE 174 bool "support multibyte functions in libc" 175 help 176 Includes code for multi-byte characters 177 178config PICOLIBC_PICOEXIT 179 bool "use smaller atexit/onexit implementation" 180 default y 181 help 182 Provides a simpler atexit/onexit implementation that doesn't use 183 malloc, but only supports a small number (32) of exit handlers. 184 185config PICOLIBC_MULTITHREAD 186 bool "support multiple threads using retargetable locking API" 187 default y 188 help 189 Protects shared data structures in libc with mutexes that use 190 an API which can be retargeted to OS provided routines. 191 192config PICOLIBC_GLOBAL_ERRNO 193 bool "use a single global variable for errno" 194 help 195 Picolibc usually uses a TLS variable for errno, ensuring that 196 multiple threads have a reliable mechanism for detecting libc 197 exceptions. This option switches to a single global errno variable, 198 which can be used to avoid TLS variable usage by the library if 199 necessary. 200 201endif # PICOLIBC_USE_MODULE 202 203endif # PICOLIBC 204