Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4459 closed defect (fixed)

MSVC broken using latest 32bit Windows build

Reported by: Rüdiger Franke Owned by: Adrian Pop
Priority: critical Milestone: 1.12.0
Component: Build Environment Version: v1.12.0
Keywords: Cc: Niklas Worschech

Description (last modified by Rüdiger Franke)

After deinstallation of OpenModelica-v1.11.0-32bit and installation of OpenModelica-v1.12.0-dev-466-g214f0d6-32bit the below error message pops up when attempting to simulate or FMU export a model using the Cpp runtime and MSVC.

Gcc works, but the exported model produces sporadically wrong results. The system outside OpenModelica did not change between versions 1.11 and 1.12.
The wrong results using gcc could not be reproduced under Linux.

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 
Copyright (C) Microsoft Corporation.  All rights reserved. 
 
        cl /FeMyModel.dll OMCppMyModelCalcHelperMain.cpp /DWIN32 /D_WINDOWS /W3 /GR /EHsc /Zm113 /Od /EHa /fp:except   /W4  /MP /D_DEBUG /MDd /Zi /Ob0 /RTC1  -DUSE_DGESV -DOMC_BUILD -DUSE_THREAD -DSUNDIALS_MAJOR_VERSION=2 -DSUNDIALS_MINOR_VERSION=6 -DPMC_USE_SUNDIALS /w /I"C:/OpenModelica1.12.0-dev-32bit//include/omc/cpp/" /I"C:/OpenModelica1.12.0-dev-32bit//include/omc/cpp/3rdParty/boost/msvc/" /I"" /I. /TP /DNOMINMAX /DNO_INTERACTIVE_DEPENDENCY /DFMU_BUILD /DRUNTIME_STATIC_LINKING /link /DLL /NOENTRY /LIBPATH:"C:/OpenModelica1.12.0-dev-32bit//lib/omc/cpp/msvc" /LIBPATH:"C:/OpenModelica1.12.0-dev-32bit//bin" OMCppSystem_static.lib OMCppMath_static.lib OMCppExtensionUtilities_static.lib OMCppFMU_static.lib OMCppNewton_static.lib OMCppDgesv_static.lib OMCppDgesvSolver_static.lib ModelicaExternalC.lib ModelicaStandardTables.lib OMCppModelicaUtilities_static.lib -L"C:/home/MyLib" 
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 
Copyright (C) Microsoft Corporation.  All rights reserved. 
 
cl : Command line warning D9025 : overriding '/EHs' with '/EHa' 
cl : Command line warning D9025 : overriding '/W3' with '/W4' 
cl : Command line warning D9025 : overriding '/W4' with '/w' 
OMCppMyModelCalcHelperMain.cpp 
C:\OpenModelica1.12.0-dev-32bit\include\omc\cpp\Core/Modelica.h(59) : fatal error C1083: Cannot open include file: 'thread': No such file or directory 
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2' 
Stop. 
RESULT: 2  

Change History (13)

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

Description: modified (diff)

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

Here is the respective functioning compiler call using OpenModelica 1.11:

        cl /FeMyModel.dll OMCppMyModelCalcHelperMain.cpp /DWIN32 /D_WINDOWS /W3 /GR /EHsc /Zm113 /Od /EHa /fp:except   /W4  /MP /MD /D NDEBUG -DUSE_CPP_03 -DUSE_DGESV -DOMC_BUILD -DSUNDIALS_MAJOR_VERSION=2 -DSUNDIALS_MINOR_VERSION=6 -DPMC_USE_SUNDIALS /w /I"C:/OpenModelica1.11.0-32bit//include/omc/cpp/" /I"C:/OpenModelica1.11.0-32bit//include/omc/cpp/3rdParty/boost/msvc/" /I"" /I. /TP /DNOMINMAX /DNO_INTERACTIVE_DEPENDENCY /DFMU_BUILD /DRUNTIME_STATIC_LINKING /link /DLL /NOENTRY /LIBPATH:"C:/OpenModelica1.11.0-32bit//lib/omc/cpp/msvc" /LIBPATH:"C:/OpenModelica1.11.0-32bit//bin" OMCppSystem_static.lib OMCppMath_static.lib OMCppExtensionUtilities_static.lib OMCppFMU_static.lib OMCppNewton_static.lib OMCppDgesv_static.lib ModelicaExternalC.lib ModelicaStandardTables.lib OMCppModelicaUtilities_static.lib -L"C:/home/MyLib"

It contains:

/MD /D NDEBUG -DUSE_CPP_03

whereas the non-functioning call of OpenModelica 1.12alpha/nightly contains instead:

/D_DEBUG /MDd /Zi /Ob0 /RTC1

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

Cc: Niklas Worschech added

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

Finally I could reproduce the random errors when using Gcc. The following pull request cleans up the DgesvSolver code and fixes the initialization of nominal values

https://github.com/OpenModelica/OMCompiler/pull/1706/

Let's wait for the next nightly build to see if this fixes the Gcc issues under Windows as well.

Horrible if the same functionality gets copied/pasted into several modules.

What is the meaning of using LinearSolver calling dgesv for simulation executables and DgesvSolver duplicating the dgesv calls and introducing errors for FMI export???

Why is DgesvSolver not the default for executables as well, while LinearSolver gets renamed to KluSolver and only implements the sparse part?

comment:5 by Niklas Worschech, 7 years ago

The Linersolver also uses dgetc2 and dgesc2 from Lapack if the A matrix is singular.
This functions are not include in 3rdParty Dgesv library

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

Priority: blockercritical

OK. LinearSolver also seems to automatically switch between Dgesv and Klu, depending on the availability of sparse information.

The prio of this ticket can be reduced because at least Gcc works under Windows again after the fix in DgesvSolver.

The MSVC issue remains. Please note that, besides compiler version, also the debug settings changed. The former NDEBUG appears more appropriate for FMI export.

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

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

Owner: changed from Martin Sjölund to Adeel Asghar
Status: newassigned

comment:8 by Adrian Pop, 7 years ago

Owner: changed from Adeel Asghar to Adrian Pop
Status: assignedaccepted

comment:9 by Adrian Pop, 7 years ago

The release and nightly builds are using MSVC version 2013 to build the libs shipped.
I guess that somehow we should have different flags depending on which compiler version OMC detects (or which one is set via the OMEdit settings).

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

You might also specify in the release notes that MSVC 2010 is not supported anymore, but at least 2013. It seems that this finally brings support for C++11 (no -DUSE_CPP_03 anymore).

An important remaining question is why debug settings changed from /MD /D NDEBUG to /D_DEBUG /MDd. This means that generated binary code does not run on a standard Windows machine anymore, because debug libs (/MDd) only come with a development environment!?

Why did the compiler flags change along with the compiler version?

comment:11 by Adrian Pop, 7 years ago

Resolution: fixed
Status: acceptedclosed

In 26026:

comment:12 by Adrian Pop, 7 years ago

In 26027:

comment:13 by Adrian Pop, 7 years ago

The problem was in the makefiles and the invocation of targets we were testing for BUILDTYPE and we build with BuildType=Release instead of BUILDTYPE=Release. A bit weird that environment variables are case dependent.

Note: See TracTickets for help on using tickets.