1# Picolibc 2Copyright © 2018-2023 Keith Packard 3 4Picolibc is library offering standard C library APIs that targets 5small embedded systems with limited RAM. Picolibc was formed by blending 6code from [Newlib](http://sourceware.org/newlib/) and 7[AVR Libc](https://www.nongnu.org/avr-libc/). 8 9Build status: 10 11 * ![Linux](https://github.com/picolibc/picolibc/workflows/Linux/badge.svg?branch=main) 12 * ![Zephyr](https://github.com/picolibc/picolibc/workflows/Zephyr/badge.svg?branch=main) 13 * ![Mac OS X](https://github.com/picolibc/picolibc/workflows/Mac%20OS%20X/badge.svg) 14 15## License 16 17Picolibc source comes from a variety of places and has a huge variety 18of copyright holders and license texts. While much of the code comes 19from Newlib, none of the GPL-related bits used to build the library 20are left in the repository, so all of the source code uses BSD-like 21licenses, a mixture of 2- and 3- clause BSD itself and a variety of 22other (mostly older) licenses with similar terms. 23 24There are two files used for testing printf, test/printf-tests.c and 25test/testcases.c which are licensed under the GPL version 2 or 26later. There is also a shell script, GeneratePicolibcCrossFile.sh 27which is licensed under the AGPL version 3 or later which is provided 28as a helper for people building the library, but not used by picolibc 29otherwise. 30 31The file COPYING.picolibc contains all of the current copyright and 32license information in the Debian standard machine-readable format. It 33was generated using the make-copyrights and find-copyright 34scripts. 35 36## Supported Architectures 37 38Picolibc has integrated testing support for many architectures which 39is used to validate the code for all patch integration: 40 41 * ARC (32- and 64- bit) 42 * ARM (32- and 64- bit) 43 * i386 (Native and Linux hosted, for testing) 44 * Motorola 68000 (m68k) 45 * MIPS 46 * MSP430 47 * Nios II 48 * Power9 49 * RISC-V (both 32- and 64- bit) 50 * SparcV8 (32 bit) 51 * x86_64 (Native and Linux hosted, for testing) 52 53There is also build infrastructure and continuous build validation, 54but no integrated testing available for additional architectures: 55 56 * Microblaze (32-bit, big and little endian) 57 * PowerPC (big and little endian) 58 * Sparc64 59 * Xtensa (ESP8266, ESP32) 60 61Supporting architectures that already have Newlib code requires: 62 63 1. newlib/libc/machine/_architecture_/meson.build to build the 64 architecture-specific libc bits. This should at least include 65 setjmp/longjmp support as these cannot be performed in 66 architecture independent code and are needed by libstdc++. 67 68 2. Checking for atomic support for tinystdio. Tinystdio requires 69 atomics for ungetc to work correctly in a reentrant 70 environment. By default, it stores them in 16-bit values, but 71 some architectures only have 32-bit atomics. To avoid ABI 72 issues, the size selected isn't detected automatically, instead 73 it must be configured in newlib/libc/tinystdio/stdio.h. 74 75 3. newlib/libm/machine/_architecture_/meson.build to build any 76 architecture-specific libm bits 77 78 4. picocrt/machine/_architecture_ source code and build bits 79 for startup code needed for the architecture. Useful in all 80 cases, but this is necessary to run tests under qemu if your 81 platform can do that. 82 83 5. cross-_gcc-triple_.txt to configure the meson cross-compilation 84 mechanism to use the right tools 85 86 6. do-_architecture_-configure to make testing the cross-compilation 87 setup easier. 88 89 7. newlib/libc/picolib support. This should include whatever startup 90 helpers are required (like ARM interrupt vector) and TLS support 91 (if your compiler includes this). 92 93 8. run-_architecture_ script to run tests under QEMU. Look at the ARM 94 and RISC-V examples to get a sense of what this needs to do and 95 how it gets invoked from the cross-_gcc-triple_.txt configuration 96 file. 97 98## Relation to newlib 99 100Picolibc is mostly built from pieces of newlib, and retains the 101directory structure of that project. While there have been a lot of 102changes in the build system and per-thread data storage, the bulk of 103the source code remains unchanged. 104 105To keep picolibc and newlib code in sync, newlib changes will be 106regularly incorporated. To ease integration of these changes into 107picolibc, some care needs to be taken while editing the code: 108 109 * Files should not be renamed. 110 * Fixes that also benefit users of newlib should also be sent to the 111 newlib project 112 * Changes, where possible, should be made in a way compatible with 113 newlib design. For example, instead of using 'errno' (which is 114 valid in picolibc), use __errno_r(r), even when 'r' is not defined 115 in the local context. 116 117The bulk of newlib changes over the last several years have been in 118areas unrelated to the code used by picolibc, so keeping things in 119sync has not been difficult so far. 120 121## Documentation 122 123Introductory documentation. Read these first: 124 125 * [Building Picolibc](doc/build.md). Explains how to compile picolibc yourself. 126 * [Using Picolibc](doc/using.md). Shows how to compile and link 127 applications once you have picolibc built and installed. 128 * [Linking with Picolibc.ld](doc/linking.md). Provides more details 129 about the linking process. 130 * [Hello World](hello-world/README.md). Build and run a stand-alone C 131 application by following step-by-step instructions 132 133Detailed documentation. Use these to learn more details about how to 134use Picolibc: 135 136 * [Picolibc initialization](doc/init.md) 137 * [Operating System Support](doc/os.md). 138 * [Printf and Scanf in Picolibc](doc/printf.md) 139 * [Thread Local Storage](doc/tls.md) 140 * [Re-entrancy and Locking](doc/locking.md) 141 * [Selecting ctype implementation](doc/ctype.md) 142 * [Picolibc as embedded source](doc/embedsource.md) 143 * [Releasing Picolibc](doc/releasing.md) 144 * [Copyright and license information](COPYING.picolibc) 145 146## Releases 147 148### Picolibc version 1.8.6 149 150 * Fix some FORTITY_SOURCE issues with tinystdio 151 152 * Add __eh_* symbols to picolibc.ld for LLVM libunwind. Thanks Alex 153 Richardson. 154 155 * Merge in newlib annual release (4.4.0). Some minor updates to 156 aarch64 assembly code formatting (thanks to Sebastian Huber) and a 157 few other fixes. 158 159 * Enable 32-bit SPARC for testing. 160 161 * Fix a bunch of fmemopen bugs and add some tests. Thanks to Alex 162 Richardson. 163 164 * Finish support for targets with unusual float types, mapping 165 target types to 32-, 64-, 80- and 128- bit picolibc code. 166 167 * Add SuperH support, including testing infrastructure. Thanks to 168 Adrian Siekierka for help with this. 169 170 * Improve debugger stack trace in risc-v exception code. Thanks to 171 Alex Richardson. 172 173 * Add an option (-Dfast-bufio=true) for more efficient fread/fwrite 174 implementations when layered atop bufio. Thanks for the suggestion 175 from Zachary Yedidia. 176 177 * Fix cmake usage of FORMAT_ variables (note the lack of a leading 178 underscore). 179 180 * Remove explicit _POSIX_C_SOURCE definition in zephyr/zephr.cmake. 181 182 * Clean up public inline functions to share a common mechanism for 183 using gnu_inline semantics. Fix isblank. This ensures that no 184 static inline declarations exist in public API headers which are 185 required to be external linkage ("real") symbols. 186 187 * Create an alternate ctype implementation that avoids using the 188 _ctype_ array and just does direct value comparisons. This only 189 works when picolibc is limited to ASCII. Applications can select 190 whether they want this behavior at application compilation time 191 without needing to rebuild the C library. Thanks to P. Frost for 192 the suggestion. 193 194 * Unify most fenv implementations to use gnu_inline instead of 195 regular functions to improve performance. x86 was left out because 196 those fenv functions are complicated by the mix of 8087 and modern 197 FPU support. 198 199 * Add a separate FILE for stderr when using POSIX I/O. Split 200 stdin/stdout/stderr into three files to avoid pulling in 201 those which aren't used. Thanks to Zachary Yedidia. 202 203### Picolibc version 1.8.5 204 205 * Detect clang multi-lib support correctly by passing compiler flags. 206 Thanks to xbjfk for identifying the problem. 207 208 * Create a new 'long-long' printf variant. This provides enough 209 variety to satisfy the Zephyr cbprintf options without needing to 210 build the library from scratch. 211 212 * Adjust use of custom binary to decimal conversion code so that it 213 is only enabled for types beyond the register size of the 214 target. This avoids the cost of this code when the application is 215 already likely to be using the soft division routines. 216 217### Picolibc version 1.8.4 218 219 * Make math overflow and underflow handlers respect rounding modes. 220 221 * Add full precision fma/fmaf fallbacks by adapting the long-double 222 code which uses two floats/doubles and some careful exponent 223 management to ensure that only a single rounding operation occurs. 224 225 * Fix more m68k 80-bit float bugs 226 227 * Fix m68k asm ABI by returning pointers in %a0 and %d0 228 229 * Use an m68k-unknown-elf toolchain for m68k testing, including 230 multi-lib to check various FPU configurations on older and more 231 modern 68k targets. 232 233 * Improve CI speed by using ccache on zephyr and mac tests, 234 compressing the docker images and automatically canceling jobs when 235 the related PR is updated. Thanks to Peter Jonsson. 236 237 * Move a bunch of read-only data out of RAM and into flash by adding 238 'const' attributes in various places. 239 240 * Add a new linker symbol, `__heap_size_min`, which specifies a 241 minimum heap size. The linker will emit an error if this much space 242 is not available between the end of static data and the stack. 243 244 * Fix a bunch of bugs on targets with 16-bit int type. Thanks to 245 Peter Jonsson for many of these. 246 247 * Work around a handful of platform bugs on MSP430. I think these are 248 compiler bugs as they occur using both the binutils simulator and 249 mspsim. 250 251 * Run tests on MSP430 using the simulator that comes with gdb. Thanks to 252 Peter Jonsson for spliting tests apart to make them small enough to 253 link in under 1MB. This requires a patch adding primitive 254 semihosting to the simulator. 255 256 * Provide a division-free binary to decimal conversion option for 257 printf at friends. This is useful on targets without hardware 258 divide as it avoids pulling in a (usually large) software 259 implementation. This is controlled with the 'printf-small-ultoa' 260 meson option and is 'false' by default. 261 262 * Add 'minimal' printf and scanf variants. These reduce functionality 263 by removing code that acts on most data modifers including width 264 and precision fields and alternate presentation modes. A new config 265 variable, minimal-io-long-long, controls whether that code supports 266 long long types. 267 268 * Add a 'assert-verbose' option which controls whether the assert 269 macro is chatty by default. It is 'true' by default, which 270 preserves the existing code, but when set to 'false', then a 271 failing assert calls __assert_no_msg with no arguments, saving the 272 memory usually occupied by the filename, function name and 273 expression. 274 275 * Fix arm asm syntax for mrc/mcr instructions to make clang happy. 276 Thanks to Radovan Blažek for this patch. 277 278### Picolibc version 1.8.3 279 280 * Fix bugs in floor and ceil implementations. 281 282 * Use -fanalyzer to find and fix a range of issues. 283 284 * Add __ubsan_handle_out_of_bounds implementation. This enables 285 building applications with -fsanitize=bounds and 286 -fno-sanitize-undefined-trap-on-error. 287 288 * Validate exception configuration on targets with mixed exception 289 support where some types have exceptions and others don't. Right 290 now, that's only arm platforms where any soft float implementations 291 don't build with exception support. 292 293 * Fix bugs in nexttowards/nextafter on clang caused by the compiler 294 re-ordering code and causing incorrect exception generation. 295 296 * Use the small/slow string code when -fsanitize=address is used 297 while building the library. This avoids reading beyond the end of 298 strings and triggering faults. 299 300 * Handle soft float on x86 and sparc targets. That mostly required 301 disabling the hardware exception API, along with a few other minor 302 bug fixes. 303 304 * Add runtime support for arc, mips, nios2 and m68k. This enables CI 305 testing on these architectures using qemu. 306 307 * Fix 80-bit floating math library support for m68k targets. 308 309 * Fix arm testing infra to use various qemu models that expand 310 testing to all standard multi-lib configurations. 311 312 * Adjust floating exception stubs to return success when appropriate, 313 instead of always returning ENOSYS. 314 315 * Make sure sNaN raises FE_INVALID and is converted to qNaN in 316 truncl, frexpl and roundl 317 318 * Avoid NaN result from fmal caused by multiply overflow when 319 addend is infinity (-inf + inf results in NaN in that case). 320 321### Picolibc version 1.8.2 322 323 * Support _ZEPHYR_SOURCE macro which, like _POSIX_SOURCE et al, 324 controls whether the library expresses the Zephyr C library API. 325 This is also automatically selected when the __ZEPHYR__ macro is 326 defined and no other _*_SOURCE macro is defined. 327 328 * Add another cross compile property, 'libgcc', which specifies the 329 library containing soft float and other compiler support routines. 330 331 * Fix a couple of minor imprecisions in pow and 80-bit powl. 332 333 * Merge newlib changes that included an update to the ARM assembly 334 code. 335 336 * Replace inexact float/string conversion code with smaller code that 337 doesn't use floating point operations to save additional space on 338 soft float targets. 339 340 * More cmake fixes, including making the inexact printf and locale 341 options work. 342 343### Picolibc version 1.8.1 344 345 * Fix cmake build system to auto-detect compiler characteristics 346 instead of assuming the compiler is a recent version of GCC. This 347 allows building using cmake with clang. 348 349 * Fix cmake build system to leave out TLS support when TLS is 350 disabled on the cmake command line. 351 352 * Replace inline asm with attributes for __weak_reference macro 353 354 * Add allocation attributes to malloc and stdio functions. This 355 allows the compiler to detect allocation related mistakes as well 356 as perform some additional optimizations. Bugs found by this change 357 were also addressed. 358 359 * Add wchar_t support to tinystdio, eliminating the last missing 360 feature compared with the legacy stdio bits from newlib. With this, 361 libstdc++ can be built with wide char I/O support, eliminating the 362 last missing feature there as well. 363 364 * Eliminate use of command line tools when building with a new enough 365 version of meson. Thanks to Michael Platings. 366 367 * Add Microblaze support. Thanks to Alp Sayin. 368 369 * Switch semihosting to use binary mode when opening files. Thanks to 370 Hardy Griech. 371 372 * Build and install static library versions of the crt0 startup 373 code. These allows developers to reference them as libraries on the 374 command line instead of needing special compiler support to locate 375 the different variants, which is useful when using clang. Thanks to 376 Simon Tatham. 377 378 * Simplify the signal/raise implementation to use a single global 379 array of signal handlers and to not use getpid and kill, instead 380 raise now directly invokes _exit. This makes using assert and abort 381 simpler and doesn't cause a large TLS block to be allocated. Thanks 382 to Joe Nelson for discovering the use of a TLS variable here. 383 384### Picolibc version 1.8 385 386With the addition of nearly complete long double support in the math 387library, it seems like it's time to declare a larger version increment 388than usual. 389 390 * Improve arc and xtensa support, adding TLS helpers and other build fixes 391 392 * Fix FPSCR state for Arm8.1-M low overhead loops (thanks to David 393 Green) 394 395 * Add -Werror=double-promotion to default error set and fix related 396 errors. (thanks to Ryan McClelland) 397 398 * Fix locking bug in malloc out-of-memory path and freeing a locked 399 mutex in the tinystdio bufio code. These were found with lock 400 debugging code in Zephyr. 401 402 * Add some missing functions in tinystdio, strto*l_l, remove, 403 tmpname/tmpfile which were published in stdio.h but not included in 404 the library. 405 406 * Switch read/write functions to use POSIX types instead of legacy 407 cygwin types. This makes mapping to existing an POSIX api work 408 right. 409 410 * Add %b support to tinystdio printf and scanf. These are disabled by 411 default as they aren't yet standardized. 412 413 * Fix avr math function support. The avr version of gcc has modes 414 where double and long double are 32 or 64 bits, so the math library 415 code now detects all of that at compile time rather than build time 416 and reconfigures the functions to match the compiler types. 417 418 * Add nearly complete long double support from openlibm for 80-bit 419 Intel and 128-bit IEEE values (in addition to supporting 64-bit 420 long doubles). Still missing are Bessel functions and decimal 421 printf/scanf support. 422 423 * Add limited long double support for IBM 'double double' form. This 424 is enough to run some simple tests, but doesn't have any 425 significant math functions yet. 426 427 * Get Power9 code running under qemu with OPAL. This was mostly 428 needed to validate the big-endian and exception code for 128-bit 429 long doubles, but was also used to validate the double double 430 support. 431 432 * Provide times() and sysconf() implementations in semihosting. You 433 can now build and run the dhrystone benchmark without any further 434 code. 435 436 * Fix use of TLS variables with stricter alignment requirements in 437 the default linker script and startup code. (thanks to Joakim 438 Nohlgård and Alexander Richardson who found this issue while 439 working on lld support). 440 441### Picolibc version 1.7.9 442 443 * Support all Zephyr SDK targets 444 445 * Support relocating the toolchain by using GCC_EXEC_PREFIX for 446 sysroot-install when compiler doesn't use sysroot. 447 448 * Add MIPS, SPARC and ARC support 449 450 * Deal with RISC-V changes in gcc that don't reliably include zicsr 451 452 * Support Picolibc as default C library with -Dsystem-libc option. 453 With this, you can use picolibc without any extra compiler options. 454 455 * Merge current newlib bits to get code that doesn't use struct _reent 456 457 * Get rid of struct _reent in legacy stdio code 458 459 * Support 16-bit int targets by fixing a few places assuming 460 sizeof(int) == 4, object sizes not using size_t, wint_t for 461 ucs-4 values 462 463 * Add MSP430 support 464 465 * Fix a couple of clang bugs (one on Cortex M0) 466 467 * Support libc++ by adding non-standard mbstate_t.h 468 469 * Merge i686 and x86_64 code to allow x86 multilib builds 470 471 * Merge Xtensa newlib bits 472 473 * Support Xtensa ESP32 targets 474 475 * Add Nios II support 476 477### Picolibc version 1.7.8 478 479 1. Fix el/ix level 4 code type errors 480 481 2. Fix out-of-source CMake build (thanks Max Behensky) 482 483 3. Improve build.md docs (thanks Kalle Raiskila) 484 485 4. Fix cmake build for various architectures 486 487 5. Initialize lock in fdopen 488 489 6. Remove %M from linker paths in single-arch builds 490 491 7. Shrink tinystdio vfprintf and vfscanf a bit 492 493 8. Use -fno-builtin-malloc -fno-builtin-free (GCC 12 compat) 494 495 9. Use -fno-builtin-copysignl (GCC 12 compat) 496 497 10. Add _zicsr to -march for risc-v picocrt (binutils 2.38 compat) 498 499 11. Add -no-warn-rwx-segments to link spec (binutils 2.38 compat) 500 501### Picolibc version 1.7.7 502 503 1. Fix semihost gettimeofday, add a test. 504 505 2. Fix config option documentation. (Thanks to rdiez) 506 507 3. Document how re-entrant locking APIs are used. (Thanks to rdiez) 508 509 4. Fix some 16-bit int issues in tinystdio. (Thanks to Ayke van 510 Laethem) 511 512 5. Make header files a bit more POSIX compliant, installing rpc 513 headers, moving byte swapping macros to arpa/inet.h 514 515 6. Fix some stdio bugs found by Zephyr test suite: snprintf return 516 value on buffer overflow, add ftello/fseeko, fputc return value, 517 %0a formatting, clear EOF status after ungetc/fseek. 518 519 7. Re-do buffered I/O support to handle mixed read/write files 520 correctly. This adds setbuf, setbuffer, setlinebuf, setvbuf. 521 522 8. Add fmemopen and freopen. 523 524 9. Add enough cmake support to allow Zephyr to build picolibc as a 525 module using that, rather than meson. 526 527 10. Merge current newlib bits 528 529 11. Fix %p printf/scanf on ILP64 targets. 530 531### Picolibc version 1.7.6 532 533 1. Fix use with C++ applications caused by a syntax error in 534 picolibc.specs 535 536 2. Automatically include '-nostdlib' to options used while 537 evaluating build rules to ensure tests work as expected. 538 539 3. Publish aarch64 inline math functions, ensure that inline fma 540 functions work in installed applications for arm and risc-v. 541 542### Picolibc version 1.7.5 543 544 1. Fix build on big-endian systems (thanks to Thomas Daede) 545 546 2. Add m68k support (thanks to Thomas Daede). 547 548 3. Fix build issues with ARM Cortex-a9 target (thanks to Ilia 549 Sergachev). 550 551 4. Fix fwrite(x,0,y,z) in both tinystdio and legacy stdio. tinystdio 552 returned the wrong value and legacy stdio caused a divide-by-zero 553 fault. 554 555 5. Update Ryu code to match upstream (minor fixes) 556 557 6. Fix various __NEWLIB and __PICOLIBC macros; they were using a 558 single leading underscore instead of two (thanks to Vincent 559 Palatin). 560 561 7. Fix tinystdio error-handling bugs 562 563 8. Merge recent newlib changes (fixed ltdoa in legacy stdio) 564 565 9. Speed improvements for github CI system 566 567 10. Big-endian PowerPC support 568 569 11. Fail builds if most 'run_command' uses fail (thanks to Johan de 570 Claville Christiansen) 571 572 12. Positional parameters in tinystdio. With this, I think tinystdio 573 is feature complete. 574 575 13. Support for multiple build-styles of picolibc (minsize/release) 576 in one binary package. This still requires separate meson runs. 577 578 14. Testing with glibc test code. This uncovered numerous bugs, 579 mostly math errno/exception mistakes, but also a few serious 580 bugs, including a couple of places where the nano-malloc failed 581 to check for out-of-memory. Picolibc now passes all of the glibc 582 math tests except for jn, yn, lgamma and tgamma. The picolibc 583 versions of those functions are too inaccurate. Picolibc also 584 passes most other relevant glibc tests, including stdio, 585 string and stdlib areas. 586 587 15. Tinystdio version of fcvt now has a static buffer large enough to 588 hold the maximum return size. 589 590 16. Tinystdio versions of ecvtbuf and fcvtbuf have been replaced 591 with ecvt_r and fcvt_r equivalents, which take a 'len' parameter 592 to prevent buffer overruns. 593 594 17. Add the GeneratePicolibcCrossFile.sh script which provides a way 595 to isolate picolibc build scripts from the vagaries of meson 596 version shifts (thanks to R. Diez). 597 598 18. Add 'semihost' version of crt0 that calls 'exit' after main 599 returns. The ARM and RISC-V versions of this also include trap 600 handlers for exceptions that print out information and exit when 601 an exception occurs. 602 603### Picolibc version 1.7.4 604 605 1. Clean up meson build bits, including use of 'fs module (thanks to 606 Yasushi Shoji). 607 608 2. Speed up github actions by sharing Debian docker image (thanks to 609 Yasushi Shoji). 610 611 3. Reduce use of intermediate static libraries during build 612 613 4. Use standard Meson architecture names everywhere (thanks to 614 Yasushi Shoji). 615 616 5. Support building with -D_FORTIFY_SOURCE enabled. 617 618 6. Clean up 32-bit arm assembly code, eliminating __aeabi wrappers 619 where possible. 620 621 7. Add basename, dirname and fnmatch back. 622 623 8. Fix all old-style (K&R) function definitions. 624 625 9. Enable lots more compiler warning flags. 626 627 10. Remove last uses of alloca in legacy stdio code. 628 629 11. Add tests from musl libc-testsuite. There aren't many tests, but 630 these identified a few bugs. 631 632 12. Add lots more exception and errno tests for the math functions. 633 634 13. Restructure math library to always use the `__math_err` functions 635 to raise exceptions and set errno. This removes the w_*.c wrapper 636 functions and eliminates the `__ieee names`. This centralizes 637 compiler work-arounds to ensure run-time evaluation of 638 expressions intended to raise exceptions. In the process, all of 639 the libm/math files were reformatted with clang-format. 640 641 14. Make tinystdio '%a' compatible with glibc, including supporting 642 rounding and trimming trailing zeros when possible. 643 644 15. Remove floating point exception generation code on targets 645 without floating point exception support. This reduces code size 646 on soft float machines without affecting results. 647 648### Picolibc version 1.7.3 649 650 1. Add -Wall -Wextra to default builds. Fixed warnings this raised. 651 652 2. Add htonl and friends (based on __htonl). Thanks to Johan de 653 Claville Christiansen 654 655 3. Set errno in scalbn and scalbnf (patch forwarded to newlib). 656 657 4. Merge newlib recent changes which includes a couple of libm fixes. 658 659### Picolibc version 1.7.2 660 661 1. Fix picolibc.ld to split C++ exceptions back apart (thanks to 662 Khalil Estell) 663 664 2. Add vsscanf to tinystdio (required for libstdc++). 665 666 3. Also stick -isystem in C++ compile command to try and get 667 picolibc headers to be used instead of newlib. 668 669### Picolibc version 1.7.1 670 671 1. Add __cxa_atexit implementation to 'picoexit' path as required by 672 C++ 673 674 2. Fix lack of 'hh' support in integer-only tinystdio printf path. 675 676 3. Fix tinystdio __file flag initialization for C++ apps 677 678### Picolibc version 1.7 679 680 1. Merge libc and libm into a single library. Having them split 681 doesn't offer any advantages while requiring that applications add 682 '-lm' to link successfully. Having them merged allows use of libm 683 calls from libc code. 684 685 2. Add hex float format to *printf, *scanf and strto{d,f,ld}. This is 686 required for C99 support. 687 688 3. Unify strto{d,f,ld} and *scanf floating point parsing code. This 689 ensures that the library is consistent in how floats are parsed. 690 691 4. Make strto{d,f,ld} set errno to ERANGE on overflow/underflow, 692 including when the result is a subnormal number. 693 694### Picolibc version 1.6.2 695 696 1. Change `restrict` keyword in published headers to `__restrict` to 697 restore compatibility with applications building with --std=c18. 698 699 2. Additional cleanups in time conversion funcs (Thanks to R. Riez) 700 701### Picolibc version 1.6.1 702 703 1. Code cleanups for time conversion funcs (Thanks to R. Diez) 704 705 2. Add '-fno-stack-protector' when supported by the C compiler 706 to avoid trouble building with native Ubuntu GCC. 707 708 3. Bug fix for converting denorms with sscanf and strto{d,f,ld}. 709 710 4. Use __asm__ for inline asm code to allow building applications 711 with --std=c18 712 713 5. Fix exit code for semihosting 'abort' call to make it visible 714 to the hosting system. 715 716 6. Add strfromf and strfromd implementations. These are simple 717 wrappers around sscanf, but strfromf handles float conversions 718 without requiring a pass through 'double' or special linker hacks. 719 720### Picolibc version 1.6 721 722 1. Bugfix for snprintf(buf, 0) and vsnprintf(buf, 0) to avoid 723 smashing memory 724 725 2. Support building libstdc++ on top of picolibc 726 727 3. Add 'hosted' crt0 variant that calls exit when main 728 returns. This makes testing easier without burdening embedded apps 729 with unused exit processing code. 730 731 4. Add 'minimal' crt0 variant that skips constructors to 732 save space on systems known to not use any. 733 734 5. Fix HW floating point initialization on 32-bit ARM processors to 735 perform 'dsb' and 'isb' instructions to ensure the FPU enabling 736 write is complete before executing any FPU instructions. 737 738 6. Create a new '--picolibc-prefix' GCC command line parameter that 739 sets the base of all picolibc file names. 740 741 7. Add bare-metal i386 and x86_64 initializatiton code (thanks to 742 Mike Haertel). These initalize the processor from power up to 743 running code without requiring any BIOS. 744 745 8. Merge newlib as of late April, 2021 746 747 9. Add 'timegm' function (thanks to R. Diez). 748 74910. Fix a number of tinystdio bugs: handle fread with size==0, parse 750 'NAN' and 'INF' in fscanf in a case-insensitive manner, fix 751 negative precision to '*' arguments in printf, fix handling of 752 'j', 'z' and 't' argument size specifiers (thanks to Sebastian 753 Meyer). 754 75511. Make the fenv API more consistent and more conformant with the 756 spec. All architectures now fall back to the default code 757 for soft float versions, which avoids having the various exception 758 and rounding modes get defined when not supported. 759 760### Picolibc version 1.5.1 761 762 1. Make riscv crt0 '_exit' symbol 'weak' to allow linking without 763 this function. 764 765### Picolibc version 1.5 766 767 1. Make picolibc more compatible with C++ compilers. 768 769 2. Add GCC specs file and linker script for building C++ applications 770 with G++ that enable exception handling by linking in call stack 771 information. 772 773 3. A few clang build fixes, including libm exception generation 774 775 4. Nano malloc fixes, especially for 'unusual' arguments 776 777 5. Merge in newlib 4.1.0 code 778 779 6. More libm exception/errno/infinity fixes, mostly in the gamma funcs. 780 781 7. Add tests for all semihost v2.0 functions. 782 783 8. A few RISC-V assembly fixes and new libm code. 784 785 9. Build fixes to reliably replace generic code with 786 architecture-specific implementations. 787 788With a patch which is pending for GCC 11, we'll be able to build C++ 789applications that use picolibc with exceptions and iostream. 790 791### Picolibc version 1.4.7 792 793 1. Fix numerous libm exception and errno bugs. The math functions are 794 all now verified to match the C19 and Posix standards in this 795 area. 796 797 2. Change behavior of 'gamma' function to match glibc which returns 798 lgamma for this function. Applications should not use this 799 function, they should pick either lgamma or tgamma as appropriate. 800 801 3. Fix fma/fmaf on arm and RISC-V so that the machine-specific versions 802 are used when the hardware has support. Also fix the math library 803 to only use fma/fmaf when it is supported by the hardware. 804 805 4. Fix numerous nano-malloc bugs, especially with unusual parameters. 806 807 5. Change nano-malloc to always clear returned memory. 808 809 6. Improve nano-realloc to perform better in various ways, including 810 merging adjacent free blocks and expanding the heap. 811 812 7. Add malloc tests, both a basic functional test and a stress test. 813 814 8. Improve build portability to Windows. Picolibc should now build 815 using mingw. 816 817 9. Use hardware TLS register on ARM when available. 818 819 10. Support clang compiler. Thanks to Denis Feklushkin 820 <denis.feklushkin@gmail.com> and Joakim Nohlgård <joakim@nohlgard.se>. 821 822 11. Avoid implicit float/double conversions. Check this by having 823 clang builds use -Wdouble-promotion -Werror=double-promotion 824 flags 825 826 12. Have portable code check for machine-specific overrides by 827 matching filenames. This avoids building libraries with 828 duplicate symbols and retains compatibility with newlib (which 829 uses a different mechanism for this effect). 830 831 13. Patches to support building with [CompCert](http://compcert.inria.fr/), a 832 formally verified compiler. Thanks to Sebastian Meyer 833 <meyer@absint.com>. 834 835### Picolibc version 1.4.6 836 837 1. Install 'ssp' (stack smashing protection) header files. This fixes 838 compiling with -D_FORTIFY_SOURCE. 839 840 2. Make getc/ungetc re-entrant. This feature, which is enabled by 841 default, uses atomic instruction sequences that do not require 842 OS support. 843 844 3. Numerous iconv fixes, including enabling testing and switching 845 external CCS file loading to use stdio. By default, iconv provides 846 built-in CCS data for all of the supported encodings, which takes 847 a fairly large amount of read-only memory. Iconv is now always 848 included in picolibc as it isn't included in applications unless 849 explicitly referenced by them. 850 851 4. Add __getauxval stub implementation to make picolibc work with 852 GCC version 10 compiled for aarch64-linux-gnu. 853 854 5. Change how integer- and float- only versions of printf and scanf 855 are selected. Instead of re-defining the symbols using the C 856 preprocessor, picolibc now re-defines the symbols at link 857 time. This avoids having applications compiled with a mixture of 858 modes link in multiple versions of the underlying functions, while 859 still preserving the smallest possible integer-only 860 implementation. 861 862 6. Document how to use picolibc on a native POSIX system for 863 testing. Check out the [os.md](doc/os.md) file for details. 864 865 7. Merge current newlib bits in. This includes better fenv support, 866 for which tests are now included in the picolibc test suite. 867 868### Picolibc version 1.4.5 869 870 1. Fix section order in picolibc.ld to give applications correct 871 control over the layout of .preserve, .init and .fini regions. 872 873 2. Add startup and TLS support for aarch64 and non Cortex-M 32-bit 874 arm. 875 876### Picolibc version 1.4.4 877 878 1. Fix floating point 'g' format output in tinystdio. (e.g., 879 for 10.0, print '10' instead of '1e+01'). There are tests which 880 verify a range of 'g' cases like these now. 881 882 2. Merge current newlib bits. The only thing which affects picolibc 883 is the addition of fenv support for arm. 884 885### Picolibc version 1.4.3 886 887 1. Make fix for CVE 2019-14871 - CVE 2019-14878 in original newlib 888 stdio code not call 'abort'. Allocation failures are now reported 889 back to the application. 890 891 2. Add 'exact' floating point print/scan code to tinystdio. Thanks 892 to Sreepathi Pai for pointing me at the Ryu code by Ulf 893 Adams. 894 895 3. Add regular expression functions from newlib. These were removed 896 by accident while removing POSIX filesystem-specific code. 897 898 4. Make tinystdio versions of [efg]cvt functions. This means that the 899 default tinystdio version of picolibc no longer calls malloc from 900 these functions. 901 902 5. More clang-compatibility fixes. (Thanks to Denis Feklushkin) 903 904 6. Remove stdatomic.h and tgmath.h. (they should not be provide by picolibc) 905 906### Picolibc version 1.4.2 907 908 1. Clang source compatibility. Clang should now be able to compile 909 the library. Thanks to Denis Feklushkin for figuring out how 910 to make this work. 911 912 2. aarch64 support. This enables the existing aarch64 code and 913 provides an example configuration file for getting it 914 built. Thanks for Anthony Anderson for this feature. 915 916 3. Testing on github on push and pull-request. For now, this is 917 limited to building the library due to a bug in qemu. 918 919 4. Get newlib stdio working again. You can now usefully use Newlib's 920 stdio. This requires a working malloc and is substantially larger 921 than tinystdio, but has more accurate floating point input. This 922 requires POSIX functions including read, write and a few others. 923 924 5. Fix long double strtold. The working version is only available 925 when using tinystdio; if using newlib stdio, strtold is simply not 926 available. 927 928 6. Improve tinystdio support for C99 printf/scanf additions. 929 930 7. Check for correct prefix when sysroot-install option is 931 selected. The value of this option depends on how gcc was 932 configured, and (alas) meson won't let us set it at runtime, so 933 instead we complain if the wrong value was given and display the 934 correct value. 935 936 8. Sync up with current newlib head. 937 938### Picolibc version 1.4.1 939 940This release contains an important TLS fix for ARM along with a few 941minor compatibility fixes 942 943 1. Make __aeabi_read_tp respect ARM ABI register requirements to 944 avoid clobbering register contents during TLS variable use. 945 946 2. Use cpu_family instead of cpu in meson config, which is 'more 947 correct' when building for a single cpu instead of multilib. 948 949 3. Make arm sample interrupt vector work with clang 950 951 4. Use __inline instead of inline in published headers to allow 952 compiling with -ansi 953 954 5. Make 'naked' RISC-V _start function contain only asm 955 statements as required by clang (and recommended by gcc). 956 957 6. Use -msave-restore in sample RISC-V cross-compile 958 configuration. This saves text space. 959 960### Picolibc version 1.4 961 962This release was focused on cleaning up the copyright and license 963information. 964 965 1. Copyright information should now be present in every source file. 966 967 2. License information, where it could be inferred from the 968 repository, was added to many files. 969 970 3. 4-clause BSD licenses were changed (with permission) to 3-clause 971 972 4. Fix RISC-V ieeefp.h exception bits 973 974 5. Merge past newlib 3.2.0 975 976 6. Add PICOLIBC_TLS preprocessor define when the library has TLS support 977 978### Picolibc version 1.3 979 980This release now includes tests, and fixes bugs found by them. 981 982 1. ESP8266 support added, thanks to Jonathan McDowell. 983 984 2. Numerous test cases from newlib have been fixed, and 985 precision requirements adjusted so that the library now 986 passes its own test suite on x86, RISC-V and ARM. 987 988 3. String/number conversion bug fixes. This includes fcvt/ecvt/gcvt 989 shared with newlib and tinystdio printf/scanf 990 991 4. A few RISC-V ABI fixes, including setting the TLS base correctly, 992 compiling with -mcmodel=medany, and enabling the FPU for libraries 993 built to use it. 994 995 5. Semihosting updates, including adding unlink, kill and getpid 996 (which are used by some tests). 997 998### Picolibc version 1.2 999 1000This release includes important fixes in picolibc.ld and more 1001semihosting support. 1002 1003 1. File I/O and clock support for semihosting. This enables fopen/fdopen 1004 support in tinystdio along with an API to fetch a real time clock 1005 value. 1006 1007 2. Fix picolibc.ld to not attempt to use redefined symbols for memory 1008 space definitions. These re-definitions would fail and the default 1009 values be used for system memory definitions. Instead, just use 1010 the ? : operators each place the values are needed. Linker scripts 1011 continue to mystify. 1012 1013 3. Expose library definitions in 'picolibc.h', instead of 'newlib.h' 1014 and '_newlib_version.h' 1015 1016 4. Define HAVE_SEMIHOST when semihosting support is available. This 1017 lets the 'hello-world' example do some semihost specific things. 1018 1019### Picolibc version 1.1 1020 1021A minor update from 1.0, this release includes: 1022 1023 1. semihost support. This adds console I/O and exit(3) support on ARM 1024 and RISC-V hosts using the standard semihosting interfaces. 1025 1026 2. Posix I/O support in tinystdio. When -Dposix-io=true is included 1027 in the meson command line (which is the default), tinystdio adds 1028 support for fopen and fdopen by using malloc, open, close, read, 1029 write and lseek. If -Dposix-console=true is also passed to meson, 1030 then picolibc will direct stdin/stdout/stderr to the posix 1031 standard file descriptors (0, 1, 2). 1032 1033 3. Merge recent upstream newlib code. This brings picolibc up to date 1034 with current newlib sources. 1035 1036 4. Hello world example. This uses a simple Makefile to demonstrate 1037 how to us picolibc when installed for ARM and RISC-V embedded 1038 processors. The resulting executables can be run under qemu. 1039 1040 5. Remove newlib/libm/mathfp directory. This experimental code never 1041 worked correctly anyways. 1042 1043### Picolibc version 1.0 1044 1045This is the first release of picolibc. Major changes from newlib 1046include: 1047 1048 1. Remove all non-BSD licensed code. None of it was used in building 1049 the embedded library, and removing it greatly simplifies the 1050 license situation. 1051 1052 2. Move thread-local values to native TLS mechanism 1053 1054 3. Add smaller stdio from avr-libc, which is enabled by default 1055 1056 4. Switch build system to meson. This has two notable benefits; the first 1057 is that building the library is much faster, the second is that 1058 it isolates build system changes from newlib making merging of 1059 newlib changes much easier. 1060 1061 5. Add simple startup code. This can be used in environments that 1062 don't have complicated requirements, allowing small applications 1063 to avoid needing to figure this out. 1064 1065