Opened 7 years ago

Last modified 3 years ago

#4540 new defect

Cannot change CFLAGS for C++ FMI simulations

Reported by: Martin Sjölund Owned by: somebody
Priority: high Milestone:
Component: Cpp Run-time Version:
Keywords: Cc: Rüdiger Franke, Niklas Worschech

Description

The C++ runtime does not respect the optimization flags set by the user using the setCFlags() API function (and additionally you cannot query which flags are being used from within OM).

Change History (9)

comment:1 by Rüdiger Franke, 7 years ago

The current practice is to manually modify the automatically generated <modelName>.makefile in the working directory and call

   make -f <modelName>.makefile

to get different compiler optimizations applied.

It would indeed be good if these flags could be changed within the automatic process. Where do you enter CFLAGS in OMEdit?

comment:2 by Martin Sjölund, 7 years ago

In Simulation Setup:

C/C++ Compiler Flags (Optional): textbox

This option is accepted by the C++ makefiles (uses translateModel(M, cflags="...")). But, setCFlags() which is supposed to do the same thing is not accepted.

translateModelFMU does not accept the cflags="..." optional argument.

comment:3 by Rüdiger Franke, 7 years ago

Hmm... The simulators of the C and Cpp runtime are compiled with -O0 per default. Specifying -O2 in the textbox results in both: -O0 ... -O2. Doesn't appear hard to implement. Does neither look like change CFLAGS; more like a means to add something missing, like an include path.

Should -O0 possibly be removed from the default flags?
Moreover, couldn't the textbox be placed under Tools->Options->Simulation, next to Target Compiler?

How to treat the -gflag?

Last edited 7 years ago by Rüdiger Franke (previous) (diff)

comment:4 by Martin Sjölund, 7 years ago

-g is not in the default flags. -O0 -O2 is identical to -O2 so having it in the default flags doesn't hurt and it is indeed changing the level (but also doesn't actually do anything, so it can be removed); note that with setCFlags() you do change the flag and can remove the default (including -fPIC which is necessary for compilation to succeed).

comment:5 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:6 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:7 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:8 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:9 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.