GCC can generate code for a variety of target machines. Here is some information specific to the Cortex-M MCU.
For optimal code generation, consideration should be given to microarchitecture specific details. For GCC, you may use the option -march=armv7 to specific ARMv7 (and the -M variant) Thumb2 instruction, or you can use the more specific -mcpu=cortex-m4f for more optimal code generation. JumpStart C++ for Cortex IDE automatically sets the optimal option based on the target device selection.
The GCC option -mfloat-abi=<option> controls the behavior of floating point code generation. The valid options are:
A Cortex-M4 MCU may have an optional single precision FPU and the Cortex-M7 MCU may have an optional single and double precision FPU. Even if there is an FPU, you may not want to enable the FPU for compatibility and other considerations. You can specify these options in thedialog box.
Some third-party libraries may require specific floating-point options. For example, to build FreeRTOS, you must use -mfpu=fpv5-sp-d16 and -mfloat-abi=hard.
The C library that comes with GCC is called glibc. However, glibc is written to run on big computers running an operating system such as Linux. For embedded system use, glibc is often too bloated and contains features not useful or not needed. For example, an embedded system would rarely need the full semantics of the stdio library with FILE I/O support, or C library locale support.
The “newlib” library was written to replace glibc for embedded system use, eliminating OS dependencies. For example, instead of calling OS system call to perform file I/O, it relies on board support package to write a byte to the serial port. It also uses more permissive free software licenses to eliminate concerns about GNU encumberment when using GNU code in glibc.
To further optimize for MCU targets, where memory space is limited, newlib-nano, or just nano-lib, was written to reduce code and data size, and to eliminate features not needed for MCU environment.
The GCC distribution included in JumpStart C++ includes both newlib and nano-lib with newlib being the default. To use nano-lib, use the linker options -specs nano.specs and -specs nosys.specs. These are specified automatically if you use of the IDE’s new-project wizards.