Skip to content

Commit

Permalink
Disable the link-time optimizer. Download the binary files when doing…
Browse files Browse the repository at this point in the history
… make emcc

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19287 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 24, 2014
1 parent a391652 commit 42a4e11
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -4405,7 +4405,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then '<%s.cflags%> ' /* From the simulate() command */%>
CPPFLAGS=-I"<%makefileParams.omhome%>/include/omc/c" -I. <%makefileParams.includes ; separator=" "%> <% if not stringEq(Config.simCodeTarget(),"JavaScript") then "-DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME" else "-DOMC_EMCC"%>
LDFLAGS=<%dirExtra%> <%
if stringEq(Config.simCodeTarget(),"JavaScript") then <<-L'<%makefileParams.omhome%>/lib/omc/emcc' -lblas -llapack -lexpat -lSimulationRuntimeC -lf2c --llvm-lto 2 -s TOTAL_MEMORY=536870912 -s MAX_SETJMPS=200 -s OUTLINING_LIMIT=20000 --pre-js <%makefileParams.omhome%>/lib/omc/emcc/pre.js>>
if stringEq(Config.simCodeTarget(),"JavaScript") then <<-L'<%makefileParams.omhome%>/lib/omc/emcc' -lblas -llapack -lexpat -lSimulationRuntimeC -lf2c -s TOTAL_MEMORY=536870912 -s OUTLINING_LIMIT=20000 --pre-js <%makefileParams.omhome%>/lib/omc/emcc/pre.js>>
else <<-L"<%makefileParams.omhome%>/lib/omc" -L"<%makefileParams.omhome%>/lib" -Wl,<% if stringEq(makefileParams.platform, "win32") then "--stack,0x2000000,"%>-rpath,"<%makefileParams.omhome%>/lib/omc" -Wl,-rpath,"<%makefileParams.omhome%>/lib" <%ParModelicaLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%>>>
%>
MAINFILE=<%fileNamePrefix%>.c
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenJS.tpl
Expand Up @@ -9,7 +9,7 @@ template markdownFile(SimCode simCode)
::=
match simCode case SIMCODE(__) then
let () = textFile(markdownContents(simCode), '<%fileNamePrefix%>.md')
let () = textFile(nodeJSDriver(simCode), '<%fileNamePrefix%>.node.js')
let () = textFile(nodeJSDriver(simCode), '<%fileNamePrefix%>_node.js')
""
end markdownFile;

Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/Makefile.common
Expand Up @@ -94,7 +94,7 @@ RUNTIMEINITIALIZATION_HEADERS = \
# ./simulation/solver/solver_main.h \
# ./util/list.h \

.PHONY : clean all $(LIBF2C) emcc emcc-clean
.PHONY : clean all $(LIBF2C) emcc emcc-clean emcc/libSimulationRuntimeC.so emcc/libf2c.so

all : install

Expand Down
19 changes: 14 additions & 5 deletions SimulationRuntime/c/Makefile.in
Expand Up @@ -42,12 +42,21 @@ include Makefile.common
Makefile: Makefile.in
cd $(top_builddir); ./config.status

emcc: Makefile emcc/pre.js
emcc: Makefile emcc/pre.js emcc/liblapack.so emcc/libblas.so emcc/libexpat.so emcc/libSimulationRuntimeC.so emcc/libf2c.so
cp /usr/include/expat*.h .
emmake $(MAKE) OBJ_EXT=.bc CC=emcc CXX=emcc CFLAGS=" $(CPPFLAGS) -Os -DOMC_EMCC -DNO_INTERACTIVE_DEPENDENCY -I./simulation/libf2c/" libSimulationRuntimeC.bc
cp emcc/pre.js emcc/*.so $(builddir_lib)/emcc/
@# emcc -Os --llvm-lto 2 -o $(builddir_lib)/emcc/libSimulationRuntimeC.js -s SIDE_MODULE=1 -s ASM_JS=1 -s TOTAL_MEMORY=536870912 -s OUTLINING_LIMIT=20000 libSimulationRuntimeC.bc simulation/libf2c/libf2c.bc emcc/liblapack.so emcc/libblas.so emcc/libexpat.so
emcc/liblapack.so:
wget -O $@ https://github.com/tshort/openmodelica-javascript/blob/master/liblapack.so?raw=true || (rm -f $@ ; false)
emcc/libblas.so:
wget -O $@ https://github.com/tshort/openmodelica-javascript/blob/master/libblas.so?raw=true || (rm -f $@ ; false)
emcc/libexpat.so:
wget -O $@ https://github.com/tshort/openmodelica-javascript/blob/master/libexpat.so?raw=true || (rm -f $@ ; false)
emcc/libf2c.so:
emmake $(MAKE) -C simulation/libf2c OBJ_EXT=.bc CC=emcc CXX=emcc CFLAGS="-Os" libf2c.bc
cp emcc/pre.js $(builddir_lib)/emcc/
cp libSimulationRuntimeC.bc $(builddir_lib)/emcc/libSimulationRuntimeC.so
cp simulation/libf2c/libf2c.bc $(builddir_lib)/emcc/libf2c.so
cp simulation/libf2c/libf2c.bc emcc/libf2c.so
emcc/libSimulationRuntimeC.so:
emmake $(MAKE) OBJ_EXT=.bc CC=emcc CXX=emcc CFLAGS=" $(CPPFLAGS) -Os -DOMC_EMCC -DNO_INTERACTIVE_DEPENDENCY -I./simulation/libf2c/" libSimulationRuntimeC.bc
cp libSimulationRuntimeC.bc emcc/libSimulationRuntimeC.so
emcc-clean: Makefile
$(MAKE) OBJ_EXT=.bc clean
10 changes: 7 additions & 3 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -89,13 +89,15 @@

using namespace std;

static int interactiveSimulation = 0; /* This variable signals if an simulation session is interactive or non-interactive (by default) */

#ifndef NO_INTERACTIVE_DEPENDENCY
Socket sim_communication_port;
static int sim_communication_port_open = 0;
#endif

extern "C" {

static int interactiveSimulation = 0; /* This variable signals if an simulation session is interactive or non-interactive (by default) */

int terminationTerminate = 0; /* Becomes non-zero when user terminates simulation. */
FILE_INFO TermInfo; /* message for termination. */

Expand Down Expand Up @@ -320,10 +322,10 @@ void initializeOutputFilter(MODEL_DATA *modelData, modelica_string variableFilte
{
#ifndef _MSC_VER
int cheap = resultFormatHasCheapAliasesAndParameters;
std::string varfilter(variableFilter);
regex_t myregex;
int flags = REG_EXTENDED;
int rc;
std::string varfilter(variableFilter);
string tmp = ("^(" + varfilter + ")$");
const char *filter = tmp.c_str(); // C++ strings are horrible to work with...
if (modelData->nStates > 0 && 0 == strcmp(modelData->realVarsData[0].info.name, "$dummy")) {
Expand Down Expand Up @@ -998,3 +1000,5 @@ void (*omc_assert)(threadData_t*,FILE_INFO info, const char *msg, ...) = omc_ass
void (*omc_assert_warning)(FILE_INFO info, const char *msg, ...) = omc_assert_warning_simulation;
void (*omc_terminate)(FILE_INFO info, const char *msg, ...) = omc_terminate_simulation;
void (*omc_throw)(threadData_t*) = omc_throw_simulation;

} // extern "C"

0 comments on commit 42a4e11

Please sign in to comment.