Skip to content

Support multiple newlib variants (normal and nano) #152

@stephanosio

Description

@stephanosio

The Newlib library, included as part of embedded toolchains (e.g. GNU ARM Embedded), is often available in two forms: normal (libc.a, libg.a, ...) and nano (libc_nano.a, libg_nano.a,, ...).

Zephyr SDK only builds the nano-like variant as the main C runtime library used by the GCC (libc.a, libg.a, ...), and this yields an unacceptable level of performance for essential runtime functions (e.g. memset and memcpy), as detailed in the issue #151.

This is partly due to the inherent limitation of crosstool-ng, which is used to build the toolchains including GCC and Newlib, that it does not allow specifying multiple newlib build configurations for single target; hence, making it impossible for the normal and nano newlib variants to coexist.

Since the performance limitations of the nano variant is so severe, it is imperative that both variants are available in the Zephyr SDK to support a wide variety of devices.

Using the ARM microcontroller architectures as an example, it would be desirable to link the nano variant for the Cortex-M0 and -M0+ devices where the available memory space is very limited, while the normal variant would be more desirable for the less memory-constrained Cortex-M3 and -M4 devices; as for Cortex-M7, there would be no justification whatsoever for linking the nano variant given its performance limitations.

In order to support multiple newlib variants, the following changes should be implemented:

  1. Add nano variant-specific newlib configurations to the crosstool-ng (crosstool-ng/config/libc/newlib.in).

    • Keep all LIBC_NEWLIB_... configs as is. These configurations will be used to build the normal variant (libc.a, libg.a ...).
    • Mirror all LIBC_NEWLIB_... configs to LIBC_NANO_NEWLIB_... configs. These configurations will be used to build the nano variant (libc_nano.a, libg_nano.a ...).
  2. Modify crosstool-ng build script to build LIBC and LIBC_NANO variants separately.

  3. Apply newlib normal and nano variant configurations (based on the GNU ARM Embedded build script) to the Zephyr SDK crosstool-ng build configs.

    • Apply normal variant configurations to LIBC_NEWLIB_... configs.
    • Apply nano variant configurations to LIBC_NANO_NEWLIB_... configs.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions