GeezerVison is showing keithp.com — picolibc


Picolibc: C Libraries for Smaller Embedded Systems
Picolibc is a set of standard C libraries, both libc and libm,
designed for smaller embedded systems with limited ROM and
RAM. Picolibc includes code from
Newlib and
AVR Libc. Picolibc has been tested
on RISC-V and ARM processors.
Picolibc was previously named newlib-nano, but that name has another
definition within newlib and so the Picolibc name was adopted instead.
Releases
Picolibc packages are available in the dist directory here
Presentations
I’ve written a presentation for Linaro Connect and the Embedded Linux
Conference. I wrote complete notes to go with the slides, so I’ve uploaded
the slides and notes here.
Pre-built GNU Arm Embedded Binaries
Pre-built binaries are available in the gnu-arm-embedded directory here
These packages are designed to be used with specific versions of the
GNU Arm Embedded Toolchain.
Get the zip file for the version matching the toolchain you have installed.
First, download and install the GNU Arm Embedded Toolchain. Next,
download the matching Picolibc zip file. Then, unpack the Picolibc zip
file “on top” of the GNU Arm Embedded Toolchain. This is done most
easily by opening up a command prompt window and using a zip file
extractor to overlay the picolibc bits on top of the GNU Arm Embedded Toolchain bits.
On Windows, you can use the 7-Zip command line tool, 7z. If the
Picolibc zip file is in
c:\Users\keithp\Downloads\picolibc-1.6-10-2020-q4-major.zip, and the
GNU Arm Embedded Toolchain is installed in c:\Program Files (x86)\GNU
Arm Embedded Toolchain\10 2020-q4-major, then you’d type:
C:\Users\keithp> cd "c:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major"
C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major> 7z x C:\Users\keithp\picolibc-1.6-10-2020-q4-major.zip
To verify that you have the right directory, you can check the
contents which should look like this:
c:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major>dir
Volume in drive C has no label.
Volume Serial Number is 4047-33CE
Directory of c:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major
06/02/2021 05:01 PM <DIR> .
06/02/2021 05:01 PM <DIR> ..
06/03/2021 04:25 PM <DIR> arm-none-eabi
06/02/2021 05:01 PM <DIR> bin
06/02/2021 05:01 PM <DIR> lib
06/02/2021 05:01 PM <DIR> share
06/02/2021 05:01 PM 162,555 uninstall.exe
On Linux, you can use the unzip tool. If the Picolibc zip file is in
~/Downloads/picolibc-1.6-10-2020-q4-major.zip and the GNU Arm
Embedded Toolchain is installed in
/opt/arm/gcc-arm-none-eabi-10-2020-q4-major, then you’d type:
$ cd /opt/arm/gcc-arm-none-eabi-10-2020-q4-major
$ unzip ~/Downloads/picolibc-1.6-10-2020-q4-major.zip
To verify that you have the right directory, you can check the
contents which should look like this:
$ ls -l
total 16
drwxr-xr-x 7 keithp keithp 4096 Jun 4 18:21 arm-none-eabi
drwxr-xr-x 2 keithp keithp 4096 Nov 23 2020 bin
drwxr-xr-x 3 keithp keithp 4096 Nov 23 2020 lib
drwxr-xr-x 4 keithp keithp 4096 Nov 23 2020 share
Picolibc release 1.8.12
Native Linux support on a couple of architectures. This allows
building of numerous Linux applications and test cases.
Clean up some picolibc structs that attempted to match native Linux
layout. Instead, map the contents at runtime, just like the new
native linux syscall support does.
Eliminate off64_t type; off_t is always 64 bits.
Fix iconv to not write partial codepoints to conform
to the spec.
vfprintf(”%lc”) takes a wint_t parameter, not int. This only
matters when int is smaller than 32 bits (as on msp430). Make %lc
work with a L’\0’ value and ignore any specified precision.
Fix some corner cases in vfprintf when wchar_t is 16 bits.
Use an array for strerror instead of a switch statement.
In ARM semihosting, preserve LR register and add an option
to use hlt instead of svc for arm arch >= 8 as that’s the
new recommendation. Thanks to Simi Pallipurath.
Add POSIX group file functions (getgrname et al).
Add vectorized memset, memcpy and memmove for RISC-V. Thanks to
Pincheng Wang.
Eliminate recursive locking of libc lock.
Simplify arc4random state and fork detection logic.
Fix possible NULL pointer dereference in the mbrtoc
functions. Thanks to Gergely Futo.
Provide semihosting calls for Hexagon. Thanks to Kushal Pal and
Zain Siddavatam.
Fix vfprintf_s thread safety analysis warning. Thanks to Brian
Cain.
Add clang thread safety analysis annotations for functions which
change lock state. Thanks to Brian Cain.
Fix strerror_r to handle missing entries in errnames array. Thanks
to mrashad.
Remove —gc-sections from picolibc.specs. This was more important
when the vfprintf and vfscanf variants were tied together to avoid
pulling in a vfscanf implementation.
Make CI report the detected code formatting errors. Thanks to
Kushal Pal.
Add 32-bit vector implementations for memmove, memcpy and
memset. Thanks to Abdallah Abdelhafeez.
Fix generic C version of riscv memcpy so the loop only copies 8
elements rather than 9. Thanks to Abdallah Abdelhafeez.
Add fopencookie and open_memstream. Thanks to Alexey Lapshin.
Improve performance of riscv strcmp function by re-ordering
instructions. Thanks to Abdallah Abdelhafeez.
Add Hexagon floating point environment support. Thanks to Zain
Siddavatam.
Fix bufio lazy lock initialization race. Thanks to Kushal Pal.
Add support for riscv Zcmt extension. Thanks to Sam Elliott.
Fix fflush(NULL) when -Dstdio-exit-flush=true. Thanks to Kushal Pal
for finding this bug.
Test arm code using FVP. Thanks to Mark Murray.
Add Hexagon assembly for various memory/string operations. Thanks
to Kushal Pal.
Make directory used by various temporary file functions
configurable. Use /tmp for the native Linux ports. Thanks to Zain
Siddavatam.
Add Hexagon optimized math functions. Thanks to Zain Siddavatam.
Initialize AArch64 SME in picocrt. Thanks to Mark Murray.
Add crt variant that enables riscv zicfilp/zicfiss features. Thanks
to Ahmed Shehab.
Add dynamic linking support for Hexagon. Thanks to Kushal Pal.
Add quick_exit and at_quick_exit. Thanks to Kushal Pal.
Fix undefined behavior in floating point printf. Thanks to Alberto
Escolar Piedras.
Picolibc release 1.8.11
Use __math_inexact to generate FE_INEXACT in several math
functions. Thanks to Gergely Futo.
Support riscv ’-mlarge’ model in asm code.
Initialize riscv vector unit in startup code when present.
Improve arm32 A-profile operation in Thumb state. Thanks to Victor
Campos.
Remove duplicate isinf and isnan declarations that were visible
even when building with C++. Thanks to Mostafa Salman.
Improve accuracy of cacoshf for real inputs. Thanks to Ahmed
Shehab.
Avoid use of float types in vfprintf to avoid unnecessary fpu
register use.
Add missing pid_t and getdate_err declarations to time.h.
Implement getdate and getdate_r as required by POSIX.
Fix numerous minor bugs in strptime.
Test exception handling on m68k
Add Hexagon architecture support. Thanks to Kushal Pal.
Clean up RISC-V asm code integration. Thanks to Venkata Ramanaiah
Nalamothu.
Add more math tests, including exhaustive binary 32 testing.
Improve cbrtf precision to within 1ulp.
Fix lgammaf for values between -0x1p-70 and -0x1p-64.
Add some missing stdint.h bits that are new in C23.
Improve accuracy of erfcf for values between 1.25 and 28. Improve
performance for values between 0x1p-56 and 0x1p-26.
Fix memchr on targets with 16-bit int and 32-bit long (MSP430).
Mask needle with 0xff on rx version of memchr.
Add missing POSIX functionality in fnmatch to support character
classes, equivalence classes and collating sequences. Limit fnmatch
recursion for ’*’ operators to 16 levels.
Rename cross compile property ‘libgcc’ to ‘librt’ since we can now
specify either libgcc or compiler-rt as run-time library. However,
‘libgcc’ is still supported for backward compatibility.
Fix bug in 32-bit riscv stpcpy which returned the wrong
value. Improve performance slightly by avoiding duplicate memory
reads of the tail of the string.
Make sure __STDC_LIB_EXT1__ gets defined as appropriate. Thanks to
Mostafa Salman.
Fix -long_option parsing in getopt_long_only.
Add strfmon and strfmon_l as required by POSIX.
Add dprintf and vdprintf as required by POSIX.
Improve JIS transcoding performance by building translation tables
in both directions.
Fix a bunch of iconv bugs and improve POSIX conformance by
supporting //IGNORE, //DISCARD and //TRANSLIT modes.
Reformat code with clang-format
Restructure directories, moving libc and libm to the top level and
moving all tests under tests/. Remove stdio and malloc variants.
Add ‘no-flash’ crt0 variant, thanks to Kushal Pal.
Update minimum required meson version from 0.53 to 0.61.
Add -Dfstat-bufsiz option that uses fstat to select stdio buffer
sizes. Thanks to Alexey Lapshin.
Rewrite __rem_pio2f. This new version is faster than the old while
remaining API compatible and not using double datatypes.
Update libc/machine/riscv. Thanks to Yuriy Kolerov.
Fix the way the zicsr extension is enabled while building the crt0
code. Thanks to Yuriy Kolerov.
Avoid linking in malloc when using bufio with static FILEs.
Picolibc release 1.8.10
Add missing POSIX constants to limits.h.
Add Renesas RX support. Thanks to Duy Dguyen.
Update to Unicode 16.0. This matches glibc 2.41.
Add TLS support and testing on loongarch, m68k, or1k, powerpc and
superh.
Fix a couple of strncpy bugs in ARC assembly code.
Clean up preprocessor symbols: remove unused symbols, rename
picolibc.h symbols to use a __ prefix and not include PICOLIBC or
NEWLIB in the names.
Detect compiler attributes and builtins at compile time rather than
configure time where possible. Delete attributes and builtins not
used within the library implementation.
Remove non-standard elf.h and mstats API.
Clean up float predicates to make sure we provide implementations
of isinf, isnan and finite for all three types, both with and
without prefixes. Use symbol aliases to share the same function
implementation. Use the versions for the type generic macros
instead of fpclassify. Switch users of these within the math
library to use the type-generic versions.
Start SuperH FPU in single mode when required.
Test sh1 and sh2 targets using the binutils simulator.
Initialize PowerPC IPLT table at startup.
Switch printf/scanf aliases to prefer —printf=/—scanf= compiler
options
Control UCS-2 and UCS-4 locales with mb-ucs-charsets configuration
option.
Add stdio-locking option to provide full POSIX re-entrancy support
in tinystdio. Thanks to Alexey Lapshin.
Add wcsto* string to number functions using tinystdio conversion
code. Avoids malloc call for float conversions.
Add TLS API support for x86 targets. Thanks to TK Chia.
Add -fsanitize=undefined handlers and make library build with that
enabled.
Picolibc release 1.8.9
Use common clang/gcc feature detection macros on arm.
Additional clang/compiler-rt work-arounds for arm which is less
consistent in handling exceptions.
Use clang multilib support for aarch64
Build fix on arc which would build two strchr versions in release
mode.
Add picocrt and semihost support for xtensa. Test xtensa dc233c.
Add C11’s <uchar.h> header and implementation.
Add nano-malloc-clear-freed option to erase memory released in free
or realloc.
Add memset_explicit from C23.
Work around broken clang builtin malloc which fails to set errno.
Widen C++ _CTYPE_DATA array to fix mis-classification of \t; C++
requires bitmasks for all ctype operations, and 8 bits is not
enough. Thanks to M-Moawad.
Update case conversion tables to Unicode 15.1.0
Fix documentation formatting. Thanks to Eduard Tanase.
Fix support for using long-long vfprintf version by default. Thanks
to Louis Peens.
Remove arm unaligned memcpy asm code. This couldn’t support targets
that only supported unaligned access. Use a new faster C version
for this case.
Add asnprintf and vasnprintf as provided by newlib
Support ARM’s FVP emulator. Thanks to Oliver Stannard.
Remove arc strlen asm code as it would access memory before the
provided buffer and fall afoul of the stack bounds checking
hardware.
Support —printf={d,f,l,i,m} in place of
-DPICOLIBC*PRINTF_SCANF. This is the syntax proposed in the
patches submitted to gcc for picolibc support.
Add LoongArch support, including testing. Thanks to Jiaxun Yang.
Use new picolibc-ci-tools project which builds custom toolchain
bits automatically. Thanks to Jiaxun Yang.
Add OpenRisc support, including testing. Thanks to Joel Holdsworth.
Add LatticMico32 support, including testing. Thanks to Jiaxun Yang.
Add MIPS semihosting support. Thanks to Jiaxun Yang.
Add older GCC compiler support, including versions < 4.4. Thanks to
Joel Holdsworth.
Add coreboot configurations and tests. Thanks to Jeremy Bettis and
Jon Murphy.
Fix numerous charset conversion errors for non-Unicode locales.
Make sure malloc return is aligned by using max_align_t. Thanks to
Alex Richardson.
Replace iconv and locale implementations with smaller code offering
the same locale functionality as before while the iconv code shares
the same charset support as the locale code instead of having a
completely separate implementation.
Picolibc release 1.8.8
Fixed 3 bugs in the powf computation. Thanks to Fabian Schriever.
Fixed a bunch of build issues found by Zephyr.
Improve C++ testing and compatibility.
Picolibc release 1.8.7
Support ARM v8.1-m BTI and PAC features
Fix stdio buffered backend automatic flushing of stdout when
reading stdin.
Support _FORTIFY_SOURCE=3
Fix several fesetround implementations to return an error when
passed an invalid argument. Thanks to Abdallah Abdelhafeez.
Document headers which the compiler must provide. Thanks to Alexey
Brodkin.
Generate mktemp/tmpnam filenames using random() so they don’t
repeat even if they aren’t used before another name is generated.
Set error flag when fgetc is called on an file without read
mode. Thanks to Mohamed Moawad.
Add type casting to CMPLX, CMPLXF and CMPLXL macros (as glibc
does). Thanks to Mostafa Salman.
Add mips64 support and build the library during CI.
Make fgets return any accumulated string on EOF instead of
always returning NULL. Thanks to Hana Ashour.
Use C99 minimum array size in asctime_r and ctime_r API
declarations (’[static 26]’). Bounds check the generated value and
return NULL/EOVERFLOW on overflow.
Make Zephyr’s -Oz cmake option enable
PREFER_SIZE_OVER_SPEED. Thanks to Jonathon Penix.
Add funopen to tinystdio.
Validate all public headers with a C++ compiler to make sure they
at least compile successfully. Fix time.h.
Stop using -include picolibc.h during library build.
Add -Wmissing-declarations and -Wmissing-prototypes to library
build flags. Fix a rather large pile of missing prototypes caused
by source files failing to add GNU_SOURCE or DEFAULT_SOURCE
definitions.
Add POSIX “unlocked” I/O functions to tinystdio. These don’t
actually do anything because tinystdio doesn’t do any
locking. However, flockfile/funlockfile grab the global C library
lock so applications synchronizing with that API will “work”.
Fix wide orientation handling in tinystdio. Thanks to Ahmed Shehab.
Add aarch64 soft float support for armv8. Clang allows this with
-march=armv8-a+nofp -mabi=aapcs-soft. This required building a
custom toolchain that included a compiler-rt library built with the
right options.
Add fgetpos and fsetpos to tinystdio. Thanks to Hana Ashour.
Restore missing members of ‘struct sigevent’. Over eager removal of
_POSIX_THREADS support caused these to be accidentally deleted some
time ago.
Test on i386 native target.
Fix hex float scanning and printing. Thanks to Hana Ashour and
Ahmed Shehab.
Fix double rounding in %f printf. Thanks to Ahmed Shehab for
constructing a test case that identified the issue.
Add mem_align to the “big” malloc version. Thanks to Simon Tatham.
Adjust POSIX and C headers to limit symbol exposure to that
specified in the standards.
Fix rounding in float scanf. This does round twice for input longer
than the required number of digits, but that’s permitted by the C
specification.
Support %a/%A in scanf. Support arbitrary precision in %a/%A
printf. Fix NaN/INF formatting in %a/%A printf. Thanks to Ahmed
Shehab.
Provide a build-time option to enable %n in printf. This is
disabled by default for security concerns, but supported in case
someone needs strict C conformance. Thanks to Ahmed Shehab.
Make freopen clear the unget buffer. Thanks to Mostafa Salman.
Fix wide and multi-byte character support in printf and scanf. For
strict standards conformance, there’s now an option that enables
%lc/%ls in printf even if multi-byte support is not enabled.
Enable MMU in picocrt on A profile ARM and AARCH64 targets when
present. This is required by the latest qemu which now more
accurately emulates this hardware. Thanks to Alex Richardson.
Fix AARCH64 asm code in ILP32 mode.
Parse NaN() in sscanf. This is required by the standard,
although picolibc doesn’t do anything with . Thanks to
Mohamed Moawad.
Clean up header files. Picolibc tries to limit symbol definitions
to those specified in the C and POSIX specs.
Add support for C’s Annex K functions. These are bounds-checking
versions of various memory and string functions. Thanks to Mostafa
Salman.
Perform locale string validation in newlocale even when _MB_CAPABLE
isn’t defined. Thanks to Mostafa Salman.
Place compiler-rt library after C library when linking
tests. Thanks to Oliver Stannard.
Picolibc version 1.8.6
Fix some FORTITY_SOURCE issues with tinystdio
Add _eh* symbols to picolibc.ld for LLVM libunwind. Thanks Alex
Richardson.
Merge in newlib annual release (4.4.0). Some minor updates to
aarch64 assembly code formatting (thanks to Sebastian Huber) and a
few other fixes.
Enable 32-bit SPARC for testing.
Fix a bunch of fmemopen bugs and add some tests. Thanks to Alex
Richardson.
Finish support for targets with unusual float types, mapping
target types to 32-, 64-, 80- and 128- bit picolibc code.
Add SuperH support, including testing infrastructure. Thanks to
Adrian Siekierka for help with this.
Improve debugger stack trace in risc-v exception code. Thanks to
Alex Richardson.
Add an option (-Dfast-bufio=true) for more efficient fread/fwrite
implementations when layered atop bufio. Thanks for the suggestion
from Zachary Yedidia.
Fix cmake usage of FORMAT_ variables (note the lack of a leading
underscore).
Remove explicit _POSIX_C_SOURCE definition in zephyr/zephr.cmake.
Clean up public inline functions to share a common mechanism for
using gnu_inline semantics. Fix isblank. This ensures that no
static inline declarations exist in public API headers which are
required to be external linkage (”real”) symbols.
Create an alternate ctype implementation that avoids using the
ctype array and just does direct value comparisons. This only
works when picolibc is limited to ASCII. Applications can select
whether they want this behavior at application compilation time
without needing to rebuild the C library. Thanks to P. Frost for
the suggestion.
Unify most fenv implementations to use gnu_inline instead of
regular functions to improve performance. x86 was left out because
those fenv functions are complicated by the mix of 8087 and modern
FPU support.
Add a separate FILE for stderr when using POSIX I/O. Split
stdin/stdout/stderr into three files to avoid pulling in
those which aren’t used. Thanks to Zachary Yedidia.
Picolibc version 1.8.5
Detect clang multi-lib support correctly by passing compiler flags.
Thanks to xbjfk for identifying the problem.
Create a new ‘long-long’ printf variant. This provides enough
variety to satisfy the Zephyr cbprintf options without needing to
build the library from scratch.
Adjust use of custom binary to decimal conversion code so that it
is only enabled for types beyond the register size of the
target. This avoids the cost of this code when the application is
already likely to be using the soft division routines.
Picolibc version 1.8.4
Make math overflow and underflow handlers respect rounding modes.
Add full precision fma/fmaf fallbacks by adapting the long-double
code which uses two floats/doubles and some careful exponent
management to ensure that only a single rounding operation occurs.
Fix more m68k 80-bit float bugs
Fix m68k asm ABI by returning pointers in %a0 and %d0
Use an m68k-unknown-elf toolchain for m68k testing, including
multi-lib to check various FPU configurations on older and more
modern 68k targets.
Improve CI speed by using ccache on zephyr and mac tests,
compressing the docker images and automatically canceling jobs when
the related PR is updated. Thanks to Peter Jonsson.
Move a bunch of read-only data out of RAM and into flash by adding
‘const’ attributes in various places.
Add a new linker symbol, __heap_size_min, which specifies a
minimum heap size. The linker will emit an error if this much space
is not available between the end of static data and the stack.
Fix a bunch of bugs on targets with 16-bit int type. Thanks to
Peter Jonsson for many of these.
Work around a handful of platform bugs on MSP430. I think these are
compiler bugs as they occur using both the binutils simulator and
mspsim.
Run tests on MSP430 using the simulator that comes with gdb. Thanks to
Peter Jonsson for spliting tests apart to make them small enough to
link in under 1MB. This requires a patch adding primitive
semihosting to the simulator.
Provide a division-free binary to decimal conversion option for
printf at friends. This is useful on targets without hardware
divide as it avoids pulling in a (usually large) software
implementation. This is controlled with the ‘printf-small-ultoa’
meson option and is ‘false’ by default.
Add ‘minimal’ printf and scanf variants. These reduce functionality
by removing code that acts on most data modifers including width
and precision fields and alternate presentation modes. A new config
variable, minimal-io-long-long, controls whether that code supports
long long types.
Add a ‘assert-verbose’ option which controls whether the assert
macro is chatty by default. It is ‘true’ by default, which
preserves the existing code, but when set to ‘false’, then a
failing assert calls __assert_no_msg with no arguments, saving the
memory usually occupied by the filename, function name and
expression.
Fix arm asm syntax for mrc/mcr instructions to make clang happy.
Thanks to Radovan Blažek for this patch.
Picolibc version 1.8.3
Fix bugs in floor and ceil implementations.
Use -fanalyzer to find and fix a range of issues.
Add __ubsan_handle_out_of_bounds implementation. This enables
building applications with -fsanitize=bounds and
-fno-sanitize-undefined-trap-on-error.
Validate exception configuration on targets with mixed exception
support where some types have exceptions and others don’t. Right
now, that’s only arm platforms where any soft float implementations
don’t build with exception support.
Fix bugs in nexttowards/nextafter on clang caused by the compiler
re-ordering code and causing incorrect exception generation.
Use the small/slow string code when -fsanitize=address is used
while building the library. This avoids reading beyond the end of
strings and triggering faults.
Handle soft float on x86 and sparc targets. That mostly required
disabling the hardware exception API, along with a few other minor
bug fixes.
Add runtime support for arc, mips, nios2 and m68k. This enables CI
testing on these architectures using qemu.
Fix 80-bit floating math library support for m68k targets.
Fix arm testing infra to use various qemu models that expand
testing to all standard multi-lib configurations.
Adjust floating exception stubs to return success when appropriate,
instead of always returning ENOSYS.
Make sure sNaN raises FE_INVALID and is converted to qNaN in
truncl, frexpl and roundl
Avoid NaN result from fmal caused by multiply overflow when
addend is infinity (-inf + inf results in NaN in that case).
Picolibc version 1.8.2
Support _ZEPHYR_SOURCE macro which, like _POSIX_SOURCE et al,
controls whether the library expresses the Zephyr C library API.
This is also automatically selected when the __ZEPHYR__ macro is
defined and no other _*_SOURCE macro is defined.
Add another cross compile property, ‘libgcc’, which specifies the
library containing soft float and other compiler support routines.
Fix a couple of minor imprecisions in pow and 80-bit powl.
Merge newlib changes that included an update to the ARM assembly
code.
Replace inexact float/string conversion code with smaller code that
doesn’t use floating point operations to save additional space on
soft float targets.
More cmake fixes, including making the inexact printf and locale
options work.
Picolibc version 1.8.1
Fix cmake build system to auto-detect compiler characteristics
instead of assuming the compiler is a recent version of GCC. This
allows building using cmake with clang.
Fix cmake build system to leave out TLS support when TLS is
disabled on the cmake command line.
Replace inline asm with attributes for __weak_reference macro
Add allocation attributes to malloc and stdio functions. This
allows the compiler to detect allocation related mistakes as well
as perform some additional optimizations. Bugs found by this change
were also addressed.
Add wchar_t support to tinystdio, eliminating the last missing
feature compared with the legacy stdio bits from newlib. With this,
libstdc++ can be built with wide char I/O support, eliminating the
last missing feature there as well.
Eliminate use of command line tools when building with a new enough
version of meson. Thanks to Michael Platings.
Add Microblaze support. Thanks to Alp Sayin.
Switch semihosting to use binary mode when opening files. Thanks to
Hardy Griech.
Build and install static library versions of the crt0 startup
code. These allows developers to reference them as libraries on the
command line instead of needing special compiler support to locate
the different variants, which is useful when using clang. Thanks to
Simon Tatham.
Simplify the signal/raise implementation to use a single global
array of signal handlers and to not use getpid and kill, instead
raise now directly invokes _exit. This makes using assert and abort
simpler and doesn’t cause a large TLS block to be allocated. Thanks
to Joe Nelson for discovering the use of a TLS variable here.
Picolibc version 1.8
With the addition of nearly complete long double support in the math
library, it seems like it’s time to declare a larger version increment
than usual.
Improve arc and xtensa support, adding TLS helpers and other build fixes
Fix FPSCR state for Arm8.1-M low overhead loops (thanks to David
Green)
Add -Werror=double-promotion to default error set and fix related
errors. (thanks to Ryan McClelland)
Fix locking bug in malloc out-of-memory path and freeing a locked
mutex in the tinystdio bufio code. These were found with lock
debugging code in Zephyr.
Add some missing functions in tinystdio, strto*l_l, remove,
tmpname/tmpfile which were published in stdio.h but not included in
the library.
Switch read/write functions to use POSIX types instead of legacy
cygwin types. This makes mapping to existing an POSIX api work
right.
Add %b support to tinystdio printf and scanf. These are disabled by
default as they aren’t yet standardized.
Fix avr math function support. The avr version of gcc has modes
where double and long double are 32 or 64 bits, so the math library
code now detects all of that at compile time rather than build time
and reconfigures the functions to match the compiler types.
Add nearly complete long double support from openlibm for 80-bit
Intel and 128-bit IEEE values (in addition to supporting 64-bit
long doubles). Still missing are Bessel functions and decimal
printf/scanf support.
Add limited long double support for IBM ‘double double’ form. This
is enough to run some simple tests, but doesn’t have any
significant math functions yet.
Get Power9 code running under qemu with OPAL. This was mostly
needed to validate the big-endian and exception code for 128-bit
long doubles, but was also used to validate the double double
support.
Provide times() and sysconf() implementations in semihosting. You
can now build and run the dhrystone benchmark without any further
code.
Fix use of TLS variables with stricter alignment requirements in
the default linker script and startup code. (thanks to Joakim
Nohlgård and Alexander Richardson who found this issue while
working on lld support).
Picolibc version 1.7.9
Support all Zephyr SDK targets
Support relocating the toolchain by using GCC_EXEC_PREFIX for
sysroot-install when compiler doesn’t use sysroot.
Add MIPS, SPARC and ARC support
Deal with RISC-V changes in gcc that don’t reliably include zicsr
Support Picolibc as default C library with -Dsystem-libc option.
With this, you can use picolibc without any extra compiler options.
Merge current newlib bits to get code that doesn’t use struct _reent
Get rid of struct _reent in legacy stdio code
Support 16-bit int targets by fixing a few places assuming
sizeof(int) == 4, object sizes not using size_t, wint_t for
ucs-4 values
Add MSP430 support
Fix a couple of clang bugs (one on Cortex M0)
Support libc++ by adding non-standard mbstate_t.h
Merge i686 and x86_64 code to allow x86 multilib builds
Merge Xtensa newlib bits
Support Xtensa ESP32 targets
Add Nios II support
Picolibc version 1.7.8
Fix el/ix level 4 code type errors
Fix out-of-source CMake build (thanks Max Behensky)
Improve build.md docs (thanks Kalle Raiskila)
Fix cmake build for various architectures
Initialize lock in fdopen
Remove %M from linker paths in single-arch builds
Shrink tinystdio vfprintf and vfscanf a bit
Use -fno-builtin-malloc -fno-builtin-free (GCC 12 compat)
Use -fno-builtin-copysignl (GCC 12 compat)
Add _zicsr to -march for risc-v picocrt (binutils 2.38 compat)
Add -no-warn-rwx-segments to link spec (binutils 2.38 compat)
Picolibc version 1.7.7
Fix semihost gettimeofday, add a test.
Fix config option documentation. (Thanks to rdiez)
Document how re-entrant locking APIs are used. (Thanks to rdiez)
Fix some 16-bit int issues in tinystdio. (Thanks to Ayke van
Laethem)
Make header files a bit more POSIX compliant, installing rpc
headers, moving byte swapping macros to arpa/inet.h
Fix some stdio bugs found by Zephyr test suite: snprintf return
value on buffer overflow, add ftello/fseeko, fputc return value,
%0a formatting, clear EOF status after ungetc/fseek.
Re-do buffered I/O support to handle mixed read/write files
correctly. This adds setbuf, setbuffer, setlinebuf, setvbuf.
Add fmemopen and freopen.
Add enough cmake support to allow Zephyr to build picolibc as a
module using that, rather than meson.
Merge current newlib bits
Fix %p printf/scanf on ILP64 targets.
Picolibc version 1.7.6
Fix use with C++ applications caused by a syntax error in
picolibc.specs
Automatically include ’-nostdlib’ to options used while
evaluating build rules to ensure tests work as expected.
Publish aarch64 inline math functions, ensure that inline fma
functions work in installed applications for arm and risc-v.
Picolibc version 1.7.5
Fix build on big-endian systems (thanks to Thomas Daede)
Add m68k support (thanks to Thomas Daede).
Fix build issues with ARM Cortex-a9 target (thanks to Ilia
Sergachev).
Fix fwrite(x,0,y,z) in both tinystdio and legacy stdio. tinystdio
returned the wrong value and legacy stdio caused a divide-by-zero
fault.
Update Ryu code to match upstream (minor fixes)
Fix various NEWLIB and PICOLIBC macros; they were using a
single leading underscore instead of two (thanks to Vincent
Palatin).
Fix tinystdio error-handling bugs
Merge recent newlib changes (fixed ltdoa in legacy stdio)
Speed improvements for github CI system
Big-endian PowerPC support
Fail builds if most ‘run_command’ uses fail (thanks to Johan de
Claville Christiansen)
Positional parameters in tinystdio. With this, I think tinystdio
is feature complete.
Support for multiple build-styles of picolibc (minsize/release)
in one binary package. This still requires separate meson runs.
Testing with glibc test code. This uncovered numerous bugs,
mostly math errno/exception mistakes, but also a few serious
bugs, including a couple of places where the nano-malloc failed
to check for out-of-memory. Picolibc now passes all of the glibc
math tests except for jn, yn, lgamma and tgamma. The picolibc
versions of those functions are too inaccurate. Picolibc also
passes most other relevant glibc tests, including stdio,
string and stdlib areas.
Tinystdio version of fcvt now has a static buffer large enough to
hold the maximum return size.
Tinystdio versions of ecvtbuf and fcvtbuf have been replaced
with ecvt_r and fcvt_r equivalents, which take a ‘len’ parameter
to prevent buffer overruns.
Add the GeneratePicolibcCrossFile.sh script which provides a way
to isolate picolibc build scripts from the vagaries of meson
version shifts (thanks to R. Diez).
Add ‘semihost’ version of crt0 that calls ‘exit’ after main
returns. The ARM and RISC-V versions of this also include trap
handlers for exceptions that print out information and exit when
an exception occurs.
Picolibc version 1.7.4
Clean up meson build bits, including use of ‘fs module (thanks to
Yasushi Shoji).
Speed up github actions by sharing Debian docker image (thanks to
Yasushi Shoji).
Reduce use of intermediate static libraries during build
Use standard Meson architecture names everywhere (thanks to
Yasushi Shoji).
Support building with -D_FORTIFY_SOURCE enabled.
Clean up 32-bit arm assembly code, eliminating __aeabi wrappers
where possible.
Add basename, dirname and fnmatch back.
Fix all old-style (K&R) function definitions.
Enable lots more compiler warning flags.
Remove last uses of alloca in legacy stdio code.
Add tests from musl libc-testsuite. There aren’t many tests, but
these identified a few bugs.
Add lots more exception and errno tests for the math functions.
Restructure math library to always use the math_err functions
to raise exceptions and set errno. This removes the w_*.c wrapper
functions and eliminates the ieee names. This centralizes
compiler work-arounds to ensure run-time evaluation of
expressions intended to raise exceptions. In the process, all of
the libm/math files were reformatted with clang-format.
Make tinystdio ’%a’ compatible with glibc, including supporting
rounding and trimming trailing zeros when possible.
Remove floating point exception generation code on targets
without floating point exception support. This reduces code size
on soft float machines without affecting results.
Picolibc version 1.7.3
Add -Wall -Wextra to default builds. Fixed warnings this raised.
Add htonl and friends (based on __htonl). Thanks to Johan de
Claville Christiansen
Set errno in scalbn and scalbnf (patch forwarded to newlib).
Merge newlib recent changes which includes a couple of libm fixes.
Picolibc version 1.7.2
Fix picolibc.ld to split C++ exceptions back apart (thanks to
Khalil Estell)
Add vsscanf to tinystdio (required for libstdc++).
Also stick -isystem in C++ compile command to try and get
picolibc headers to be used instead of newlib.
Picolibc version 1.7.1
Add __cxa_atexit implementation to ‘picoexit’ path as required by
C++
Fix lack of ‘hh’ support in integer-only tinystdio printf path.
Fix tinystdio __file flag initialization for C++ apps
Picolibc version 1.7
Merge libc and libm into a single library. Having them split
doesn’t offer any advantages while requiring that applications add
’-lm’ to link successfully. Having them merged allows use of libm
calls from libc code.
Add hex float format to printf, scanf and strto{d,f,ld}. This is
required for C99 support.
Unify strto{d,f,ld} and *scanf floating point parsing code. This
ensures that the library is consistent in how floats are parsed.
Make strto{d,f,ld} set errno to ERANGE on overflow/underflow,
including when the result is a subnormal number.
Picolibc version 1.6.2
Change restrict keyword in published headers to __restrict to
restore compatibility with applications building with —std=c18.
Additional cleanups in time conversion funcs (Thanks to R. Riez)
Picolibc version 1.6.1
Code cleanups for time conversion funcs (Thanks to R. Diez)
Add ’-fno-stack-protector’ when supported by the C compiler
to avoid trouble building with native Ubuntu GCC.
Bug fix for converting denorms with sscanf and strto{d,f,ld}.
Use asm for inline asm code to allow building applications
with —std=c18
Fix exit code for semihosting ‘abort’ call to make it visible
to the hosting system.
Add strfromf and strfromd implementations. These are simple
wrappers around sscanf, but strfromf handles float conversions
without requiring a pass through ‘double’ or special linker hacks.
Picolibc version 1.6
Bugfix for snprintf(buf, 0) and vsnprintf(buf, 0) to avoid
smashing memory
Support building libstdc++ on top of picolibc
Add ‘hosted’ crt0 variant that calls exit when main
returns. This makes testing easier without burdening embedded apps
with unused exit processing code.
Add ‘minimal’ crt0 variant that skips constructors to
save space on systems known to not use any.
Fix HW floating point initialization on 32-bit ARM processors to
perform ‘dsb’ and ‘isb’ instructions to ensure the FPU enabling
write is complete before executing any FPU instructions.
Create a new ’—picolibc-prefix’ GCC command line parameter that
sets the base of all picolibc file names.
Add bare-metal i386 and x86_64 initializatiton code (thanks to
Mike Haertel). These initalize the processor from power up to
running code without requiring any BIOS.
Merge newlib as of late April, 2021
Add ‘timegm’ function (thanks to R. Diez).
Fix a number of tinystdio bugs: handle fread with size==0, parse
‘NAN’ and ‘INF’ in fscanf in a case-insensitive manner, fix
negative precision to ’*’ arguments in printf, fix handling of
‘j’, ‘z’ and ‘t’ argument size specifiers (thanks to Sebastian
Meyer).
Make the fenv API more consistent and more conformant with the
spec. All architectures now fall back to the default code
for soft float versions, which avoids having the various exception
and rounding modes get defined when not supported.
Picolibc version 1.5.1
- Make riscv crt0 ‘_exit’ symbol ‘weak’ to allow linking without
this function.
Picolibc version 1.5
Make picolibc more compatible with C++ compilers.
Add GCC specs file and linker script for building C++ applications
with G++ that enable exception handling by linking in call stack
information.
A few clang build fixes, including libm exception generation
Nano malloc fixes, especially for ‘unusual’ arguments
Merge in newlib 4.1.0 code
More libm exception/errno/infinity fixes, mostly in the gamma funcs.
Add tests for all semihost v2.0 functions.
A few RISC-V assembly fixes and new libm code.
Build fixes to reliably replace generic code with
architecture-specific implementations.
With a patch which is pending for GCC 11, we’ll be able to build C++
applications that use picolibc with exceptions and iostream.
Picolibc version 1.4.7
Fix numerous libm exception and errno bugs. The math functions are
all now verified to match the C19 and Posix standards in this
area.
Change behavior of ‘gamma’ function to match glibc which returns
lgamma for this function. Applications should not use this
function, they should pick either lgamma or tgamma as appropriate.
Fix fma/fmaf on arm and RISC-V so that the machine-specific versions
are used when the hardware has support. Also fix the math library
to only use fma/fmaf when it is supported by the hardware.
Fix numerous nano-malloc bugs, especially with unusual parameters.
Change nano-malloc to always clear returned memory.
Improve nano-realloc to perform better in various ways, including
merging adjacent free blocks and expanding the heap.
Add malloc tests, both a basic functional test and a stress test.
Improve build portability to Windows. Picolibc should now build
using mingw.
Use hardware TLS register on ARM when available.
Support clang compiler. Thanks to Denis Feklushkin
[email protected] and Joakim Nohlgård [email protected].
Avoid implicit float/double conversions. Check this by having
clang builds use -Wdouble-promotion -Werror=double-promotion
flags
Have portable code check for machine-specific overrides by
matching filenames. This avoids building libraries with
duplicate symbols and retains compatibility with newlib (which
uses a different mechanism for this effect).
Patches to support building with CompCert, a
formally verified compiler. Thanks to Sebastian Meyer
[email protected].
Documentation
There’s a bunch of documentation written in common mark, which this
ikiwiki instance doesn’t handle, so for now here are links to the pages
rendered at github:
Debian Packages
Pre-built Debian packages for Debian unstable are available upstream
There are four Picolibc packages in the archive:
picolibc-riscv64-unknown-elf. RISC-V embedded libraries, built using
gcc-riscv64-unknown-elf.
picolibc-arm-none-eabi. ARM embedded libraries, built using
gcc-arm-none-eabi
picolibc-xtensa-lx106-elf. ESP8266 Xtensa lx106 embedded libraries,
built using gcc-xtensa-lx106-elf.
picolibc-aarch64-linux-gnu. 64-bit ARM embedded libraries, built using
gcc-aarch64-linux-gnu (that’s the only compiler for this architecture).
Source Code
You can find Picolibc in either my git repository or
github
As Picolibc is a combination of code from both Newlib and AVR-libc,
the licensing of the source code is fairly complicated, but the
general result is similar to the BSD 3-clause or MIT license.
Contributing
Changes to picolibc code, or to the picolibc build environment, can be
submitted in the github project above, or to the picolibc mailing
list. Changes to code
shared with newlib should also be submitted to newlib.
|