Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#3775 closed enhancement (fixed)

Support multi-platform FMUs from OMEdit

Reported by: Rüdiger Franke Owned by: Adeel Asghar
Priority: high Milestone:
Component: OMEdit Version:
Keywords: Cc: Martin Sjölund, Adrian Pop

Description

A couple of months ago the command buildModelFMU was extended with a list of platforms. See Martin's presentation at the OpenModelica workshop:

buildModelFMU(FmuExportCrossCompile, version = "2.0",
  fmuType = "me_cs", platforms = {
    // Requires osxcross manually installed
    "i386-apple-darwin15",
    "x86_64-apple-darwin15",
    // apt-get install gcc-arm-linux-gnueabihf
    "arm-linux-gnueabihf",
    "x86_64-linux-gnu",
    // apt-get install libc6-dev : i386
    "i686-linux-gnu",
    // apt-get install gcc-mingw-w64-x86-64
    "x86_64-w64-mingw32",
    // apt-get install gcc-mingw-w64-i686
    "i686-w64-mingw32"
  });

This works for the C and the Cpp runtime by now. OMEdit should allow to configure target platforms for FMI export. In the simplest case by manually entering a list of platforms in a text field under

Tools->Options->FMI

Change History (18)

comment:1 by Martin Sjölund, 9 years ago

It should be possible to create a list by searching for programs in the PATH matching [a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[g]cc, or possibly looking at /usr/lib/ or /usr/include dirs as a simple step helping the user.

comment:2 by Rüdiger Franke, 9 years ago

This would of course be better.

cd /usr/bin; ls [a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[g]cc

gives for instance:

i686-w64-mingw32-gcc  x86_64-linux-gnu-gcc

This could be used to generate a list of check boxes:

  • Tools
    • Options/FMI/Platforms
      • i686-w64-mingw32
      • x86_64-linux-gnu

The labels of the selected boxes would be passed as platforms to buildModelFMU. If nothing is selected (default setting) then no platforms are passed to buildModelFMU, resulting in an FMU for the native platform.

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

In the case of Cpp, one has to cross compile the runtime first. It will be installed besides the regular omc libs. In the example of comment:2 we have:

$OMHOME/lib/i686-w64-mingw32/omc
$OMHOME/lib/x86_64-linux-gnu/omc

If the C runtime would also precompile runtime libs, then this information could be used to generate a list of platforms independently of the compiler name.

Ultimately the Windows build might also use such a directory structure, e.g. having something like:

$OMHOME/lib/arm-microsoft-wince/omc
$OMHOME/lib/i386-microsoft-win32/omc
$OMHOME/lib/x86_64-microsoft-win32/omc
$OMHOME/lib/x86_64-w64-mingw32/omc

(the last directory for the default gcc compiler shipping with OpenModelica, gcc -dumpmachine)

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

comment:4 by Rüdiger Franke, 9 years ago

Cc: Adrian Pop added

comment:5 by Adeel Asghar, 9 years ago

Added support for it in cd92453/OMEdit.

comment:6 by Rüdiger Franke, 9 years ago

I'm getting the error message:

/bin/sh: 1: i686-w64-mingw32-gcc-g++: not found

Can you strip the compiler suffix -gcc from the platform names?

comment:7 by Adeel Asghar, 9 years ago

When are you getting this error? When you try to export FMU or just when displaying list of platforms in Options->Tools->FMI?

comment:8 by Rüdiger Franke, 9 years ago

I'm getting this error when compiling an FMU, because the *_FMU.makefile appends -g++ to the platform triplet. Also OMEdit should just show i686-w64-mingw32 instead of i686-w64-mingw32-gcc.

comment:9 by Adeel Asghar, 9 years ago

I guess we should update the regular expression to [a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[g] or should have two different filters one for gcc and one for g++ i.e.,

  • [a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[g]cc
  • [a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[g]++

Removing -gcc might result in output of irrelevant strings.

Also I think we should include QDir::Executable filter in the call to QDir::entryList.

comment:10 by Martin Sjölund, 9 years ago

I don't think g++ is necessary to look for (it's almost always a symlink to the corresponding gcc). rfranke is correct i686-w64-mingw32 instead of i686-w64-mingw32-gcc.

If you use QDir::Executable, make sure that you still find symbolic links (most gcc versions point somewhere else).

comment:11 by Adeel Asghar, 9 years ago

but don't you think [a-zA-Z0-9_-]*-[a-zA-Z0-9_-]*-[a-zA-Z0-9_-]* will output irrelevant files as well.

comment:12 by Rüdiger Franke, 9 years ago

This pull request does what I meant:

https://github.com/OpenModelica/OMEdit/pull/13

comment:13 by Rüdiger Franke, 9 years ago

Just created first cross-compiled and multi-platform FMUs from OMEdit :-)

Btw. the Cpp runtime does always creates a static FMU. This is because FMUs are intended to be exported to other machines and to survive version changes of the exporting tool. With dynamic FMUs I encountered the problem that after a couple of weeks the dynamic FMU crashed even on the same machine, because something had changed in a linked runtime lib, no matter if generated with C or Cpp runtime.

This is why the default linkage should not be "dynamic" but "static".

comment:14 by Adeel Asghar, 9 years ago

Resolution: fixed
Status: newclosed

Made "static" the default linkage in 4bcfe5e/OMEdit. I am sure Martin will not be happy with that but I think it doesn't matter since you can set your preferred linkage in OMEdit's settings.

comment:15 by Martin Sjölund, 9 years ago

I am happy with that. There is a reason I pushed for statically linked FMUs...

comment:16 by Martin Sjölund, 9 years ago

The only problem is co-simulation does not support it, I think.

comment:17 by Rüdiger Franke, 9 years ago

This pull request should finally do it for clang and gcc:

https://github.com/OpenModelica/OMEdit/pull/14

Regarding static linking: we must find a compromise under Linux. The system libs can only be linked dynamically, e.g. -static-libgcc does not work for a shared lib. But they are rather stable and care about versions. The OpenModelica runtime libs on the other side may change on a daily basis -- they should really be linked statically. Other libs, like expat, sundials, lapack, etc. are somewhere in between.

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

Milestone: 1.10.0

Milestone deleted

Note: See TracTickets for help on using tickets.