Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit bfccc5f

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
fix MetaModelica examples on mingw
- this is until we fix PR: #2138 - compile also with -fno-ipa-pure-const - link functions with -lOpenModelicaCompiler if MetaModelica flag is on Belonging to [master]: - #2654
1 parent 5b5cfe8 commit bfccc5f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Compiler/Template/CodegenC.tpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5780,11 +5780,13 @@ case SIMCODE(modelInfo=MODELINFO(varInfo=varInfo as VARINFO(__)), delayedExps=DE
57805780
let libsPos2 = if dirExtra then libsStr // else ""
57815781
let ParModelicaExpLibs = if acceptParModelicaGrammar() then '-lParModelicaExpl -lOpenCL' // else ""
57825782
let ParModelicaAutoLibs = if Flags.isSet(Flags.PARMODAUTO) then '-lParModelicaAuto -ltbb -lpugixml -lboost_system' // else ""
5783+
let ExtraStack = if boolOr(stringEq(makefileParams.platform, "win32"),stringEq(makefileParams.platform, "win64")) then '--stack,16777216,'
57835784
let extraCflags = match sopt case SOME(s as SIMULATION_SETTINGS(__)) then
57845785
match s.method case "dassljac" then "-D_OMC_JACOBIAN "
57855786

57865787
<<
57875788
# Makefile generated by OpenModelica
5789+
# Platform: <%makefileParams.platform%>
57885790

57895791
# Simulations use -O3 by default
57905792
CC=<%if boolOr(Flags.isSet(Flags.PARMODAUTO),acceptParModelicaGrammar()) then 'g++' else '<%makefileParams.ccompiler%>'%>
@@ -5799,7 +5801,7 @@ case SIMCODE(modelInfo=MODELINFO(varInfo=varInfo as VARINFO(__)), delayedExps=DE
57995801
%>CPPFLAGS=<%makefileParams.includes ; separator=" "%> -I"<%makefileParams.omhome%>/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME<% if stringEq(Config.simCodeTarget(),"JavaScript") then " -DOMC_EMCC"%><% if Flags.isSet(Flags.OMC_RELOCATABLE_FUNCTIONS) then " -DOMC_GENERATE_RELOCATABLE_CODE"%> -DOMC_MODEL_PREFIX=<%modelNamePrefix(simCode)%> -DOMC_NUM_MIXED_SYSTEMS=<%varInfo.numMixedSystems%> -DOMC_NUM_LINEAR_SYSTEMS=<%varInfo.numLinearSystems%> -DOMC_NUM_NONLINEAR_SYSTEMS=<%varInfo.numNonLinearSystems%> -DOMC_NDELAY_EXPRESSIONS=<%maxDelayedIndex%> -DOMC_NVAR_STRING=<%varInfo.numStringAlgVars%>
58005802
LDFLAGS=<%
58015803
if stringEq(Config.simCodeTarget(),"JavaScript") then <<-L'<%makefileParams.omhome%>/lib/<%getTriple()%>/omc/emcc' -lblas -llapack -lexpat -lSimulationRuntimeC -s TOTAL_MEMORY=805306368 -s OUTLINING_LIMIT=20000 --pre-js $(OMC_EMCC_PRE_JS)>>
5802-
else <<-L"<%makefileParams.omhome%>/lib/<%getTriple()%>/omc" -L"<%makefileParams.omhome%>/lib" -Wl,<% if boolOr(stringEq(makefileParams.platform, "win32"),stringEq(makefileParams.platform, "win64")) then "--stack,16777216,"%>-rpath,"<%makefileParams.omhome%>/lib/<%getTriple()%>/omc" -Wl,-rpath,"<%makefileParams.omhome%>/lib" <%ParModelicaExpLibs%> <%ParModelicaAutoLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%> >>
5804+
else <<-L"<%makefileParams.omhome%>/lib/<%getTriple()%>/omc" -L"<%makefileParams.omhome%>/lib" -Wl,<%ExtraStack%>-rpath,"<%makefileParams.omhome%>/lib/<%getTriple()%>/omc" -Wl,-rpath,"<%makefileParams.omhome%>/lib" <%ParModelicaExpLibs%> <%ParModelicaAutoLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%> >>
58035805
%>
58045806
DIREXTRA=<%stringReplace(dirExtra,"#","\\#") /* make strips everything after # */%>
58055807
MAINFILE=<%fileNamePrefix%>.c

Compiler/Template/CodegenCFunctions.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,12 @@ match fnCode
237237
case FUNCTIONCODE(makefileParams=MAKEFILE_PARAMS(__)) then
238238
let libsStr = (makefileParams.libs ;separator=" ")
239239
let ParModelicaExpLibs = if acceptParModelicaGrammar() then '-lParModelicaExpl -lOpenCL' // else ""
240+
let ExtraStack = if boolOr(stringEq(makefileParams.platform, "win32"),stringEq(makefileParams.platform, "win64")) then '--stack,16777216,'
241+
let WinMingwExtraLibs = if boolAnd(acceptMetaModelicaGrammar(), boolOr(stringEq(makefileParams.platform, "win32"),stringEq(makefileParams.platform, "win64"))) then '-lOpenModelicaCompiler'
240242

241243
<<
242244
# Makefile generated by OpenModelica
245+
# Platform: <%makefileParams.platform%>
243246

244247
# Dynamic loading uses -O0 by default
245248
SIM_OR_DYNLOAD_OPT_LEVEL=-O0
@@ -253,7 +256,7 @@ case FUNCTIONCODE(makefileParams=MAKEFILE_PARAMS(__)) then
253256
CPPFLAGS= -I"<%makefileParams.omhome%>/include/omc/c" <%makefileParams.includes ; separator=" "%><%
254257
if Flags.isSet(Flags.OMC_RELOCATABLE_FUNCTIONS) then " -DOMC_GENERATE_RELOCATABLE_CODE"
255258
%>
256-
LDFLAGS= -L"<%makefileParams.omhome%>/lib/<%getTriple()%>/omc" -Wl,-rpath,'<%makefileParams.omhome%>/lib/<%getTriple()%>/omc' <%ParModelicaExpLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%>
259+
LDFLAGS= -L"<%makefileParams.omhome%>/lib/<%getTriple()%>/omc" -Wl,<%ExtraStack%>-rpath,'<%makefileParams.omhome%>/lib/<%getTriple()%>/omc' <%ParModelicaExpLibs%> <%WinMingwExtraLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%>
257260
PERL=perl
258261
MAINFILE=<%name%>.c
259262

Compiler/runtime/omc_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@
115115
* Visual Studio then use the SSE instructions,
116116
* not the normal i387 FPU
117117
*/
118-
#define DEFAULT_CFLAGS "-falign-functions -mstackrealign -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
118+
#define DEFAULT_CFLAGS "-falign-functions -fno-ipa-pure-const -mstackrealign -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
119119
#else
120-
#define DEFAULT_CFLAGS "-falign-functions ${MODELICAUSERCFLAGS}"
120+
#define DEFAULT_CFLAGS "-falign-functions -fno-ipa-pure-const ${MODELICAUSERCFLAGS}"
121121
#endif
122122
#if defined(__x86_64__)
123123
/* -fPIC needed on x86_64! */

0 commit comments

Comments
 (0)