Optimization Settings

About this task

OpenOCD uses three environment variables, DEBUG, BENCH, and DEBUG_OG. It is simplest to set them variables as global environment variables for all projects in your workspace. Then, you can adjust them as needed for individual projects.

Note: When you configure the SoC in the IP Manager, you can choose whether to turn on the debug mode by default or not. When you generate the SoC, the setting is saved in the /embedded_sw/bsp/efinix/EfxSapphireSoc/include/soc.mk file. If you want to change the debug mode, you can change the setting in the IP Configuration wizard and re-generate the SoC or use the following instructions to add the variables to your project and change them there.

Choose Window > Preferences to open the Preferences window and perform the following steps.

Procedure

  1. In the left navigation menu, expand C/C++ > Build.
  2. Click C/C++ > Build > Environment.
  3. Click Add to add the following environment variables:
  4. Click Apply and Close.

Results

Table 1. Environment Settings for Preferences Window
Variable Value Description
DEBUG no Enables or disables debug mode.
no: Debugging is turned off
yes: Debugging is enabled (-g3)
Note: Setting the DEBUG to no prevents you from debugging step by step in the IDE but saves memory resources.
DEBUG_OG no Enables or disables optimization during debugging.
Use an uppercase letter O not a zero.
no: No optimization for debugging (-O0 setting)
yes: Optimization for debugging (-Og setting)
BENCH no Modify the optimization level when DEBUG is set to no.
no: Optimization for size (-Os)
yes: Optimization for speed (-O3)

Alternatively, you may modify the variable through the projects's makefile similar to how it is done for coremark demo project.

PROJ_NAME=coremark
STANDALONE = ..
DEBUG=no
BENCH=yes
CFLAGS += -DITERATIONS=2000

SRCS =       $(wildcard src/*.c) \
             $(wildcard src/*.cpp) \
             $(wildcard src/*.S) \
             ${STANDALONE}/common/start.S

include ${STANDALONE}/common/bsp.mk
include ${STANDALONE}/common/riscv64-unknown-elf.mk
include ${STANDALONE}/common/standalone.mk
Note: For more information on the optimization settings, refer to https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/Optimize-Options.html