Article ID: 000078613 Content Type: Troubleshooting Last Reviewed: 09/14/2011

Compiler Flags for Building Custom Newlib

Environment

    Quartus® II Subscription Edition
    Nios® II Embedded Design Suite (EDS)
    Nios® II Processor
    Nios® II (Classic) Processor
BUILT IN - ARTICLE INTRO SECOND COMPONENT

Critical Issue

Description

“Common BSP Tasks” in the Nios II Software Build Tools chapter of the Nios II Software Developer’s Handbook describes how to compile a custom version of the newlib library. However, it does not list the compiler flags that must be selected to generate the correct library.

Resolution

The missing information is as follows:

The Nios II EDS provides a number of precompiled newlib implementations. The provided libraries are precompiled with every viable combination of the GCC compiler flags shown in .

When you create a BSP with a precompiled newlib, the Nios II SBT selects the newlib matching your BSP’s compiler settings. When you create a custom newlib, you must ensure that the compiler flags listed in match your BSP’s settings.

GCC Compiler Options for Newlib
Option NamePurpose
-pg Link for profiling with gprof
-EB Generate big-endian code
-mstack-checkEnable stack checking
-mno-hw-mul Disable use of the mul family of instructions
-mhw-mulx Enable use of the mulx family of instructions
-mcustom-fpu-cfg Use a floating point custom instruction

The Nios II-specific compiler flag -mcustom-fpu-cfg requires the Nios II processor core to be implemented with the floating-point custom instruction as specified in the flag argument. The compiler flag can have one of the following two argument values:

  • -mcustom-fpu-cfg=60-1--Use the Nios II floating-point custom instruction without divider
  • -mcustom-fpu-cfg=60-2--Use the Nios II floating-point custom instruction with divider

For details about the Nios II-specific compiler flags -mstack-check, -mno-hw-mul, and -mhw-mulx, refer to “Altera Nios II Options” in Using the GNU Compiler Collection (GCC), installed with the Nios II EDS. For details about the -pg compiler flag, refer to “Compiling a Program for Profiling” in GNU Profiler, installed with the Nios II EDS. To find the installed documentation, on the Windows Start menu, click Programs > Altera > Nios II EDS <version> > Nios II <version> Documentation, and then click Literature.

Related Products

This article applies to 1 products

Intel® Programmable Devices

1