Main Content

Troubleshoot Long Build Times for Real-Time Application

The model build process for my Simscape™ Multibody™ models is slow and uses an unexpected amount of memory.

What This Issue Means

The default QNX® Neutrino® compiler switches for Simulink® Real-Time™ apply optimizations that lead to long build times or slow builds for some complex models, such as Simscape Multibody models.

Try This Workaround

To improve the real-time application build speed, change the compiler switch selections from the default selections by adding the -fdisable-rtl-sched2 switch for the C/C++ compiler:

  1. Open your Simulink Real-Time model.

  2. In the Simulink Editor, from the Real-Time tab, select Hardware Settings.

  3. Select Code Generation > Build configuration > Specify

  4. Click the C Compiler options and add option -fdisable-rtl-sched2.

  5. Click the C++ Compiler options and add option -fdisable-rtl-sched2.

  6. Click Apply and OK.

After updating the compiler options, the options appear as shown.

Update the model C Compiler and C++ Compiler options.

If you prefer to use a programmatic approach to update these compiler switches, you could use this code.

% add a compiler flag '-fdisable-rtl-sched2'

set_param(modelName, 'BuildConfiguration', 'Specify');
options = get_param(modelName, 'CustomToolchainOptions');
ccompiler_idx = find(strcmp(options, 'C Compiler'));
cppcompiler_idx = find(strcmp(options, 'C++ Compiler'));
options{ccompiler_idx+1} = ...
    [options{ccompiler_idx+1} ' -fdisable-rtl-sched2'];
options{cppcompiler_idx+1} = ...
    [options{cppcompiler_idx+1} ' -fdisable-rtl-sched2'];
set_param(modelName, 'CustomToolchainOptions', options);

External Websites