Main Content

Control Compiler Optimizations

To control compiler optimizations for a makefile build at the GUI level, use the Compiler optimization level parameter. The Compiler optimization level parameter provides

  • Target-independent values Optimizations on (faster runs) and Optimizations off (faster builds), which allow you to easily toggle compiler optimizations on and off during code development

  • The value Custom for entering custom compiler optimization flags at the Simulink® GUI level, rather than editing compiler flags into template makefiles (TMFs) or supplying compiler flags to build process make commands

The default setting is Optimizations off (faster builds). Selecting the value Custom enables the Custom compiler optimization flags field, in which you can enter custom compiler optimization flags (for example, -O2).

If you specify compiler options for your makefile build using OPT_OPTS, MEX_OPTS (except MEX_OPTS="-v"), or MEX_OPT_FILE, the value of Compiler optimization level is ignored and a warning is issued about the ignored parameter.

For a rapid simulation that uses the MinGW® compiler:

  • If RTWCompilerOptimization is set to 'on', the build process customizes compiler optimization to minimize run time. The build process ignores the BuildConfiguration and CustomToolchainOptions settings.

  • If RTWCompilerOptimization is set to 'custom' or 'off', the build process uses BuildConfiguration and CustomToolchainOptions settings. The build process ignores the RTWCompilerOptimization setting.

Related Topics