Opened 9 years ago
Closed 8 years ago
#4140 closed defect (fixed)
Questionable compiler options (-O0 -march=native) when building FMUs
| Reported by: | Owned by: | Martin Sjölund | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.13.0 |
| Component: | FMI | Version: | v1.11.0 |
| Keywords: | Cc: |
Description
It seems that Open Modelica builds FMUs with options including -O0 -march=native on Linux.
How to reproduce
- Open terminal window and run
sudo execsnoop | less. - Build some FMU with OMEdit (cross compilation is off)
- Locate
./configureinvocation at the top and multiple C compiler invocations to the bottom of the log
What really happens
./configureis invoked like this:/bin/sh -c cd "Test.fmutmp/sources" && ./configure CC='clang' CFLAGS='-fPIC -O0 -march=native ' LDFLAGS='-L'/usr/lib/x86_64-linux-gnu/omc' -Wl,-rpath,'/usr/lib/x86_64-linux-gnu/omc' ' && make clean
- C compiler is invoked like this:
clang -fPIC -O0 -march=native -fno-stack-protector ...
What is expected
I do not know what the best optimization level is for all the usage scenarios of FMU but no optimization at all hardly fits the most trivial of them -- simulation. But -march=native seems good for local simulation but very strange for FMU intended to be run on different machine.
I have tested it with omc:
loadModel(Modelica);
loadFile("Test.mo");
buildModelFMU(
Test,
fmuType="cs",
version="2.0"
);
It seems like it is the case for omc too, but not when performing cross-compilation (platforms argument for buildModelFMU).
Maybe these options can be adjusted somewhere in the UI but -O0 -march=native are surprising defaults.
Change History (2)
comment:1 by , 8 years ago
| Milestone: | Future → 1.13.0 |
|---|---|
| Owner: | changed from to |
| Status: | new → accepted |
comment:2 by , 8 years ago
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |

Fixed in 09e106c for the coming 1.13.0 release.
Note that the optimization flags come from back when GCC was being used and compilations times with optimization were many times the simulation times (especially since only the generated code is being compiled with -O0; the numerical solvers are already optimized except when cross-compiling).