1#
2# SPDX-License-Identifier: BSD-3-Clause
3#
4# Copyright © 2019 Keith Packard
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12#
13# 2. Redistributions in binary form must reproduce the above
14#    copyright notice, this list of conditions and the following
15#    disclaimer in the documentation and/or other materials provided
16#    with the distribution.
17#
18# 3. Neither the name of the copyright holder nor the names of its
19#    contributors may be used to endorse or promote products derived
20#    from this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33# OF THE POSSIBILITY OF SUCH DAMAGE.
34#
35option('fast-strcmp', type: 'boolean', value: true,
36       description: 'Always optimize strcmp for performance')
37
38option('have-alias-attribute', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
39       description: 'Compiler supports __alias__ attribute')
40
41option('have-format-attribute', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
42       description: 'Compiler supports __format__ attribute')
43
44option('have-weak-attribute', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
45       description: 'Compiler supports __weak__ attribute')
46
47option('multilib', type: 'boolean', value: true,
48       description: 'Enable multilib compile')
49
50option('multilib-list', type: 'array', value: [],
51       description: 'List of multilib configurations to build for')
52
53option('multilib-exclude', type: 'array', value: [],
54       description: 'Multilib configurations containing any of these strings will not be built')
55
56option('build-type-subdir', type: 'string',
57       description: 'Build-type subdir. Also skips installing .specs file')
58
59option('picolib', type: 'boolean', value: true,
60       description: 'Include pico lib bits')
61
62option('picocrt', type: 'boolean', value: true,
63       description: 'Include pico crt bits')
64
65option('picocrt-enable-mmu', type: 'boolean', value: true,
66       description: 'Enable memory management unit in picocrt startup')
67
68option('picocrt-lib', type: 'boolean', value: true,
69       description: 'Include pico crt bits in lib form')
70
71option('semihost', type: 'boolean', value: true,
72       description: 'Include semihost bits')
73
74option('specsdir', type: 'string',
75       description: 'Installation directory for .specs file')
76
77option('sysroot-install', type: 'boolean', value: false,
78       description: 'Install in gcc sysroot')
79
80option('sysroot-install-skip-checks', type: 'boolean', value: false,
81       description: 'Skip sysroot path checks during config')
82
83option('system-libc', type: 'boolean', value: false,
84       description: 'Install as system C library')
85
86option('picoexit', type: 'boolean', value: true,
87       description: 'Smaller exit/atexit/onexit code')
88
89option('sanitize-bounds', type: 'boolean', value: false,
90       description: 'Build the library with -fsanitize=bounds')
91
92option('sanitize-trap-on-error', type: 'boolean', value: false,
93       description: 'Build the library with -fsanitize-undefined-trap-on-error')
94
95option('use-stdlib', type: 'boolean', value: false,
96       description: 'Do not bypass the standard system library with -nostdlib (useful for native testing)')
97
98option('profile', type: 'boolean', value: false,
99       description: 'Enable profiling by adding -pg -no-pie to compile flags')
100
101option('freestanding', type: 'boolean', value: false,
102       description: 'Build the library with -ffreestanding (useful for Zephyr testing)')
103
104option('analyzer', type: 'boolean', value: false,
105       description: 'Enable the analyzer while compiling with -fanalyzer')
106
107option('assert-verbose', type: 'boolean', value: true,
108       description: 'Assert provides verbose information')
109
110#
111# Testing options
112#
113option('native-tests', type: 'boolean', value: false,
114       description: 'Run some tests against native libc too')
115option('native-math-tests', type: 'boolean', value: true,
116       description: 'Run math tests against native libm when native-tests is enable')
117option('tests', type: 'boolean', value: false,
118       description: 'Enable tests')
119option('tests-cdefs', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
120       description: 'Enable test of sys/cdefs.h. If set to auto, enable when tests are enabled')
121option('tests-enable-stack-protector', type: 'boolean', value: true,
122       description: 'tests enable stack protector')
123option('tests-enable-full-malloc-stress', type: 'boolean', value: false,
124       description: 'tests enable stress test for full malloc')
125option('tests-enable-posix-io', type: 'boolean', value: true,
126       description: 'tests enable posix-io when available')
127option('test-long-double', type: 'boolean', value: true,
128       description: 'Enable long double tests on targets with long double type')
129option('split-large-tests', type: 'boolean', value: false,
130       description: 'Split large tests into pieces for smaller targets')
131option('test-stdin', type: 'boolean', value: false,
132       description: 'Enable tests that use stdin. This only works on a few targets')
133option('fortify-source', type: 'combo', choices: ['none', '1', '2', '3'], value: '3',
134       description: 'Set _FORTIFY_SOURCE=<value> when building tests')
135
136option('tinystdio', type: 'boolean', value: true,
137       description: 'Use tiny stdio from avr libc')
138
139#
140# Options applying to both legacy stdio and tinystdio
141#
142option('io-c99-formats', type: 'boolean', value: true,
143       description: 'enable C99 support in IO functions like printf/scanf')
144option('newlib-io-c99-formats', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
145       description: 'enable C99 support in IO functions like printf/scanf')
146option('io-long-long', type: 'boolean', value: false,
147       description: 'enable long long type support in IO functions like printf/scanf')
148option('newlib-io-long-long', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
149       description: 'enable long long type support in IO functions like printf/scanf')
150option('io-pos-args', type: 'boolean', value: false,
151       description: 'enable printf-family positional arg support (always enabled for tinystdio float)')
152option('newlib-io-pos-args', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
153       description: 'enable printf-family positional arg support (always enabled for tinystdio float)')
154option('io-long-double', type: 'boolean', value: false,
155       description: 'enable long double type support in IO functions printf/scanf')
156option('newlib-io-long-double', type: 'boolean', value: false,
157       description: 'enable long double type support in IO functions printf/scanf')
158
159#
160# Options applying only to tinystdio
161#
162option('io-float-exact', type: 'boolean', value: true,
163       description: 'use float/string code which supports round-tripping')
164option('atomic-ungetc', type: 'boolean', value: true,
165       description: 'use atomics in fgetc/ungetc to make them re-entrant')
166option('posix-io', type: 'boolean', value: true,
167       description: 'Provide fopen/fdopen using POSIX I/O (open, close, read, write, lseek)')
168option('posix-console', type: 'boolean', value: false,
169       description: 'Use POSIX I/O for stdin/stdout/stderr')
170option('format-default', type: 'combo', choices: ['double', 'float', 'long-long', 'integer', 'minimal'], value: 'double',
171       description: 'which printf/scanf versions should be the default')
172option('printf-aliases', type: 'boolean', value: true,
173       description: 'Allow link-time printf aliases')
174option('io-percent-b', type: 'boolean', value: false,
175       description: 'enable proposed %b/%B format in printf and scanf in tinystdio (default: false)')
176option('printf-small-ultoa', type: 'boolean', value: true,
177       description: 'Avoid softare division in decimal conversions')
178option('printf-percent-n', type: 'boolean', value: false,
179       description: 'Support %n in printf format strings (default: false)')
180option('minimal-io-long-long', type: 'boolean', value: false,
181       description: 'enable long long type support in minimal printf/scanf')
182option('fast-bufio', type: 'boolean', value: false,
183       description: 'enable some faster buffered i/o operations')
184option('io-wchar', type: 'boolean', value: false,
185       description: 'enable wide character support in printf/scanf even when newlib-mb is false')
186
187#
188# Options applying to only legacy stdio
189#
190option('newlib-elix-level', type: 'integer', value: 4,
191       description: 'desired elix library level (0-4)')
192option('newlib-fseek-optimization', type: 'boolean', value: false,
193       description: 'enable fseek optimization')
194option('newlib-fvwrite-in-streamio', type: 'boolean', value: false,
195       description: 'disable iov in streamio')
196option('newlib-global-stdio-streams', type: 'boolean', value: false,
197       description: 'enable global stdio streams')
198option('newlib-io-float', type: 'boolean', value: false,
199       description: 'enable printf/scanf family float support')
200option('newlib-nano-formatted-io', type: 'boolean', value: false,
201       description: 'Use nano version formatted IO')
202option('newlib-reent-small', type: 'boolean', value: false,
203       description: 'enable small reentrant struct support')
204option('newlib-stdio64', type: 'boolean', value: true,
205       description: 'Include stdio64 with newlib stdio')
206option('newlib-unbuf-stream-opt', type: 'boolean', value: false,
207       description: 'enable unbuffered stream optimization in streamio')
208option('newlib-wide-orient', type: 'boolean', value: false,
209       description: 'Turn off wide orientation in streamio')
210option('newlib-have-fcntl', type: 'boolean', value: false,
211       description: 'System has fcntl function')
212
213#
214# Internationalization options
215#
216
217option('newlib-iconv-encodings', type: 'array',
218       description: 'enable specific comma-separated list of bidirectional iconv encodings to be built-in')
219option('newlib-iconv-from-encodings', type: 'array',
220       description: 'enable specific comma-separated list of "from" iconv encodings to be built-in')
221option('newlib-iconv-to-encodings', type: 'array',
222       description: 'enable specific comma-separated list of "to" iconv encodings to be built-in')
223option('newlib-iconv-external-ccs', type: 'boolean', value:false,
224       description: 'Load iconv CCS tables from files rather than having them built-in')
225option('newlib-iconv-dir', type: 'string',
226       description: 'Installation directory for iconv CCS files')
227option('newlib-iconv-runtime-dir', type: 'string',
228       description: 'Path used at runtime to locate iconv CCS files')
229option('newlib-iconv-encodings-exclude', type: 'array',
230       description: 'enable specific comma-separated list of bidirectional iconv encodings to be excluded')
231
232option('newlib-locale-info', type: 'boolean', value: false,
233       description: 'locale support')
234option('newlib-locale-info-extended', type: 'boolean', value: false,
235       description: 'extended locale support')
236option('newlib-mb', type: 'boolean', value: false,
237       description: 'enable multibyte support')
238
239#
240# Startup/shutdown options
241#
242option('lite-exit', type: 'boolean', value: true,
243       description: 'enable light weight exit')
244option('newlib-atexit-dynamic-alloc', type: 'boolean', value: false,
245       description: 'enable dynamic allocation of atexit entries')
246option('newlib-global-atexit', type: 'boolean', value: false,
247       description: 'enable atexit data structure as global')
248option('newlib-initfini', type: 'boolean', value: true,
249       description: 'Supports _init() and _fini()')
250option('newlib-initfini-array', type: 'boolean', value: true,
251       description: 'compiler supports INIT_ARRAY section types')
252option('newlib-register-fini', type: 'boolean', value: false,
253       description: 'enable finalization function registration using atexit')
254option('fake-semihost', type: 'boolean', value: false,
255       description: 'create fake semihost library to link tests')
256option('crt-runtime-size', type: 'boolean', value: false,
257       description: 'compute crt memory space sizes at runtime')
258option('atomic-signal', type: 'boolean', value: true,
259       description: 'use atomics in signal/raise to make them re-entrant')
260
261#
262# Malloc option
263#
264option('newlib-nano-malloc', type: 'boolean', value: true,
265       description: 'use small-footprint nano-malloc implementation')
266
267#
268# Locking support
269#
270option('newlib-multithread', type: 'boolean', value: true,
271       description: 'enable support for multiple threads')
272option('newlib-retargetable-locking', type: 'boolean', value: true,
273       description: 'Allow locking routines to be retargeted at link time')
274
275#
276# Thread-local storage support
277#
278option('thread-local-storage', type: 'combo', choices: ['true', 'false', 'auto', 'picolibc'], value: 'picolibc',
279       description: 'use thread local storage for static data ("picolibc": picolibc and toolchain support) ("auto": toolchain supports) (default: "picolibc")')
280option('tls-model', type: 'combo', choices: ['global-dynamic', 'local-dynamic', 'initial-exec', 'local-exec'], value: 'local-exec',
281       description: 'Set TLS model. No-op when thread-local-storage is false')
282option('newlib-global-errno', type: 'boolean', value: false,
283       description: 'use global errno variable')
284option('errno-function', type: 'string',
285       value: 'false',
286       description: 'Use this function to compute errno address (default false, auto means autodetect, zephyr means use z_errno_wrap if !tls)')
287option('tls-rp2040', type: 'boolean', value: false,
288       description: 'Use Raspberry Pi RP2040 CPUID register to index thread local storage value')
289
290#
291# Math options
292#
293# Use "obsolete" math code, which use 'float' for 'float' functions
294# instead of the newer code which uses 'double' instead.
295#
296option('newlib-obsolete-math', type: 'combo', choices: ['true', 'false', 'auto'],
297       value: 'auto',
298       description: 'Use float type for float valued math routines (default: automatic based on platform)')
299option('newlib-obsolete-math-float', type: 'combo', choices: ['true', 'false', 'auto'],
300       value: 'auto',
301       description: 'Use old math code that uses float type for float valued math routines (default: automatic based on platform)')
302option('newlib-obsolete-math-double', type: 'combo', choices: ['true', 'false', 'auto'],
303       value: 'auto',
304       description: 'Use old math code for double valued math routines (default: automatic based on platform)')
305option('want-math-errno', type: 'boolean', value: false,
306       description: 'Set errno in math functions according to stdc (default: false)')
307
308#
309# Obsolete newlib options
310#
311option('newlib-long-time_t', type: 'boolean', value: false,
312       description: 'define time_t to long instead of a 64-bit type')
313option('newlib-missing-syscall-names', type: 'boolean', value: false,
314       description: 'system only provides regular syscall API')
315option('newlib-reentrant-syscalls-provided', type: 'boolean', value: false,
316       description: 'system provides reentrant syscall API')
317option('newlib-supplied-syscalls', type: 'boolean', value: false,
318       description: 'newlib supplies system call functions')
319