Specifications
You can control the optimization and debug level through the project makefile, which determines the
compiler options.
Example 4–5. Default Application Makefile Settings
APP_CFLAGS_OPTIMIZATION := -O0
APP_CFLAGS_DEBUG_LEVEL := -g
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 application makefile to contain the symbol definitions shown in the following
example. The absence of a value on the right hand side of the APP_CFLAGS_DEBUG_LEVEL definition causes
the compiler to omit generating a symbol table.
Example 4–6. Application Makefile Settings with Optimization
APP_CFLAGS_OPTIMIZATION := -O3
APP_CFLAGS_DEBUG_LEVEL :=
Note:
When you change compiler options in a makefile, before building the project, run make clean to
ensure that all sources are recompiled with the correct flags.
For more information about makefile editing and make clean, refer to the “Applications and Libraries”
chapter.
Related Information
Applications and Libraries on page 4-4
Configuring a BSP for Debugging
You individually specify the optimization and debug level for the application and BSP projects, and any
user library projects you might be using. You use the BSP settings hal.make.bsp_cflags_debug and
hal.make.bsp_cflags_optimization to specify the optimization and debug level in a BSP, as shown in
the “Configuring a BSP for Debugging” example.
Example 4–7. Configuring a BSP for Debugging
nios2-bsp hal my_bsp --set hal.make.bsp_cflags_debug -g \
--set hal.make.bsp_cflags_optimization -O0r
Alternatively, you can manipulate the BSP settings with a Tcl script.
You can easily copy an existing BSP and modify it to create a different build configuration.
For more information, refer to the “Copying, Moving, or Renaming a BSP” chapter.
To change the optimization and debug level for a user library, use the same procedure as for an applica‐
tion.
Note:
Normally you must set the optimization and debug levels the same for the application, the BSP,
and all user libraries in a software project. If you mix settings, you cannot debug those components
which do not have debug settings. For example, if you compile your BSP with the -O0 flag and
without the -g flag, you cannot step into the newlib printf() function.
Related Information
Copying, Moving, or Renaming a BSP on page 4-9
4-18
Configuring a BSP for Debugging
NII5V2
2015.05.14
Altera Corporation
Nios II Software Build Tools
Send Feedback