Nios® V Processor Software Developer Handbook

ID 743810
Date 10/02/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

4.2.4.4. Configuring Optimization and Debugger Options

You can specify the optimization and debug level for the application and BSP projects, and any user library projects you might be using. Use the BSP Editor settings hal.make.cflags_debug and hal.make.cflags_optimization to specify the optimization and debug level for the whole project.

Configuring the hal.make.cflags_debug and hal.make.cflags_optimization sets the optimization and debug levels to be the same for the application, the BSP, and all user libraries in a software project. This is to prevent mix settings that disable debuggability to those components which do not have debug settings. For example, if you compile your BSP only with the -O0 flag and without the -g flag, you cannot step into the newlib printf() function.
  • To configure the whole software project for debugging:

    When creating a new BSP:
    niosv-bsp --create --qsys=<Platform Designer system> --type=hal 
    --cmd=”set_setting hal.make.cflags_debug {-g}” --cmd=”set_setting
    hal.make.cflags_optimization {-O0}” settings.bsp
    When updating an existing BSP:
    niosv-bsp --update --cmd=”set_setting hal.make.cflags_debug {-g}” 
    --cmd=”set_setting hal.make.cflags_optimization {-O0}” settings.bsp

    When your project is fully debugged and ready for release, you might want to enable optimization and omit the symbol table, to achieve faster, smaller executable code. To enable optimization and turn off the symbol table, edit the BSP Editor settings as shown in the following example. The absence of a value in hal.make.cflags_debug causes the compiler to omit generating a symbol table.

  • To configure the whole software project for release:
    When creating a new BSP:
    niosv-bsp --create --qsys=<Platform Designer system> --type=hal 
    --cmd=”set_setting hal.make.cflags_debug {none}” --cmd=”set_setting hal.make.cflags_optimization {-O3}” settings.bsp
    When updating an existing BSP:
    niosv-bsp --update --cmd=”set_setting hal.make.cflags_debug {none}” 
    --cmd=”set_setting hal.make.cflags_optimization {-O3}” settings.bsp