﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4140	Questionable compiler options (-O0 -march=native) when building FMUs	anatoly.trosinenko@…	Martin Sjölund	"It seems that Open Modelica builds FMUs with options including {{{-O0 -march=native}}} on Linux.

== How to reproduce ==
1. Open terminal window and run {{{sudo execsnoop | less}}}.
2. Build some FMU with OMEdit (cross compilation is off)
3. Locate {{{./configure}}} invocation at the top and multiple C compiler invocations to the bottom of the log

== What really happens ==
1. {{{./configure}}} is 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
}}}
2. 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."	defect	closed	high	1.13.0	FMI	v1.11.0	fixed		
