Main Content

Compiler optimization level


Control compiler optimizations for building generated code, using flexible, generalized controls.


This parameter only appears when the model is configured to use a template makefile-based code generation target, as described in Configure Toolchain or Template Makefile Build Process.

Category: Code Generation


Default: Optimizations off (faster builds)

Optimizations off (faster builds)

Customizes compilation during the build process to minimize compilation time.

Optimizations on (faster runs)

Customizes compilation during the makefile build process to minimize run time.


Allows you to specify custom compiler optimization flags to be applied during the makefile build process.


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

  • Custom allows you to enter custom compiler optimization flags at Simulink® GUI level, rather than editing compiler flags into template makefiles (TMFs) or supplying compiler flags to make commands.

  • 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.


This parameter enables Custom compiler optimization flags.

Command-Line Information

Parameter: RTWCompilerOptimization
Type: character vector
Value: 'off' | 'on' | 'custom'
Default: 'off'

Recommended Settings

DebuggingOptimizations off (faster builds)
TraceabilityOptimizations off (faster builds)
EfficiencyOptimizations on (faster runs) (execution), No impact (ROM, RAM)
Safety precautionNo impact

Related Topics