Nios II Classic Software Developer’s Handbook

ID 683282
Date 5/14/2015
Public
Document Table of Contents

4.4.3.4. Creating a Custom Version of newlib

The Nios II EDS comes with a number of precompiled libraries. These libraries include the newlib libraries (libc.a and libm.a). The Nios II SBT allows you to create your own custom compiled version of the newlib libraries.

To create a custom compiled version of newlib, set a BSP setting to the desired compiler flags. If you are using nios2-bsp, type the following command:

nios2-bsp hal my_bsp --set hal.custom_newlib_flags "-O0 -pg"

Because newlib uses the open source configure utility, its build flow differs from other files in the BSP. When Makefile builds the BSP, it runs the configure utility. The configure utility creates a makefile in the build directory, which compiles the newlib source. The newlib library files are copied to the BSP directory named newlib. The newlib source files are not copied to the BSP.

Note: The Nios II SBT recompiles newlib whenever you introduce new compiler flags. For example, if you use compiler flags to add floating point math hardware support, newlib is recompiled to use the hardware. Recompiling newlib might take several minutes.
For the most up-to-date list of precompiled libraries and the corresponding switches, enter the following command:
nios2-elf-gcc --print-multi-lib

For more information about Nios II specific flags, refer to the "Nios II Options" section in the GCC online documentation.